Efficient Form of the Blowfish Algorithm

A more efficient form of the Blowfish Algorithm is presented with the 16-round loop expanded inline to avoid the 'Swap' step.

If you look at the Blowfish process again, you will see that the performance can be improved if the 16-round loop is expanded inline to avoid the "Swap xL and xR" step.

Here is a more efficient form of the Blowfish algorithm without loop as mentioned in the BlowfishJ implementation developed by Markus Hahn, http://come.to/hahn:

Input: 
   T: 64 bits of clear text
   P1, P2, ..., P18: 18 sub-keys
   F(): Round function
   
Output: 
   C: 64 bits of cipher text

Algorithm - Blowfish Encryption:
   C = Blowfish(T), Blowfish round process without loop defined as:
      (L, R) = T, dividing T into two 32-bit parts
      L = L XOR P1
      R = R XOR F(L) XOR P2
      L = L XOR F(R) XOR P3
      R = R XOR F(L) XOR P4
      L = L XOR F(R) XOR P5
      R = R XOR F(L) XOR P6
      L = L XOR F(R) XOR P7
      R = R XOR F(L) XOR P8
      L = L XOR F(R) XOR P9
      R = R XOR F(L) XOR P10
      L = L XOR F(R) XOR P11
      R = R XOR F(L) XOR P12
      L = L XOR F(R) XOR P13
      R = R XOR F(L) XOR P14
      L = L XOR F(R) XOR P15
      R = R XOR F(L) XOR P16
      L = L XOR F(R) XOR P17
      R = R XOR P18
      C = (R, L), combine R and L into 64-bit block

As you can see, the "Swap L and R" step is no longer needed.

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