aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2014-04-16 08:40:04 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2014-04-16 08:40:04 -0400
commit4585988f838605e34194a4a8121b64c7039adba9 (patch)
tree0c64f093a6c5c842ebf8b375cb98b8df1f7c60c9 /crypto
parent7ded6e3d1bf5f83786753d1e0556a5c9711ced8a (diff)
crypto: testmgr - add test cases for SHA-1, SHA-224, SHA-256 and AES-CCM
This adds test cases for SHA-1, SHA-224, SHA-256 and AES-CCM with an input size that is an exact multiple of the block size. The reason is that some implementations use a different code path for these cases. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/testmgr.h53
1 files changed, 47 insertions, 6 deletions
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index 3db83dbba1d9..c5d911dd8039 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -487,7 +487,7 @@ static struct hash_testvec crct10dif_tv_template[] = {
487 * SHA1 test vectors from from FIPS PUB 180-1 487 * SHA1 test vectors from from FIPS PUB 180-1
488 * Long vector from CAVS 5.0 488 * Long vector from CAVS 5.0
489 */ 489 */
490#define SHA1_TEST_VECTORS 3 490#define SHA1_TEST_VECTORS 4
491 491
492static struct hash_testvec sha1_tv_template[] = { 492static struct hash_testvec sha1_tv_template[] = {
493 { 493 {
@@ -529,6 +529,11 @@ static struct hash_testvec sha1_tv_template[] = {
529 "\x45\x9c\x02\xb6\x9b\x4a\xa8\xf5\x82\x17", 529 "\x45\x9c\x02\xb6\x9b\x4a\xa8\xf5\x82\x17",
530 .np = 4, 530 .np = 4,
531 .tap = { 63, 64, 31, 5 } 531 .tap = { 63, 64, 31, 5 }
532 }, {
533 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
534 .psize = 64,
535 .digest = "\xc8\x71\xf6\x9a\x63\xcc\xa9\x84\x84\x82"
536 "\x64\xe7\x79\x95\x5d\xd7\x19\x41\x7c\x91",
532 } 537 }
533}; 538};
534 539
@@ -536,7 +541,7 @@ static struct hash_testvec sha1_tv_template[] = {
536/* 541/*
537 * SHA224 test vectors from from FIPS PUB 180-2 542 * SHA224 test vectors from from FIPS PUB 180-2
538 */ 543 */
539#define SHA224_TEST_VECTORS 2 544#define SHA224_TEST_VECTORS 3
540 545
541static struct hash_testvec sha224_tv_template[] = { 546static struct hash_testvec sha224_tv_template[] = {
542 { 547 {
@@ -556,13 +561,20 @@ static struct hash_testvec sha224_tv_template[] = {
556 "\x52\x52\x25\x25", 561 "\x52\x52\x25\x25",
557 .np = 2, 562 .np = 2,
558 .tap = { 28, 28 } 563 .tap = { 28, 28 }
564 }, {
565 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
566 .psize = 64,
567 .digest = "\xc4\xdb\x2b\x3a\x58\xc3\x99\x01"
568 "\x42\xfd\x10\x92\xaa\x4e\x04\x08"
569 "\x58\xbb\xbb\xe8\xf8\x14\xa7\x0c"
570 "\xef\x3b\xcb\x0e",
559 } 571 }
560}; 572};
561 573
562/* 574/*
563 * SHA256 test vectors from from NIST 575 * SHA256 test vectors from from NIST
564 */ 576 */
565#define SHA256_TEST_VECTORS 2 577#define SHA256_TEST_VECTORS 3
566 578
567static struct hash_testvec sha256_tv_template[] = { 579static struct hash_testvec sha256_tv_template[] = {
568 { 580 {
@@ -581,7 +593,14 @@ static struct hash_testvec sha256_tv_template[] = {
581 "\xf6\xec\xed\xd4\x19\xdb\x06\xc1", 593 "\xf6\xec\xed\xd4\x19\xdb\x06\xc1",
582 .np = 2, 594 .np = 2,
583 .tap = { 28, 28 } 595 .tap = { 28, 28 }
584 }, 596 }, {
597 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-",
598 .psize = 64,
599 .digest = "\xb5\xfe\xad\x56\x7d\xff\xcb\xa4"
600 "\x2c\x32\x29\x32\x19\xbb\xfb\xfa"
601 "\xd6\xff\x94\xa3\x72\x91\x85\x66"
602 "\x3b\xa7\x87\x77\x58\xa3\x40\x3a",
603 }
585}; 604};
586 605
587/* 606/*
@@ -12844,7 +12863,7 @@ static struct cipher_testvec cast6_xts_dec_tv_template[] = {
12844#define AES_GCM_4106_DEC_TEST_VECTORS 7 12863#define AES_GCM_4106_DEC_TEST_VECTORS 7
12845#define AES_GCM_4543_ENC_TEST_VECTORS 1 12864#define AES_GCM_4543_ENC_TEST_VECTORS 1
12846#define AES_GCM_4543_DEC_TEST_VECTORS 2 12865#define AES_GCM_4543_DEC_TEST_VECTORS 2
12847#define AES_CCM_ENC_TEST_VECTORS 7 12866#define AES_CCM_ENC_TEST_VECTORS 8
12848#define AES_CCM_DEC_TEST_VECTORS 7 12867#define AES_CCM_DEC_TEST_VECTORS 7
12849#define AES_CCM_4309_ENC_TEST_VECTORS 7 12868#define AES_CCM_4309_ENC_TEST_VECTORS 7
12850#define AES_CCM_4309_DEC_TEST_VECTORS 10 12869#define AES_CCM_4309_DEC_TEST_VECTORS 10
@@ -18746,7 +18765,29 @@ static struct aead_testvec aes_ccm_enc_tv_template[] = {
18746 "\x7c\xf9\xbe\xc2\x40\x88\x97\xc6" 18765 "\x7c\xf9\xbe\xc2\x40\x88\x97\xc6"
18747 "\xba", 18766 "\xba",
18748 .rlen = 33, 18767 .rlen = 33,
18749 }, 18768 }, {
18769 /*
18770 * This is the same vector as aes_ccm_rfc4309_enc_tv_template[0]
18771 * below but rewritten to use the ccm algorithm directly.
18772 */
18773 .key = "\x83\xac\x54\x66\xc2\xeb\xe5\x05"
18774 "\x2e\x01\xd1\xfc\x5d\x82\x66\x2e",
18775 .klen = 16,
18776 .iv = "\x03\x96\xac\x59\x30\x07\xa1\xe2\xa2\xc7\x55\x24\0\0\0\0",
18777 .alen = 0,
18778 .input = "\x19\xc8\x81\xf6\xe9\x86\xff\x93"
18779 "\x0b\x78\x67\xe5\xbb\xb7\xfc\x6e"
18780 "\x83\x77\xb3\xa6\x0c\x8c\x9f\x9c"
18781 "\x35\x2e\xad\xe0\x62\xf9\x91\xa1",
18782 .ilen = 32,
18783 .result = "\xab\x6f\xe1\x69\x1d\x19\x99\xa8"
18784 "\x92\xa0\xc4\x6f\x7e\xe2\x8b\xb1"
18785 "\x70\xbb\x8c\xa6\x4c\x6e\x97\x8a"
18786 "\x57\x2b\xbe\x5d\x98\xa6\xb1\x32"
18787 "\xda\x24\xea\xd9\xa1\x39\x98\xfd"
18788 "\xa4\xbe\xd9\xf2\x1a\x6d\x22\xa8",
18789 .rlen = 48,
18790 }
18750}; 18791};
18751 18792
18752static struct aead_testvec aes_ccm_dec_tv_template[] = { 18793static struct aead_testvec aes_ccm_dec_tv_template[] = {