"bf-ofb" 2-Block Test Vectors

A tutorial example is provided to show how to build a table of test vectors for Blowfish algorithm in OFB mode on 2-block (16-byte) plaintext messages using OpenSSL 'enc -bf-ofb' command.

Since there are not enough test vectors published on the Internet for Blowfish algorithm in OFB operation mode, let's build a test vector table with 2-block plaintext messages.

Here is my Perl script, which takes a list of secret keys, IV and plaintext, then encrypts them one by one by calling the OpenSSL "enc -bf-ofb" command:

#- OpenSSL-bf-ofb-2-Block-Test-Vector.pl
#- Copyright (c) 2015, HerongYang.com, All Rights Reserved.
#- 
   @tests = split(/\n/, getInput());
   print("Blowfish OFB 2-Block Test Vectors in Hex:\n");
   foreach (@tests) {
      ($i, $keyHex, $ivHex, $plainHex) = split(/ +/,$_);
      open(OUT, "> plain.txt");
      binmode(OUT);
      print OUT pack('H*',$plainHex);
      close(OUT);

      $cmd = "\\local\\gnuwin32\\bin\\openssl enc -bf-ofb -e "
           . "-K $keyHex$keyHex -iv $ivHex " 
           . "-in plain.txt -out cipher.txt -nopad";
      system($cmd);
      
      open(IN, "< cipher.txt");
      binmode(IN);
      read(IN,$cipherStr,16);
      $cipherHex = unpack('H*',$cipherStr);
      close(IN);

      print("$i - Secret Key: $keyHex + IV: $ivHex\n");
      print("   Plaintext: $plainHex\n");
      print("   Ciphertext: $cipherHex\n");
   }

sub getInput {
   return $input = << 'EOD';
1  0000000000000000 0000000000000000 E1C030E74C14D2614EF997456198DD78
2  FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF BA8A39A94193ADC151866FD5B85ECB8A
3  3000000000000000 1000000000000001 C170D6977BAF4AFF7D856F9A613063F2
4  1111111111111111 1111111111111111 695CFFB69DC5B0BA2466DD878B963C9D
5  0123456789ABCDEF 1111111111111111 354D26A3D1C5D03161F9C3802281B096
6  1111111111111111 0123456789ABCDEF 3F389598F060D6C67D0CC630AFDA1EC7
7  FEDCBA9876543210 0123456789ABCDEF 52BA6077910130BB0ACEAB0FC6A0A28D
8  7CA110454A1A6E57 01A1D6D039776742 8E1482495AAE778259C68245EB05282B
9  0131D9619DC1376E 5CD54CA83DEF57DA 278EC4570AFBA00BB1B8CC0B250F09A0
10 07A1133E4A0B2686 0248D43806F67172 A721AF5F8FE286E61730E5778BEA1DA4
11 3849674C2602319E 51454B582DDF440A 41B5844B528DEBCBA25E7856CF2651EB
12 04B915BA43FEB5B6 42FD443059577FA2 C7E83F0896578AB9353882B109CE8F1A
13 0113B970FD34F2CE 059B5E0851CF143A 574315272A39D84448F4D0884C379918
14 0170F175468FB5E6 0756D8E0774761D2 5968C3C90812BE01432193B78951FC98
15 43297FAD38E373FE 762514B829BF486A 9229B7E3B6B1776813F04154D69D1AE5
16 07A7137045DA2A16 3BDD119049372802 49DB91A767ED20BE2EEDDA93FFD39C79
17 04689104C2FD3B2F 26955F6835AF609A 19FF040A73E6FC0CD887E0393C2DA6E3
18 37D06BB516CB7546 164D5E404F275232 7B6A20E27D9800955F99D04F5B163969
19 1F08260D1AC2465E 6B056E18759F5CCA DE229E1EBD41B5B84A057A3B24D3977B
20 584023641ABA6176 004BD6EF09176062 0FDDDE1A8A5B83F0452031C1E4FADA8E
21 025816164629B007 480D39006EE762F2 FEBD1D7E17CBCA417555AE39F59B87BD
22 49793EBC79B3258F 437540C8698F3CFA A7ED7F44B8B2D1AD53C55F9CB49FC019
23 4FB05E1515AB73A7 072D43A077075292 395B6287FC04BF007A8E7BFA937E89A3
24 49E95D6D4CA229BF 02FE55778117F12A A3D5548F3DF976BECF9C5D7A4986ADB5
25 018310DC409B26D6 1D9D5C5018F728C2 A97AC0003948A6AFD1ABB290658BC778
26 1C587F1C13924FEF 305532286D6F295A B04625239644223755CB3774D13EF201
27 0101010101010101 0123456789ABCDEF 60C5BAADE0C9C3E3FA34EC4847B268B2
28 1F1F1F1F0E0E0E0E 0123456789ABCDEF 91E789440185282EA790795108EA3CAE
29 E0FEE0FEF1FEF1FE 0123456789ABCDEF B37736664428E3FAC39E072D9FAC631D
30 0000000000000000 FFFFFFFFFFFFFFFF FFDA124B8354E2BD014933E0CDAFF6E4
31 FFFFFFFFFFFFFFFF 0000000000000000 5BC51F22E32C2CE8F21E9A77B71C49BC
32 0123456789ABCDEF 0000000000000000 BFAF44BDD441F9F6245946885754369A
33 FEDCBA9876543210 FFFFFFFFFFFFFFFF BDC6CD6E802DE0976B5C5A9C5D9E0A5A
EOD
}

