aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/tcrypt.c4
-rw-r--r--crypto/testmgr.c9
-rw-r--r--crypto/testmgr.h96
3 files changed, 109 insertions, 0 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 0452036b1d45..ea3b8a8db721 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -707,6 +707,10 @@ static void do_test(int m)
707 tcrypt_test("hmac(rmd160)"); 707 tcrypt_test("hmac(rmd160)");
708 break; 708 break;
709 709
710 case 150:
711 tcrypt_test("ansi_cprng");
712 break;
713
710 case 200: 714 case 200:
711 test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, 715 test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
712 speed_template_16_24_32); 716 speed_template_16_24_32);
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index adc54cfd39df..5183ec5a4517 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1380,6 +1380,15 @@ static int alg_test_cprng(const struct alg_test_desc *desc, const char *driver,
1380/* Please keep this list sorted by algorithm name. */ 1380/* Please keep this list sorted by algorithm name. */
1381static const struct alg_test_desc alg_test_descs[] = { 1381static const struct alg_test_desc alg_test_descs[] = {
1382 { 1382 {
1383 .alg = "ansi_cprng",
1384 .test = alg_test_cprng,
1385 .suite = {
1386 .cprng = {
1387 .vecs = ansi_cprng_aes_tv_template,
1388 .count = ANSI_CPRNG_AES_TEST_VECTORS
1389 }
1390 }
1391 }, {
1383 .alg = "cbc(aes)", 1392 .alg = "cbc(aes)",
1384 .test = alg_test_skcipher, 1393 .test = alg_test_skcipher,
1385 .suite = { 1394 .suite = {
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index 13d5a61d0e77..c1c709b57ddb 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -6208,6 +6208,102 @@ static struct aead_testvec aes_ccm_rfc4309_dec_tv_template[] = {
6208 }, 6208 },
6209}; 6209};
6210 6210
6211/*
6212 * ANSI X9.31 Continuous Pseudo-Random Number Generator (AES mode)
6213 * test vectors, taken from Appendix B.2.9 and B.2.10:
6214 * http://csrc.nist.gov/groups/STM/cavp/documents/rng/RNGVS.pdf
6215 * Only AES-128 is supported at this time.
6216 */
6217#define ANSI_CPRNG_AES_TEST_VECTORS 6
6218
6219static struct cprng_testvec ansi_cprng_aes_tv_template[] = {
6220 {
6221 .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
6222 "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
6223 .klen = 16,
6224 .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
6225 "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xf9",
6226 .dtlen = 16,
6227 .v = "\x80\x00\x00\x00\x00\x00\x00\x00"
6228 "\x00\x00\x00\x00\x00\x00\x00\x00",
6229 .vlen = 16,
6230 .result = "\x59\x53\x1e\xd1\x3b\xb0\xc0\x55"
6231 "\x84\x79\x66\x85\xc1\x2f\x76\x41",
6232 .rlen = 16,
6233 .loops = 1,
6234 }, {
6235 .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
6236 "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
6237 .klen = 16,
6238 .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
6239 "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfa",
6240 .dtlen = 16,
6241 .v = "\xc0\x00\x00\x00\x00\x00\x00\x00"
6242 "\x00\x00\x00\x00\x00\x00\x00\x00",
6243 .vlen = 16,
6244 .result = "\x7c\x22\x2c\xf4\xca\x8f\xa2\x4c"
6245 "\x1c\x9c\xb6\x41\xa9\xf3\x22\x0d",
6246 .rlen = 16,
6247 .loops = 1,
6248 }, {
6249 .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
6250 "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
6251 .klen = 16,
6252 .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
6253 "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfb",
6254 .dtlen = 16,
6255 .v = "\xe0\x00\x00\x00\x00\x00\x00\x00"
6256 "\x00\x00\x00\x00\x00\x00\x00\x00",
6257 .vlen = 16,
6258 .result = "\x8a\xaa\x00\x39\x66\x67\x5b\xe5"
6259 "\x29\x14\x28\x81\xa9\x4d\x4e\xc7",
6260 .rlen = 16,
6261 .loops = 1,
6262 }, {
6263 .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
6264 "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
6265 .klen = 16,
6266 .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
6267 "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfc",
6268 .dtlen = 16,
6269 .v = "\xf0\x00\x00\x00\x00\x00\x00\x00"
6270 "\x00\x00\x00\x00\x00\x00\x00\x00",
6271 .vlen = 16,
6272 .result = "\x88\xdd\xa4\x56\x30\x24\x23\xe5"
6273 "\xf6\x9d\xa5\x7e\x7b\x95\xc7\x3a",
6274 .rlen = 16,
6275 .loops = 1,
6276 }, {
6277 .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42"
6278 "\xed\x06\x1c\xab\xb8\xd4\x62\x02",
6279 .klen = 16,
6280 .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62"
6281 "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfd",
6282 .dtlen = 16,
6283 .v = "\xf8\x00\x00\x00\x00\x00\x00\x00"
6284 "\x00\x00\x00\x00\x00\x00\x00\x00",
6285 .vlen = 16,
6286 .result = "\x05\x25\x92\x46\x61\x79\xd2\xcb"
6287 "\x78\xc4\x0b\x14\x0a\x5a\x9a\xc8",
6288 .rlen = 16,
6289 .loops = 1,
6290 }, { /* Monte Carlo Test */
6291 .key = "\x9f\x5b\x51\x20\x0b\xf3\x34\xb5"
6292 "\xd8\x2b\xe8\xc3\x72\x55\xc8\x48",
6293 .klen = 16,
6294 .dt = "\x63\x76\xbb\xe5\x29\x02\xba\x3b"
6295 "\x67\xc9\x25\xfa\x70\x1f\x11\xac",
6296 .dtlen = 16,
6297 .v = "\x57\x2c\x8e\x76\x87\x26\x47\x97"
6298 "\x7e\x74\xfb\xdd\xc4\x95\x01\xd1",
6299 .vlen = 16,
6300 .result = "\x48\xe9\xbd\x0d\x06\xee\x18\xfb"
6301 "\xe4\x57\x90\xd5\xc3\xfc\x9b\x73",
6302 .rlen = 16,
6303 .loops = 10000,
6304 },
6305};
6306
6211/* Cast5 test vectors from RFC 2144 */ 6307/* Cast5 test vectors from RFC 2144 */
6212#define CAST5_ENC_TEST_VECTORS 3 6308#define CAST5_ENC_TEST_VECTORS 3
6213#define CAST5_DEC_TEST_VECTORS 3 6309#define CAST5_DEC_TEST_VECTORS 3