Skip to content

Commit bca4feb

Browse files
horiagherbertx
authored andcommitted
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 <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 7256725 commit bca4feb

File tree

3 files changed

+220
-0
lines changed

3 files changed

+220
-0
lines changed

crypto/tcrypt.c

+8
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,14 @@ static int do_test(int m)
15111511
ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))");
15121512
break;
15131513

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+
15141522
case 200:
15151523
test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
15161524
speed_template_16_24_32);

crypto/testmgr.c

+32
Original file line numberDiff line numberDiff line change
@@ -1808,6 +1808,22 @@ static const struct alg_test_desc alg_test_descs[] = {
18081808
.count = ANSI_CPRNG_AES_TEST_VECTORS
18091809
}
18101810
}
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+
}
18111827
}, {
18121828
.alg = "authenc(hmac(sha1),cbc(aes))",
18131829
.test = alg_test_aead,
@@ -1820,6 +1836,22 @@ static const struct alg_test_desc alg_test_descs[] = {
18201836
}
18211837
}
18221838
}
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+
}
18231855
}, {
18241856
.alg = "authenc(hmac(sha256),cbc(aes))",
18251857
.test = alg_test_aead,

crypto/testmgr.h

+180
Original file line numberDiff line numberDiff line change
@@ -12821,6 +12821,10 @@ static struct cipher_testvec cast6_xts_dec_tv_template[] = {
1282112821
#define AES_DEC_TEST_VECTORS 4
1282212822
#define AES_CBC_ENC_TEST_VECTORS 5
1282312823
#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
1282412828
#define HMAC_SHA1_AES_CBC_ENC_TEST_VECTORS 7
1282512829
#define HMAC_SHA256_AES_CBC_ENC_TEST_VECTORS 7
1282612830
#define HMAC_SHA512_AES_CBC_ENC_TEST_VECTORS 7
@@ -13627,6 +13631,90 @@ static struct cipher_testvec aes_cbc_dec_tv_template[] = {
1362713631
},
1362813632
};
1362913633

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+
1363013718
static struct aead_testvec hmac_sha1_aes_cbc_enc_tv_template[] = {
1363113719
{ /* RFC 3602 Case 1 */
1363213720
#ifdef __LITTLE_ENDIAN
@@ -13876,6 +13964,98 @@ static struct aead_testvec hmac_sha1_aes_cbc_enc_tv_template[] = {
1387613964
},
1387713965
};
1387813966

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+
1387914059
static struct aead_testvec hmac_sha256_aes_cbc_enc_tv_template[] = {
1388014060
{ /* RFC 3602 Case 1 */
1388114061
#ifdef __LITTLE_ENDIAN

0 commit comments

Comments
 (0)