"bf-cfb" Encryption Verification

A tutorial example is provided to verify OpenSSL 'enc -bf-cfb' command against the Blowfish CFB test vector published at www.schneier.com.

Okay, we have learned that OpenSSL "enc -bf-cfb" command can perform Blowfish encryption in CFB mode on multiple plaintext blocks. Now we needed to verify its output against existing Blowfish CFB test vectors.

When I search the Internet, I only see one published test vector for Blowfish in CFB mode at https://www.schneier.com/code/vectors.txt:

chaining mode test data
key[16]   = 0123456789ABCDEFF0E1D2C3B4A59687
iv[8]     = FEDCBA9876543210
data[29]  = "7654321 Now is the time for " (includes trailing '\0')
data[29]  = 37363534333231204E6F77206973207468652074696D6520666F722000
cfb64 cipher text cipher[29]= 
E73214A2822139CAF26ECF6D2EB9E76E3DA3DE04D1517200519D57A6C3 

Below is the my test to verify OpenSSL "enc -bf-cfb" cipher against the above test vector:

C:\herong>perl -e "binmode(STDOUT); print pack('H*', 
'37363534333231204E6F77206973207468652074696D6520666F722000000000')"
   >> CFB-Test-Vector.txt

C:\herong>\local\gnuwin32\bin\openssl enc -bf-cfb -e 
   -K 0123456789ABCDEFF0E1D2C3B4A59687 -iv FEDCBA9876543210  
   -in CFB-Test-Vector.txt -out cipher.txt -nopad -p
salt=0200000028264901
key=0123456789ABCDEFF0E1D2C3B4A59687
iv =FEDCBA9876543210

C:\herong>perl -e "while (read(STDIN,$_,1)){print unpack('H*',$_);}" 
   < cipher.txt
e73214a2822139caf26ecf6d2eb9e76e3da3de04d1517200519d57a6c3 384ece
----------------------------------------------------------
         Matched the test vector at schneier.com

Congratulations! The ciphertext matches with what given in the test vector. Now we can confidently say that OpenSSL "enc -bf-cfb" command works correctly.

Last update: 2015.

Table of Contents

 About This Book

 Blowfish Cipher Algorithm

 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

 "bf-cfb" Cipher with Literal Key

 "bf-cfb" Cipher on Multiple Blocks

"bf-cfb" Encryption Verification

 "bf-cfb" 2-Block Test Vectors

 "bf-cfb" Cipher with Salted Key

 "bf-cfb" Cipher with Random Salt

 "enc -bf-cfb" Command Summary

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

 References

 PDF Printing Version