crypto: testmgr - Add Poly1305 test vectors from RFC7539
Signed-off-by: Martin Willi <martin@strongswan.org> Acked-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
f979e014c5
commit
eee9dc6162
@ -3314,6 +3314,15 @@ static const struct alg_test_desc alg_test_descs[] = {
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "poly1305",
|
||||
.test = alg_test_hash,
|
||||
.suite = {
|
||||
.hash = {
|
||||
.vecs = poly1305_tv_template,
|
||||
.count = POLY1305_TEST_VECTORS
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "rfc3686(ctr(aes))",
|
||||
.test = alg_test_skcipher,
|
||||
|
259
crypto/testmgr.h
259
crypto/testmgr.h
@ -3025,6 +3025,265 @@ static struct hash_testvec hmac_sha512_tv_template[] = {
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
* Poly1305 test vectors from RFC7539 A.3.
|
||||
*/
|
||||
|
||||
#define POLY1305_TEST_VECTORS 11
|
||||
|
||||
static struct hash_testvec poly1305_tv_template[] = {
|
||||
{ /* Test Vector #1 */
|
||||
.key = "\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
.ksize = 32,
|
||||
.plaintext = "\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
.psize = 64,
|
||||
.digest = "\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
}, { /* Test Vector #2 */
|
||||
.key = "\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x36\xe5\xf6\xb5\xc5\xe0\x60\x70"
|
||||
"\xf0\xef\xca\x96\x22\x7a\x86\x3e",
|
||||
.ksize = 32,
|
||||
.plaintext = "\x41\x6e\x79\x20\x73\x75\x62\x6d"
|
||||
"\x69\x73\x73\x69\x6f\x6e\x20\x74"
|
||||
"\x6f\x20\x74\x68\x65\x20\x49\x45"
|
||||
"\x54\x46\x20\x69\x6e\x74\x65\x6e"
|
||||
"\x64\x65\x64\x20\x62\x79\x20\x74"
|
||||
"\x68\x65\x20\x43\x6f\x6e\x74\x72"
|
||||
"\x69\x62\x75\x74\x6f\x72\x20\x66"
|
||||
"\x6f\x72\x20\x70\x75\x62\x6c\x69"
|
||||
"\x63\x61\x74\x69\x6f\x6e\x20\x61"
|
||||
"\x73\x20\x61\x6c\x6c\x20\x6f\x72"
|
||||
"\x20\x70\x61\x72\x74\x20\x6f\x66"
|
||||
"\x20\x61\x6e\x20\x49\x45\x54\x46"
|
||||
"\x20\x49\x6e\x74\x65\x72\x6e\x65"
|
||||
"\x74\x2d\x44\x72\x61\x66\x74\x20"
|
||||
"\x6f\x72\x20\x52\x46\x43\x20\x61"
|
||||
"\x6e\x64\x20\x61\x6e\x79\x20\x73"
|
||||
"\x74\x61\x74\x65\x6d\x65\x6e\x74"
|
||||
"\x20\x6d\x61\x64\x65\x20\x77\x69"
|
||||
"\x74\x68\x69\x6e\x20\x74\x68\x65"
|
||||
"\x20\x63\x6f\x6e\x74\x65\x78\x74"
|
||||
"\x20\x6f\x66\x20\x61\x6e\x20\x49"
|
||||
"\x45\x54\x46\x20\x61\x63\x74\x69"
|
||||
"\x76\x69\x74\x79\x20\x69\x73\x20"
|
||||
"\x63\x6f\x6e\x73\x69\x64\x65\x72"
|
||||
"\x65\x64\x20\x61\x6e\x20\x22\x49"
|
||||
"\x45\x54\x46\x20\x43\x6f\x6e\x74"
|
||||
"\x72\x69\x62\x75\x74\x69\x6f\x6e"
|
||||
"\x22\x2e\x20\x53\x75\x63\x68\x20"
|
||||
"\x73\x74\x61\x74\x65\x6d\x65\x6e"
|
||||
"\x74\x73\x20\x69\x6e\x63\x6c\x75"
|
||||
"\x64\x65\x20\x6f\x72\x61\x6c\x20"
|
||||
"\x73\x74\x61\x74\x65\x6d\x65\x6e"
|
||||
"\x74\x73\x20\x69\x6e\x20\x49\x45"
|
||||
"\x54\x46\x20\x73\x65\x73\x73\x69"
|
||||
"\x6f\x6e\x73\x2c\x20\x61\x73\x20"
|
||||
"\x77\x65\x6c\x6c\x20\x61\x73\x20"
|
||||
"\x77\x72\x69\x74\x74\x65\x6e\x20"
|
||||
"\x61\x6e\x64\x20\x65\x6c\x65\x63"
|
||||
"\x74\x72\x6f\x6e\x69\x63\x20\x63"
|
||||
"\x6f\x6d\x6d\x75\x6e\x69\x63\x61"
|
||||
"\x74\x69\x6f\x6e\x73\x20\x6d\x61"
|
||||
"\x64\x65\x20\x61\x74\x20\x61\x6e"
|
||||
"\x79\x20\x74\x69\x6d\x65\x20\x6f"
|
||||
"\x72\x20\x70\x6c\x61\x63\x65\x2c"
|
||||
"\x20\x77\x68\x69\x63\x68\x20\x61"
|
||||
"\x72\x65\x20\x61\x64\x64\x72\x65"
|
||||
"\x73\x73\x65\x64\x20\x74\x6f",
|
||||
.psize = 375,
|
||||
.digest = "\x36\xe5\xf6\xb5\xc5\xe0\x60\x70"
|
||||
"\xf0\xef\xca\x96\x22\x7a\x86\x3e",
|
||||
}, { /* Test Vector #3 */
|
||||
.key = "\x36\xe5\xf6\xb5\xc5\xe0\x60\x70"
|
||||
"\xf0\xef\xca\x96\x22\x7a\x86\x3e"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
.ksize = 32,
|
||||
.plaintext = "\x41\x6e\x79\x20\x73\x75\x62\x6d"
|
||||
"\x69\x73\x73\x69\x6f\x6e\x20\x74"
|
||||
"\x6f\x20\x74\x68\x65\x20\x49\x45"
|
||||
"\x54\x46\x20\x69\x6e\x74\x65\x6e"
|
||||
"\x64\x65\x64\x20\x62\x79\x20\x74"
|
||||
"\x68\x65\x20\x43\x6f\x6e\x74\x72"
|
||||
"\x69\x62\x75\x74\x6f\x72\x20\x66"
|
||||
"\x6f\x72\x20\x70\x75\x62\x6c\x69"
|
||||
"\x63\x61\x74\x69\x6f\x6e\x20\x61"
|
||||
"\x73\x20\x61\x6c\x6c\x20\x6f\x72"
|
||||
"\x20\x70\x61\x72\x74\x20\x6f\x66"
|
||||
"\x20\x61\x6e\x20\x49\x45\x54\x46"
|
||||
"\x20\x49\x6e\x74\x65\x72\x6e\x65"
|
||||
"\x74\x2d\x44\x72\x61\x66\x74\x20"
|
||||
"\x6f\x72\x20\x52\x46\x43\x20\x61"
|
||||
"\x6e\x64\x20\x61\x6e\x79\x20\x73"
|
||||
"\x74\x61\x74\x65\x6d\x65\x6e\x74"
|
||||
"\x20\x6d\x61\x64\x65\x20\x77\x69"
|
||||
"\x74\x68\x69\x6e\x20\x74\x68\x65"
|
||||
"\x20\x63\x6f\x6e\x74\x65\x78\x74"
|
||||
"\x20\x6f\x66\x20\x61\x6e\x20\x49"
|
||||
"\x45\x54\x46\x20\x61\x63\x74\x69"
|
||||
"\x76\x69\x74\x79\x20\x69\x73\x20"
|
||||
"\x63\x6f\x6e\x73\x69\x64\x65\x72"
|
||||
"\x65\x64\x20\x61\x6e\x20\x22\x49"
|
||||
"\x45\x54\x46\x20\x43\x6f\x6e\x74"
|
||||
"\x72\x69\x62\x75\x74\x69\x6f\x6e"
|
||||
"\x22\x2e\x20\x53\x75\x63\x68\x20"
|
||||
"\x73\x74\x61\x74\x65\x6d\x65\x6e"
|
||||
"\x74\x73\x20\x69\x6e\x63\x6c\x75"
|
||||
"\x64\x65\x20\x6f\x72\x61\x6c\x20"
|
||||
"\x73\x74\x61\x74\x65\x6d\x65\x6e"
|
||||
"\x74\x73\x20\x69\x6e\x20\x49\x45"
|
||||
"\x54\x46\x20\x73\x65\x73\x73\x69"
|
||||
"\x6f\x6e\x73\x2c\x20\x61\x73\x20"
|
||||
"\x77\x65\x6c\x6c\x20\x61\x73\x20"
|
||||
"\x77\x72\x69\x74\x74\x65\x6e\x20"
|
||||
"\x61\x6e\x64\x20\x65\x6c\x65\x63"
|
||||
"\x74\x72\x6f\x6e\x69\x63\x20\x63"
|
||||
"\x6f\x6d\x6d\x75\x6e\x69\x63\x61"
|
||||
"\x74\x69\x6f\x6e\x73\x20\x6d\x61"
|
||||
"\x64\x65\x20\x61\x74\x20\x61\x6e"
|
||||
"\x79\x20\x74\x69\x6d\x65\x20\x6f"
|
||||
"\x72\x20\x70\x6c\x61\x63\x65\x2c"
|
||||
"\x20\x77\x68\x69\x63\x68\x20\x61"
|
||||
"\x72\x65\x20\x61\x64\x64\x72\x65"
|
||||
"\x73\x73\x65\x64\x20\x74\x6f",
|
||||
.psize = 375,
|
||||
.digest = "\xf3\x47\x7e\x7c\xd9\x54\x17\xaf"
|
||||
"\x89\xa6\xb8\x79\x4c\x31\x0c\xf0",
|
||||
}, { /* Test Vector #4 */
|
||||
.key = "\x1c\x92\x40\xa5\xeb\x55\xd3\x8a"
|
||||
"\xf3\x33\x88\x86\x04\xf6\xb5\xf0"
|
||||
"\x47\x39\x17\xc1\x40\x2b\x80\x09"
|
||||
"\x9d\xca\x5c\xbc\x20\x70\x75\xc0",
|
||||
.ksize = 32,
|
||||
.plaintext = "\x27\x54\x77\x61\x73\x20\x62\x72"
|
||||
"\x69\x6c\x6c\x69\x67\x2c\x20\x61"
|
||||
"\x6e\x64\x20\x74\x68\x65\x20\x73"
|
||||
"\x6c\x69\x74\x68\x79\x20\x74\x6f"
|
||||
"\x76\x65\x73\x0a\x44\x69\x64\x20"
|
||||
"\x67\x79\x72\x65\x20\x61\x6e\x64"
|
||||
"\x20\x67\x69\x6d\x62\x6c\x65\x20"
|
||||
"\x69\x6e\x20\x74\x68\x65\x20\x77"
|
||||
"\x61\x62\x65\x3a\x0a\x41\x6c\x6c"
|
||||
"\x20\x6d\x69\x6d\x73\x79\x20\x77"
|
||||
"\x65\x72\x65\x20\x74\x68\x65\x20"
|
||||
"\x62\x6f\x72\x6f\x67\x6f\x76\x65"
|
||||
"\x73\x2c\x0a\x41\x6e\x64\x20\x74"
|
||||
"\x68\x65\x20\x6d\x6f\x6d\x65\x20"
|
||||
"\x72\x61\x74\x68\x73\x20\x6f\x75"
|
||||
"\x74\x67\x72\x61\x62\x65\x2e",
|
||||
.psize = 127,
|
||||
.digest = "\x45\x41\x66\x9a\x7e\xaa\xee\x61"
|
||||
"\xe7\x08\xdc\x7c\xbc\xc5\xeb\x62",
|
||||
}, { /* Test Vector #5 */
|
||||
.key = "\x02\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
.ksize = 32,
|
||||
.plaintext = "\xff\xff\xff\xff\xff\xff\xff\xff"
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff",
|
||||
.psize = 16,
|
||||
.digest = "\x03\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
}, { /* Test Vector #6 */
|
||||
.key = "\x02\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff"
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff",
|
||||
.ksize = 32,
|
||||
.plaintext = "\x02\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
.psize = 16,
|
||||
.digest = "\x03\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
}, { /* Test Vector #7 */
|
||||
.key = "\x01\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
.ksize = 32,
|
||||
.plaintext = "\xff\xff\xff\xff\xff\xff\xff\xff"
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff"
|
||||
"\xf0\xff\xff\xff\xff\xff\xff\xff"
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff"
|
||||
"\x11\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
.psize = 48,
|
||||
.digest = "\x05\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
}, { /* Test Vector #8 */
|
||||
.key = "\x01\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
.ksize = 32,
|
||||
.plaintext = "\xff\xff\xff\xff\xff\xff\xff\xff"
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff"
|
||||
"\xfb\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
|
||||
"\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe"
|
||||
"\x01\x01\x01\x01\x01\x01\x01\x01"
|
||||
"\x01\x01\x01\x01\x01\x01\x01\x01",
|
||||
.psize = 48,
|
||||
.digest = "\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
}, { /* Test Vector #9 */
|
||||
.key = "\x02\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
.ksize = 32,
|
||||
.plaintext = "\xfd\xff\xff\xff\xff\xff\xff\xff"
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff",
|
||||
.psize = 16,
|
||||
.digest = "\xfa\xff\xff\xff\xff\xff\xff\xff"
|
||||
"\xff\xff\xff\xff\xff\xff\xff\xff",
|
||||
}, { /* Test Vector #10 */
|
||||
.key = "\x01\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x04\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
.ksize = 32,
|
||||
.plaintext = "\xe3\x35\x94\xd7\x50\x5e\x43\xb9"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x33\x94\xd7\x50\x5e\x43\x79\xcd"
|
||||
"\x01\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x01\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
.psize = 64,
|
||||
.digest = "\x14\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x55\x00\x00\x00\x00\x00\x00\x00",
|
||||
}, { /* Test Vector #11 */
|
||||
.key = "\x01\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x04\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
.ksize = 32,
|
||||
.plaintext = "\xe3\x35\x94\xd7\x50\x5e\x43\xb9"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x33\x94\xd7\x50\x5e\x43\x79\xcd"
|
||||
"\x01\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
.psize = 48,
|
||||
.digest = "\x13\x00\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
* DES test vectors.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user