diff options
-rw-r--r-- | crypto/tcrypt.c | 53 | ||||
-rw-r--r-- | crypto/testmgr.c | 40 | ||||
-rw-r--r-- | crypto/testmgr.h | 125 |
3 files changed, 217 insertions, 1 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 579dce071463..4675459e82da 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
@@ -72,7 +72,8 @@ static char *check[] = { | |||
72 | "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", | 72 | "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", |
73 | "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", | 73 | "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", |
74 | "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320", | 74 | "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320", |
75 | "lzo", "cts", "zlib", NULL | 75 | "lzo", "cts", "zlib", "sha3-224", "sha3-256", "sha3-384", "sha3-512", |
76 | NULL | ||
76 | }; | 77 | }; |
77 | 78 | ||
78 | struct tcrypt_result { | 79 | struct tcrypt_result { |
@@ -1284,6 +1285,22 @@ static int do_test(const char *alg, u32 type, u32 mask, int m) | |||
1284 | ret += tcrypt_test("crct10dif"); | 1285 | ret += tcrypt_test("crct10dif"); |
1285 | break; | 1286 | break; |
1286 | 1287 | ||
1288 | case 48: | ||
1289 | ret += tcrypt_test("sha3-224"); | ||
1290 | break; | ||
1291 | |||
1292 | case 49: | ||
1293 | ret += tcrypt_test("sha3-256"); | ||
1294 | break; | ||
1295 | |||
1296 | case 50: | ||
1297 | ret += tcrypt_test("sha3-384"); | ||
1298 | break; | ||
1299 | |||
1300 | case 51: | ||
1301 | ret += tcrypt_test("sha3-512"); | ||
1302 | break; | ||
1303 | |||
1287 | case 100: | 1304 | case 100: |
1288 | ret += tcrypt_test("hmac(md5)"); | 1305 | ret += tcrypt_test("hmac(md5)"); |
1289 | break; | 1306 | break; |
@@ -1691,6 +1708,22 @@ static int do_test(const char *alg, u32 type, u32 mask, int m) | |||
1691 | test_hash_speed("poly1305", sec, poly1305_speed_template); | 1708 | test_hash_speed("poly1305", sec, poly1305_speed_template); |
1692 | if (mode > 300 && mode < 400) break; | 1709 | if (mode > 300 && mode < 400) break; |
1693 | 1710 | ||
1711 | case 322: | ||
1712 | test_hash_speed("sha3-224", sec, generic_hash_speed_template); | ||
1713 | if (mode > 300 && mode < 400) break; | ||
1714 | |||
1715 | case 323: | ||
1716 | test_hash_speed("sha3-256", sec, generic_hash_speed_template); | ||
1717 | if (mode > 300 && mode < 400) break; | ||
1718 | |||
1719 | case 324: | ||
1720 | test_hash_speed("sha3-384", sec, generic_hash_speed_template); | ||
1721 | if (mode > 300 && mode < 400) break; | ||
1722 | |||
1723 | case 325: | ||
1724 | test_hash_speed("sha3-512", sec, generic_hash_speed_template); | ||
1725 | if (mode > 300 && mode < 400) break; | ||
1726 | |||
1694 | case 399: | 1727 | case 399: |
1695 | break; | 1728 | break; |
1696 | 1729 | ||
@@ -1770,6 +1803,24 @@ static int do_test(const char *alg, u32 type, u32 mask, int m) | |||
1770 | test_ahash_speed("rmd320", sec, generic_hash_speed_template); | 1803 | test_ahash_speed("rmd320", sec, generic_hash_speed_template); |
1771 | if (mode > 400 && mode < 500) break; | 1804 | if (mode > 400 && mode < 500) break; |
1772 | 1805 | ||
1806 | case 418: | ||
1807 | test_ahash_speed("sha3-224", sec, generic_hash_speed_template); | ||
1808 | if (mode > 400 && mode < 500) break; | ||
1809 | |||
1810 | case 419: | ||
1811 | test_ahash_speed("sha3-256", sec, generic_hash_speed_template); | ||
1812 | if (mode > 400 && mode < 500) break; | ||
1813 | |||
1814 | case 420: | ||
1815 | test_ahash_speed("sha3-384", sec, generic_hash_speed_template); | ||
1816 | if (mode > 400 && mode < 500) break; | ||
1817 | |||
1818 | |||
1819 | case 421: | ||
1820 | test_ahash_speed("sha3-512", sec, generic_hash_speed_template); | ||
1821 | if (mode > 400 && mode < 500) break; | ||
1822 | |||
1823 | |||
1773 | case 499: | 1824 | case 499: |
1774 | break; | 1825 | break; |
1775 | 1826 | ||
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index c727fb0cb021..b773a563809b 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
@@ -3659,6 +3659,46 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
3659 | } | 3659 | } |
3660 | } | 3660 | } |
3661 | }, { | 3661 | }, { |
3662 | .alg = "sha3-224", | ||
3663 | .test = alg_test_hash, | ||
3664 | .fips_allowed = 1, | ||
3665 | .suite = { | ||
3666 | .hash = { | ||
3667 | .vecs = sha3_224_tv_template, | ||
3668 | .count = SHA3_224_TEST_VECTORS | ||
3669 | } | ||
3670 | } | ||
3671 | }, { | ||
3672 | .alg = "sha3-256", | ||
3673 | .test = alg_test_hash, | ||
3674 | .fips_allowed = 1, | ||
3675 | .suite = { | ||
3676 | .hash = { | ||
3677 | .vecs = sha3_256_tv_template, | ||
3678 | .count = SHA3_256_TEST_VECTORS | ||
3679 | } | ||
3680 | } | ||
3681 | }, { | ||
3682 | .alg = "sha3-384", | ||
3683 | .test = alg_test_hash, | ||
3684 | .fips_allowed = 1, | ||
3685 | .suite = { | ||
3686 | .hash = { | ||
3687 | .vecs = sha3_384_tv_template, | ||
3688 | .count = SHA3_384_TEST_VECTORS | ||
3689 | } | ||
3690 | } | ||
3691 | }, { | ||
3692 | .alg = "sha3-512", | ||
3693 | .test = alg_test_hash, | ||
3694 | .fips_allowed = 1, | ||
3695 | .suite = { | ||
3696 | .hash = { | ||
3697 | .vecs = sha3_512_tv_template, | ||
3698 | .count = SHA3_512_TEST_VECTORS | ||
3699 | } | ||
3700 | } | ||
3701 | }, { | ||
3662 | .alg = "sha384", | 3702 | .alg = "sha384", |
3663 | .test = alg_test_hash, | 3703 | .test = alg_test_hash, |
3664 | .fips_allowed = 1, | 3704 | .fips_allowed = 1, |
diff --git a/crypto/testmgr.h b/crypto/testmgr.h index 487ec880e889..b70e3c92bedd 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h | |||
@@ -376,6 +376,131 @@ static struct hash_testvec md4_tv_template [] = { | |||
376 | }, | 376 | }, |
377 | }; | 377 | }; |
378 | 378 | ||
379 | #define SHA3_224_TEST_VECTORS 3 | ||
380 | static struct hash_testvec sha3_224_tv_template[] = { | ||
381 | { | ||
382 | .plaintext = "", | ||
383 | .digest = "\x6b\x4e\x03\x42\x36\x67\xdb\xb7" | ||
384 | "\x3b\x6e\x15\x45\x4f\x0e\xb1\xab" | ||
385 | "\xd4\x59\x7f\x9a\x1b\x07\x8e\x3f" | ||
386 | "\x5b\x5a\x6b\xc7", | ||
387 | }, { | ||
388 | .plaintext = "a", | ||
389 | .psize = 1, | ||
390 | .digest = "\x9e\x86\xff\x69\x55\x7c\xa9\x5f" | ||
391 | "\x40\x5f\x08\x12\x69\x68\x5b\x38" | ||
392 | "\xe3\xa8\x19\xb3\x09\xee\x94\x2f" | ||
393 | "\x48\x2b\x6a\x8b", | ||
394 | }, { | ||
395 | .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkl" | ||
396 | "jklmklmnlmnomnopnopq", | ||
397 | .psize = 56, | ||
398 | .digest = "\x8a\x24\x10\x8b\x15\x4a\xda\x21" | ||
399 | "\xc9\xfd\x55\x74\x49\x44\x79\xba" | ||
400 | "\x5c\x7e\x7a\xb7\x6e\xf2\x64\xea" | ||
401 | "\xd0\xfc\xce\x33", | ||
402 | }, | ||
403 | }; | ||
404 | |||
405 | #define SHA3_256_TEST_VECTORS 3 | ||
406 | static struct hash_testvec sha3_256_tv_template[] = { | ||
407 | { | ||
408 | .plaintext = "", | ||
409 | .digest = "\xa7\xff\xc6\xf8\xbf\x1e\xd7\x66" | ||
410 | "\x51\xc1\x47\x56\xa0\x61\xd6\x62" | ||
411 | "\xf5\x80\xff\x4d\xe4\x3b\x49\xfa" | ||
412 | "\x82\xd8\x0a\x4b\x80\xf8\x43\x4a", | ||
413 | }, { | ||
414 | .plaintext = "a", | ||
415 | .psize = 1, | ||
416 | .digest = "\x80\x08\x4b\xf2\xfb\xa0\x24\x75" | ||
417 | "\x72\x6f\xeb\x2c\xab\x2d\x82\x15" | ||
418 | "\xea\xb1\x4b\xc6\xbd\xd8\xbf\xb2" | ||
419 | "\xc8\x15\x12\x57\x03\x2e\xcd\x8b", | ||
420 | }, { | ||
421 | .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkl" | ||
422 | "jklmklmnlmnomnopnopq", | ||
423 | .psize = 56, | ||
424 | .digest = "\x41\xc0\xdb\xa2\xa9\xd6\x24\x08" | ||
425 | "\x49\x10\x03\x76\xa8\x23\x5e\x2c" | ||
426 | "\x82\xe1\xb9\x99\x8a\x99\x9e\x21" | ||
427 | "\xdb\x32\xdd\x97\x49\x6d\x33\x76", | ||
428 | }, | ||
429 | }; | ||
430 | |||
431 | |||
432 | #define SHA3_384_TEST_VECTORS 3 | ||
433 | static struct hash_testvec sha3_384_tv_template[] = { | ||
434 | { | ||
435 | .plaintext = "", | ||
436 | .digest = "\x0c\x63\xa7\x5b\x84\x5e\x4f\x7d" | ||
437 | "\x01\x10\x7d\x85\x2e\x4c\x24\x85" | ||
438 | "\xc5\x1a\x50\xaa\xaa\x94\xfc\x61" | ||
439 | "\x99\x5e\x71\xbb\xee\x98\x3a\x2a" | ||
440 | "\xc3\x71\x38\x31\x26\x4a\xdb\x47" | ||
441 | "\xfb\x6b\xd1\xe0\x58\xd5\xf0\x04", | ||
442 | }, { | ||
443 | .plaintext = "a", | ||
444 | .psize = 1, | ||
445 | .digest = "\x18\x15\xf7\x74\xf3\x20\x49\x1b" | ||
446 | "\x48\x56\x9e\xfe\xc7\x94\xd2\x49" | ||
447 | "\xee\xb5\x9a\xae\x46\xd2\x2b\xf7" | ||
448 | "\x7d\xaf\xe2\x5c\x5e\xdc\x28\xd7" | ||
449 | "\xea\x44\xf9\x3e\xe1\x23\x4a\xa8" | ||
450 | "\x8f\x61\xc9\x19\x12\xa4\xcc\xd9", | ||
451 | }, { | ||
452 | .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkl" | ||
453 | "jklmklmnlmnomnopnopq", | ||
454 | .psize = 56, | ||
455 | .digest = "\x99\x1c\x66\x57\x55\xeb\x3a\x4b" | ||
456 | "\x6b\xbd\xfb\x75\xc7\x8a\x49\x2e" | ||
457 | "\x8c\x56\xa2\x2c\x5c\x4d\x7e\x42" | ||
458 | "\x9b\xfd\xbc\x32\xb9\xd4\xad\x5a" | ||
459 | "\xa0\x4a\x1f\x07\x6e\x62\xfe\xa1" | ||
460 | "\x9e\xef\x51\xac\xd0\x65\x7c\x22", | ||
461 | }, | ||
462 | }; | ||
463 | |||
464 | |||
465 | #define SHA3_512_TEST_VECTORS 3 | ||
466 | static struct hash_testvec sha3_512_tv_template[] = { | ||
467 | { | ||
468 | .plaintext = "", | ||
469 | .digest = "\xa6\x9f\x73\xcc\xa2\x3a\x9a\xc5" | ||
470 | "\xc8\xb5\x67\xdc\x18\x5a\x75\x6e" | ||
471 | "\x97\xc9\x82\x16\x4f\xe2\x58\x59" | ||
472 | "\xe0\xd1\xdc\xc1\x47\x5c\x80\xa6" | ||
473 | "\x15\xb2\x12\x3a\xf1\xf5\xf9\x4c" | ||
474 | "\x11\xe3\xe9\x40\x2c\x3a\xc5\x58" | ||
475 | "\xf5\x00\x19\x9d\x95\xb6\xd3\xe3" | ||
476 | "\x01\x75\x85\x86\x28\x1d\xcd\x26", | ||
477 | }, { | ||
478 | .plaintext = "a", | ||
479 | .psize = 1, | ||
480 | .digest = "\x69\x7f\x2d\x85\x61\x72\xcb\x83" | ||
481 | "\x09\xd6\xb8\xb9\x7d\xac\x4d\xe3" | ||
482 | "\x44\xb5\x49\xd4\xde\xe6\x1e\xdf" | ||
483 | "\xb4\x96\x2d\x86\x98\xb7\xfa\x80" | ||
484 | "\x3f\x4f\x93\xff\x24\x39\x35\x86" | ||
485 | "\xe2\x8b\x5b\x95\x7a\xc3\xd1\xd3" | ||
486 | "\x69\x42\x0c\xe5\x33\x32\x71\x2f" | ||
487 | "\x99\x7b\xd3\x36\xd0\x9a\xb0\x2a", | ||
488 | }, { | ||
489 | .plaintext = "abcdbcdecdefdefgefghfghighijhijkijkl" | ||
490 | "jklmklmnlmnomnopnopq", | ||
491 | .psize = 56, | ||
492 | .digest = "\x04\xa3\x71\xe8\x4e\xcf\xb5\xb8" | ||
493 | "\xb7\x7c\xb4\x86\x10\xfc\xa8\x18" | ||
494 | "\x2d\xd4\x57\xce\x6f\x32\x6a\x0f" | ||
495 | "\xd3\xd7\xec\x2f\x1e\x91\x63\x6d" | ||
496 | "\xee\x69\x1f\xbe\x0c\x98\x53\x02" | ||
497 | "\xba\x1b\x0d\x8d\xc7\x8c\x08\x63" | ||
498 | "\x46\xb5\x33\xb4\x9c\x03\x0d\x99" | ||
499 | "\xa2\x7d\xaf\x11\x39\xd6\xe7\x5e", | ||
500 | }, | ||
501 | }; | ||
502 | |||
503 | |||
379 | /* | 504 | /* |
380 | * MD5 test vectors from RFC1321 | 505 | * MD5 test vectors from RFC1321 |
381 | */ | 506 | */ |