diff options
author | Horia Geanta <horia.geanta@freescale.com> | 2014-03-14 11:46:51 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-03-21 09:54:27 -0400 |
commit | bca4feb0d4fe2d5da1a0f31ef89f63709aba4906 (patch) | |
tree | 35f55c781ce29e88edc0594e2d663464ede00ca5 | |
parent | 72567258f0643eda5d622be16e35fb933aa6146e (diff) |
crypto: testmgr - add aead null encryption test vectors
Add test vectors for aead with null encryption and md5,
respectively sha1 authentication.
Input data is taken from test vectors listed in RFC2410.
Signed-off-by: Horia Geanta <horia.geanta@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | crypto/tcrypt.c | 8 | ||||
-rw-r--r-- | crypto/testmgr.c | 32 | ||||
-rw-r--r-- | crypto/testmgr.h | 180 |
3 files changed, 220 insertions, 0 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 0d9003ae8c61..870be7b4dc05 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
@@ -1511,6 +1511,14 @@ static int do_test(int m) | |||
1511 | ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))"); | 1511 | ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))"); |
1512 | break; | 1512 | break; |
1513 | 1513 | ||
1514 | case 156: | ||
1515 | ret += tcrypt_test("authenc(hmac(md5),ecb(cipher_null))"); | ||
1516 | break; | ||
1517 | |||
1518 | case 157: | ||
1519 | ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))"); | ||
1520 | break; | ||
1521 | |||
1514 | case 200: | 1522 | case 200: |
1515 | test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, | 1523 | test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, |
1516 | speed_template_16_24_32); | 1524 | speed_template_16_24_32); |
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 77955507f6f1..dc3cf3535ef0 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
@@ -1809,6 +1809,22 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1809 | } | 1809 | } |
1810 | } | 1810 | } |
1811 | }, { | 1811 | }, { |
1812 | .alg = "authenc(hmac(md5),ecb(cipher_null))", | ||
1813 | .test = alg_test_aead, | ||
1814 | .fips_allowed = 1, | ||
1815 | .suite = { | ||
1816 | .aead = { | ||
1817 | .enc = { | ||
1818 | .vecs = hmac_md5_ecb_cipher_null_enc_tv_template, | ||
1819 | .count = HMAC_MD5_ECB_CIPHER_NULL_ENC_TEST_VECTORS | ||
1820 | }, | ||
1821 | .dec = { | ||
1822 | .vecs = hmac_md5_ecb_cipher_null_dec_tv_template, | ||
1823 | .count = HMAC_MD5_ECB_CIPHER_NULL_DEC_TEST_VECTORS | ||
1824 | } | ||
1825 | } | ||
1826 | } | ||
1827 | }, { | ||
1812 | .alg = "authenc(hmac(sha1),cbc(aes))", | 1828 | .alg = "authenc(hmac(sha1),cbc(aes))", |
1813 | .test = alg_test_aead, | 1829 | .test = alg_test_aead, |
1814 | .fips_allowed = 1, | 1830 | .fips_allowed = 1, |
@@ -1821,6 +1837,22 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
1821 | } | 1837 | } |
1822 | } | 1838 | } |
1823 | }, { | 1839 | }, { |
1840 | .alg = "authenc(hmac(sha1),ecb(cipher_null))", | ||
1841 | .test = alg_test_aead, | ||
1842 | .fips_allowed = 1, | ||
1843 | .suite = { | ||
1844 | .aead = { | ||
1845 | .enc = { | ||
1846 | .vecs = hmac_sha1_ecb_cipher_null_enc_tv_template, | ||
1847 | .count = HMAC_SHA1_ECB_CIPHER_NULL_ENC_TEST_VECTORS | ||
1848 | }, | ||
1849 | .dec = { | ||
1850 | .vecs = hmac_sha1_ecb_cipher_null_dec_tv_template, | ||
1851 | .count = HMAC_SHA1_ECB_CIPHER_NULL_DEC_TEST_VECTORS | ||
1852 | } | ||
1853 | } | ||
1854 | } | ||
1855 | }, { | ||
1824 | .alg = "authenc(hmac(sha256),cbc(aes))", | 1856 | .alg = "authenc(hmac(sha256),cbc(aes))", |
1825 | .test = alg_test_aead, | 1857 | .test = alg_test_aead, |
1826 | .fips_allowed = 1, | 1858 | .fips_allowed = 1, |
diff --git a/crypto/testmgr.h b/crypto/testmgr.h index 7d44aa3d6b44..3db83dbba1d9 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h | |||
@@ -12821,6 +12821,10 @@ static struct cipher_testvec cast6_xts_dec_tv_template[] = { | |||
12821 | #define AES_DEC_TEST_VECTORS 4 | 12821 | #define AES_DEC_TEST_VECTORS 4 |
12822 | #define AES_CBC_ENC_TEST_VECTORS 5 | 12822 | #define AES_CBC_ENC_TEST_VECTORS 5 |
12823 | #define AES_CBC_DEC_TEST_VECTORS 5 | 12823 | #define AES_CBC_DEC_TEST_VECTORS 5 |
12824 | #define HMAC_MD5_ECB_CIPHER_NULL_ENC_TEST_VECTORS 2 | ||
12825 | #define HMAC_MD5_ECB_CIPHER_NULL_DEC_TEST_VECTORS 2 | ||
12826 | #define HMAC_SHA1_ECB_CIPHER_NULL_ENC_TEST_VECTORS 2 | ||
12827 | #define HMAC_SHA1_ECB_CIPHER_NULL_DEC_TEST_VECTORS 2 | ||
12824 | #define HMAC_SHA1_AES_CBC_ENC_TEST_VECTORS 7 | 12828 | #define HMAC_SHA1_AES_CBC_ENC_TEST_VECTORS 7 |
12825 | #define HMAC_SHA256_AES_CBC_ENC_TEST_VECTORS 7 | 12829 | #define HMAC_SHA256_AES_CBC_ENC_TEST_VECTORS 7 |
12826 | #define HMAC_SHA512_AES_CBC_ENC_TEST_VECTORS 7 | 12830 | #define HMAC_SHA512_AES_CBC_ENC_TEST_VECTORS 7 |
@@ -13627,6 +13631,90 @@ static struct cipher_testvec aes_cbc_dec_tv_template[] = { | |||
13627 | }, | 13631 | }, |
13628 | }; | 13632 | }; |
13629 | 13633 | ||
13634 | static struct aead_testvec hmac_md5_ecb_cipher_null_enc_tv_template[] = { | ||
13635 | { /* Input data from RFC 2410 Case 1 */ | ||
13636 | #ifdef __LITTLE_ENDIAN | ||
13637 | .key = "\x08\x00" /* rta length */ | ||
13638 | "\x01\x00" /* rta type */ | ||
13639 | #else | ||
13640 | .key = "\x00\x08" /* rta length */ | ||
13641 | "\x00\x01" /* rta type */ | ||
13642 | #endif | ||
13643 | "\x00\x00\x00\x00" /* enc key length */ | ||
13644 | "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
13645 | "\x00\x00\x00\x00\x00\x00\x00\x00", | ||
13646 | .klen = 8 + 16 + 0, | ||
13647 | .iv = "", | ||
13648 | .input = "\x01\x23\x45\x67\x89\xab\xcd\xef", | ||
13649 | .ilen = 8, | ||
13650 | .result = "\x01\x23\x45\x67\x89\xab\xcd\xef" | ||
13651 | "\xaa\x42\xfe\x43\x8d\xea\xa3\x5a" | ||
13652 | "\xb9\x3d\x9f\xb1\xa3\x8e\x9b\xae", | ||
13653 | .rlen = 8 + 16, | ||
13654 | }, { /* Input data from RFC 2410 Case 2 */ | ||
13655 | #ifdef __LITTLE_ENDIAN | ||
13656 | .key = "\x08\x00" /* rta length */ | ||
13657 | "\x01\x00" /* rta type */ | ||
13658 | #else | ||
13659 | .key = "\x00\x08" /* rta length */ | ||
13660 | "\x00\x01" /* rta type */ | ||
13661 | #endif | ||
13662 | "\x00\x00\x00\x00" /* enc key length */ | ||
13663 | "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
13664 | "\x00\x00\x00\x00\x00\x00\x00\x00", | ||
13665 | .klen = 8 + 16 + 0, | ||
13666 | .iv = "", | ||
13667 | .input = "Network Security People Have A Strange Sense Of Humor", | ||
13668 | .ilen = 53, | ||
13669 | .result = "Network Security People Have A Strange Sense Of Humor" | ||
13670 | "\x73\xa5\x3e\x1c\x08\x0e\x8a\x8a" | ||
13671 | "\x8e\xb5\x5f\x90\x8e\xfe\x13\x23", | ||
13672 | .rlen = 53 + 16, | ||
13673 | }, | ||
13674 | }; | ||
13675 | |||
13676 | static struct aead_testvec hmac_md5_ecb_cipher_null_dec_tv_template[] = { | ||
13677 | { | ||
13678 | #ifdef __LITTLE_ENDIAN | ||
13679 | .key = "\x08\x00" /* rta length */ | ||
13680 | "\x01\x00" /* rta type */ | ||
13681 | #else | ||
13682 | .key = "\x00\x08" /* rta length */ | ||
13683 | "\x00\x01" /* rta type */ | ||
13684 | #endif | ||
13685 | "\x00\x00\x00\x00" /* enc key length */ | ||
13686 | "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
13687 | "\x00\x00\x00\x00\x00\x00\x00\x00", | ||
13688 | .klen = 8 + 16 + 0, | ||
13689 | .iv = "", | ||
13690 | .input = "\x01\x23\x45\x67\x89\xab\xcd\xef" | ||
13691 | "\xaa\x42\xfe\x43\x8d\xea\xa3\x5a" | ||
13692 | "\xb9\x3d\x9f\xb1\xa3\x8e\x9b\xae", | ||
13693 | .ilen = 8 + 16, | ||
13694 | .result = "\x01\x23\x45\x67\x89\xab\xcd\xef", | ||
13695 | .rlen = 8, | ||
13696 | }, { | ||
13697 | #ifdef __LITTLE_ENDIAN | ||
13698 | .key = "\x08\x00" /* rta length */ | ||
13699 | "\x01\x00" /* rta type */ | ||
13700 | #else | ||
13701 | .key = "\x00\x08" /* rta length */ | ||
13702 | "\x00\x01" /* rta type */ | ||
13703 | #endif | ||
13704 | "\x00\x00\x00\x00" /* enc key length */ | ||
13705 | "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
13706 | "\x00\x00\x00\x00\x00\x00\x00\x00", | ||
13707 | .klen = 8 + 16 + 0, | ||
13708 | .iv = "", | ||
13709 | .input = "Network Security People Have A Strange Sense Of Humor" | ||
13710 | "\x73\xa5\x3e\x1c\x08\x0e\x8a\x8a" | ||
13711 | "\x8e\xb5\x5f\x90\x8e\xfe\x13\x23", | ||
13712 | .ilen = 53 + 16, | ||
13713 | .result = "Network Security People Have A Strange Sense Of Humor", | ||
13714 | .rlen = 53, | ||
13715 | }, | ||
13716 | }; | ||
13717 | |||
13630 | static struct aead_testvec hmac_sha1_aes_cbc_enc_tv_template[] = { | 13718 | static struct aead_testvec hmac_sha1_aes_cbc_enc_tv_template[] = { |
13631 | { /* RFC 3602 Case 1 */ | 13719 | { /* RFC 3602 Case 1 */ |
13632 | #ifdef __LITTLE_ENDIAN | 13720 | #ifdef __LITTLE_ENDIAN |
@@ -13876,6 +13964,98 @@ static struct aead_testvec hmac_sha1_aes_cbc_enc_tv_template[] = { | |||
13876 | }, | 13964 | }, |
13877 | }; | 13965 | }; |
13878 | 13966 | ||
13967 | static struct aead_testvec hmac_sha1_ecb_cipher_null_enc_tv_template[] = { | ||
13968 | { /* Input data from RFC 2410 Case 1 */ | ||
13969 | #ifdef __LITTLE_ENDIAN | ||
13970 | .key = "\x08\x00" /* rta length */ | ||
13971 | "\x01\x00" /* rta type */ | ||
13972 | #else | ||
13973 | .key = "\x00\x08" /* rta length */ | ||
13974 | "\x00\x01" /* rta type */ | ||
13975 | #endif | ||
13976 | "\x00\x00\x00\x00" /* enc key length */ | ||
13977 | "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
13978 | "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
13979 | "\x00\x00\x00\x00", | ||
13980 | .klen = 8 + 20 + 0, | ||
13981 | .iv = "", | ||
13982 | .input = "\x01\x23\x45\x67\x89\xab\xcd\xef", | ||
13983 | .ilen = 8, | ||
13984 | .result = "\x01\x23\x45\x67\x89\xab\xcd\xef" | ||
13985 | "\x40\xc3\x0a\xa1\xc9\xa0\x28\xab" | ||
13986 | "\x99\x5e\x19\x04\xd1\x72\xef\xb8" | ||
13987 | "\x8c\x5e\xe4\x08", | ||
13988 | .rlen = 8 + 20, | ||
13989 | }, { /* Input data from RFC 2410 Case 2 */ | ||
13990 | #ifdef __LITTLE_ENDIAN | ||
13991 | .key = "\x08\x00" /* rta length */ | ||
13992 | "\x01\x00" /* rta type */ | ||
13993 | #else | ||
13994 | .key = "\x00\x08" /* rta length */ | ||
13995 | "\x00\x01" /* rta type */ | ||
13996 | #endif | ||
13997 | "\x00\x00\x00\x00" /* enc key length */ | ||
13998 | "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
13999 | "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
14000 | "\x00\x00\x00\x00", | ||
14001 | .klen = 8 + 20 + 0, | ||
14002 | .iv = "", | ||
14003 | .input = "Network Security People Have A Strange Sense Of Humor", | ||
14004 | .ilen = 53, | ||
14005 | .result = "Network Security People Have A Strange Sense Of Humor" | ||
14006 | "\x75\x6f\x42\x1e\xf8\x50\x21\xd2" | ||
14007 | "\x65\x47\xee\x8e\x1a\xef\x16\xf6" | ||
14008 | "\x91\x56\xe4\xd6", | ||
14009 | .rlen = 53 + 20, | ||
14010 | }, | ||
14011 | }; | ||
14012 | |||
14013 | static struct aead_testvec hmac_sha1_ecb_cipher_null_dec_tv_template[] = { | ||
14014 | { | ||
14015 | #ifdef __LITTLE_ENDIAN | ||
14016 | .key = "\x08\x00" /* rta length */ | ||
14017 | "\x01\x00" /* rta type */ | ||
14018 | #else | ||
14019 | .key = "\x00\x08" /* rta length */ | ||
14020 | "\x00\x01" /* rta type */ | ||
14021 | #endif | ||
14022 | "\x00\x00\x00\x00" /* enc key length */ | ||
14023 | "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
14024 | "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
14025 | "\x00\x00\x00\x00", | ||
14026 | .klen = 8 + 20 + 0, | ||
14027 | .iv = "", | ||
14028 | .input = "\x01\x23\x45\x67\x89\xab\xcd\xef" | ||
14029 | "\x40\xc3\x0a\xa1\xc9\xa0\x28\xab" | ||
14030 | "\x99\x5e\x19\x04\xd1\x72\xef\xb8" | ||
14031 | "\x8c\x5e\xe4\x08", | ||
14032 | .ilen = 8 + 20, | ||
14033 | .result = "\x01\x23\x45\x67\x89\xab\xcd\xef", | ||
14034 | .rlen = 8, | ||
14035 | }, { | ||
14036 | #ifdef __LITTLE_ENDIAN | ||
14037 | .key = "\x08\x00" /* rta length */ | ||
14038 | "\x01\x00" /* rta type */ | ||
14039 | #else | ||
14040 | .key = "\x00\x08" /* rta length */ | ||
14041 | "\x00\x01" /* rta type */ | ||
14042 | #endif | ||
14043 | "\x00\x00\x00\x00" /* enc key length */ | ||
14044 | "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
14045 | "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
14046 | "\x00\x00\x00\x00", | ||
14047 | .klen = 8 + 20 + 0, | ||
14048 | .iv = "", | ||
14049 | .input = "Network Security People Have A Strange Sense Of Humor" | ||
14050 | "\x75\x6f\x42\x1e\xf8\x50\x21\xd2" | ||
14051 | "\x65\x47\xee\x8e\x1a\xef\x16\xf6" | ||
14052 | "\x91\x56\xe4\xd6", | ||
14053 | .ilen = 53 + 20, | ||
14054 | .result = "Network Security People Have A Strange Sense Of Humor", | ||
14055 | .rlen = 53, | ||
14056 | }, | ||
14057 | }; | ||
14058 | |||
13879 | static struct aead_testvec hmac_sha256_aes_cbc_enc_tv_template[] = { | 14059 | static struct aead_testvec hmac_sha256_aes_cbc_enc_tv_template[] = { |
13880 | { /* RFC 3602 Case 1 */ | 14060 | { /* RFC 3602 Case 1 */ |
13881 | #ifdef __LITTLE_ENDIAN | 14061 | #ifdef __LITTLE_ENDIAN |