Crypt::ECB Encryption Test Cases

Test cases are provided to run Crypt::ECB with Crypt::Blowfish and no padding. Secret key must be between 8 bytes and 56 bytes long.

Now let's run some tests with the example script provided in the previous tutorial.

1. Run Crypt-ECB-Blowfish-Encryption.pl with a Blowfish test vector, I got the expected ciphertext:

C:\herong >perl Crypt-ECB-Blowfish-Encryption.pl 
   0000000000000000 0000000000000000
Crypt::ECB Encryption Test - output in Hex:
   Secret Key     (0000000000000000)
   Plaintext      (0000000000000000)
Creating Crypt::ECB with secret key ...
Encrypting plaintext...
   Ciphertext     (4ef997456198dd78)
Decrypting ciphertext...
   Decrypted text (0000000000000000)
   Secret Key     (0000000000000000)
   Padding        (0)

2. Run Crypt-ECB-Blowfish-Encryption.pl with 2 Blowfish test vectors in 2 plaintext blocks, I got the expected ciphertext.

C:\herong >perl Crypt-ECB-Blowfish-Encryption.pl 
   0000000000000000 0000000000000000ffffffffffffffff
Crypt::ECB Encryption Test - output in Hex:
   Secret Key     (0000000000000000)
   Plaintext      (0000000000000000ffffffffffffffff)
Creating Crypt::ECB with secret key ...
Encrypting plaintext...
   Ciphertext     (4ef997456198dd78014933e0cdaff6e4)
Decrypting ciphertext...
   Decrypted text (0000000000000000ffffffffffffffff)
   Secret Key     (0000000000000000)
   Padding        (0)

3. Run Crypt-ECB-Blowfish-Encryption.pl with a secret key less than 8 bytes. I got the expected error:

C:\herong >perl Crypt-ECB-Blowfish-Encryption.pl 
   11223344 0123456789abcdef
Crypt::ECB Encryption Test - output in Hex:
   Secret Key     (11223344)
   Plaintext      (0123456789abcdef)
Creating Crypt::ECB with secret key ...
Encrypting plaintext...
Invalid length key at C:/local/Perl/site/lib/Crypt/Blowfish.pm 
line 42.

4. Run Crypt-ECB-Blowfish-Encryption.pl with a secret key more than 56 bytes. I got the expected error:

C:\herong>perl Crypt-ECB-Blowfish-Encryption.pl 
   11223344556677889900...11223344556677889900 0123456789abcdef
Crypt::ECB Encryption Test - output in Hex:
   Secret Key     (1122334455667788990011223344556677889900
                   1122334455667788990011223344556677889900
                   1122334455667788990011223344556677889900)
   Plaintext      (0123456789abcdef)
Creating Crypt::ECB with secret key ...
Encrypting plaintext...
Invalid length key at C:/local/Perl/site/lib/Crypt/Blowfish.pm 
line 42.

5. Run Crypt-ECB-Blowfish-Encryption.pl with a half block. I got the expected error:

C:\herong >perl Crypt-ECB-Blowfish-Encryption.pl 
   1122334455667788 01234567
Crypt::ECB Encryption Test - output in Hex:
   Secret Key     (1122334455667788)
   Plaintext      (01234567)
Creating Crypt::ECB with secret key ...
Encrypting plaintext...
Your message length is not a multiple of Blowfish's blocksize 
(8 bytes). Correct this by hand or tell me to handle padding.

Conclusion: When using Crypt::ECB and Crypt::Blowfish, secret key must be between 8 bytes and 56 bytes long.

Last update: 2015.

Table of Contents

 About This Book

 Blowfish Cipher Algorithm

 Perl Crypt::Blowfish Module

Perl Crypt::ECB Perl Module

 What is Crypt::ECB?

 Installing Crypt::ECB 1.45 with ActivePerl

 Crypt::ECB Encryption with No Padding

Crypt::ECB Encryption Test Cases

 Crypt::ECB Auto Padding

 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

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

 References

 PDF Printing Version