diff options
Diffstat (limited to 'src/pluto/alg/ike_alg_blowfish.c')
-rw-r--r-- | src/pluto/alg/ike_alg_blowfish.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/pluto/alg/ike_alg_blowfish.c b/src/pluto/alg/ike_alg_blowfish.c index 2bbef051b..3172cd817 100644 --- a/src/pluto/alg/ike_alg_blowfish.c +++ b/src/pluto/alg/ike_alg_blowfish.c @@ -16,6 +16,81 @@ #define BLOWFISH_KEY_MAX_LEN 448 +/** + * Blowfish CBC encryption test vectors + */ + +/** + * Test vector by Eric Young + */ + +static const u_char bf_test0_key[] = { + 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, + 0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87 +}; + +static const u_char bf_test0_iv[] = { + 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 +}; + +static const u_char bf_test0_plain[] = { + /* "7654321 Now is the time for " */ + 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20, + 0x4E, 0x6F, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74, + 0x68, 0x65, 0x20, 0x74, 0x69, 0x6D, 0x65, 0x20, + 0x66, 0x6F, 0x72, 0x20, 0x00, 0x00, 0x00, 0x00 +}; + +static const u_char bf_test0_cipher[] = { + 0x6B, 0x77, 0xB4, 0xD6, 0x30, 0x06, 0xDE, 0xE6, + 0x05, 0xB1, 0x56, 0xE2, 0x74, 0x03, 0x97, 0x93, + 0x58, 0xDE, 0xB9, 0xE7, 0x15, 0x46, 0x16, 0xD9, + 0x59, 0xF1, 0x65, 0x2B, 0xD5, 0xFF, 0x92, 0xCC +}; + +/** + * Test vector by Chilkat Software + * (www.chilkatsoft.com/p/php_blowfish.asp) + */ + +static const u_char bf_test1_key[] = { + 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50 +}; + +static const u_char bf_test1_iv[] = { + 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38 +}; + +static const u_char bf_test1_plain[] = { + /* "The quick brown fox jumped over the lazy dog" */ + 0x54, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63, + 0x6b, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e, 0x20, + 0x66, 0x6f, 0x78, 0x20, 0x6a, 0x75, 0x6d, 0x70, + 0x65, 0x64, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x20, + 0x74, 0x68, 0x65, 0x20, 0x6c, 0x61, 0x7a, 0x79, + 0x20, 0x64, 0x6f, 0x67, 0x00, 0x00, 0x00, 0x00 +}; + +static const u_char bf_test1_cipher[] = { + 0x27, 0x68, 0x55, 0xca, 0x6c, 0x0d, 0x60, 0xf7, + 0xd9, 0x70, 0x82, 0x10, 0x44, 0x0c, 0x10, 0x72, + 0xe0, 0x5d, 0x07, 0x8e, 0x73, 0x3b, 0x34, 0xb4, + 0x19, 0x8d, 0x60, 0x9d, 0xc2, 0xfc, 0xc2, 0xf0, + 0xc3, 0x09, 0x26, 0xcd, 0xef, 0x3b, 0x6d, 0x52, + 0xba, 0xf6, 0xe3, 0x45, 0xaa, 0x03, 0xf8, 0x3e +}; + +static const enc_testvector_t bf_enc_testvectors[] = { + { sizeof(bf_test0_key), bf_test0_key, bf_test0_iv, + sizeof(bf_test0_plain), bf_test0_plain, bf_test0_cipher }, + { sizeof(bf_test1_key), bf_test1_key, bf_test1_iv, + sizeof(bf_test1_plain), bf_test1_plain, bf_test1_cipher }, + { 0, NULL, NULL, 0, NULL, NULL } +}; + static void do_blowfish(u_int8_t *buf, size_t buf_len, u_int8_t *key, size_t key_size, u_int8_t *iv, bool enc) { @@ -36,6 +111,7 @@ struct encrypt_desc algo_blowfish = keydeflen: BLOWFISH_KEY_MIN_LEN, keymaxlen: BLOWFISH_KEY_MAX_LEN, do_crypt: do_blowfish, + enc_testvectors: bf_enc_testvectors, }; int ike_alg_blowfish_init(void); |