Crypt::CBC Literal Key Error Cases

Error cases are provided on secret key size and IV size when using Crypt::CBC with the Literal Key option. Secret key must be 56 bytes long and IV must be 8 bytes long.

Now let's try Crypt::CBC with the Literal Key option in some error conditions.

1. Run Crypt-CBC-Blowfish-Literal-Key.pl with a secret key less than 56 bytes. I got the expected error:

C:\herong>perl Crypt-CBC-Blowfish-Literal-Key.pl 
   1122334455667788 0000000000000000 0123456789abcdef
   
Crypt::CBC Literal Key Test - output in Hex:
   Secret Key     (1122334455667788)
   IV             (0000000000000000)
   Plaintext      (0123456789abcdef)
Creating Crypt::CBC with Literal Key...
If specified by -literal_key, then the key length must be equal to 
the chosen cipher's key length of 56 bytes at Crypt-CBC-Blowfish-
Literal-Key.pl line 23.

2. Run Crypt-CBC-Blowfish-Literal-Key.pl with a secret key more than 56 bytes. I got the expected error:

C:\herong>perl Crypt-CBC-Blowfish-Literal-Key.pl 
   11223344556677889900...11223344556677889900 0000000000000000 
   0123456789abcdef
   
Crypt::CBC Literal Key Test - output in Hex:
   Secret Key     (1122334455667788990011223344556677889900
                   1122334455667788990011223344556677889900
                   1122334455667788990011223344556677889900)
   IV             (0000000000000000)
   Plaintext      (0123456789abcdef)
Creating Crypt::CBC with Literal Key...
If specified by -literal_key, then the key length must be equal to 
the chosen cipher's key length of 56 bytes at Crypt-CBC-Blowfish-
Literal-Key.pl line 23.

3. Run Crypt-CBC-Blowfish-Literal-Key.pl with an IV less than 8 bytes. I got the expected error:

C:\herong>perl Crypt-CBC-Blowfish-Literal-Key.pl 
   11223344556677889900...112233445566 00000000 0123456789abcdef

Crypt::CBC Literal Key Test - output in Hex:
   Secret Key     (1122334455667788990011223344556677889900
                   1122334455667788990011223344556677889900
                   11223344556677889900112233445566)
   IV             (00000000)
   Plaintext      (0123456789abcdef)
Creating Crypt::CBC with Literal Key...
Initialization vector must be exactly 8 bytes long when using the 
Blowfish cipher at Crypt-CBC-Blowfish-Literal-Key.pl line 23.

4. Run Crypt-CBC-Blowfish-Literal-Key.pl with an IV more than 8 bytes. I got the expected error:

C:\herong>perl Crypt-CBC-Blowfish-Literal-Key.pl 
   11223344556677889900...112233445566 000000000000000011223344
   0123456789abcdef

Crypt::CBC Literal Key Test - output in Hex:
   Secret Key     (1122334455667788990011223344556677889900
                   1122334455667788990011223344556677889900
                   11223344556677889900112233445566)
   IV             (000000000000000011223344)
   Plaintext      (0123456789abcdef)
Creating Crypt::CBC with Literal Key...
Initialization vector must be exactly 8 bytes long when using the 
Blowfish cipher at Crypt-CBC-Blowfish-Literal-Key.pl line 23.

Conclusion: When using Crypt::CBC and Crypt::Blowfish with the Literal Key option, secret key must be 56 bytes long and IV must be 8 bytes long.

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

 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

 References

 PDF Printing Version