From: Tobias Brunner Date: Wed, 10 Apr 2013 17:26:05 +0000 (+0200) Subject: Add test vectors for RC2 X-Git-Tag: 5.1.0dr1~149^2~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cb38e2f30ad771e8985b6c45203a56fea00608ce;p=thirdparty%2Fstrongswan.git Add test vectors for RC2 --- diff --git a/src/libstrongswan/plugins/test_vectors/Makefile.am b/src/libstrongswan/plugins/test_vectors/Makefile.am index 5280300a8d..20716d3a0d 100644 --- a/src/libstrongswan/plugins/test_vectors/Makefile.am +++ b/src/libstrongswan/plugins/test_vectors/Makefile.am @@ -26,6 +26,7 @@ libstrongswan_test_vectors_la_SOURCES = \ test_vectors/des.c \ test_vectors/idea.c \ test_vectors/null.c \ + test_vectors/rc2.c \ test_vectors/rc5.c \ test_vectors/serpent_cbc.c \ test_vectors/twofish_cbc.c \ diff --git a/src/libstrongswan/plugins/test_vectors/test_vectors.h b/src/libstrongswan/plugins/test_vectors/test_vectors.h index a004697792..788baae573 100644 --- a/src/libstrongswan/plugins/test_vectors/test_vectors.h +++ b/src/libstrongswan/plugins/test_vectors/test_vectors.h @@ -55,6 +55,14 @@ TEST_VECTOR_CRYPTER(des3_cbc2) TEST_VECTOR_CRYPTER(idea1) TEST_VECTOR_CRYPTER(idea2) TEST_VECTOR_CRYPTER(null1) +TEST_VECTOR_CRYPTER(rc2_1) +TEST_VECTOR_CRYPTER(rc2_2) +TEST_VECTOR_CRYPTER(rc2_3) +TEST_VECTOR_CRYPTER(rc2_4) +TEST_VECTOR_CRYPTER(rc2_5) +TEST_VECTOR_CRYPTER(rc2_6) +TEST_VECTOR_CRYPTER(rc2_7) +TEST_VECTOR_CRYPTER(rc2_8) TEST_VECTOR_CRYPTER(rc5_1) TEST_VECTOR_CRYPTER(rc5_2) TEST_VECTOR_CRYPTER(serpent_cbc1) diff --git a/src/libstrongswan/plugins/test_vectors/test_vectors/rc2.c b/src/libstrongswan/plugins/test_vectors/test_vectors/rc2.c new file mode 100644 index 0000000000..b03d12038c --- /dev/null +++ b/src/libstrongswan/plugins/test_vectors/test_vectors/rc2.c @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2013 Tobias Brunner + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the Licenseor (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be usefulbut + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include + +/** + * Test vectors from RFC 2268 + */ + +/** + * RC2 key length 8 bytes, effective key length 63 bits + */ +crypter_test_vector_t rc2_1 = { + .alg = ENCR_RC2_CBC, .key_size = RC2_KEY_SIZE(8, 63), .len = 8, + .key = "\x00\x00\x00\x00\x00\x00\x00\x00", + .iv = "\x00\x00\x00\x00\x00\x00\x00\x00", + .plain = "\x00\x00\x00\x00\x00\x00\x00\x00", + .cipher = "\xeb\xb7\x73\xf9\x93\x27\x8e\xff", +}; + +/** + * RC2 key length 8 bytes, effective key length 64 bits + */ +crypter_test_vector_t rc2_2 = { + .alg = ENCR_RC2_CBC, .key_size = RC2_KEY_SIZE(8, 64), .len = 8, + .key = "\xff\xff\xff\xff\xff\xff\xff\xff", + .iv = "\x00\x00\x00\x00\x00\x00\x00\x00", + .plain = "\xff\xff\xff\xff\xff\xff\xff\xff", + .cipher = "\x27\x8b\x27\xe4\x2e\x2f\x0d\x49", +}; + +/** + * RC2 key length 8 bytes, effective key length 64 bits + */ +crypter_test_vector_t rc2_3 = { + .alg = ENCR_RC2_CBC, .key_size = RC2_KEY_SIZE(8, 64), .len = 8, + .key = "\x30\x00\x00\x00\x00\x00\x00\x00", + .iv = "\x00\x00\x00\x00\x00\x00\x00\x00", + .plain = "\x10\x00\x00\x00\x00\x00\x00\x01", + .cipher = "\x30\x64\x9e\xdf\x9b\xe7\xd2\xc2", +}; + +/** + * RC2 key length 1 byte, effective key length 64 bits + */ +crypter_test_vector_t rc2_4 = { + .alg = ENCR_RC2_CBC, .key_size = RC2_KEY_SIZE(1, 64), .len = 8, + .key = "\x88", + .iv = "\x00\x00\x00\x00\x00\x00\x00\x00", + .plain = "\x00\x00\x00\x00\x00\x00\x00\x00", + .cipher = "\x61\xa8\xa2\x44\xad\xac\xcc\xf0", +}; + +/** + * RC2 key length 7 bytes, effective key length 64 bits + */ +crypter_test_vector_t rc2_5 = { + .alg = ENCR_RC2_CBC, .key_size = RC2_KEY_SIZE(7, 64), .len = 8, + .key = "\x88\xbc\xa9\x0e\x90\x87\x5a", + .iv = "\x00\x00\x00\x00\x00\x00\x00\x00", + .plain = "\x00\x00\x00\x00\x00\x00\x00\x00", + .cipher = "\x6c\xcf\x43\x08\x97\x4c\x26\x7f", +}; + +/** + * RC2 key length 16 bytes, effective key length 64 bits + */ +crypter_test_vector_t rc2_6 = { + .alg = ENCR_RC2_CBC, .key_size = RC2_KEY_SIZE(16, 64), .len = 8, + .key = "\x88\xbc\xa9\x0e\x90\x87\x5a\x7f\x0f\x79\xc3\x84\x62\x7b\xaf\xb2", + .iv = "\x00\x00\x00\x00\x00\x00\x00\x00", + .plain = "\x00\x00\x00\x00\x00\x00\x00\x00", + .cipher = "\x1a\x80\x7d\x27\x2b\xbe\x5d\xb1", +}; + +/** + * RC2 key length 16 bytes, effective key length 128 bits + */ +crypter_test_vector_t rc2_7 = { + .alg = ENCR_RC2_CBC, .key_size = RC2_KEY_SIZE(16, 128), .len = 8, + .key = "\x88\xbc\xa9\x0e\x90\x87\x5a\x7f\x0f\x79\xc3\x84\x62\x7b\xaf\xb2", + .iv = "\x00\x00\x00\x00\x00\x00\x00\x00", + .plain = "\x00\x00\x00\x00\x00\x00\x00\x00", + .cipher = "\x22\x69\x55\x2a\xb0\xf8\x5c\xa6", +}; + +/** + * RC2 key length 33 bytes, effective key length 129 bits + */ +crypter_test_vector_t rc2_8 = { + .alg = ENCR_RC2_CBC, .key_size = RC2_KEY_SIZE(33, 129), .len = 8, + .key = "\x88\xbc\xa9\x0e\x90\x87\x5a\x7f\x0f\x79\xc3\x84\x62\x7b\xaf\xb2" + "\x16\xf8\x0a\x6f\x85\x92\x05\x84\xc4\x2f\xce\xb0\xbe\x25\x5d\xaf\x1e", + .iv = "\x00\x00\x00\x00\x00\x00\x00\x00", + .plain = "\x00\x00\x00\x00\x00\x00\x00\x00", + .cipher = "\x5b\x78\xd3\xa4\x3d\xff\xf1\xf1", +};