From 0fb1ec30001352065c76c5c6a42bdef362b522d9 Mon Sep 17 00:00:00 2001 From: Kasoju Mallikarjun Date: Wed, 1 Jun 2011 18:06:46 +0530 Subject: crypto: testmgr - Adding ofb(aes) and cmac(aes) tests Added ofb(aes) and cmac(aes) tests Original-Change-Id: Ia79b0f979af88d337e91164f0b8b6d0eba18cd03 Reviewed-on: http://git-master/r/34701 Reviewed-by: Mallikarjun Kasoju Tested-by: Mallikarjun Kasoju Reviewed-by: Hanumanth Venkateswa Moganty Rebase-Id: R383d7f642cab41350f54367687861615f9484cf3 --- crypto/tcrypt.c | 8 ++ crypto/testmgr.c | 10 ++ crypto/testmgr.h | 274 +++++++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 232 insertions(+), 60 deletions(-) (limited to 'crypto') diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 66d254ce0d11..862ca71f032c 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -1174,6 +1174,10 @@ static int do_test(int m) ret += tcrypt_test("ghash"); break; + case 47: + ret += tcrypt_test("ofb(aes)"); + break; + case 100: ret += tcrypt_test("hmac(md5)"); break; @@ -1218,6 +1222,10 @@ static int do_test(int m) ret += tcrypt_test("hmac(crc32)"); break; + case 110: + ret += tcrypt_test("cmac(aes)"); + break; + case 150: ret += tcrypt_test("ansi_cprng"); break; diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 5823735cf381..e7b1938a2edf 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -1942,6 +1942,16 @@ static const struct alg_test_desc alg_test_descs[] = { } } } + },{ + .alg = "cmac(aes)", + .test = alg_test_hash, + .fips_allowed = 1, + .suite = { + .hash = { + .vecs = cmac_aes_tv_template, + .count = CMAC_AES_TEST_VECTORS + } + } }, { .alg = "cmac(aes)", .test = alg_test_hash, diff --git a/crypto/testmgr.h b/crypto/testmgr.h index 1e701bc075b9..51f6f32488d6 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h @@ -657,6 +657,59 @@ static struct hash_testvec sha512_tv_template[] = { }, }; +#define CMAC_AES_TEST_VECTORS 4 + +static struct hash_testvec cmac_aes_tv_template[] = { + { + .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6" + "\xab\xf7\x15\x88\x09\xcf\x4f\x3c", + .ksize = 16, + .plaintext = "", + .psize = 0, + .digest = "\xbb\x1d\x69\x29\xe9\x59\x37\x28" + "\x7f\xa3\x7d\x12\x9b\x75\x67\x46", + }, + { + .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6" + "\xab\xf7\x15\x88\x09\xcf\x4f\x3c", + .ksize = 16, + .plaintext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" + "\xe9\x3d\x7e\x11\x73\x93\x17\x2a", + .psize = 16, + .digest = "\x07\x0a\x16\xb4\x6b\x4d\x41\x44" + "\xf7\x9b\xdd\x9d\xd0\x4a\x28\x7c", + }, + { + .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6" + "\xab\xf7\x15\x88\x09\xcf\x4f\x3c", + .ksize = 16, + .plaintext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" + "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" + "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" + "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" + "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11", + .psize = 40, + .digest = "\xdf\xa6\x67\x47\xde\x9a\xe6\x30" + "\x30\xca\x32\x61\x14\x97\xc8\x27", + }, + { + .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6" + "\xab\xf7\x15\x88\x09\xcf\x4f\x3c", + .ksize = 16, + .plaintext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" + "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" + "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" + "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" + "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" + "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" + "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" + "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + .psize = 64, + .digest = "\x51\xf0\xbe\xbf\x7e\x3b\x9d\x92" + "\xfc\x49\x74\x17\x79\x36\x3c\xfe", + }, + +}; /* * WHIRLPOOL test vectors from Whirlpool package @@ -12797,8 +12850,8 @@ static struct cipher_testvec cast6_xts_dec_tv_template[] = { #define AES_XTS_DEC_TEST_VECTORS 5 #define AES_CTR_ENC_TEST_VECTORS 5 #define AES_CTR_DEC_TEST_VECTORS 5 -#define AES_OFB_ENC_TEST_VECTORS 1 -#define AES_OFB_DEC_TEST_VECTORS 1 +#define AES_OFB_ENC_TEST_VECTORS 3 +#define AES_OFB_DEC_TEST_VECTORS 3 #define AES_CTR_3686_ENC_TEST_VECTORS 7 #define AES_CTR_3686_DEC_TEST_VECTORS 6 #define AES_GCM_ENC_TEST_VECTORS 9 @@ -16327,6 +16380,165 @@ static struct cipher_testvec aes_ctr_dec_tv_template[] = { }, }; +static struct cipher_testvec aes_ofb_enc_tv_template[] = { + { /* From NIST Special Publication 800-38A, Appendix F.5 */ + .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6" + "\xab\xf7\x15\x88\x09\xcf\x4f\x3c", + .klen = 16, + .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" + "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" + "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" + "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" + "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" + "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" + "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" + "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + .ilen = 64, + .result = "\x3B\x3F\xD9\x2E\xB7\x2D\xAD\x20" + "\x33\x34\x49\xF8\xE8\x3C\xFB\x4A" + "\x77\x89\x50\x8D\x16\x91\x8F\x03" + "\xF5\x3C\x52\xDA\xC5\x4E\xD8\x25" + "\x97\x40\x05\x1E\x9C\x5F\xEC\xF6" + "\x43\x44\xF7\xA8\x22\x60\xED\xCC" + "\x30\x4C\x65\x28\xF6\x59\xC7\x78" + "\x66\xA5\x10\xD9\xC1\xD6\xAE\x5E", + .rlen = 64, + }, { + .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52" + "\xc8\x10\xf3\x2b\x80\x90\x79\xe5" + "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", + .klen = 24, + .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" + "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" + "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" + "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" + "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" + "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" + "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" + "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + .ilen = 64, + .result = "\xCD\xC8\x0D\x6F\xDD\xF1\x8C\xAB" + "\x34\xC2\x59\x09\xC9\x9A\x41\x74" + "\xFC\xC2\x8B\x8D\x4C\x63\x83\x7C" + "\x09\xE8\x17\x00\xC1\x10\x04\x01" + "\x8D\x9A\x9A\xEA\xC0\xF6\x59\x6F" + "\x55\x9C\x6D\x4D\xAF\x59\xA5\xF2" + "\x6D\x9F\x20\x08\x57\xCA\x6C\x3E" + "\x9C\xAC\x52\x4B\xD9\xAC\xC9\x2A", + .rlen = 64, + }, { + .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe" + "\x2b\x73\xae\xf0\x85\x7d\x77\x81" + "\x1f\x35\x2c\x07\x3b\x61\x08\xd7" + "\x2d\x98\x10\xa3\x09\x14\xdf\xf4", + .klen = 32, + .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" + "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" + "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" + "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" + "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" + "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" + "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" + "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + .ilen = 64, + .result = "\xDC\x7E\x84\xBF\xDA\x79\x16\x4B" + "\x7E\xCD\x84\x86\x98\x5D\x38\x60" + "\x4F\xEB\xDC\x67\x40\xD2\x0B\x3A" + "\xC8\x8F\x6A\xD8\x2A\x4F\xB0\x8D" + "\x71\xAB\x47\xA0\x86\xE8\x6E\xED" + "\xF3\x9D\x1C\x5B\xBA\x97\xC4\x08" + "\x01\x26\x14\x1D\x67\xF3\x7B\xE8" + "\x53\x8F\x5A\x8B\xE7\x40\xE4\x84", + .rlen = 64, + } +}; + +static struct cipher_testvec aes_ofb_dec_tv_template[] = { + /* From NIST Special Publication 800-38A, Appendix F.5 */ + { + .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6" + "\xab\xf7\x15\x88\x09\xcf\x4f\x3c", + .klen = 16, + .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + .input = "\x3B\x3F\xD9\x2E\xB7\x2D\xAD\x20" + "\x33\x34\x49\xF8\xE8\x3C\xFB\x4A" + "\x77\x89\x50\x8D\x16\x91\x8F\x03" + "\xF5\x3C\x52\xDA\xC5\x4E\xD8\x25" + "\x97\x40\x05\x1E\x9C\x5F\xEC\xF6" + "\x43\x44\xF7\xA8\x22\x60\xED\xCC" + "\x30\x4C\x65\x28\xF6\x59\xC7\x78" + "\x66\xA5\x10\xD9\xC1\xD6\xAE\x5E", + .ilen = 64, + .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" + "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" + "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" + "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" + "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" + "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" + "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" + "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + .rlen = 64, + }, { + .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52" + "\xc8\x10\xf3\x2b\x80\x90\x79\xe5" + "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", + .klen = 24, + .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + .input = "\xCD\xC8\x0D\x6F\xDD\xF1\x8C\xAB" + "\x34\xC2\x59\x09\xC9\x9A\x41\x74" + "\xFC\xC2\x8B\x8D\x4C\x63\x83\x7C" + "\x09\xE8\x17\x00\xC1\x10\x04\x01" + "\x8D\x9A\x9A\xEA\xC0\xF6\x59\x6F" + "\x55\x9C\x6D\x4D\xAF\x59\xA5\xF2" + "\x6D\x9F\x20\x08\x57\xCA\x6C\x3E" + "\x9C\xAC\x52\x4B\xD9\xAC\xC9\x2A", + .ilen = 64, + .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" + "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" + "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" + "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" + "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" + "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" + "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" + "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + .rlen = 64, + }, { + .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe" + "\x2b\x73\xae\xf0\x85\x7d\x77\x81" + "\x1f\x35\x2c\x07\x3b\x61\x08\xd7" + "\x2d\x98\x10\xa3\x09\x14\xdf\xf4", + .klen = 32, + .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + .input = "\xDC\x7E\x84\xBF\xDA\x79\x16\x4B" + "\x7E\xCD\x84\x86\x98\x5D\x38\x60" + "\x4F\xEB\xDC\x67\x40\xD2\x0B\x3A" + "\xC8\x8F\x6A\xD8\x2A\x4F\xB0\x8D" + "\x71\xAB\x47\xA0\x86\xE8\x6E\xED" + "\xF3\x9D\x1C\x5B\xBA\x97\xC4\x08" + "\x01\x26\x14\x1D\x67\xF3\x7B\xE8" + "\x53\x8F\x5A\x8B\xE7\x40\xE4\x84", + .ilen = 64, + .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" + "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" + "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" + "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" + "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" + "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" + "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" + "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + .rlen = 64, + } +}; + static struct cipher_testvec aes_ctr_rfc3686_enc_tv_template[] = { { /* From RFC 3686 */ .key = "\xae\x68\x52\xf8\x12\x10\x67\xcc" @@ -17550,64 +17762,6 @@ static struct cipher_testvec aes_ctr_rfc3686_dec_tv_template[] = { }, }; -static struct cipher_testvec aes_ofb_enc_tv_template[] = { - /* From NIST Special Publication 800-38A, Appendix F.5 */ - { - .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6" - "\xab\xf7\x15\x88\x09\xcf\x4f\x3c", - .klen = 16, - .iv = "\x00\x01\x02\x03\x04\x05\x06\x07\x08" - "\x09\x0a\x0b\x0c\x0d\x0e\x0f", - .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" - "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" - "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" - "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" - "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" - "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" - "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" - "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", - .ilen = 64, - .result = "\x3b\x3f\xd9\x2e\xb7\x2d\xad\x20" - "\x33\x34\x49\xf8\xe8\x3c\xfb\x4a" - "\x77\x89\x50\x8d\x16\x91\x8f\x03\xf5" - "\x3c\x52\xda\xc5\x4e\xd8\x25" - "\x97\x40\x05\x1e\x9c\x5f\xec\xf6\x43" - "\x44\xf7\xa8\x22\x60\xed\xcc" - "\x30\x4c\x65\x28\xf6\x59\xc7\x78" - "\x66\xa5\x10\xd9\xc1\xd6\xae\x5e", - .rlen = 64, - } -}; - -static struct cipher_testvec aes_ofb_dec_tv_template[] = { - /* From NIST Special Publication 800-38A, Appendix F.5 */ - { - .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6" - "\xab\xf7\x15\x88\x09\xcf\x4f\x3c", - .klen = 16, - .iv = "\x00\x01\x02\x03\x04\x05\x06\x07\x08" - "\x09\x0a\x0b\x0c\x0d\x0e\x0f", - .input = "\x3b\x3f\xd9\x2e\xb7\x2d\xad\x20" - "\x33\x34\x49\xf8\xe8\x3c\xfb\x4a" - "\x77\x89\x50\x8d\x16\x91\x8f\x03\xf5" - "\x3c\x52\xda\xc5\x4e\xd8\x25" - "\x97\x40\x05\x1e\x9c\x5f\xec\xf6\x43" - "\x44\xf7\xa8\x22\x60\xed\xcc" - "\x30\x4c\x65\x28\xf6\x59\xc7\x78" - "\x66\xa5\x10\xd9\xc1\xd6\xae\x5e", - .ilen = 64, - .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" - "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" - "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" - "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" - "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" - "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" - "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" - "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", - .rlen = 64, - } -}; - static struct aead_testvec aes_gcm_enc_tv_template[] = { { /* From McGrew & Viega - http://citeseer.ist.psu.edu/656989.html */ .key = zeroed_string, -- cgit v1.2.3