Blowfish Cipher Tutorials - Herong's Tutorial Examples - v2.03, by Herong Yang
"bf-cbc" Encryption Verification
A tutorial example is provided to verify OpenSSL 'enc -bf-cbc' command against the Blowfish CBC test vector published at www.schneier.com.
Okay, we have learned that OpenSSL "enc -bf-cbc" command can perform Blowfish encryption in CBC mode on multiple plaintext blocks. Now we needed to verify its output against existing Blowfish CBC test vectors.
When I search the Internet, I only see one published test vector for Blowfish in CBC 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 cbc cipher text cipher[32]= 6B77B4D63006DEE605B156E27403979358DEB9E7154616D959F1652BD5FF92CC
Below is the my test to verify OpenSSL "enc -bf-cbc" cipher against the above test vector:
C:\herong>perl -e "binmode(STDOUT); print pack('H*', \ '37363534333231204E6F77206973207468652074696D6520666F722000000000')" \ >> CBC-Test-Vector.txt C:\herong>\local\gnuwin32\bin\openssl enc -bf-cbc -e \ -K 0123456789ABCDEFF0E1D2C3B4A59687 -iv FEDCBA9876543210 \ -in CBC-Test-Vector.txt -out cipher.txt -nopad -p salt=0200000028263F01 key=0123456789ABCDEFF0E1D2C3B4A59687 iv =FEDCBA9876543210 C:\herong>perl -e "while (read(STDIN,$_,1)){print unpack('H*',$_);}" \ < cipher.txt 6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc
Congratulations! The ciphertext matches with what given in the test vector. Now we can confidently say that OpenSSL "enc -bf-cbc" command works correctly.
Table of Contents
OpenSSL "enc -bf-ecb" for Blowfish/ECB Encryption
►OpenSSL "enc -bf-cbc" for Blowfish/CBC Encryption
"bf-cbc" Cipher with Literal Key
"bf-cbc" Cipher on Multiple Blocks
►"bf-cbc" Encryption Verification
"bf-cbc" Cipher with Salted Key
"bf-cbc" Cipher with Random Salt
OpenSSL "enc -bf-cfb" for Blowfish/CFB Encryption
OpenSSL "enc -bf-ofb" for Blowfish/OFB Encryption