Blowfish Cipher Decryption Algorithm

The Blowfish cipher decryption algorithm is presented. It is identical to the encryption algorithm, except that Sub-keys, P1, P2, ..., P18, are applied in reverse order.

The decryption algorithm of a block cipher is usually identical to encryption algorithm step by step in reverse order. But for the Blowfish cipher, the encryption algorithm is so well designed, that the decryption algorithm is identical to the encryption algorithm step by step in the same order, only with the sub-keys applied in the reverse order.

Here is the Blowfish decryption algorithm with the 16-round loop expanded inline:

Input: 
   CC: 64 bits of ciphertext
   P1, P2, ..., P18: 18 sub-keys
   F(): Round function
   
Output: 
   TT: 64 bits of plaintext

Algorithm - Blowfish Decryption:
   (LL, RR) = CC, dividing CC into two 32-bit parts
   LL = LL XOR P18
   RR = RR XOR F(LL) XOR P17
   LL = LL XOR F(RR) XOR P16
   RR = RR XOR F(LL) XOR P15
   LL = LL XOR F(RR) XOR P14
   RR = RR XOR F(LL) XOR P13
   LL = LL XOR F(RR) XOR P12
   RR = RR XOR F(LL) XOR P11
   LL = LL XOR F(RR) XOR P10
   RR = RR XOR F(LL) XOR P9
   LL = LL XOR F(RR) XOR P8
   RR = RR XOR F(LL) XOR P7
   LL = LL XOR F(RR) XOR P6
   RR = RR XOR F(LL) XOR P5
   LL = LL XOR F(RR) XOR P4
   RR = RR XOR F(LL) XOR P3
   LL = LL XOR F(RR) XOR P2
   RR = RR XOR P1
   TT = (RR, LL), combine RR and LL into 64-bit block

As you can see, the decryption algorithm is indeed identical to the encryption algorithm, except Sub-keys, P1, P2, ..., P18, are applied in reverse order.

Last update: 2015.

Table of Contents

 About This Book

Blowfish Cipher Algorithm

 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

 Blowfish Cipher Test Vectors

 First 8336 Fractional Hex Digits of PI

 piqpr8.c - Generating Hex Digits of PI

 Perl Crypt::Blowfish Module

 Perl Crypt::ECB Perl Module

 Perl Crypt::CBC Module

 Perl Crypt::CFB Perl Module

 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

 PHP Mcrypt Extension for Blowfish

 Blowfish 8-Bit Cipher in PHP

 References

 Full Version in PDF/EPUB