SAFER Secure and Fast Encryption Routine


SAFER (Secure And Fast Encryption Routine) is a symmetric encryption algorithm designed to provide both security and speed. It was developed by James Massey and others in the late 1990s as an alternative to existing encryption algorithms like DES (Data Encryption Standard). SAFER comes in several variations, including SAFER K-64, SAFER SK-64, SAFER K-128, and SAFER SK-128, which differ in their key sizes.

SAFER is a block cipher, meaning it operates on fixed-size blocks of data. The SAFER algorithm encrypts or decrypts data in multiple rounds, with each round consisting of several sub-operations, including key mixing, substitution, permutation, and modular arithmetic.

Let's take a closer look at the SAFER K-128 variant, which uses a 128-bit key. The algorithm operates on 8-byte (64-bit) blocks of data. Here is a step-by-step overview of the SAFER K-128 encryption process:

Key Scheduling:

  • The 128-bit encryption key is expanded into a set of round keys. This process involves generating a series of subkeys used in each round of encryption.
  • Key mixing operations are performed on the original key to produce the initial round keys.

Encryption Rounds:

  • The plaintext block is divided into two 32-bit halves, referred to as the left and right blocks.
  • A series of encryption rounds is performed, typically 6 to 8 rounds, with each round consisting of the following steps:
  • The right block is XORed with the current round key.
  • The XOR result is subjected to a substitution operation using a substitution box (S-box) that replaces each 8-bit value with another 8-bit value based on a predefined lookup table.
  • The substituted result is permuted using a permutation box (P-box) that rearranges the bits.
  • The permuted result is XORed with the left block, and the result becomes the new right block.
  • The left and right blocks are swapped.

Final Round:

  • The final round of the encryption process is similar to the encryption rounds but without the key mixing step. It only involves XORing the right block with the current round key, substituting and permuting the result, and swapping the left and right blocks.

Output:

  • The final left and right blocks are concatenated to form the ciphertext, which is the encrypted form of the original plaintext.

The decryption process for SAFER is essentially the reverse of the encryption process. The round keys are used in reverse order, and the operations in each round are inverted. Decrypting a ciphertext involves applying the decryption rounds and, finally, obtaining the original plaintext.

SAFER was designed to be both secure and fast, providing a balance between these two important factors. However, it's worth noting that SAFER is now considered to be outdated and has been superseded by more modern encryption algorithms like AES (Advanced Encryption Standard). AES is widely adopted and recommended for secure encryption applications today.