Blowfish Cipher Tutorials - Herong's Tutorial Examples - v2.03, by Herong Yang
Blowfish Test Vectors with 16-Byte Keys
A tutorial Perl example is provided to show how to build a table of test vectors with Crypt::Blowfish with 128-bit (16-byte) secret keys.
I think we have a good understanding on the Crypt::Blowfish module now. Let's try to build a test vector table with 128-bit (16-byte) secret keys.
Here is my Perl script, which takes a list of secret keys and plaintext, then encrypts them one by one:
#- Crypt-Blowfish-16-Byte-Key.pl #- Copyright (c) 2015 HerongYang.com, All Rights Reserved. #- use Crypt::Blowfish; @tests = split(/\n/, getInput()); print("Blowfish 128-Bit Key Test Vectors in Hex:\n"); foreach (@tests) { ($i, $keyHex, $plainHex) = split(/ +/,$_); $keyStr = pack("H*", $keyHex); $plainStr = pack("H*", $plainHex); $cipher = new Crypt::Blowfish($keyStr); $cipherStr = $cipher->encrypt($plainStr); $cipherHex = unpack("H*", $cipherStr); print("$i - Secret Key: $keyHex\n"); print(" Plaintext: $plainHex -> Ciphertext: $cipherHex\n"); } sub getInput { return $input = << 'EOD'; 1 00000000000000000000000000000000 4EF997456198DD78 2 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 51866FD5B85ECB8A 3 30000000000000001000000000000001 7D856F9A613063F2 4 11111111111111111111111111111111 2466DD878B963C9D 5 0123456789ABCDEF1111111111111111 61F9C3802281B096 6 11111111111111110123456789ABCDEF 7D0CC630AFDA1EC7 7 FEDCBA98765432100123456789ABCDEF 0ACEAB0FC6A0A28D 8 7CA110454A1A6E5701A1D6D039776742 59C68245EB05282B 9 0131D9619DC1376E5CD54CA83DEF57DA B1B8CC0B250F09A0 10 07A1133E4A0B26860248D43806F67172 1730E5778BEA1DA4 11 3849674C2602319E51454B582DDF440A A25E7856CF2651EB 12 04B915BA43FEB5B642FD443059577FA2 353882B109CE8F1A 13 0113B970FD34F2CE059B5E0851CF143A 48F4D0884C379918 14 0170F175468FB5E60756D8E0774761D2 432193B78951FC98 15 43297FAD38E373FE762514B829BF486A 13F04154D69D1AE5 16 07A7137045DA2A163BDD119049372802 2EEDDA93FFD39C79 17 04689104C2FD3B2F26955F6835AF609A D887E0393C2DA6E3 18 37D06BB516CB7546164D5E404F275232 5F99D04F5B163969 19 1F08260D1AC2465E6B056E18759F5CCA 4A057A3B24D3977B 20 584023641ABA6176004BD6EF09176062 452031C1E4FADA8E 21 025816164629B007480D39006EE762F2 7555AE39F59B87BD 22 49793EBC79B3258F437540C8698F3CFA 53C55F9CB49FC019 23 4FB05E1515AB73A7072D43A077075292 7A8E7BFA937E89A3 24 49E95D6D4CA229BF02FE55778117F12A CF9C5D7A4986ADB5 25 018310DC409B26D61D9D5C5018F728C2 D1ABB290658BC778 26 1C587F1C13924FEF305532286D6F295A 55CB3774D13EF201 27 01010101010101010123456789ABCDEF FA34EC4847B268B2 28 1F1F1F1F0E0E0E0E0123456789ABCDEF A790795108EA3CAE 29 E0FEE0FEF1FEF1FE0123456789ABCDEF C39E072D9FAC631D 30 0000000000000000FFFFFFFFFFFFFFFF 014933E0CDAFF6E4 31 FFFFFFFFFFFFFFFF0000000000000000 F21E9A77B71C49BC 32 0123456789ABCDEF0000000000000000 245946885754369A 33 FEDCBA9876543210FFFFFFFFFFFFFFFF 6B5C5A9C5D9E0A5A EOD }
Run the example script, you will get a nice looking Blowfish test vectors with 128-bit secret keys:
C:\herong>perl Crypt-Blowfish-16-Byte-Key.pl Blowfish 128-Bit Key Test Vectors in Hex: 1 - Secret Key: 00000000000000000000000000000000 Plaintext: 4EF997456198DD78 -> Ciphertext: e1c030e74c14d261 2 - Secret Key: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF Plaintext: 51866FD5B85ECB8A -> Ciphertext: ba8a39a94193adc1 3 - Secret Key: 30000000000000001000000000000001 Plaintext: 7D856F9A613063F2 -> Ciphertext: c170d6977baf4aff 4 - Secret Key: 11111111111111111111111111111111 Plaintext: 2466DD878B963C9D -> Ciphertext: 695cffb69dc5b0ba 5 - Secret Key: 0123456789ABCDEF1111111111111111 Plaintext: 61F9C3802281B096 -> Ciphertext: 354d26a3d1c5d031 6 - Secret Key: 11111111111111110123456789ABCDEF Plaintext: 7D0CC630AFDA1EC7 -> Ciphertext: 3f389598f060d6c6 7 - Secret Key: FEDCBA98765432100123456789ABCDEF Plaintext: 0ACEAB0FC6A0A28D -> Ciphertext: 52ba6077910130bb 8 - Secret Key: 7CA110454A1A6E5701A1D6D039776742 Plaintext: 59C68245EB05282B -> Ciphertext: 8e1482495aae7782 9 - Secret Key: 0131D9619DC1376E5CD54CA83DEF57DA Plaintext: B1B8CC0B250F09A0 -> Ciphertext: 278ec4570afba00b 10 - Secret Key: 07A1133E4A0B26860248D43806F67172 Plaintext: 1730E5778BEA1DA4 -> Ciphertext: a721af5f8fe286e6 11 - Secret Key: 3849674C2602319E51454B582DDF440A Plaintext: A25E7856CF2651EB -> Ciphertext: 41b5844b528debcb 12 - Secret Key: 04B915BA43FEB5B642FD443059577FA2 Plaintext: 353882B109CE8F1A -> Ciphertext: c7e83f0896578ab9 13 - Secret Key: 0113B970FD34F2CE059B5E0851CF143A Plaintext: 48F4D0884C379918 -> Ciphertext: 574315272a39d844 14 - Secret Key: 0170F175468FB5E60756D8E0774761D2 Plaintext: 432193B78951FC98 -> Ciphertext: 5968c3c90812be01 15 - Secret Key: 43297FAD38E373FE762514B829BF486A Plaintext: 13F04154D69D1AE5 -> Ciphertext: 9229b7e3b6b17768 16 - Secret Key: 07A7137045DA2A163BDD119049372802 Plaintext: 2EEDDA93FFD39C79 -> Ciphertext: 49db91a767ed20be 17 - Secret Key: 04689104C2FD3B2F26955F6835AF609A Plaintext: D887E0393C2DA6E3 -> Ciphertext: 19ff040a73e6fc0c 18 - Secret Key: 37D06BB516CB7546164D5E404F275232 Plaintext: 5F99D04F5B163969 -> Ciphertext: 7b6a20e27d980095 19 - Secret Key: 1F08260D1AC2465E6B056E18759F5CCA Plaintext: 4A057A3B24D3977B -> Ciphertext: de229e1ebd41b5b8 20 - Secret Key: 584023641ABA6176004BD6EF09176062 Plaintext: 452031C1E4FADA8E -> Ciphertext: 0fddde1a8a5b83f0 21 - Secret Key: 025816164629B007480D39006EE762F2 Plaintext: 7555AE39F59B87BD -> Ciphertext: febd1d7e17cbca41 22 - Secret Key: 49793EBC79B3258F437540C8698F3CFA Plaintext: 53C55F9CB49FC019 -> Ciphertext: a7ed7f44b8b2d1ad 23 - Secret Key: 4FB05E1515AB73A7072D43A077075292 Plaintext: 7A8E7BFA937E89A3 -> Ciphertext: 395b6287fc04bf00 24 - Secret Key: 49E95D6D4CA229BF02FE55778117F12A Plaintext: CF9C5D7A4986ADB5 -> Ciphertext: a3d5548f3df976be 25 - Secret Key: 018310DC409B26D61D9D5C5018F728C2 Plaintext: D1ABB290658BC778 -> Ciphertext: a97ac0003948a6af 26 - Secret Key: 1C587F1C13924FEF305532286D6F295A Plaintext: 55CB3774D13EF201 -> Ciphertext: b046252396442237 27 - Secret Key: 01010101010101010123456789ABCDEF Plaintext: FA34EC4847B268B2 -> Ciphertext: 60c5baade0c9c3e3 28 - Secret Key: 1F1F1F1F0E0E0E0E0123456789ABCDEF Plaintext: A790795108EA3CAE -> Ciphertext: 91e789440185282e 29 - Secret Key: E0FEE0FEF1FEF1FE0123456789ABCDEF Plaintext: C39E072D9FAC631D -> Ciphertext: b37736664428e3fa 30 - Secret Key: 0000000000000000FFFFFFFFFFFFFFFF Plaintext: 014933E0CDAFF6E4 -> Ciphertext: ffda124b8354e2bd 31 - Secret Key: FFFFFFFFFFFFFFFF0000000000000000 Plaintext: F21E9A77B71C49BC -> Ciphertext: 5bc51f22e32c2ce8 32 - Secret Key: 0123456789ABCDEF0000000000000000 Plaintext: 245946885754369A -> Ciphertext: bfaf44bdd441f9f6 33 - Secret Key: FEDCBA9876543210FFFFFFFFFFFFFFFF Plaintext: 6B5C5A9C5D9E0A5A -> Ciphertext: bdc6cd6e802de097
Table of Contents
Installing Crypt::Blowfish 2.14 with ActivePerl
Crypt::Blowfish Behavior Tests
Secret Keys with Repeating Pattern
Crypt::Blowfish Verification with Test Vectors
►Blowfish Test Vectors with 16-Byte Keys
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