aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2008-07-31 03:41:55 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2008-08-29 01:49:53 -0400
commit01b323245e4f6d4a22ffd73754f145f45c85988c (patch)
tree0c977ed31127c48e04bf8e4ed7808342608295bc /crypto
parentbdecd22821a0fab1f5c9e4c9b7fba894593507d4 (diff)
crypto: tcrypt - Add alg_test interface
This patch creates a new interface algorithm testing. A test can be requested for a particular implementation of an algorithm. This is achieved by taking both the name of the algorithm and that of the implementation. The all-inclusive test has also been rewritten to no longer require a duplicate listing of all algorithms with tests. In that process a number of missing tests have also been discovered and rectified. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/tcrypt.c1455
1 files changed, 1017 insertions, 438 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 97ec2bdfcce0..ed9d4ee42f7b 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -59,6 +59,45 @@ struct tcrypt_result {
59 int err; 59 int err;
60}; 60};
61 61
62struct aead_test_suite {
63 struct {
64 struct aead_testvec *vecs;
65 unsigned int count;
66 } enc, dec;
67};
68
69struct cipher_test_suite {
70 struct {
71 struct cipher_testvec *vecs;
72 unsigned int count;
73 } enc, dec;
74};
75
76struct comp_test_suite {
77 struct {
78 struct comp_testvec *vecs;
79 unsigned int count;
80 } comp, decomp;
81};
82
83struct hash_test_suite {
84 struct hash_testvec *vecs;
85 unsigned int count;
86};
87
88struct alg_test_desc {
89 const char *alg;
90 int (*test)(const struct alg_test_desc *desc, const char *driver,
91 u32 type, u32 mask);
92
93 union {
94 struct aead_test_suite aead;
95 struct cipher_test_suite cipher;
96 struct comp_test_suite comp;
97 struct hash_test_suite hash;
98 } suite;
99};
100
62static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 }; 101static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 };
63 102
64/* 103/*
@@ -98,13 +137,13 @@ static void tcrypt_complete(struct crypto_async_request *req, int err)
98 complete(&res->completion); 137 complete(&res->completion);
99} 138}
100 139
101static int test_hash(char *algo, struct hash_testvec *template, 140static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template,
102 unsigned int tcount) 141 unsigned int tcount)
103{ 142{
143 const char *algo = crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm));
104 unsigned int i, j, k, temp; 144 unsigned int i, j, k, temp;
105 struct scatterlist sg[8]; 145 struct scatterlist sg[8];
106 char result[64]; 146 char result[64];
107 struct crypto_ahash *tfm;
108 struct ahash_request *req; 147 struct ahash_request *req;
109 struct tcrypt_result tresult; 148 struct tcrypt_result tresult;
110 int ret; 149 int ret;
@@ -112,13 +151,6 @@ static int test_hash(char *algo, struct hash_testvec *template,
112 151
113 init_completion(&tresult.completion); 152 init_completion(&tresult.completion);
114 153
115 tfm = crypto_alloc_ahash(algo, 0, 0);
116 if (IS_ERR(tfm)) {
117 printk(KERN_ERR "alg: hash: Failed to load transform for %s: "
118 "%ld\n", algo, PTR_ERR(tfm));
119 return PTR_ERR(tfm);
120 }
121
122 req = ahash_request_alloc(tfm, GFP_KERNEL); 154 req = ahash_request_alloc(tfm, GFP_KERNEL);
123 if (!req) { 155 if (!req) {
124 printk(KERN_ERR "alg: hash: Failed to allocate request for " 156 printk(KERN_ERR "alg: hash: Failed to allocate request for "
@@ -249,17 +281,16 @@ static int test_hash(char *algo, struct hash_testvec *template,
249out: 281out:
250 ahash_request_free(req); 282 ahash_request_free(req);
251out_noreq: 283out_noreq:
252 crypto_free_ahash(tfm);
253 return ret; 284 return ret;
254} 285}
255 286
256static int test_aead(char *algo, int enc, struct aead_testvec *template, 287static int test_aead(struct crypto_aead *tfm, int enc,
257 unsigned int tcount) 288 struct aead_testvec *template, unsigned int tcount)
258{ 289{
290 const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm));
259 unsigned int i, j, k, n, temp; 291 unsigned int i, j, k, n, temp;
260 int ret = 0; 292 int ret = 0;
261 char *q; 293 char *q;
262 struct crypto_aead *tfm;
263 char *key; 294 char *key;
264 struct aead_request *req; 295 struct aead_request *req;
265 struct scatterlist sg[8]; 296 struct scatterlist sg[8];
@@ -278,14 +309,6 @@ static int test_aead(char *algo, int enc, struct aead_testvec *template,
278 309
279 init_completion(&result.completion); 310 init_completion(&result.completion);
280 311
281 tfm = crypto_alloc_aead(algo, 0, 0);
282
283 if (IS_ERR(tfm)) {
284 printk(KERN_ERR "alg: aead: Failed to load transform for %s: "
285 "%ld\n", algo, PTR_ERR(tfm));
286 return PTR_ERR(tfm);
287 }
288
289 req = aead_request_alloc(tfm, GFP_KERNEL); 312 req = aead_request_alloc(tfm, GFP_KERNEL);
290 if (!req) { 313 if (!req) {
291 printk(KERN_ERR "alg: aead: Failed to allocate request for " 314 printk(KERN_ERR "alg: aead: Failed to allocate request for "
@@ -538,18 +561,18 @@ static int test_aead(char *algo, int enc, struct aead_testvec *template,
538 ret = 0; 561 ret = 0;
539 562
540out: 563out:
541 crypto_free_aead(tfm);
542 aead_request_free(req); 564 aead_request_free(req);
543 return ret; 565 return ret;
544} 566}
545 567
546static int test_cipher(char *algo, int enc, 568static int test_cipher(struct crypto_ablkcipher *tfm, int enc,
547 struct cipher_testvec *template, unsigned int tcount) 569 struct cipher_testvec *template, unsigned int tcount)
548{ 570{
571 const char *algo =
572 crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm));
549 unsigned int i, j, k, n, temp; 573 unsigned int i, j, k, n, temp;
550 int ret; 574 int ret;
551 char *q; 575 char *q;
552 struct crypto_ablkcipher *tfm;
553 struct ablkcipher_request *req; 576 struct ablkcipher_request *req;
554 struct scatterlist sg[8]; 577 struct scatterlist sg[8];
555 const char *e; 578 const char *e;
@@ -563,13 +586,6 @@ static int test_cipher(char *algo, int enc,
563 e = "decryption"; 586 e = "decryption";
564 587
565 init_completion(&result.completion); 588 init_completion(&result.completion);
566 tfm = crypto_alloc_ablkcipher(algo, 0, 0);
567
568 if (IS_ERR(tfm)) {
569 printk(KERN_ERR "alg: cipher: Failed to load transform for "
570 "%s: %ld\n", algo, PTR_ERR(tfm));
571 return PTR_ERR(tfm);
572 }
573 589
574 req = ablkcipher_request_alloc(tfm, GFP_KERNEL); 590 req = ablkcipher_request_alloc(tfm, GFP_KERNEL);
575 if (!req) { 591 if (!req) {
@@ -759,7 +775,6 @@ static int test_cipher(char *algo, int enc,
759 ret = 0; 775 ret = 0;
760 776
761out: 777out:
762 crypto_free_ablkcipher(tfm);
763 ablkcipher_request_free(req); 778 ablkcipher_request_free(req);
764 return ret; 779 return ret;
765} 780}
@@ -838,7 +853,7 @@ out:
838 853
839static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 }; 854static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 };
840 855
841static void test_cipher_speed(char *algo, int enc, unsigned int sec, 856static void test_cipher_speed(const char *algo, int enc, unsigned int sec,
842 struct cipher_testvec *template, 857 struct cipher_testvec *template,
843 unsigned int tcount, u8 *keysize) 858 unsigned int tcount, u8 *keysize)
844{ 859{
@@ -1098,8 +1113,8 @@ out:
1098 return 0; 1113 return 0;
1099} 1114}
1100 1115
1101static void test_hash_speed(char *algo, unsigned int sec, 1116static void test_hash_speed(const char *algo, unsigned int sec,
1102 struct hash_speed *speed) 1117 struct hash_speed *speed)
1103{ 1118{
1104 struct scatterlist sg[TVMEMSIZE]; 1119 struct scatterlist sg[TVMEMSIZE];
1105 struct crypto_hash *tfm; 1120 struct crypto_hash *tfm;
@@ -1160,21 +1175,14 @@ out:
1160 crypto_free_hash(tfm); 1175 crypto_free_hash(tfm);
1161} 1176}
1162 1177
1163static int test_comp(char *algo, struct comp_testvec *ctemplate, 1178static int test_comp(struct crypto_comp *tfm, struct comp_testvec *ctemplate,
1164 struct comp_testvec *dtemplate, int ctcount, int dtcount) 1179 struct comp_testvec *dtemplate, int ctcount, int dtcount)
1165{ 1180{
1181 const char *algo = crypto_tfm_alg_driver_name(crypto_comp_tfm(tfm));
1166 unsigned int i; 1182 unsigned int i;
1167 char result[COMP_BUF_SIZE]; 1183 char result[COMP_BUF_SIZE];
1168 struct crypto_comp *tfm;
1169 int ret; 1184 int ret;
1170 1185
1171 tfm = crypto_alloc_comp(algo, 0, CRYPTO_ALG_ASYNC);
1172 if (IS_ERR(tfm)) {
1173 printk(KERN_ERR "alg: comp: Failed to load transform for %s: "
1174 "%ld\n", algo, PTR_ERR(tfm));
1175 return PTR_ERR(tfm);
1176 }
1177
1178 for (i = 0; i < ctcount; i++) { 1186 for (i = 0; i < ctcount; i++) {
1179 int ilen, dlen = COMP_BUF_SIZE; 1187 int ilen, dlen = COMP_BUF_SIZE;
1180 1188
@@ -1226,7 +1234,6 @@ static int test_comp(char *algo, struct comp_testvec *ctemplate,
1226 ret = 0; 1234 ret = 0;
1227 1235
1228out: 1236out:
1229 crypto_free_comp(tfm);
1230 return ret; 1237 return ret;
1231} 1238}
1232 1239
@@ -1242,549 +1249,1126 @@ static void test_available(void)
1242 } 1249 }
1243} 1250}
1244 1251
1245static void do_test(void) 1252static int alg_test_aead(const struct alg_test_desc *desc, const char *driver,
1253 u32 type, u32 mask)
1254{
1255 struct crypto_aead *tfm;
1256 int err = 0;
1257
1258 tfm = crypto_alloc_aead(driver, type, mask);
1259 if (IS_ERR(tfm)) {
1260 printk(KERN_ERR "alg: aead: Failed to load transform for %s: "
1261 "%ld\n", driver, PTR_ERR(tfm));
1262 return PTR_ERR(tfm);
1263 }
1264
1265 if (desc->suite.aead.enc.vecs) {
1266 err = test_aead(tfm, ENCRYPT, desc->suite.aead.enc.vecs,
1267 desc->suite.aead.enc.count);
1268 if (err)
1269 goto out;
1270 }
1271
1272 if (!err && desc->suite.aead.dec.vecs)
1273 err = test_aead(tfm, DECRYPT, desc->suite.aead.dec.vecs,
1274 desc->suite.aead.dec.count);
1275
1276out:
1277 crypto_free_aead(tfm);
1278 return err;
1279}
1280
1281static int alg_test_cipher(const struct alg_test_desc *desc,
1282 const char *driver, u32 type, u32 mask)
1283{
1284 struct crypto_ablkcipher *tfm;
1285 int err = 0;
1286
1287 tfm = crypto_alloc_ablkcipher(driver, type, mask);
1288 if (IS_ERR(tfm)) {
1289 printk(KERN_ERR "alg: cipher: Failed to load transform for "
1290 "%s: %ld\n", driver, PTR_ERR(tfm));
1291 return PTR_ERR(tfm);
1292 }
1293
1294 if (desc->suite.cipher.enc.vecs) {
1295 err = test_cipher(tfm, ENCRYPT, desc->suite.cipher.enc.vecs,
1296 desc->suite.cipher.enc.count);
1297 if (err)
1298 goto out;
1299 }
1300
1301 if (desc->suite.cipher.dec.vecs)
1302 err = test_cipher(tfm, DECRYPT, desc->suite.cipher.dec.vecs,
1303 desc->suite.cipher.dec.count);
1304
1305out:
1306 crypto_free_ablkcipher(tfm);
1307 return err;
1308}
1309
1310static int alg_test_comp(const struct alg_test_desc *desc, const char *driver,
1311 u32 type, u32 mask)
1312{
1313 struct crypto_comp *tfm;
1314 int err;
1315
1316 tfm = crypto_alloc_comp(driver, type, mask);
1317 if (IS_ERR(tfm)) {
1318 printk(KERN_ERR "alg: comp: Failed to load transform for %s: "
1319 "%ld\n", driver, PTR_ERR(tfm));
1320 return PTR_ERR(tfm);
1321 }
1322
1323 err = test_comp(tfm, desc->suite.comp.comp.vecs,
1324 desc->suite.comp.decomp.vecs,
1325 desc->suite.comp.comp.count,
1326 desc->suite.comp.decomp.count);
1327
1328 crypto_free_comp(tfm);
1329 return err;
1330}
1331
1332static int alg_test_hash(const struct alg_test_desc *desc, const char *driver,
1333 u32 type, u32 mask)
1246{ 1334{
1247 switch (mode) { 1335 struct crypto_ahash *tfm;
1336 int err;
1337
1338 tfm = crypto_alloc_ahash(driver, type, mask);
1339 if (IS_ERR(tfm)) {
1340 printk(KERN_ERR "alg: hash: Failed to load transform for %s: "
1341 "%ld\n", driver, PTR_ERR(tfm));
1342 return PTR_ERR(tfm);
1343 }
1344
1345 err = test_hash(tfm, desc->suite.hash.vecs, desc->suite.hash.count);
1346
1347 crypto_free_ahash(tfm);
1348 return err;
1349}
1248 1350
1351/* Please keep this list sorted by algorithm name. */
1352static const struct alg_test_desc alg_test_descs[] = {
1353 {
1354 .alg = "cbc(aes)",
1355 .test = alg_test_cipher,
1356 .suite = {
1357 .cipher = {
1358 .enc = {
1359 .vecs = aes_cbc_enc_tv_template,
1360 .count = AES_CBC_ENC_TEST_VECTORS
1361 },
1362 .dec = {
1363 .vecs = aes_cbc_dec_tv_template,
1364 .count = AES_CBC_DEC_TEST_VECTORS
1365 }
1366 }
1367 }
1368 }, {
1369 .alg = "cbc(anubis)",
1370 .test = alg_test_cipher,
1371 .suite = {
1372 .cipher = {
1373 .enc = {
1374 .vecs = anubis_cbc_enc_tv_template,
1375 .count = ANUBIS_CBC_ENC_TEST_VECTORS
1376 },
1377 .dec = {
1378 .vecs = anubis_cbc_dec_tv_template,
1379 .count = ANUBIS_CBC_DEC_TEST_VECTORS
1380 }
1381 }
1382 }
1383 }, {
1384 .alg = "cbc(blowfish)",
1385 .test = alg_test_cipher,
1386 .suite = {
1387 .cipher = {
1388 .enc = {
1389 .vecs = bf_cbc_enc_tv_template,
1390 .count = BF_CBC_ENC_TEST_VECTORS
1391 },
1392 .dec = {
1393 .vecs = bf_cbc_dec_tv_template,
1394 .count = BF_CBC_DEC_TEST_VECTORS
1395 }
1396 }
1397 }
1398 }, {
1399 .alg = "cbc(camellia)",
1400 .test = alg_test_cipher,
1401 .suite = {
1402 .cipher = {
1403 .enc = {
1404 .vecs = camellia_cbc_enc_tv_template,
1405 .count = CAMELLIA_CBC_ENC_TEST_VECTORS
1406 },
1407 .dec = {
1408 .vecs = camellia_cbc_dec_tv_template,
1409 .count = CAMELLIA_CBC_DEC_TEST_VECTORS
1410 }
1411 }
1412 }
1413 }, {
1414 .alg = "cbc(des)",
1415 .test = alg_test_cipher,
1416 .suite = {
1417 .cipher = {
1418 .enc = {
1419 .vecs = des_cbc_enc_tv_template,
1420 .count = DES_CBC_ENC_TEST_VECTORS
1421 },
1422 .dec = {
1423 .vecs = des_cbc_dec_tv_template,
1424 .count = DES_CBC_DEC_TEST_VECTORS
1425 }
1426 }
1427 }
1428 }, {
1429 .alg = "cbc(des3_ede)",
1430 .test = alg_test_cipher,
1431 .suite = {
1432 .cipher = {
1433 .enc = {
1434 .vecs = des3_ede_cbc_enc_tv_template,
1435 .count = DES3_EDE_CBC_ENC_TEST_VECTORS
1436 },
1437 .dec = {
1438 .vecs = des3_ede_cbc_dec_tv_template,
1439 .count = DES3_EDE_CBC_DEC_TEST_VECTORS
1440 }
1441 }
1442 }
1443 }, {
1444 .alg = "cbc(twofish)",
1445 .test = alg_test_cipher,
1446 .suite = {
1447 .cipher = {
1448 .enc = {
1449 .vecs = tf_cbc_enc_tv_template,
1450 .count = TF_CBC_ENC_TEST_VECTORS
1451 },
1452 .dec = {
1453 .vecs = tf_cbc_dec_tv_template,
1454 .count = TF_CBC_DEC_TEST_VECTORS
1455 }
1456 }
1457 }
1458 }, {
1459 .alg = "ccm(aes)",
1460 .test = alg_test_aead,
1461 .suite = {
1462 .aead = {
1463 .enc = {
1464 .vecs = aes_ccm_enc_tv_template,
1465 .count = AES_CCM_ENC_TEST_VECTORS
1466 },
1467 .dec = {
1468 .vecs = aes_ccm_dec_tv_template,
1469 .count = AES_CCM_DEC_TEST_VECTORS
1470 }
1471 }
1472 }
1473 }, {
1474 .alg = "crc32c",
1475 .test = alg_test_hash,
1476 .suite = {
1477 .hash = {
1478 .vecs = crc32c_tv_template,
1479 .count = CRC32C_TEST_VECTORS
1480 }
1481 }
1482 }, {
1483 .alg = "cts(cbc(aes))",
1484 .test = alg_test_cipher,
1485 .suite = {
1486 .cipher = {
1487 .enc = {
1488 .vecs = cts_mode_enc_tv_template,
1489 .count = CTS_MODE_ENC_TEST_VECTORS
1490 },
1491 .dec = {
1492 .vecs = cts_mode_dec_tv_template,
1493 .count = CTS_MODE_DEC_TEST_VECTORS
1494 }
1495 }
1496 }
1497 }, {
1498 .alg = "deflate",
1499 .test = alg_test_comp,
1500 .suite = {
1501 .comp = {
1502 .comp = {
1503 .vecs = deflate_comp_tv_template,
1504 .count = DEFLATE_COMP_TEST_VECTORS
1505 },
1506 .decomp = {
1507 .vecs = deflate_decomp_tv_template,
1508 .count = DEFLATE_DECOMP_TEST_VECTORS
1509 }
1510 }
1511 }
1512 }, {
1513 .alg = "ecb(aes)",
1514 .test = alg_test_cipher,
1515 .suite = {
1516 .cipher = {
1517 .enc = {
1518 .vecs = aes_enc_tv_template,
1519 .count = AES_ENC_TEST_VECTORS
1520 },
1521 .dec = {
1522 .vecs = aes_dec_tv_template,
1523 .count = AES_DEC_TEST_VECTORS
1524 }
1525 }
1526 }
1527 }, {
1528 .alg = "ecb(anubis)",
1529 .test = alg_test_cipher,
1530 .suite = {
1531 .cipher = {
1532 .enc = {
1533 .vecs = anubis_enc_tv_template,
1534 .count = ANUBIS_ENC_TEST_VECTORS
1535 },
1536 .dec = {
1537 .vecs = anubis_dec_tv_template,
1538 .count = ANUBIS_DEC_TEST_VECTORS
1539 }
1540 }
1541 }
1542 }, {
1543 .alg = "ecb(arc4)",
1544 .test = alg_test_cipher,
1545 .suite = {
1546 .cipher = {
1547 .enc = {
1548 .vecs = arc4_enc_tv_template,
1549 .count = ARC4_ENC_TEST_VECTORS
1550 },
1551 .dec = {
1552 .vecs = arc4_dec_tv_template,
1553 .count = ARC4_DEC_TEST_VECTORS
1554 }
1555 }
1556 }
1557 }, {
1558 .alg = "ecb(blowfish)",
1559 .test = alg_test_cipher,
1560 .suite = {
1561 .cipher = {
1562 .enc = {
1563 .vecs = bf_enc_tv_template,
1564 .count = BF_ENC_TEST_VECTORS
1565 },
1566 .dec = {
1567 .vecs = bf_dec_tv_template,
1568 .count = BF_DEC_TEST_VECTORS
1569 }
1570 }
1571 }
1572 }, {
1573 .alg = "ecb(camellia)",
1574 .test = alg_test_cipher,
1575 .suite = {
1576 .cipher = {
1577 .enc = {
1578 .vecs = camellia_enc_tv_template,
1579 .count = CAMELLIA_ENC_TEST_VECTORS
1580 },
1581 .dec = {
1582 .vecs = camellia_dec_tv_template,
1583 .count = CAMELLIA_DEC_TEST_VECTORS
1584 }
1585 }
1586 }
1587 }, {
1588 .alg = "ecb(cast5)",
1589 .test = alg_test_cipher,
1590 .suite = {
1591 .cipher = {
1592 .enc = {
1593 .vecs = cast5_enc_tv_template,
1594 .count = CAST5_ENC_TEST_VECTORS
1595 },
1596 .dec = {
1597 .vecs = cast5_dec_tv_template,
1598 .count = CAST5_DEC_TEST_VECTORS
1599 }
1600 }
1601 }
1602 }, {
1603 .alg = "ecb(cast6)",
1604 .test = alg_test_cipher,
1605 .suite = {
1606 .cipher = {
1607 .enc = {
1608 .vecs = cast6_enc_tv_template,
1609 .count = CAST6_ENC_TEST_VECTORS
1610 },
1611 .dec = {
1612 .vecs = cast6_dec_tv_template,
1613 .count = CAST6_DEC_TEST_VECTORS
1614 }
1615 }
1616 }
1617 }, {
1618 .alg = "ecb(des)",
1619 .test = alg_test_cipher,
1620 .suite = {
1621 .cipher = {
1622 .enc = {
1623 .vecs = des_enc_tv_template,
1624 .count = DES_ENC_TEST_VECTORS
1625 },
1626 .dec = {
1627 .vecs = des_dec_tv_template,
1628 .count = DES_DEC_TEST_VECTORS
1629 }
1630 }
1631 }
1632 }, {
1633 .alg = "ecb(des3_ede)",
1634 .test = alg_test_cipher,
1635 .suite = {
1636 .cipher = {
1637 .enc = {
1638 .vecs = des3_ede_enc_tv_template,
1639 .count = DES3_EDE_ENC_TEST_VECTORS
1640 },
1641 .dec = {
1642 .vecs = des3_ede_dec_tv_template,
1643 .count = DES3_EDE_DEC_TEST_VECTORS
1644 }
1645 }
1646 }
1647 }, {
1648 .alg = "ecb(khazad)",
1649 .test = alg_test_cipher,
1650 .suite = {
1651 .cipher = {
1652 .enc = {
1653 .vecs = khazad_enc_tv_template,
1654 .count = KHAZAD_ENC_TEST_VECTORS
1655 },
1656 .dec = {
1657 .vecs = khazad_dec_tv_template,
1658 .count = KHAZAD_DEC_TEST_VECTORS
1659 }
1660 }
1661 }
1662 }, {
1663 .alg = "ecb(seed)",
1664 .test = alg_test_cipher,
1665 .suite = {
1666 .cipher = {
1667 .enc = {
1668 .vecs = seed_enc_tv_template,
1669 .count = SEED_ENC_TEST_VECTORS
1670 },
1671 .dec = {
1672 .vecs = seed_dec_tv_template,
1673 .count = SEED_DEC_TEST_VECTORS
1674 }
1675 }
1676 }
1677 }, {
1678 .alg = "ecb(serpent)",
1679 .test = alg_test_cipher,
1680 .suite = {
1681 .cipher = {
1682 .enc = {
1683 .vecs = serpent_enc_tv_template,
1684 .count = SERPENT_ENC_TEST_VECTORS
1685 },
1686 .dec = {
1687 .vecs = serpent_dec_tv_template,
1688 .count = SERPENT_DEC_TEST_VECTORS
1689 }
1690 }
1691 }
1692 }, {
1693 .alg = "ecb(tea)",
1694 .test = alg_test_cipher,
1695 .suite = {
1696 .cipher = {
1697 .enc = {
1698 .vecs = tea_enc_tv_template,
1699 .count = TEA_ENC_TEST_VECTORS
1700 },
1701 .dec = {
1702 .vecs = tea_dec_tv_template,
1703 .count = TEA_DEC_TEST_VECTORS
1704 }
1705 }
1706 }
1707 }, {
1708 .alg = "ecb(tnepres)",
1709 .test = alg_test_cipher,
1710 .suite = {
1711 .cipher = {
1712 .enc = {
1713 .vecs = tnepres_enc_tv_template,
1714 .count = TNEPRES_ENC_TEST_VECTORS
1715 },
1716 .dec = {
1717 .vecs = tnepres_dec_tv_template,
1718 .count = TNEPRES_DEC_TEST_VECTORS
1719 }
1720 }
1721 }
1722 }, {
1723 .alg = "ecb(twofish)",
1724 .test = alg_test_cipher,
1725 .suite = {
1726 .cipher = {
1727 .enc = {
1728 .vecs = tf_enc_tv_template,
1729 .count = TF_ENC_TEST_VECTORS
1730 },
1731 .dec = {
1732 .vecs = tf_dec_tv_template,
1733 .count = TF_DEC_TEST_VECTORS
1734 }
1735 }
1736 }
1737 }, {
1738 .alg = "ecb(xeta)",
1739 .test = alg_test_cipher,
1740 .suite = {
1741 .cipher = {
1742 .enc = {
1743 .vecs = xeta_enc_tv_template,
1744 .count = XETA_ENC_TEST_VECTORS
1745 },
1746 .dec = {
1747 .vecs = xeta_dec_tv_template,
1748 .count = XETA_DEC_TEST_VECTORS
1749 }
1750 }
1751 }
1752 }, {
1753 .alg = "ecb(xtea)",
1754 .test = alg_test_cipher,
1755 .suite = {
1756 .cipher = {
1757 .enc = {
1758 .vecs = xtea_enc_tv_template,
1759 .count = XTEA_ENC_TEST_VECTORS
1760 },
1761 .dec = {
1762 .vecs = xtea_dec_tv_template,
1763 .count = XTEA_DEC_TEST_VECTORS
1764 }
1765 }
1766 }
1767 }, {
1768 .alg = "gcm(aes)",
1769 .test = alg_test_aead,
1770 .suite = {
1771 .aead = {
1772 .enc = {
1773 .vecs = aes_gcm_enc_tv_template,
1774 .count = AES_GCM_ENC_TEST_VECTORS
1775 },
1776 .dec = {
1777 .vecs = aes_gcm_dec_tv_template,
1778 .count = AES_GCM_DEC_TEST_VECTORS
1779 }
1780 }
1781 }
1782 }, {
1783 .alg = "hmac(md5)",
1784 .test = alg_test_hash,
1785 .suite = {
1786 .hash = {
1787 .vecs = hmac_md5_tv_template,
1788 .count = HMAC_MD5_TEST_VECTORS
1789 }
1790 }
1791 }, {
1792 .alg = "hmac(rmd128)",
1793 .test = alg_test_hash,
1794 .suite = {
1795 .hash = {
1796 .vecs = hmac_rmd128_tv_template,
1797 .count = HMAC_RMD128_TEST_VECTORS
1798 }
1799 }
1800 }, {
1801 .alg = "hmac(rmd160)",
1802 .test = alg_test_hash,
1803 .suite = {
1804 .hash = {
1805 .vecs = hmac_rmd160_tv_template,
1806 .count = HMAC_RMD160_TEST_VECTORS
1807 }
1808 }
1809 }, {
1810 .alg = "hmac(sha1)",
1811 .test = alg_test_hash,
1812 .suite = {
1813 .hash = {
1814 .vecs = hmac_sha1_tv_template,
1815 .count = HMAC_SHA1_TEST_VECTORS
1816 }
1817 }
1818 }, {
1819 .alg = "hmac(sha224)",
1820 .test = alg_test_hash,
1821 .suite = {
1822 .hash = {
1823 .vecs = hmac_sha224_tv_template,
1824 .count = HMAC_SHA224_TEST_VECTORS
1825 }
1826 }
1827 }, {
1828 .alg = "hmac(sha256)",
1829 .test = alg_test_hash,
1830 .suite = {
1831 .hash = {
1832 .vecs = hmac_sha256_tv_template,
1833 .count = HMAC_SHA256_TEST_VECTORS
1834 }
1835 }
1836 }, {
1837 .alg = "hmac(sha384)",
1838 .test = alg_test_hash,
1839 .suite = {
1840 .hash = {
1841 .vecs = hmac_sha384_tv_template,
1842 .count = HMAC_SHA384_TEST_VECTORS
1843 }
1844 }
1845 }, {
1846 .alg = "hmac(sha512)",
1847 .test = alg_test_hash,
1848 .suite = {
1849 .hash = {
1850 .vecs = hmac_sha512_tv_template,
1851 .count = HMAC_SHA512_TEST_VECTORS
1852 }
1853 }
1854 }, {
1855 .alg = "lrw(aes)",
1856 .test = alg_test_cipher,
1857 .suite = {
1858 .cipher = {
1859 .enc = {
1860 .vecs = aes_lrw_enc_tv_template,
1861 .count = AES_LRW_ENC_TEST_VECTORS
1862 },
1863 .dec = {
1864 .vecs = aes_lrw_dec_tv_template,
1865 .count = AES_LRW_DEC_TEST_VECTORS
1866 }
1867 }
1868 }
1869 }, {
1870 .alg = "lzo",
1871 .test = alg_test_comp,
1872 .suite = {
1873 .comp = {
1874 .comp = {
1875 .vecs = lzo_comp_tv_template,
1876 .count = LZO_COMP_TEST_VECTORS
1877 },
1878 .decomp = {
1879 .vecs = lzo_decomp_tv_template,
1880 .count = LZO_DECOMP_TEST_VECTORS
1881 }
1882 }
1883 }
1884 }, {
1885 .alg = "md4",
1886 .test = alg_test_hash,
1887 .suite = {
1888 .hash = {
1889 .vecs = md4_tv_template,
1890 .count = MD4_TEST_VECTORS
1891 }
1892 }
1893 }, {
1894 .alg = "md5",
1895 .test = alg_test_hash,
1896 .suite = {
1897 .hash = {
1898 .vecs = md5_tv_template,
1899 .count = MD5_TEST_VECTORS
1900 }
1901 }
1902 }, {
1903 .alg = "michael_mic",
1904 .test = alg_test_hash,
1905 .suite = {
1906 .hash = {
1907 .vecs = michael_mic_tv_template,
1908 .count = MICHAEL_MIC_TEST_VECTORS
1909 }
1910 }
1911 }, {
1912 .alg = "pcbc(fcrypt)",
1913 .test = alg_test_cipher,
1914 .suite = {
1915 .cipher = {
1916 .enc = {
1917 .vecs = fcrypt_pcbc_enc_tv_template,
1918 .count = FCRYPT_ENC_TEST_VECTORS
1919 },
1920 .dec = {
1921 .vecs = fcrypt_pcbc_dec_tv_template,
1922 .count = FCRYPT_DEC_TEST_VECTORS
1923 }
1924 }
1925 }
1926 }, {
1927 .alg = "rfc3686(ctr(aes))",
1928 .test = alg_test_cipher,
1929 .suite = {
1930 .cipher = {
1931 .enc = {
1932 .vecs = aes_ctr_enc_tv_template,
1933 .count = AES_CTR_ENC_TEST_VECTORS
1934 },
1935 .dec = {
1936 .vecs = aes_ctr_dec_tv_template,
1937 .count = AES_CTR_DEC_TEST_VECTORS
1938 }
1939 }
1940 }
1941 }, {
1942 .alg = "rmd128",
1943 .test = alg_test_hash,
1944 .suite = {
1945 .hash = {
1946 .vecs = rmd128_tv_template,
1947 .count = RMD128_TEST_VECTORS
1948 }
1949 }
1950 }, {
1951 .alg = "rmd160",
1952 .test = alg_test_hash,
1953 .suite = {
1954 .hash = {
1955 .vecs = rmd160_tv_template,
1956 .count = RMD160_TEST_VECTORS
1957 }
1958 }
1959 }, {
1960 .alg = "rmd256",
1961 .test = alg_test_hash,
1962 .suite = {
1963 .hash = {
1964 .vecs = rmd256_tv_template,
1965 .count = RMD256_TEST_VECTORS
1966 }
1967 }
1968 }, {
1969 .alg = "rmd320",
1970 .test = alg_test_hash,
1971 .suite = {
1972 .hash = {
1973 .vecs = rmd320_tv_template,
1974 .count = RMD320_TEST_VECTORS
1975 }
1976 }
1977 }, {
1978 .alg = "salsa20",
1979 .test = alg_test_cipher,
1980 .suite = {
1981 .cipher = {
1982 .enc = {
1983 .vecs = salsa20_stream_enc_tv_template,
1984 .count = SALSA20_STREAM_ENC_TEST_VECTORS
1985 }
1986 }
1987 }
1988 }, {
1989 .alg = "sha1",
1990 .test = alg_test_hash,
1991 .suite = {
1992 .hash = {
1993 .vecs = sha1_tv_template,
1994 .count = SHA1_TEST_VECTORS
1995 }
1996 }
1997 }, {
1998 .alg = "sha224",
1999 .test = alg_test_hash,
2000 .suite = {
2001 .hash = {
2002 .vecs = sha224_tv_template,
2003 .count = SHA224_TEST_VECTORS
2004 }
2005 }
2006 }, {
2007 .alg = "sha256",
2008 .test = alg_test_hash,
2009 .suite = {
2010 .hash = {
2011 .vecs = sha256_tv_template,
2012 .count = SHA256_TEST_VECTORS
2013 }
2014 }
2015 }, {
2016 .alg = "sha384",
2017 .test = alg_test_hash,
2018 .suite = {
2019 .hash = {
2020 .vecs = sha384_tv_template,
2021 .count = SHA384_TEST_VECTORS
2022 }
2023 }
2024 }, {
2025 .alg = "sha512",
2026 .test = alg_test_hash,
2027 .suite = {
2028 .hash = {
2029 .vecs = sha512_tv_template,
2030 .count = SHA512_TEST_VECTORS
2031 }
2032 }
2033 }, {
2034 .alg = "tgr128",
2035 .test = alg_test_hash,
2036 .suite = {
2037 .hash = {
2038 .vecs = tgr128_tv_template,
2039 .count = TGR128_TEST_VECTORS
2040 }
2041 }
2042 }, {
2043 .alg = "tgr160",
2044 .test = alg_test_hash,
2045 .suite = {
2046 .hash = {
2047 .vecs = tgr160_tv_template,
2048 .count = TGR160_TEST_VECTORS
2049 }
2050 }
2051 }, {
2052 .alg = "tgr192",
2053 .test = alg_test_hash,
2054 .suite = {
2055 .hash = {
2056 .vecs = tgr192_tv_template,
2057 .count = TGR192_TEST_VECTORS
2058 }
2059 }
2060 }, {
2061 .alg = "wp256",
2062 .test = alg_test_hash,
2063 .suite = {
2064 .hash = {
2065 .vecs = wp256_tv_template,
2066 .count = WP256_TEST_VECTORS
2067 }
2068 }
2069 }, {
2070 .alg = "wp384",
2071 .test = alg_test_hash,
2072 .suite = {
2073 .hash = {
2074 .vecs = wp384_tv_template,
2075 .count = WP384_TEST_VECTORS
2076 }
2077 }
2078 }, {
2079 .alg = "wp512",
2080 .test = alg_test_hash,
2081 .suite = {
2082 .hash = {
2083 .vecs = wp512_tv_template,
2084 .count = WP512_TEST_VECTORS
2085 }
2086 }
2087 }, {
2088 .alg = "xcbc(aes)",
2089 .test = alg_test_hash,
2090 .suite = {
2091 .hash = {
2092 .vecs = aes_xcbc128_tv_template,
2093 .count = XCBC_AES_TEST_VECTORS
2094 }
2095 }
2096 }, {
2097 .alg = "xts(aes)",
2098 .test = alg_test_cipher,
2099 .suite = {
2100 .cipher = {
2101 .enc = {
2102 .vecs = aes_xts_enc_tv_template,
2103 .count = AES_XTS_ENC_TEST_VECTORS
2104 },
2105 .dec = {
2106 .vecs = aes_xts_dec_tv_template,
2107 .count = AES_XTS_DEC_TEST_VECTORS
2108 }
2109 }
2110 }
2111 }
2112};
2113
2114static int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
2115{
2116 int start = 0;
2117 int end = ARRAY_SIZE(alg_test_descs);
2118
2119 while (start < end) {
2120 int i = (start + end) / 2;
2121 int diff = strcmp(alg_test_descs[i].alg, alg);
2122
2123 if (diff > 0) {
2124 end = i;
2125 continue;
2126 }
2127
2128 if (diff < 0) {
2129 start = i + 1;
2130 continue;
2131 }
2132
2133 return alg_test_descs[i].test(alg_test_descs + i, driver,
2134 type, mask);
2135 }
2136
2137 printk(KERN_INFO "alg: No test for %s (%s)\n", alg, driver);
2138 return 0;
2139}
2140
2141static inline int tcrypt_test(const char *alg)
2142{
2143 return alg_test(alg, alg, 0, 0);
2144}
2145
2146static void do_test(int m)
2147{
2148 int i;
2149
2150 switch (m) {
1249 case 0: 2151 case 0:
1250 test_hash("md5", md5_tv_template, MD5_TEST_VECTORS); 2152 for (i = 1; i < 200; i++)
1251 2153 do_test(i);
1252 test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS);
1253
1254 //DES
1255 test_cipher("ecb(des)", ENCRYPT, des_enc_tv_template,
1256 DES_ENC_TEST_VECTORS);
1257 test_cipher("ecb(des)", DECRYPT, des_dec_tv_template,
1258 DES_DEC_TEST_VECTORS);
1259 test_cipher("cbc(des)", ENCRYPT, des_cbc_enc_tv_template,
1260 DES_CBC_ENC_TEST_VECTORS);
1261 test_cipher("cbc(des)", DECRYPT, des_cbc_dec_tv_template,
1262 DES_CBC_DEC_TEST_VECTORS);
1263
1264 //DES3_EDE
1265 test_cipher("ecb(des3_ede)", ENCRYPT, des3_ede_enc_tv_template,
1266 DES3_EDE_ENC_TEST_VECTORS);
1267 test_cipher("ecb(des3_ede)", DECRYPT, des3_ede_dec_tv_template,
1268 DES3_EDE_DEC_TEST_VECTORS);
1269
1270 test_cipher("cbc(des3_ede)", ENCRYPT,
1271 des3_ede_cbc_enc_tv_template,
1272 DES3_EDE_CBC_ENC_TEST_VECTORS);
1273
1274 test_cipher("cbc(des3_ede)", DECRYPT,
1275 des3_ede_cbc_dec_tv_template,
1276 DES3_EDE_CBC_DEC_TEST_VECTORS);
1277
1278 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS);
1279
1280 test_hash("sha224", sha224_tv_template, SHA224_TEST_VECTORS);
1281
1282 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS);
1283
1284 //BLOWFISH
1285 test_cipher("ecb(blowfish)", ENCRYPT, bf_enc_tv_template,
1286 BF_ENC_TEST_VECTORS);
1287 test_cipher("ecb(blowfish)", DECRYPT, bf_dec_tv_template,
1288 BF_DEC_TEST_VECTORS);
1289 test_cipher("cbc(blowfish)", ENCRYPT, bf_cbc_enc_tv_template,
1290 BF_CBC_ENC_TEST_VECTORS);
1291 test_cipher("cbc(blowfish)", DECRYPT, bf_cbc_dec_tv_template,
1292 BF_CBC_DEC_TEST_VECTORS);
1293
1294 //TWOFISH
1295 test_cipher("ecb(twofish)", ENCRYPT, tf_enc_tv_template,
1296 TF_ENC_TEST_VECTORS);
1297 test_cipher("ecb(twofish)", DECRYPT, tf_dec_tv_template,
1298 TF_DEC_TEST_VECTORS);
1299 test_cipher("cbc(twofish)", ENCRYPT, tf_cbc_enc_tv_template,
1300 TF_CBC_ENC_TEST_VECTORS);
1301 test_cipher("cbc(twofish)", DECRYPT, tf_cbc_dec_tv_template,
1302 TF_CBC_DEC_TEST_VECTORS);
1303
1304 //SERPENT
1305 test_cipher("ecb(serpent)", ENCRYPT, serpent_enc_tv_template,
1306 SERPENT_ENC_TEST_VECTORS);
1307 test_cipher("ecb(serpent)", DECRYPT, serpent_dec_tv_template,
1308 SERPENT_DEC_TEST_VECTORS);
1309
1310 //TNEPRES
1311 test_cipher("ecb(tnepres)", ENCRYPT, tnepres_enc_tv_template,
1312 TNEPRES_ENC_TEST_VECTORS);
1313 test_cipher("ecb(tnepres)", DECRYPT, tnepres_dec_tv_template,
1314 TNEPRES_DEC_TEST_VECTORS);
1315
1316 //AES
1317 test_cipher("ecb(aes)", ENCRYPT, aes_enc_tv_template,
1318 AES_ENC_TEST_VECTORS);
1319 test_cipher("ecb(aes)", DECRYPT, aes_dec_tv_template,
1320 AES_DEC_TEST_VECTORS);
1321 test_cipher("cbc(aes)", ENCRYPT, aes_cbc_enc_tv_template,
1322 AES_CBC_ENC_TEST_VECTORS);
1323 test_cipher("cbc(aes)", DECRYPT, aes_cbc_dec_tv_template,
1324 AES_CBC_DEC_TEST_VECTORS);
1325 test_cipher("lrw(aes)", ENCRYPT, aes_lrw_enc_tv_template,
1326 AES_LRW_ENC_TEST_VECTORS);
1327 test_cipher("lrw(aes)", DECRYPT, aes_lrw_dec_tv_template,
1328 AES_LRW_DEC_TEST_VECTORS);
1329 test_cipher("xts(aes)", ENCRYPT, aes_xts_enc_tv_template,
1330 AES_XTS_ENC_TEST_VECTORS);
1331 test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template,
1332 AES_XTS_DEC_TEST_VECTORS);
1333 test_cipher("rfc3686(ctr(aes))", ENCRYPT, aes_ctr_enc_tv_template,
1334 AES_CTR_ENC_TEST_VECTORS);
1335 test_cipher("rfc3686(ctr(aes))", DECRYPT, aes_ctr_dec_tv_template,
1336 AES_CTR_DEC_TEST_VECTORS);
1337 test_aead("gcm(aes)", ENCRYPT, aes_gcm_enc_tv_template,
1338 AES_GCM_ENC_TEST_VECTORS);
1339 test_aead("gcm(aes)", DECRYPT, aes_gcm_dec_tv_template,
1340 AES_GCM_DEC_TEST_VECTORS);
1341 test_aead("ccm(aes)", ENCRYPT, aes_ccm_enc_tv_template,
1342 AES_CCM_ENC_TEST_VECTORS);
1343 test_aead("ccm(aes)", DECRYPT, aes_ccm_dec_tv_template,
1344 AES_CCM_DEC_TEST_VECTORS);
1345
1346 //CAST5
1347 test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template,
1348 CAST5_ENC_TEST_VECTORS);
1349 test_cipher("ecb(cast5)", DECRYPT, cast5_dec_tv_template,
1350 CAST5_DEC_TEST_VECTORS);
1351
1352 //CAST6
1353 test_cipher("ecb(cast6)", ENCRYPT, cast6_enc_tv_template,
1354 CAST6_ENC_TEST_VECTORS);
1355 test_cipher("ecb(cast6)", DECRYPT, cast6_dec_tv_template,
1356 CAST6_DEC_TEST_VECTORS);
1357
1358 //ARC4
1359 test_cipher("ecb(arc4)", ENCRYPT, arc4_enc_tv_template,
1360 ARC4_ENC_TEST_VECTORS);
1361 test_cipher("ecb(arc4)", DECRYPT, arc4_dec_tv_template,
1362 ARC4_DEC_TEST_VECTORS);
1363
1364 //TEA
1365 test_cipher("ecb(tea)", ENCRYPT, tea_enc_tv_template,
1366 TEA_ENC_TEST_VECTORS);
1367 test_cipher("ecb(tea)", DECRYPT, tea_dec_tv_template,
1368 TEA_DEC_TEST_VECTORS);
1369
1370
1371 //XTEA
1372 test_cipher("ecb(xtea)", ENCRYPT, xtea_enc_tv_template,
1373 XTEA_ENC_TEST_VECTORS);
1374 test_cipher("ecb(xtea)", DECRYPT, xtea_dec_tv_template,
1375 XTEA_DEC_TEST_VECTORS);
1376
1377 //KHAZAD
1378 test_cipher("ecb(khazad)", ENCRYPT, khazad_enc_tv_template,
1379 KHAZAD_ENC_TEST_VECTORS);
1380 test_cipher("ecb(khazad)", DECRYPT, khazad_dec_tv_template,
1381 KHAZAD_DEC_TEST_VECTORS);
1382
1383 //ANUBIS
1384 test_cipher("ecb(anubis)", ENCRYPT, anubis_enc_tv_template,
1385 ANUBIS_ENC_TEST_VECTORS);
1386 test_cipher("ecb(anubis)", DECRYPT, anubis_dec_tv_template,
1387 ANUBIS_DEC_TEST_VECTORS);
1388 test_cipher("cbc(anubis)", ENCRYPT, anubis_cbc_enc_tv_template,
1389 ANUBIS_CBC_ENC_TEST_VECTORS);
1390 test_cipher("cbc(anubis)", DECRYPT, anubis_cbc_dec_tv_template,
1391 ANUBIS_CBC_ENC_TEST_VECTORS);
1392
1393 //XETA
1394 test_cipher("ecb(xeta)", ENCRYPT, xeta_enc_tv_template,
1395 XETA_ENC_TEST_VECTORS);
1396 test_cipher("ecb(xeta)", DECRYPT, xeta_dec_tv_template,
1397 XETA_DEC_TEST_VECTORS);
1398
1399 //FCrypt
1400 test_cipher("pcbc(fcrypt)", ENCRYPT, fcrypt_pcbc_enc_tv_template,
1401 FCRYPT_ENC_TEST_VECTORS);
1402 test_cipher("pcbc(fcrypt)", DECRYPT, fcrypt_pcbc_dec_tv_template,
1403 FCRYPT_DEC_TEST_VECTORS);
1404
1405 //CAMELLIA
1406 test_cipher("ecb(camellia)", ENCRYPT,
1407 camellia_enc_tv_template,
1408 CAMELLIA_ENC_TEST_VECTORS);
1409 test_cipher("ecb(camellia)", DECRYPT,
1410 camellia_dec_tv_template,
1411 CAMELLIA_DEC_TEST_VECTORS);
1412 test_cipher("cbc(camellia)", ENCRYPT,
1413 camellia_cbc_enc_tv_template,
1414 CAMELLIA_CBC_ENC_TEST_VECTORS);
1415 test_cipher("cbc(camellia)", DECRYPT,
1416 camellia_cbc_dec_tv_template,
1417 CAMELLIA_CBC_DEC_TEST_VECTORS);
1418
1419 //SEED
1420 test_cipher("ecb(seed)", ENCRYPT, seed_enc_tv_template,
1421 SEED_ENC_TEST_VECTORS);
1422 test_cipher("ecb(seed)", DECRYPT, seed_dec_tv_template,
1423 SEED_DEC_TEST_VECTORS);
1424
1425 //CTS
1426 test_cipher("cts(cbc(aes))", ENCRYPT, cts_mode_enc_tv_template,
1427 CTS_MODE_ENC_TEST_VECTORS);
1428 test_cipher("cts(cbc(aes))", DECRYPT, cts_mode_dec_tv_template,
1429 CTS_MODE_DEC_TEST_VECTORS);
1430
1431 test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
1432 test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
1433 test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS);
1434 test_hash("wp384", wp384_tv_template, WP384_TEST_VECTORS);
1435 test_hash("wp256", wp256_tv_template, WP256_TEST_VECTORS);
1436 test_hash("tgr192", tgr192_tv_template, TGR192_TEST_VECTORS);
1437 test_hash("tgr160", tgr160_tv_template, TGR160_TEST_VECTORS);
1438 test_hash("tgr128", tgr128_tv_template, TGR128_TEST_VECTORS);
1439 test_comp("deflate", deflate_comp_tv_template,
1440 deflate_decomp_tv_template, DEFLATE_COMP_TEST_VECTORS,
1441 DEFLATE_DECOMP_TEST_VECTORS);
1442 test_comp("lzo", lzo_comp_tv_template, lzo_decomp_tv_template,
1443 LZO_COMP_TEST_VECTORS, LZO_DECOMP_TEST_VECTORS);
1444 test_hash("crc32c", crc32c_tv_template, CRC32C_TEST_VECTORS);
1445 test_hash("hmac(md5)", hmac_md5_tv_template,
1446 HMAC_MD5_TEST_VECTORS);
1447 test_hash("hmac(sha1)", hmac_sha1_tv_template,
1448 HMAC_SHA1_TEST_VECTORS);
1449 test_hash("hmac(sha224)", hmac_sha224_tv_template,
1450 HMAC_SHA224_TEST_VECTORS);
1451 test_hash("hmac(sha256)", hmac_sha256_tv_template,
1452 HMAC_SHA256_TEST_VECTORS);
1453 test_hash("hmac(sha384)", hmac_sha384_tv_template,
1454 HMAC_SHA384_TEST_VECTORS);
1455 test_hash("hmac(sha512)", hmac_sha512_tv_template,
1456 HMAC_SHA512_TEST_VECTORS);
1457
1458 test_hash("xcbc(aes)", aes_xcbc128_tv_template,
1459 XCBC_AES_TEST_VECTORS);
1460
1461 test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS);
1462 break; 2154 break;
1463 2155
1464 case 1: 2156 case 1:
1465 test_hash("md5", md5_tv_template, MD5_TEST_VECTORS); 2157 tcrypt_test("md5");
1466 break; 2158 break;
1467 2159
1468 case 2: 2160 case 2:
1469 test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS); 2161 tcrypt_test("sha1");
1470 break; 2162 break;
1471 2163
1472 case 3: 2164 case 3:
1473 test_cipher("ecb(des)", ENCRYPT, des_enc_tv_template, 2165 tcrypt_test("ecb(des)");
1474 DES_ENC_TEST_VECTORS); 2166 tcrypt_test("cbc(des)");
1475 test_cipher("ecb(des)", DECRYPT, des_dec_tv_template,
1476 DES_DEC_TEST_VECTORS);
1477 test_cipher("cbc(des)", ENCRYPT, des_cbc_enc_tv_template,
1478 DES_CBC_ENC_TEST_VECTORS);
1479 test_cipher("cbc(des)", DECRYPT, des_cbc_dec_tv_template,
1480 DES_CBC_DEC_TEST_VECTORS);
1481 break; 2167 break;
1482 2168
1483 case 4: 2169 case 4:
1484 test_cipher("ecb(des3_ede)", ENCRYPT, des3_ede_enc_tv_template, 2170 tcrypt_test("ecb(des3_ede)");
1485 DES3_EDE_ENC_TEST_VECTORS); 2171 tcrypt_test("cbc(des3_ede)");
1486 test_cipher("ecb(des3_ede)", DECRYPT, des3_ede_dec_tv_template,
1487 DES3_EDE_DEC_TEST_VECTORS);
1488
1489 test_cipher("cbc(des3_ede)", ENCRYPT,
1490 des3_ede_cbc_enc_tv_template,
1491 DES3_EDE_CBC_ENC_TEST_VECTORS);
1492
1493 test_cipher("cbc(des3_ede)", DECRYPT,
1494 des3_ede_cbc_dec_tv_template,
1495 DES3_EDE_CBC_DEC_TEST_VECTORS);
1496 break; 2172 break;
1497 2173
1498 case 5: 2174 case 5:
1499 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS); 2175 tcrypt_test("md4");
1500 break; 2176 break;
1501 2177
1502 case 6: 2178 case 6:
1503 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS); 2179 tcrypt_test("sha256");
1504 break; 2180 break;
1505 2181
1506 case 7: 2182 case 7:
1507 test_cipher("ecb(blowfish)", ENCRYPT, bf_enc_tv_template, 2183 tcrypt_test("ecb(blowfish)");
1508 BF_ENC_TEST_VECTORS); 2184 tcrypt_test("cbc(blowfish)");
1509 test_cipher("ecb(blowfish)", DECRYPT, bf_dec_tv_template,
1510 BF_DEC_TEST_VECTORS);
1511 test_cipher("cbc(blowfish)", ENCRYPT, bf_cbc_enc_tv_template,
1512 BF_CBC_ENC_TEST_VECTORS);
1513 test_cipher("cbc(blowfish)", DECRYPT, bf_cbc_dec_tv_template,
1514 BF_CBC_DEC_TEST_VECTORS);
1515 break; 2185 break;
1516 2186
1517 case 8: 2187 case 8:
1518 test_cipher("ecb(twofish)", ENCRYPT, tf_enc_tv_template, 2188 tcrypt_test("ecb(twofish)");
1519 TF_ENC_TEST_VECTORS); 2189 tcrypt_test("cbc(twofish)");
1520 test_cipher("ecb(twofish)", DECRYPT, tf_dec_tv_template,
1521 TF_DEC_TEST_VECTORS);
1522 test_cipher("cbc(twofish)", ENCRYPT, tf_cbc_enc_tv_template,
1523 TF_CBC_ENC_TEST_VECTORS);
1524 test_cipher("cbc(twofish)", DECRYPT, tf_cbc_dec_tv_template,
1525 TF_CBC_DEC_TEST_VECTORS);
1526 break; 2190 break;
1527 2191
1528 case 9: 2192 case 9:
1529 test_cipher("ecb(serpent)", ENCRYPT, serpent_enc_tv_template, 2193 tcrypt_test("ecb(serpent)");
1530 SERPENT_ENC_TEST_VECTORS);
1531 test_cipher("ecb(serpent)", DECRYPT, serpent_dec_tv_template,
1532 SERPENT_DEC_TEST_VECTORS);
1533 break; 2194 break;
1534 2195
1535 case 10: 2196 case 10:
1536 test_cipher("ecb(aes)", ENCRYPT, aes_enc_tv_template, 2197 tcrypt_test("ecb(aes)");
1537 AES_ENC_TEST_VECTORS); 2198 tcrypt_test("cbc(aes)");
1538 test_cipher("ecb(aes)", DECRYPT, aes_dec_tv_template, 2199 tcrypt_test("lrw(aes)");
1539 AES_DEC_TEST_VECTORS); 2200 tcrypt_test("xts(aes)");
1540 test_cipher("cbc(aes)", ENCRYPT, aes_cbc_enc_tv_template, 2201 tcrypt_test("rfc3686(ctr(aes))");
1541 AES_CBC_ENC_TEST_VECTORS);
1542 test_cipher("cbc(aes)", DECRYPT, aes_cbc_dec_tv_template,
1543 AES_CBC_DEC_TEST_VECTORS);
1544 test_cipher("lrw(aes)", ENCRYPT, aes_lrw_enc_tv_template,
1545 AES_LRW_ENC_TEST_VECTORS);
1546 test_cipher("lrw(aes)", DECRYPT, aes_lrw_dec_tv_template,
1547 AES_LRW_DEC_TEST_VECTORS);
1548 test_cipher("xts(aes)", ENCRYPT, aes_xts_enc_tv_template,
1549 AES_XTS_ENC_TEST_VECTORS);
1550 test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template,
1551 AES_XTS_DEC_TEST_VECTORS);
1552 test_cipher("rfc3686(ctr(aes))", ENCRYPT, aes_ctr_enc_tv_template,
1553 AES_CTR_ENC_TEST_VECTORS);
1554 test_cipher("rfc3686(ctr(aes))", DECRYPT, aes_ctr_dec_tv_template,
1555 AES_CTR_DEC_TEST_VECTORS);
1556 break; 2202 break;
1557 2203
1558 case 11: 2204 case 11:
1559 test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS); 2205 tcrypt_test("sha384");
1560 break; 2206 break;
1561 2207
1562 case 12: 2208 case 12:
1563 test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS); 2209 tcrypt_test("sha512");
1564 break; 2210 break;
1565 2211
1566 case 13: 2212 case 13:
1567 test_comp("deflate", deflate_comp_tv_template, 2213 tcrypt_test("deflate");
1568 deflate_decomp_tv_template, DEFLATE_COMP_TEST_VECTORS,
1569 DEFLATE_DECOMP_TEST_VECTORS);
1570 break; 2214 break;
1571 2215
1572 case 14: 2216 case 14:
1573 test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template, 2217 tcrypt_test("ecb(cast5)");
1574 CAST5_ENC_TEST_VECTORS);
1575 test_cipher("ecb(cast5)", DECRYPT, cast5_dec_tv_template,
1576 CAST5_DEC_TEST_VECTORS);
1577 break; 2218 break;
1578 2219
1579 case 15: 2220 case 15:
1580 test_cipher("ecb(cast6)", ENCRYPT, cast6_enc_tv_template, 2221 tcrypt_test("ecb(cast6)");
1581 CAST6_ENC_TEST_VECTORS);
1582 test_cipher("ecb(cast6)", DECRYPT, cast6_dec_tv_template,
1583 CAST6_DEC_TEST_VECTORS);
1584 break; 2222 break;
1585 2223
1586 case 16: 2224 case 16:
1587 test_cipher("ecb(arc4)", ENCRYPT, arc4_enc_tv_template, 2225 tcrypt_test("ecb(arc4)");
1588 ARC4_ENC_TEST_VECTORS);
1589 test_cipher("ecb(arc4)", DECRYPT, arc4_dec_tv_template,
1590 ARC4_DEC_TEST_VECTORS);
1591 break; 2226 break;
1592 2227
1593 case 17: 2228 case 17:
1594 test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS); 2229 tcrypt_test("michael_mic");
1595 break; 2230 break;
1596 2231
1597 case 18: 2232 case 18:
1598 test_hash("crc32c", crc32c_tv_template, CRC32C_TEST_VECTORS); 2233 tcrypt_test("crc32c");
1599 break; 2234 break;
1600 2235
1601 case 19: 2236 case 19:
1602 test_cipher("ecb(tea)", ENCRYPT, tea_enc_tv_template, 2237 tcrypt_test("ecb(tea)");
1603 TEA_ENC_TEST_VECTORS);
1604 test_cipher("ecb(tea)", DECRYPT, tea_dec_tv_template,
1605 TEA_DEC_TEST_VECTORS);
1606 break; 2238 break;
1607 2239
1608 case 20: 2240 case 20:
1609 test_cipher("ecb(xtea)", ENCRYPT, xtea_enc_tv_template, 2241 tcrypt_test("ecb(xtea)");
1610 XTEA_ENC_TEST_VECTORS);
1611 test_cipher("ecb(xtea)", DECRYPT, xtea_dec_tv_template,
1612 XTEA_DEC_TEST_VECTORS);
1613 break; 2242 break;
1614 2243
1615 case 21: 2244 case 21:
1616 test_cipher("ecb(khazad)", ENCRYPT, khazad_enc_tv_template, 2245 tcrypt_test("ecb(khazad)");
1617 KHAZAD_ENC_TEST_VECTORS);
1618 test_cipher("ecb(khazad)", DECRYPT, khazad_dec_tv_template,
1619 KHAZAD_DEC_TEST_VECTORS);
1620 break; 2246 break;
1621 2247
1622 case 22: 2248 case 22:
1623 test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS); 2249 tcrypt_test("wp512");
1624 break; 2250 break;
1625 2251
1626 case 23: 2252 case 23:
1627 test_hash("wp384", wp384_tv_template, WP384_TEST_VECTORS); 2253 tcrypt_test("wp384");
1628 break; 2254 break;
1629 2255
1630 case 24: 2256 case 24:
1631 test_hash("wp256", wp256_tv_template, WP256_TEST_VECTORS); 2257 tcrypt_test("wp256");
1632 break; 2258 break;
1633 2259
1634 case 25: 2260 case 25:
1635 test_cipher("ecb(tnepres)", ENCRYPT, tnepres_enc_tv_template, 2261 tcrypt_test("ecb(tnepres)");
1636 TNEPRES_ENC_TEST_VECTORS);
1637 test_cipher("ecb(tnepres)", DECRYPT, tnepres_dec_tv_template,
1638 TNEPRES_DEC_TEST_VECTORS);
1639 break; 2262 break;
1640 2263
1641 case 26: 2264 case 26:
1642 test_cipher("ecb(anubis)", ENCRYPT, anubis_enc_tv_template, 2265 tcrypt_test("ecb(anubis)");
1643 ANUBIS_ENC_TEST_VECTORS); 2266 tcrypt_test("cbc(anubis)");
1644 test_cipher("ecb(anubis)", DECRYPT, anubis_dec_tv_template,
1645 ANUBIS_DEC_TEST_VECTORS);
1646 test_cipher("cbc(anubis)", ENCRYPT, anubis_cbc_enc_tv_template,
1647 ANUBIS_CBC_ENC_TEST_VECTORS);
1648 test_cipher("cbc(anubis)", DECRYPT, anubis_cbc_dec_tv_template,
1649 ANUBIS_CBC_ENC_TEST_VECTORS);
1650 break; 2267 break;
1651 2268
1652 case 27: 2269 case 27:
1653 test_hash("tgr192", tgr192_tv_template, TGR192_TEST_VECTORS); 2270 tcrypt_test("tgr192");
1654 break; 2271 break;
1655 2272
1656 case 28: 2273 case 28:
1657 2274
1658 test_hash("tgr160", tgr160_tv_template, TGR160_TEST_VECTORS); 2275 tcrypt_test("tgr160");
1659 break; 2276 break;
1660 2277
1661 case 29: 2278 case 29:
1662 test_hash("tgr128", tgr128_tv_template, TGR128_TEST_VECTORS); 2279 tcrypt_test("tgr128");
1663 break; 2280 break;
1664 2281
1665 case 30: 2282 case 30:
1666 test_cipher("ecb(xeta)", ENCRYPT, xeta_enc_tv_template, 2283 tcrypt_test("ecb(xeta)");
1667 XETA_ENC_TEST_VECTORS);
1668 test_cipher("ecb(xeta)", DECRYPT, xeta_dec_tv_template,
1669 XETA_DEC_TEST_VECTORS);
1670 break; 2284 break;
1671 2285
1672 case 31: 2286 case 31:
1673 test_cipher("pcbc(fcrypt)", ENCRYPT, fcrypt_pcbc_enc_tv_template, 2287 tcrypt_test("pcbc(fcrypt)");
1674 FCRYPT_ENC_TEST_VECTORS);
1675 test_cipher("pcbc(fcrypt)", DECRYPT, fcrypt_pcbc_dec_tv_template,
1676 FCRYPT_DEC_TEST_VECTORS);
1677 break; 2288 break;
1678 2289
1679 case 32: 2290 case 32:
1680 test_cipher("ecb(camellia)", ENCRYPT, 2291 tcrypt_test("ecb(camellia)");
1681 camellia_enc_tv_template, 2292 tcrypt_test("cbc(camellia)");
1682 CAMELLIA_ENC_TEST_VECTORS);
1683 test_cipher("ecb(camellia)", DECRYPT,
1684 camellia_dec_tv_template,
1685 CAMELLIA_DEC_TEST_VECTORS);
1686 test_cipher("cbc(camellia)", ENCRYPT,
1687 camellia_cbc_enc_tv_template,
1688 CAMELLIA_CBC_ENC_TEST_VECTORS);
1689 test_cipher("cbc(camellia)", DECRYPT,
1690 camellia_cbc_dec_tv_template,
1691 CAMELLIA_CBC_DEC_TEST_VECTORS);
1692 break; 2293 break;
1693 case 33: 2294 case 33:
1694 test_hash("sha224", sha224_tv_template, SHA224_TEST_VECTORS); 2295 tcrypt_test("sha224");
1695 break; 2296 break;
1696 2297
1697 case 34: 2298 case 34:
1698 test_cipher("salsa20", ENCRYPT, 2299 tcrypt_test("salsa20");
1699 salsa20_stream_enc_tv_template,
1700 SALSA20_STREAM_ENC_TEST_VECTORS);
1701 break; 2300 break;
1702 2301
1703 case 35: 2302 case 35:
1704 test_aead("gcm(aes)", ENCRYPT, aes_gcm_enc_tv_template, 2303 tcrypt_test("gcm(aes)");
1705 AES_GCM_ENC_TEST_VECTORS);
1706 test_aead("gcm(aes)", DECRYPT, aes_gcm_dec_tv_template,
1707 AES_GCM_DEC_TEST_VECTORS);
1708 break; 2304 break;
1709 2305
1710 case 36: 2306 case 36:
1711 test_comp("lzo", lzo_comp_tv_template, lzo_decomp_tv_template, 2307 tcrypt_test("lzo");
1712 LZO_COMP_TEST_VECTORS, LZO_DECOMP_TEST_VECTORS);
1713 break; 2308 break;
1714 2309
1715 case 37: 2310 case 37:
1716 test_aead("ccm(aes)", ENCRYPT, aes_ccm_enc_tv_template, 2311 tcrypt_test("ccm(aes)");
1717 AES_CCM_ENC_TEST_VECTORS);
1718 test_aead("ccm(aes)", DECRYPT, aes_ccm_dec_tv_template,
1719 AES_CCM_DEC_TEST_VECTORS);
1720 break; 2312 break;
1721 2313
1722 case 38: 2314 case 38:
1723 test_cipher("cts(cbc(aes))", ENCRYPT, cts_mode_enc_tv_template, 2315 tcrypt_test("cts(cbc(aes))");
1724 CTS_MODE_ENC_TEST_VECTORS);
1725 test_cipher("cts(cbc(aes))", DECRYPT, cts_mode_dec_tv_template,
1726 CTS_MODE_DEC_TEST_VECTORS);
1727 break; 2316 break;
1728 2317
1729 case 39: 2318 case 39:
1730 test_hash("rmd128", rmd128_tv_template, RMD128_TEST_VECTORS); 2319 tcrypt_test("rmd128");
1731 break; 2320 break;
1732 2321
1733 case 40: 2322 case 40:
1734 test_hash("rmd160", rmd160_tv_template, RMD160_TEST_VECTORS); 2323 tcrypt_test("rmd160");
1735 break; 2324 break;
1736 2325
1737 case 41: 2326 case 41:
1738 test_hash("rmd256", rmd256_tv_template, RMD256_TEST_VECTORS); 2327 tcrypt_test("rmd256");
1739 break; 2328 break;
1740 2329
1741 case 42: 2330 case 42:
1742 test_hash("rmd320", rmd320_tv_template, RMD320_TEST_VECTORS); 2331 tcrypt_test("rmd320");
2332 break;
2333
2334 case 43:
2335 tcrypt_test("ecb(seed)");
1743 break; 2336 break;
1744 2337
1745 case 100: 2338 case 100:
1746 test_hash("hmac(md5)", hmac_md5_tv_template, 2339 tcrypt_test("hmac(md5)");
1747 HMAC_MD5_TEST_VECTORS);
1748 break; 2340 break;
1749 2341
1750 case 101: 2342 case 101:
1751 test_hash("hmac(sha1)", hmac_sha1_tv_template, 2343 tcrypt_test("hmac(sha1)");
1752 HMAC_SHA1_TEST_VECTORS);
1753 break; 2344 break;
1754 2345
1755 case 102: 2346 case 102:
1756 test_hash("hmac(sha256)", hmac_sha256_tv_template, 2347 tcrypt_test("hmac(sha256)");
1757 HMAC_SHA256_TEST_VECTORS);
1758 break; 2348 break;
1759 2349
1760 case 103: 2350 case 103:
1761 test_hash("hmac(sha384)", hmac_sha384_tv_template, 2351 tcrypt_test("hmac(sha384)");
1762 HMAC_SHA384_TEST_VECTORS);
1763 break; 2352 break;
1764 2353
1765 case 104: 2354 case 104:
1766 test_hash("hmac(sha512)", hmac_sha512_tv_template, 2355 tcrypt_test("hmac(sha512)");
1767 HMAC_SHA512_TEST_VECTORS);
1768 break; 2356 break;
1769 2357
1770 case 105: 2358 case 105:
1771 test_hash("hmac(sha224)", hmac_sha224_tv_template, 2359 tcrypt_test("hmac(sha224)");
1772 HMAC_SHA224_TEST_VECTORS);
1773 break; 2360 break;
1774 2361
1775 case 106: 2362 case 106:
1776 test_hash("xcbc(aes)", aes_xcbc128_tv_template, 2363 tcrypt_test("xcbc(aes)");
1777 XCBC_AES_TEST_VECTORS);
1778 break; 2364 break;
1779 2365
1780 case 107: 2366 case 107:
1781 test_hash("hmac(rmd128)", hmac_rmd128_tv_template, 2367 tcrypt_test("hmac(rmd128)");
1782 HMAC_RMD128_TEST_VECTORS);
1783 break; 2368 break;
1784 2369
1785 case 108: 2370 case 108:
1786 test_hash("hmac(rmd160)", hmac_rmd160_tv_template, 2371 tcrypt_test("hmac(rmd160)");
1787 HMAC_RMD160_TEST_VECTORS);
1788 break; 2372 break;
1789 2373
1790 case 200: 2374 case 200:
@@ -1947,11 +2531,6 @@ static void do_test(void)
1947 case 1000: 2531 case 1000:
1948 test_available(); 2532 test_available();
1949 break; 2533 break;
1950
1951 default:
1952 /* useful for debugging */
1953 printk("not testing anything\n");
1954 break;
1955 } 2534 }
1956} 2535}
1957 2536
@@ -1978,7 +2557,7 @@ static int __init tcrypt_mod_init(void)
1978 goto err_free_axbuf; 2557 goto err_free_axbuf;
1979 } 2558 }
1980 2559
1981 do_test(); 2560 do_test(mode);
1982 2561
1983 /* We intentionaly return -EAGAIN to prevent keeping 2562 /* We intentionaly return -EAGAIN to prevent keeping
1984 * the module. It does all its work from init() 2563 * the module. It does all its work from init()