Note that we have to binary mode when writing and reading data to and from files. Also note that we have to use the secret key twice, "-K $keyHex$keyHex", to avoid OpenSSL padding it with 0x00, because it has only 8 bytes.

When running the example script, I got the following:

Blowfish OFB 2-Block Test Vectors in Hex:
1 - Secret Key: 0000000000000000 + IV: 0000000000000000
   Plaintext: E1C030E74C14D2614EF997456198DD78
   Ciphertext: af39a7a22d8c0f19af39a7a22d8c0f19
2 - Secret Key: FFFFFFFFFFFFFFFF + IV: FFFFFFFFFFFFFFFF
   Plaintext: BA8A39A94193ADC151866FD5B85ECB8A
   Ciphertext: eb0c567cf9cd664beb0c567cf9cd664b
3 - Secret Key: 3000000000000000 + IV: 1000000000000001
   Plaintext: C170D6977BAF4AFF7D856F9A613063F2
   Ciphertext: bcf5b90d1a9f290de32af8538f065c22
4 - Secret Key: 1111111111111111 + IV: 1111111111111111
   Plaintext: 695CFFB69DC5B0BA2466DD878B963C9D
   Ciphertext: 4d3a223116538c274d3a223116538c27
5 - Secret Key: 0123456789ABCDEF + IV: 1111111111111111
   Plaintext: 354D26A3D1C5D03161F9C3802281B096
   Ciphertext: 54b4e523f34460a7a941d4928c87c4e1
6 - Secret Key: 1111111111111111 + IV: 0123456789ABCDEF
   Plaintext: 3F389598F060D6C67D0CC630AFDA1EC7
   Ciphertext: 423453a85fbac801354f9d5832cf97e1
7 - Secret Key: FEDCBA9876543210 + IV: 0123456789ABCDEF
   Plaintext: 52BA6077910130BB0ACEAB0FC6A0A28D
   Ciphertext: 5874cb7857a19236bc9b974a38a0877b
8 - Secret Key: 7CA110454A1A6E57 + IV: 01A1D6D039776742
   Plaintext: 8E1482495AAE778259C68245EB05282B
   Ciphertext: d7d2000cb1ab5fa923c6b7a25f5d6c79
9 - Secret Key: 0131D9619DC1376E + IV: 5CD54CA83DEF57DA
   Plaintext: 278EC4570AFBA00BB1B8CC0B250F09A0
   Ciphertext: 9636085c2ff4a9ab532ddcf67c6db496
10 - Secret Key: 07A1133E4A0B2686 + IV: 0248D43806F67172
   Plaintext: A721AF5F8FE286E61730E5778BEA1DA4
   Ciphertext: b0114a2804089b4219eb13227b59b104
11 - Secret Key: 3849674C2602319E + IV: 51454B582DDF440A
   Plaintext: 41B5844B528DEBCBA25E7856CF2651EB
   Ciphertext: e3ebfc1d9dabba20c3c7d3884dfdc6de
12 - Secret Key: 04B915BA43FEB5B6 + IV: 42FD443059577FA2
   Plaintext: C7E83F0896578AB9353882B109CE8F1A
   Ciphertext: f2d0bdb99f9905a3d6365541c7bfec81
13 - Secret Key: 0113B970FD34F2CE + IV: 059B5E0851CF143A
   Plaintext: 574315272A39D84448F4D0884C379918
   Ciphertext: 1fb7c5af660e415ca5a5a0ec270a1c82
14 - Secret Key: 0170F175468FB5E6 + IV: 0756D8E0774761D2
   Plaintext: 5968C3C90812BE01432193B78951FC98
   Ciphertext: 1a49507e8143429959736490b6140d3d
15 - Secret Key: 43297FAD38E373FE + IV: 762514B829BF486A
   Plaintext: 9229B7E3B6B1776813F04154D69D1AE5
   Ciphertext: 81d9f6b7602c6d8dd42fd1f09e259c33
