Skip to content

Commit a22d48c

Browse files
abajkherbertx
authored andcommitted
crypto: testmgr - Add test vectors for authenc(hmac(sha224),cbc(aes))
Test vectors were generated starting from existing CBC(AES) test vectors (RFC3602, NIST SP800-38A) and adding HMAC(SHA224) computed with Python script. Then, the results were double-checked on Mediatek MT7981 (safexcel) and NXP P2020 (talitos). Both platforms pass self-tests. Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 030218d commit a22d48c

2 files changed

Lines changed: 292 additions & 0 deletions

File tree

crypto/testmgr.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4123,6 +4123,13 @@ static const struct alg_test_desc alg_test_descs[] = {
41234123
.alg = "authenc(hmac(sha1),rfc3686(ctr(aes)))",
41244124
.test = alg_test_null,
41254125
.fips_allowed = 1,
4126+
}, {
4127+
.alg = "authenc(hmac(sha224),cbc(aes))",
4128+
.generic_driver = "authenc(hmac-sha224-lib,cbc(aes-generic))",
4129+
.test = alg_test_aead,
4130+
.suite = {
4131+
.aead = __VECS(hmac_sha224_aes_cbc_tv_temp)
4132+
}
41264133
}, {
41274134
.alg = "authenc(hmac(sha224),cbc(des))",
41284135
.generic_driver = "authenc(hmac-sha224-lib,cbc(des-generic))",

crypto/testmgr.h

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16291,6 +16291,291 @@ static const struct aead_testvec hmac_sha1_ecb_cipher_null_tv_temp[] = {
1629116291
},
1629216292
};
1629316293

