**Blowfish Cipher Tutorials - Herong's Tutorial Examples** - Version 2.01, by Dr. Herong Yang

Blowfish Cipher Encryption Algorithm

The Blowfish cipher algorithm is presented based on the algorithm designer Bruce Schneier's technical paper. Blowfish cipher is 16-round and 64-bit block cipher.

Blowfish algorithm was developed by Bruce Schneier in 1993. Here is the Blowfish encryption algorithm presented in Bruce's paper "Description of a New Variable-Length Key, 64-Bit Block Cipher (Blowfish)" at http://www.schneier.com/paper-blowfish-fse.html:

Input: T: 64 bits of plaintext P{1), P(2), ..., P(18): 18 sub-keys, 32 bits each F(): Round function Output: C: 64 bits of ciphertext Algorithm - Blowfish Encryption: C = Blowfish(T), Blowfish round process defined as: (xL, xR) = T, dividing T into two 32-bit parts Loop on i from = 1 to 16 xL = xL XOR P(i) xR = F(xL) XOR xR Swap xL and xR End of loop Swap xL and xR xR = xR XOR P(17) xL = xL XOR P(18) C = (xL, xR), combine xL, xR into 64-bit block

The round function F(A) is defined as:

Input: A: 32-bit input data S1[], S2[], S3[], S4[]: 4 S-box lookup tables, 256 bits each Output B: 32-bit output data Algorithm (a, b, c, d) = A, dividing A into four 8-bit parts B = ( (S1[a] + S2[b] mod 2**32) XOR S3[c] ) + S[d] mod 2**32

As you can see from the algorithm, Blowfish is clearly a 16-round and 64-bit block cipher.

See next tutorials on how Sub-keys P{1), P(2), ..., P(18) and S-boxes S1[], S2[], S3[], S4[] are constructed.

Last update: 2018.

Table of Contents

►Blowfish Cipher Encryption Algorithm

Key Schedule (Sub-Keys and S-Boxes) Algorithm

Efficient Form of the Blowfish Algorithm

Blowfish Cipher Decryption Algorithm

Proof of Blowfish Cipher Algorithm

First 8336 Fractional Hex Digits of PI

piqpr8.c - Generating Hex Digits of PI

OpenSSL "enc -bf-ecb" for Blowfish/ECB Encryption

OpenSSL "enc -bf-cbc" for Blowfish/CBC Encryption

OpenSSL "enc -bf-cfb" for Blowfish/CFB Encryption

OpenSSL "enc -bf-ofb" for Blowfish/OFB Encryption