13 #define BLOWFISH_KEY_MIN_LEN 128
14 #define BLOWFISH_KEY_MAX_LEN 448
18 * Blowfish CBC encryption test vectors
22 * Test vector by Eric Young
25 static const u_char bf_test0_key
[] = {
26 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
27 0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87
30 static const u_char bf_test0_iv
[] = {
31 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10
34 static const u_char bf_test0_plain
[] = {
35 /* "7654321 Now is the time for " */
36 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
37 0x4E, 0x6F, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
38 0x68, 0x65, 0x20, 0x74, 0x69, 0x6D, 0x65, 0x20,
39 0x66, 0x6F, 0x72, 0x20, 0x00, 0x00, 0x00, 0x00
42 static const u_char bf_test0_cipher
[] = {
43 0x6B, 0x77, 0xB4, 0xD6, 0x30, 0x06, 0xDE, 0xE6,
44 0x05, 0xB1, 0x56, 0xE2, 0x74, 0x03, 0x97, 0x93,
45 0x58, 0xDE, 0xB9, 0xE7, 0x15, 0x46, 0x16, 0xD9,
46 0x59, 0xF1, 0x65, 0x2B, 0xD5, 0xFF, 0x92, 0xCC
50 * Test vector by Chilkat Software
51 * (www.chilkatsoft.com/p/php_blowfish.asp)
54 static const u_char bf_test1_key
[] = {
55 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
56 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
57 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
58 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50
61 static const u_char bf_test1_iv
[] = {
62 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38
65 static const u_char bf_test1_plain
[] = {
66 /* "The quick brown fox jumped over the lazy dog" */
67 0x54, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63,
68 0x6b, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e, 0x20,
69 0x66, 0x6f, 0x78, 0x20, 0x6a, 0x75, 0x6d, 0x70,
70 0x65, 0x64, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x20,
71 0x74, 0x68, 0x65, 0x20, 0x6c, 0x61, 0x7a, 0x79,
72 0x20, 0x64, 0x6f, 0x67, 0x00, 0x00, 0x00, 0x00
75 static const u_char bf_test1_cipher
[] = {
76 0x27, 0x68, 0x55, 0xca, 0x6c, 0x0d, 0x60, 0xf7,
77 0xd9, 0x70, 0x82, 0x10, 0x44, 0x0c, 0x10, 0x72,
78 0xe0, 0x5d, 0x07, 0x8e, 0x73, 0x3b, 0x34, 0xb4,
79 0x19, 0x8d, 0x60, 0x9d, 0xc2, 0xfc, 0xc2, 0xf0,
80 0xc3, 0x09, 0x26, 0xcd, 0xef, 0x3b, 0x6d, 0x52,
81 0xba, 0xf6, 0xe3, 0x45, 0xaa, 0x03, 0xf8, 0x3e
84 static const enc_testvector_t bf_enc_testvectors
[] = {
85 { sizeof(bf_test0_key
), bf_test0_key
, bf_test0_iv
,
86 sizeof(bf_test0_plain
), bf_test0_plain
, bf_test0_cipher
},
87 { sizeof(bf_test1_key
), bf_test1_key
, bf_test1_iv
,
88 sizeof(bf_test1_plain
), bf_test1_plain
, bf_test1_cipher
},
89 { 0, NULL
, NULL
, 0, NULL
, NULL
}
92 struct encrypt_desc algo_blowfish
=
94 algo_type
: IKE_ALG_ENCRYPT
,
95 algo_id
: OAKLEY_BLOWFISH_CBC
,
98 enc_blocksize
: BLOWFISH_BLOCK_SIZE
,
99 keyminlen
: BLOWFISH_KEY_MIN_LEN
,
100 keydeflen
: BLOWFISH_KEY_MIN_LEN
,
101 keymaxlen
: BLOWFISH_KEY_MAX_LEN
,
102 enc_testvectors
: bf_enc_testvectors
,
105 int ike_alg_blowfish_init(void);
108 ike_alg_blowfish_init(void)
110 int ret
= ike_alg_register_enc(&algo_blowfish
);
115 IKE_ALG_INIT_NAME: ike_alg_blowfish_init