Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

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