Crypt::CBC Salted Key Test Cases

Some test cases are provided to run Crypt::CBC with the salted key option. Passphrase can have any length. But salt must be 8 bytes long.

In the previous tutorial, we learned how to use Crypt::CBC module with the Salted Key option. In this tutorial, let's run some test cases with example Perl script presented in the previous tutorial.

Very short (1-byte) passphrase encryption - No problem.

C:\herong>perl Crypt-CBC-Blowfish-Salted-Key.pl \
  11 0000000000000000 0123456789abcdef
  
Crypt::CBC Salted Key - output in Hex:
   Passphrase      (11)
   Salt            (0000000000000000)
   Plaintext       (0123456789abcdef)
Creating Crypt::CBC with Passphrase and Salt...
Encrypting plaintext...
   Cipher Output   (53616c7465645f5f00000000000000000e2e3d50d7e78d99)
   Header Name     (53616c7465645f5f)
   Header Value    (0000000000000000)
   Ciphertext      (0e2e3d50d7e78d99)
Decrypting ciphertext...
   Decrypted text  (0123456789abcdef)
   Pass Phrase     (11)
   Salt            (0000000000000000)
   IV              (d70a0b076d909375)

Very long (80-byte) passphrase encryption - No problem.

C:\herong>perl Crypt-CBC-Blowfish-Salted-Key.pl \
   11223344556677889900...11223344556677889900 0000000000000000 \
   0123456789abcdef
   
Crypt::CBC Salted Key - output in Hex:
   Passphrase      (1122334455667788990011223344556677889900
                    1122334455667788990011223344556677889900
                    1122334455667788990011223344556677889900
                    1122334455667788990011223344556677889900)
   Salt            (0000000000000000)
   Plaintext       (0123456789abcdef)
Creating Crypt::CBC with Passphrase and Salt...
Encrypting plaintext...
   Cipher Output   (53616c7465645f5f0000000000000000db7f8fb0e94e33a6)
   Header Name     (53616c7465645f5f)
   Header Value    (0000000000000000)
   Ciphertext      (db7f8fb0e94e33a6)
Decrypting ciphertext...
   Decrypted text  (0123456789abcdef)
   Pass Phrase     (1122334455667788990011223344556677889900
                    1122334455667788990011223344556677889900
                    1122334455667788990011223344556677889900
                    1122334455667788990011223344556677889900)
   Salt            (0000000000000000)
   IV              (3c05d2f32c8d1d14)

2-block encryption - No problem.

C:\herong>perl Crypt-CBC-Blowfish-Salted-Key.pl \
   1122334455667788 0000000000000000 0123456789abcdeffedcba9876543210
   
Crypt::CBC Salted Key - output in Hex:
   Passphrase      (1122334455667788)
   Salt            (0000000000000000)
   Plaintext       (0123456789abcdeffedcba9876543210)
Creating Crypt::CBC with Passphrase and Salt...
Encrypting plaintext...
   Cipher Output   (53616c7465645f5f0000000000000000
                    8eb0ddf700ee18b1737b88dc8869996b)
   Header Name     (53616c7465645f5f)
   Header Value    (0000000000000000)
   Ciphertext      (8eb0ddf700ee18b1737b88dc8869996b)
Decrypting ciphertext...
   Decrypted text  (0123456789abcdeffedcba9876543210)
   Pass Phrase     (1122334455667788)
   Salt            (0000000000000000)
   IV              (eda37dc506202bd2)

Short (1-byte) salt encryption - Getting an error as expected. Salt must be 8 bytes long.

C:\herong>perl Crypt-CBC-Blowfish-Salted-Key.pl \
   1122334455667788 00 0123456789abcdef
   
Crypt::CBC Salted Key - output in Hex:
   Passphrase      (1122334455667788)
   Salt            (00)
   Plaintext       (0123456789abcdef)
Creating Crypt::CBC with Passphrase and Salt...
Argument to -salt must be exactly 8 bytes long at 
Crypt-CBC-Blowfish-Salted-Key.pl line 20.

Last update: 2018.

Table of Contents

 About This Book

 Blowfish Cipher Algorithm

 Perl Crypt::Blowfish Module

 Perl Crypt::ECB Perl Module

Perl Crypt::CBC Module

 What is Crypt::CBC

 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 Options

 Crypt::CBC Padding Option Tests

 Crypt::CBC Blowfish Encryption Summary

 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