summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2018-10-19 19:01:53 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2018-11-09 04:41:38 -0500
commit7da66670775d201f633577f5b15a4bbeebaaa2b0 (patch)
tree9f4b19d1a0e900ca6f7ed02d069ab755ed2edbb9
parentfa4600734b74f74d9169c3015946d4722f8bcf79 (diff)
crypto: testmgr - add AES-CFB tests
Add AES128/192/256-CFB testvectors from NIST SP800-38A. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/tcrypt.c5
-rw-r--r--crypto/testmgr.c7
-rw-r--r--crypto/testmgr.h76
3 files changed, 88 insertions, 0 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index c20c9f5c18f2..1026173d721a 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -1736,6 +1736,7 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
1736 ret += tcrypt_test("ctr(aes)"); 1736 ret += tcrypt_test("ctr(aes)");
1737 ret += tcrypt_test("rfc3686(ctr(aes))"); 1737 ret += tcrypt_test("rfc3686(ctr(aes))");
1738 ret += tcrypt_test("ofb(aes)"); 1738 ret += tcrypt_test("ofb(aes)");
1739 ret += tcrypt_test("cfb(aes)");
1739 break; 1740 break;
1740 1741
1741 case 11: 1742 case 11:
@@ -2060,6 +2061,10 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
2060 speed_template_16_24_32); 2061 speed_template_16_24_32);
2061 test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, 2062 test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
2062 speed_template_16_24_32); 2063 speed_template_16_24_32);
2064 test_cipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
2065 speed_template_16_24_32);
2066 test_cipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
2067 speed_template_16_24_32);
2063 break; 2068 break;
2064 2069
2065 case 201: 2070 case 201:
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index b1f79c6bf409..84937ceb4bd8 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -2691,6 +2691,13 @@ static const struct alg_test_desc alg_test_descs[] = {
2691 } 2691 }
2692 } 2692 }
2693 }, { 2693 }, {
2694 .alg = "cfb(aes)",
2695 .test = alg_test_skcipher,
2696 .fips_allowed = 1,
2697 .suite = {
2698 .cipher = __VECS(aes_cfb_tv_template)
2699 },
2700 }, {
2694 .alg = "chacha20", 2701 .alg = "chacha20",
2695 .test = alg_test_skcipher, 2702 .test = alg_test_skcipher,
2696 .suite = { 2703 .suite = {
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index 1fe7b97ba03f..b5b0d29761ce 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -11449,6 +11449,82 @@ static const struct cipher_testvec aes_cbc_tv_template[] = {
11449 }, 11449 },
11450}; 11450};
11451 11451
11452static const struct cipher_testvec aes_cfb_tv_template[] = {
11453 { /* From NIST SP800-38A */
11454 .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
11455 "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
11456 .klen = 16,
11457 .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
11458 "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
11459 .ptext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
11460 "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
11461 "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
11462 "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
11463 "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
11464 "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
11465 "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
11466 "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
11467 .ctext = "\x3b\x3f\xd9\x2e\xb7\x2d\xad\x20"
11468 "\x33\x34\x49\xf8\xe8\x3c\xfb\x4a"
11469 "\xc8\xa6\x45\x37\xa0\xb3\xa9\x3f"
11470 "\xcd\xe3\xcd\xad\x9f\x1c\xe5\x8b"
11471 "\x26\x75\x1f\x67\xa3\xcb\xb1\x40"
11472 "\xb1\x80\x8c\xf1\x87\xa4\xf4\xdf"
11473 "\xc0\x4b\x05\x35\x7c\x5d\x1c\x0e"
11474 "\xea\xc4\xc6\x6f\x9f\xf7\xf2\xe6",
11475 .len = 64,
11476 }, {
11477 .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
11478 "\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
11479 "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
11480 .klen = 24,
11481 .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
11482 "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
11483 .ptext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
11484 "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
11485 "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
11486 "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
11487 "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
11488 "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
11489 "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
11490 "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
11491 .ctext = "\xcd\xc8\x0d\x6f\xdd\xf1\x8c\xab"
11492 "\x34\xc2\x59\x09\xc9\x9a\x41\x74"
11493 "\x67\xce\x7f\x7f\x81\x17\x36\x21"
11494 "\x96\x1a\x2b\x70\x17\x1d\x3d\x7a"
11495 "\x2e\x1e\x8a\x1d\xd5\x9b\x88\xb1"
11496 "\xc8\xe6\x0f\xed\x1e\xfa\xc4\xc9"
11497 "\xc0\x5f\x9f\x9c\xa9\x83\x4f\xa0"
11498 "\x42\xae\x8f\xba\x58\x4b\x09\xff",
11499 .len = 64,
11500 }, {
11501 .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe"
11502 "\x2b\x73\xae\xf0\x85\x7d\x77\x81"
11503 "\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
11504 "\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
11505 .klen = 32,
11506 .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
11507 "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
11508 .ptext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
11509 "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
11510 "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
11511 "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
11512 "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
11513 "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
11514 "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
11515 "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
11516 .ctext = "\xdc\x7e\x84\xbf\xda\x79\x16\x4b"
11517 "\x7e\xcd\x84\x86\x98\x5d\x38\x60"
11518 "\x39\xff\xed\x14\x3b\x28\xb1\xc8"
11519 "\x32\x11\x3c\x63\x31\xe5\x40\x7b"
11520 "\xdf\x10\x13\x24\x15\xe5\x4b\x92"
11521 "\xa1\x3e\xd0\xa8\x26\x7a\xe2\xf9"
11522 "\x75\xa3\x85\x74\x1a\xb9\xce\xf8"
11523 "\x20\x31\x62\x3d\x55\xb1\xe4\x71",
11524 .len = 64,
11525 },
11526};
11527
11452static const struct aead_testvec hmac_md5_ecb_cipher_null_enc_tv_template[] = { 11528static const struct aead_testvec hmac_md5_ecb_cipher_null_enc_tv_template[] = {
11453 { /* Input data from RFC 2410 Case 1 */ 11529 { /* Input data from RFC 2410 Case 1 */
11454#ifdef __LITTLE_ENDIAN 11530#ifdef __LITTLE_ENDIAN