Chapter 5. Blowfish

Table of Contents

Design criteria
Keying
Encryption
Decryption
Cryptanalysis

Design criteria

  1. Fast -- not require much CPU

  2. Compact -- not require much memory

  3. Simple -- makes it easy to analyze and program (so no implementation errors)

  4. Variable security -- variable keylength is useful

Blowfish is a 64-bit block cipher.

Keying

The user inputs a key of up to 448 bits, but the algorithm wants 4168 bytes (18 32-bit subkeys (the P-array) and four 32-bit S-boxes with 256 entries each). The subkeys are calculated by encrypting the all-zero string using the input key XORed with pi (in hex). This process is repeated as needed to generate the P-array and the S-boxes.

Encryption

Modes

Steps

Blowfish is just another Feistel network with 16 rounds. Each round XORs the left half against a different subkey from the P-array. The function used in the Feistel network works by dividing the 32-bit number into four 8-bit numbers to get: (a,b,c,d) = F(a,b,c,d) = ((S1,a + S2,b mod 232) XOR S3,c) + S4,d mod 232

Decryption

Same as encryption, but using the P-array in reverse order.

Cryptanalysis

Some attacks known against reduced-round variants, but not against the full 16 rounds. It's recommended to use twofish, a related, but faster and better cipher, though.