Blowfish Cipher Tutorials - Herong's Tutorial Examples - v2.03, by Herong Yang
Crypt::CBC Encryption Verification
A tutorial example is provided to verify Crypt::CBC against the Blowfish CBC test vector published at www.schneier.com.
Okay, I think we have learned enough on how to use the Crypt::CBC module. 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
I think we can run my example script, Crypt-CBC-Blowfish-Cipher-Object.pl, to validate this:
C:\herong>perl Crypt-CBC-Blowfish-Cipher-Object.pl \ 0123456789ABCDEFF0E1D2C3B4A59687 FEDCBA9876543210 \ 37363534333231204E6F77206973207468652074696D6520666F722000000000 Crypt::CBC Blowfish Object Test - output in Hex: Secret Key (0123456789ABCDEFF0E1D2C3B4A59687) IV (FEDCBA9876543210) Plaintext (37363534333231204E6F772069732074 68652074696D6520666F722000000000) Creating Crypt::CBC with Blowfish Object ... Encrypting plaintext... Ciphertext (6b77b4d63006dee605b156e274039793 58deb9e7154616d959f1652bd5ff92cc) Decrypting ciphertext... Decrypted text (37363534333231204e6f772069732074 68652074696d6520666f722000000000) Pass Phrase () IV (fedcba9876543210)
Congratulations! The ciphertext matches with what given in the test vector. Now we can confidently say that Crypt::CBC and Crypt::Blowfish modules work correctly.
Table of Contents
Installing Crypt::CBC 2.33 with ActivePerl
Crypt::CBC Encryption with Literal Keys
Crypt::CBC Literal Key Error Cases
Crypt::CBC Encryption with Crypt::Blowfish Objects
Crypt::CBC Operation Simulation
►Crypt::CBC Encryption Verification
Blowfish CBC 2-Block Test Vectors
Crypt::CBC Prepending IV to Ciphertext
Crypt::CBC Encryption with Salted Keys
Crypt::CBC Salted Key Test Cases
Crypt::CBC Secret Key and IV Algorithm
Crypt::CBC Encryption with Random Salt
Crypt::CBC Padding Option Tests
Crypt::CBC Blowfish Encryption Summary
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