16 - Secret Key: 07A7137045DA2A16 + IV: 3BDD119049372802
   Plaintext: 49DB91A767ED20BE2EEDDA93FFD39C79
   Ciphertext: 67364b34983ebcc7c3ad3008a1748aa6
17 - Secret Key: 04689104C2FD3B2F + IV: 26955F6835AF609A
   Plaintext: 19FF040A73E6FC0CD887E0393C2DA6E3
   Ciphertext: c178e4334fcb5aefdd22c329bbbc574b
18 - Secret Key: 37D06BB516CB7546 + IV: 164D5E404F275232
   Plaintext: 7B6A20E27D9800955F99D04F5B163969
   Ciphertext: 24f3f0ad268e39fc7f088b5a6c2e7749
19 - Secret Key: 1F08260D1AC2465E + IV: 6B056E18759F5CCA
   Plaintext: DE229E1EBD41B5B84A057A3B24D3977B
   Ciphertext: 9427e425999222c399faeb58eec40264
20 - Secret Key: 584023641ABA6176 + IV: 004BD6EF09176062
   Plaintext: 0FDDDE1A8A5B83F0452031C1E4FADA8E
   Ciphertext: 4afdefdb6ea1597e65ccb00f8db3f12d
21 - Secret Key: 025816164629B007 + IV: 480D39006EE762F2
   Plaintext: FEBD1D7E17CBCA417555AE39F59B87BD
   Ciphertext: 8be8b347e2504dfcad04dcfb94c5c6b0
22 - Secret Key: 49793EBC79B3258F + IV: 437540C8698F3CFA
   Plaintext: A7ED7F44B8B2D1AD53C55F9CB49FC019
   Ciphertext: f42820d80c2d11b47dec7318e4f97afa
23 - Secret Key: 4FB05E1515AB73A7 + IV: 072D43A077075292
   Plaintext: 395B6287FC04BF007A8E7BFA937E89A3
   Ciphertext: 43d5197d6f7a36a3037779347b2a1e81
24 - Secret Key: 49E95D6D4CA229BF + IV: 02FE55778117F12A
   Plaintext: A3D5548F3DF976BECF9C5D7A4986ADB5
   Ciphertext: 6c4909f5747fdb0b1b9bdd6fee149017
25 - Secret Key: 018310DC409B26D6 + IV: 1D9D5C5018F728C2
   Plaintext: A97AC0003948A6AFD1ABB290658BC778
   Ciphertext: 78d172905cc361d7dead2a5ce8fb2e31
26 - Secret Key: 1C587F1C13924FEF + IV: 305532286D6F295A
   Plaintext: B04625239644223755CB3774D13EF201
   Ciphertext: e58d1257477ad036fc75ecc9226e564a
27 - Secret Key: 0101010101010101 + IV: 0123456789ABCDEF
   Plaintext: 60C5BAADE0C9C3E3FA34EC4847B268B2
   Ciphertext: 9af156e5a77bab51c285fd5eb233f1e6
28 - Secret Key: 1F1F1F1F0E0E0E0E + IV: 0123456789ABCDEF
   Plaintext: 91E789440185282EA790795108EA3CAE
   Ciphertext: 3677f015096f1480ff4502f5b4f17bbc
29 - Secret Key: E0FEE0FEF1FEF1FE + IV: 0123456789ABCDEF
   Plaintext: B37736664428E3FAC39E072D9FAC631D
   Ciphertext: 70e9314bdb8480e736354ebd17eb412d
30 - Secret Key: 0000000000000000 + IV: FFFFFFFFFFFFFFFF
   Plaintext: FFDA124B8354E2BD014933E0CDAFF6E4
   Ciphertext: fe9321ab4efb1459215fff837fea938e
31 - Secret Key: FFFFFFFFFFFFFFFF + IV: 0000000000000000
   Plaintext: 5BC51F22E32C2CE8F21E9A77B71C49BC
   Ciphertext: a9db85555430655460e44366c6079f9a
32 - Secret Key: 0123456789ABCDEF + IV: 0000000000000000
   Plaintext: BFAF44BDD441F9F6245946885754369A
   Ciphertext: 9bf602358315cf6cc31667d3c1938ef7
33 - Secret Key: FEDCBA9876543210 + IV: FFFFFFFFFFFFFFFF
   Plaintext: BDC6CD6E802DE0976B5C5A9C5D9E0A5A
   Ciphertext: d69a97f2ddb3eacd3416e4d0657cf4d1

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

 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

 "bf-ofb" Cipher with Literal Key

 "bf-ofb" Cipher on Multiple Blocks

 "bf-ofb" Encryption Verification

"bf-ofb" 2-Block Test Vectors

 "bf-ofb" Cipher with Salted Key

 "bf-ofb" Cipher with Random Salt

 "enc -bf-ofb" Command Summary

 References

 PDF Printing Version