16294+
static const struct aead_testvec hmac_sha224_aes_cbc_tv_temp[] = {
16295+
{ /* RFC 3602 Case 1 */
16296+
#ifdef __LITTLE_ENDIAN
16297+
.key = "\x08\x00" /* rta length */
16298+
"\x01\x00" /* rta type */
16299+
#else
16300+
.key = "\x00\x08" /* rta length */
16301+
"\x00\x01" /* rta type */
16302+
#endif
16303+
"\x00\x00\x00\x10" /* enc key length */
16304+
"\x00\x00\x00\x00\x00\x00\x00\x00"
16305+
"\x00\x00\x00\x00\x00\x00\x00\x00"
16306+
"\x00\x00\x00\x00\x00\x00\x00\x00"
16307+
"\x00\x00\x00\x00"
16308+
"\x06\xa9\x21\x40\x36\xb8\xa1\x5b"
16309+
"\x51\x2e\x03\xd5\x34\x12\x00\x06",
16310+
.klen = 8 + 28 + 16,
16311+
.iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30"
16312+
"\xb4\x22\xda\x80\x2c\x9f\xac\x41",
16313+
.assoc = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30"
16314+
"\xb4\x22\xda\x80\x2c\x9f\xac\x41",
16315+
.alen = 16,
16316+
.ptext = "Single block msg",
16317+
.plen = 16,
16318+
.ctext = "\xe3\x53\x77\x9c\x10\x79\xae\xb8"
16319+
"\x27\x08\x94\x2d\xbe\x77\x18\x1a"
16320+
"\x17\xe8\x00\x76\x70\x71\xd1\x72"
16321+
"\xf8\xd0\x91\x51\x67\xf9\xdf\xd6"
16322+
"\x0d\x56\x1a\xb3\x52\x19\x85\xae"
16323+
"\x46\x74\xb6\x98",
16324+
.clen = 16 + 28,
16325+
}, { /* RFC 3602 Case 2 */
16326+
#ifdef __LITTLE_ENDIAN
16327+
.key = "\x08\x00" /* rta length */
16328+
"\x01\x00" /* rta type */
16329+
#else
16330+
.key = "\x00\x08" /* rta length */
16331+
"\x00\x01" /* rta type */
16332+
#endif
16333+
"\x00\x00\x00\x10" /* enc key length */
16334+
"\x20\x21\x22\x23\x24\x25\x26\x27"
16335+
"\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
16336+
"\x30\x31\x32\x33\x34\x35\x36\x37"
16337+
"\x38\x39\x3a\x3b"
16338+
"\xc2\x86\x69\x6d\x88\x7c\x9a\xa0"
16339+
"\x61\x1b\xbb\x3e\x20\x25\xa4\x5a",
16340+
.klen = 8 + 28 + 16,
16341+
.iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28"
16342+
"\xdd\xb3\xba\x69\x5a\x2e\x6f\x58",
16343+
.assoc = "\x56\x2e\x17\x99\x6d\x09\x3d\x28"
16344+
"\xdd\xb3\xba\x69\x5a\x2e\x6f\x58",
16345+
.alen = 16,
16346+
.ptext = "\x00\x01\x02\x03\x04\x05\x06\x07"
16347+
"\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
16348+
"\x10\x11\x12\x13\x14\x15\x16\x17"
16349+
"\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
16350+
.plen = 32,
16351+
.ctext = "\xd2\x96\xcd\x94\xc2\xcc\xcf\x8a"
16352+
"\x3a\x86\x30\x28\xb5\xe1\xdc\x0a"
16353+
"\x75\x86\x60\x2d\x25\x3c\xff\xf9"
16354+
"\x1b\x82\x66\xbe\xa6\xd6\x1a\xb1"
16355+
"\xa1\x11\xfa\xbb\x1e\x04\x7e\xe7"
16356+
"\x4c\x5f\x65\xbf\x68\x8d\x33\x9d"
16357+
"\xbc\x74\x9b\xf3\x15\xf3\x8f\x8d"
16358+
"\xe8\xaf\x33\xe0",
16359+
16360+
.clen = 32 + 28,
16361+
}, { /* RFC 3602 Case 3 */
16362+
#ifdef __LITTLE_ENDIAN
16363+
.key = "\x08\x00" /* rta length */
16364+
"\x01\x00" /* rta type */
16365+
#else
16366+
.key = "\x00\x08" /* rta length */
16367+
"\x00\x01" /* rta type */
16368+
#endif
16369+
"\x00\x00\x00\x10" /* enc key length */
16370+
"\x11\x22\x33\x44\x55\x66\x77\x88"
16371+
"\x99\xaa\xbb\xcc\xdd\xee\xff\x11"
16372+
"\x22\x33\x44\x55\x66\x77\x88\x99"
16373+
"\xaa\xbb\xcc\xdd"
16374+
"\x6c\x3e\xa0\x47\x76\x30\xce\x21"
16375+
"\xa2\xce\x33\x4a\xa7\x46\xc2\xcd",
16376+
.klen = 8 + 28 + 16,
16377+
.iv = "\xc7\x82\xdc\x4c\x09\x8c\x66\xcb"
16378+
"\xd9\xcd\x27\xd8\x25\x68\x2c\x81",
16379+
.assoc = "\xc7\x82\xdc\x4c\x09\x8c\x66\xcb"
16380+
"\xd9\xcd\x27\xd8\x25\x68\x2c\x81",
16381+
.alen = 16,
16382+
.ptext = "This is a 48-byte message (exactly 3 AES blocks)",
16383+
.plen = 48,
16384+
.ctext = "\xd0\xa0\x2b\x38\x36\x45\x17\x53"
16385+
"\xd4\x93\x66\x5d\x33\xf0\xe8\x86"
16386+
"\x2d\xea\x54\xcd\xb2\x93\xab\xc7"
16387+
"\x50\x69\x39\x27\x67\x72\xf8\xd5"
16388+
"\x02\x1c\x19\x21\x6b\xad\x52\x5c"
16389+
"\x85\x79\x69\x5d\x83\xba\x26\x84"
16390+
"\x60\xb3\xca\x0e\xc1\xfe\xf2\x27"
16391+
"\x5a\x41\xe4\x99\xa8\x19\x56\xf1"
16392+
"\x44\x98\x27\x9f\x99\xb0\x4a\xad"
16393+
"\x4d\xc1\x1e\x88",
16394+
.clen = 48 + 28,
16395+
}, { /* RFC 3602 Case 4 */
16396+
#ifdef __LITTLE_ENDIAN
16397+
.key = "\x08\x00" /* rta length */
16398+
"\x01\x00" /* rta type */
16399+
#else
16400+
.key = "\x00\x08" /* rta length */
16401+
"\x00\x01" /* rta type */
16402+
#endif
16403+
"\x00\x00\x00\x10" /* enc key length */
16404+
"\x11\x22\x33\x44\x55\x66\x77\x88"
16405+
"\x99\xaa\xbb\xcc\xdd\xee\xff\x11"
16406+
"\x22\x33\x44\x55\x66\x77\x88\x99"
16407+
"\xaa\xbb\xcc\xdd"
16408+
"\x56\xe4\x7a\x38\xc5\x59\x89\x74"
16409+
"\xbc\x46\x90\x3d\xba\x29\x03\x49",
16410+
.klen = 8 + 28 + 16,
16411+
.iv = "\x8c\xe8\x2e\xef\xbe\xa0\xda\x3c"
16412+
"\x44\x69\x9e\xd7\xdb\x51\xb7\xd9",
16413+
.assoc = "\x8c\xe8\x2e\xef\xbe\xa0\xda\x3c"
16414+
"\x44\x69\x9e\xd7\xdb\x51\xb7\xd9",
16415+
.alen = 16,
16416+
.ptext = "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
16417+
"\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
16418+
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
16419+
"\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
16420+
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
16421+
"\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
16422+
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
16423+
"\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
16424+
.plen = 64,
16425+
.ctext = "\xc3\x0e\x32\xff\xed\xc0\x77\x4e"
16426+
"\x6a\xff\x6a\xf0\x86\x9f\x71\xaa"
16427+
"\x0f\x3a\xf0\x7a\x9a\x31\xa9\xc6"
16428+
"\x84\xdb\x20\x7e\xb0\xef\x8e\x4e"
16429+
"\x35\x90\x7a\xa6\x32\xc3\xff\xdf"
16430+
"\x86\x8b\xb7\xb2\x9d\x3d\x46\xad"
16431+
"\x83\xce\x9f\x9a\x10\x2e\xe9\x9d"
16432+
"\x49\xa5\x3e\x87\xf4\xc3\xda\x55"
16433+
"\xbb\xe9\x38\xf8\xb9\xbf\xcb\x7b"
16434+
"\xa8\x22\x91\xea\x1e\xaf\x13\xba"
16435+
"\x24\x18\x64\x9c\xcb\xb4\xa9\x16"
16436+
"\x4b\x83\x9c\xec",
16437+
.clen = 64 + 28,
16438+
}, { /* RFC 3602 Case 5 */
16439+
#ifdef __LITTLE_ENDIAN
16440+
.key = "\x08\x00" /* rta length */
16441+
"\x01\x00" /* rta type */
16442+
#else
16443+
.key = "\x00\x08" /* rta length */
16444+
"\x00\x01" /* rta type */
16445+
#endif
16446+
"\x00\x00\x00\x10" /* enc key length */
16447+
"\x11\x22\x33\x44\x55\x66\x77\x88"
16448+
"\x99\xaa\xbb\xcc\xdd\xee\xff\x11"
16449+
"\x22\x33\x44\x55\x66\x77\x88\x99"
16450+
"\xaa\xbb\xcc\xdd"
16451+
"\x90\xd3\x82\xb4\x10\xee\xba\x7a"
16452+
"\xd9\x38\xc4\x6c\xec\x1a\x82\xbf",
16453+
.klen = 8 + 28 + 16,
16454+
.iv = "\xe9\x6e\x8c\x08\xab\x46\x57\x63"
16455+
"\xfd\x09\x8d\x45\xdd\x3f\xf8\x93",
16456+
.assoc = "\x00\x00\x43\x21\x00\x00\x00\x01"
16457+
"\xe9\x6e\x8c\x08\xab\x46\x57\x63"
16458+
"\xfd\x09\x8d\x45\xdd\x3f\xf8\x93",
16459+
.alen = 24,
16460+
.ptext = "\x08\x00\x0e\xbd\xa7\x0a\x00\x00"
16461+
"\x8e\x9c\x08\x3d\xb9\x5b\x07\x00"
16462+
"\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
16463+
"\x10\x11\x12\x13\x14\x15\x16\x17"
16464+
"\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
16465+
"\x20\x21\x22\x23\x24\x25\x26\x27"
16466+
"\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
16467+
"\x30\x31\x32\x33\x34\x35\x36\x37"
16468+
"\x01\x02\x03\x04\x05\x06\x07\x08"
16469+
"\x09\x0a\x0b\x0c\x0d\x0e\x0e\x01",
16470+
.plen = 80,
16471+
.ctext = "\xf6\x63\xc2\x5d\x32\x5c\x18\xc6"
16472+
"\xa9\x45\x3e\x19\x4e\x12\x08\x49"
16473+
"\xa4\x87\x0b\x66\xcc\x6b\x99\x65"
16474+
"\x33\x00\x13\xb4\x89\x8d\xc8\x56"
16475+
"\xa4\x69\x9e\x52\x3a\x55\xdb\x08"
16476+
"\x0b\x59\xec\x3a\x8e\x4b\x7e\x52"
16477+
"\x77\x5b\x07\xd1\xdb\x34\xed\x9c"
16478+
"\x53\x8a\xb5\x0c\x55\x1b\x87\x4a"
16479+
"\xa2\x69\xad\xd0\x47\xad\x2d\x59"
16480+
"\x13\xac\x19\xb7\xcf\xba\xd4\xa6"
16481+
"\x04\x5e\x83\x45\xc5\x6a\x5b\xe2"
16482+
"\x5e\xd8\x59\x06\xbd\xc7\xd2\x9b"
16483+
"\x0b\x65\x1f\x31\xc7\xe6\x9c\x39"
16484+
"\xa3\x66\xdb\xb8",
16485+
.clen = 80 + 28,
16486+
}, { /* NIST SP800-38A F.2.3 CBC-AES192.Encrypt */
16487+
#ifdef __LITTLE_ENDIAN
16488+
.key = "\x08\x00" /* rta length */
16489+
"\x01\x00" /* rta type */
16490+
#else
16491+
.key = "\x00\x08" /* rta length */
16492+
"\x00\x01" /* rta type */
16493+
#endif
16494+
"\x00\x00\x00\x18" /* enc key length */
16495+
"\x11\x22\x33\x44\x55\x66\x77\x88"
16496+
"\x99\xaa\xbb\xcc\xdd\xee\xff\x11"
16497+
"\x22\x33\x44\x55\x66\x77\x88\x99"
16498+
"\xaa\xbb\xcc\xdd"
16499+
"\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
16500+
"\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
16501+
"\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
16502+
.klen = 8 + 28 + 24,
16503+
.iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
16504+
"\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
16505+
.assoc = "\x00\x01\x02\x03\x04\x05\x06\x07"
16506+
"\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
16507+
.alen = 16,
16508+
.ptext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
16509+
"\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
16510+
"\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
16511+
"\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
16512+
"\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
16513+
"\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
16514+
"\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
16515+
"\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
16516+
.plen = 64,
16517+
.ctext = "\x4f\x02\x1d\xb2\x43\xbc\x63\x3d"
16518+
"\x71\x78\x18\x3a\x9f\xa0\x71\xe8"
16519+
"\xb4\xd9\xad\xa9\xad\x7d\xed\xf4"
16520+
"\xe5\xe7\x38\x76\x3f\x69\x14\x5a"
16521+
"\x57\x1b\x24\x20\x12\xfb\x7a\xe0"
16522+
"\x7f\xa9\xba\xac\x3d\xf1\x02\xe0"
16523+
"\x08\xb0\xe2\x79\x88\x59\x88\x81"
16524+
"\xd9\x20\xa9\xe6\x4f\x56\x15\xcd"
16525+
"\x67\x35\xcd\x86\x94\x51\x3b\x3a"
16526+
"\xaa\x07\xb1\xed\x18\x55\x62\x01"
16527+
"\x95\xb2\x53\xb5\x20\x78\x16\xd7"
16528+
"\xb8\x49\x7f\x96",
16529+
16530+
.clen = 64 + 28,
16531+
}, { /* NIST SP800-38A F.2.5 CBC-AES256.Encrypt */
16532+
#ifdef __LITTLE_ENDIAN
16533+
.key = "\x08\x00" /* rta length */
16534+
"\x01\x00" /* rta type */
16535+
#else
16536+
.key = "\x00\x08" /* rta length */
16537+
"\x00\x01" /* rta type */
16538+
#endif
16539+
"\x00\x00\x00\x20" /* enc key length */
16540+
"\x11\x22\x33\x44\x55\x66\x77\x88"
16541+
"\x99\xaa\xbb\xcc\xdd\xee\xff\x11"
16542+
"\x22\x33\x44\x55\x66\x77\x88\x99"
16543+
"\xaa\xbb\xcc\xdd"
16544+
"\x60\x3d\xeb\x10\x15\xca\x71\xbe"
16545+
"\x2b\x73\xae\xf0\x85\x7d\x77\x81"
16546+
"\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
16547+
"\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
16548+
.klen = 8 + 28 + 32,
16549+
.iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
16550+
"\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
16551+
.assoc = "\x00\x01\x02\x03\x04\x05\x06\x07"
16552+
"\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
16553+
.alen = 16,
16554+
.ptext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
16555+
"\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
16556+
"\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
16557+
"\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
16558+
"\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
16559+
"\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
16560+
"\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
16561+
"\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
16562+
.plen = 64,
16563+
.ctext = "\xf5\x8c\x4c\x04\xd6\xe5\xf1\xba"
16564+
"\x77\x9e\xab\xfb\x5f\x7b\xfb\xd6"
16565+
"\x9c\xfc\x4e\x96\x7e\xdb\x80\x8d"
16566+
"\x67\x9f\x77\x7b\xc6\x70\x2c\x7d"
16567+
"\x39\xf2\x33\x69\xa9\xd9\xba\xcf"
16568+
"\xa5\x30\xe2\x63\x04\x23\x14\x61"
16569+
"\xb2\xeb\x05\xe2\xc3\x9b\xe9\xfc"
16570+
"\xda\x6c\x19\x07\x8c\x6a\x9d\x1b"
16571+
"\xe0\xe2\x3d\x3f\x55\x24\x2c\x4d"
16572+
"\xb9\x13\x2a\xc0\x07\xbb\x3b\xda"
16573+
"\xfd\xa4\x51\x32\x3f\x44\xb1\x13"
16574+
"\x98\xf9\xbc\xb9",
16575+
.clen = 64 + 28,
16576+
},
16577+
};
16578+
1629416579
static const struct aead_testvec hmac_sha256_aes_cbc_tv_temp[] = {
1629516580
{ /* RFC 3602 Case 1 */
1629616581
#ifdef __LITTLE_ENDIAN

0 commit comments

Comments
 (0)