25 #include <linux/module.h>
27 #include <linux/slab.h>
28 #include <linux/string.h>
33 #ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
129 static void hexdump(
unsigned char *
buf,
unsigned int len)
166 static void testmgr_free_buf(
char *
buf[XBUFSIZE])
188 unsigned int tcount,
bool use_digest)
190 const char *algo = crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm));
200 if (testmgr_alloc_buf(xbuf))
203 init_completion(&tresult.completion);
212 tcrypt_complete, &tresult);
215 for (i = 0; i < tcount; i++) {
224 memcpy(hash_buff,
template[i].plaintext,
template[i].psize);
227 if (
template[i].
ksize) {
228 crypto_ahash_clear_flags(tfm, ~0);
233 "test %d for %s: ret=%d\n", j, algo,
239 ahash_request_set_crypt(req,
sg, result,
template[i].psize);
241 ret = do_one_async_hash_op(req, &tresult,
244 pr_err(
"alg: hash: digest failed on test %d "
245 "for %s: ret=%d\n", j, algo, -ret);
249 ret = do_one_async_hash_op(req, &tresult,
250 crypto_ahash_init(req));
252 pr_err(
"alt: hash: init failed on test %d "
253 "for %s: ret=%d\n", j, algo, -ret);
256 ret = do_one_async_hash_op(req, &tresult,
257 crypto_ahash_update(req));
259 pr_err(
"alt: hash: update failed on test %d "
260 "for %s: ret=%d\n", j, algo, -ret);
263 ret = do_one_async_hash_op(req, &tresult,
266 pr_err(
"alt: hash: final failed on test %d "
267 "for %s: ret=%d\n", j, algo, -ret);
273 crypto_ahash_digestsize(tfm))) {
276 hexdump(result, crypto_ahash_digestsize(tfm));
283 for (i = 0; i < tcount; i++) {
284 if (
template[i].np) {
291 for (k = 0; k <
template[
i].np; k++) {
298 template[i].plaintext + temp,
301 temp +=
template[
i].tap[
k];
304 if (
template[i].ksize) {
305 crypto_ahash_clear_flags(tfm, ~0);
311 "failed on chunking test %d "
312 "for %s: ret=%d\n", j, algo,
318 ahash_request_set_crypt(req,
sg, result,
327 &tresult.completion);
328 if (!ret && !(ret = tresult.err)) {
335 "on chunking test %d for %s: "
336 "ret=%d\n", j, algo, -ret);
340 if (
memcmp(result,
template[i].digest,
341 crypto_ahash_digestsize(tfm))) {
343 "failed for %s\n", j, algo);
344 hexdump(result, crypto_ahash_digestsize(tfm));
354 ahash_request_free(req);
356 testmgr_free_buf(xbuf);
361 static int __test_aead(
struct crypto_aead *tfm,
int enc,
365 const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm));
376 unsigned int authsize;
385 if (testmgr_alloc_buf(xbuf))
387 if (testmgr_alloc_buf(axbuf))
390 if (diff_dst && testmgr_alloc_buf(xoutbuf))
414 pr_err(
"alg: aead%s: Failed to allocate request for %s\n",
420 tcrypt_complete, &result);
422 for (i = 0, j = 0; i < tcount; i++) {
423 if (!
template[i].np) {
437 memcpy(input,
template[i].input,
template[i].ilen);
438 memcpy(assoc,
template[i].assoc,
template[i].alen);
444 crypto_aead_clear_flags(tfm, ~0);
446 crypto_aead_set_flags(
449 key =
template[
i].key;
451 ret = crypto_aead_setkey(tfm, key,
453 if (!ret ==
template[i].fail) {
454 pr_err(
"alg: aead%s: setkey failed on test %d for %s: flags=%x\n",
455 d, j, algo, crypto_aead_get_flags(tfm));
460 authsize =
abs(
template[i].rlen -
template[i].ilen);
463 pr_err(
"alg: aead%s: Failed to set authsize to %u on test %d for %s\n",
464 d, authsize, j, algo);
469 template[i].ilen + (enc ? authsize : 0));
475 (enc ? authsize : 0));
482 aead_request_set_crypt(req, sg, (diff_dst) ? sgout : sg,
483 template[i].ilen, iv);
485 aead_request_set_assoc(req, asg,
template[i].alen);
488 crypto_aead_encrypt(req) :
489 crypto_aead_decrypt(req);
493 if (
template[i].novrfy) {
495 pr_err(
"alg: aead%s: %s failed on test %d for %s: ret was 0, expected -EBADMSG\n",
506 if (!ret && !(ret = result.
err)) {
511 if (
template[i].novrfy)
516 pr_err(
"alg: aead%s: %s failed on test %d for %s: ret=%d\n",
517 d, e, j, algo, -ret);
522 if (
memcmp(q,
template[i].result,
template[i].rlen)) {
523 pr_err(
"alg: aead%s: Test %d failed on %s for %s\n",
525 hexdump(q,
template[i].rlen);
532 for (i = 0, j = 0; i < tcount; i++) {
533 if (
template[i].np) {
541 crypto_aead_clear_flags(tfm, ~0);
543 crypto_aead_set_flags(
545 key =
template[
i].key;
547 ret = crypto_aead_setkey(tfm, key,
template[i].klen);
548 if (!ret ==
template[i].fail) {
549 pr_err(
"alg: aead%s: setkey failed on chunk test %d for %s: flags=%x\n",
550 d, j, algo, crypto_aead_get_flags(tfm));
555 authsize =
abs(
template[i].rlen -
template[i].ilen);
561 for (k = 0, temp = 0; k <
template[
i].np; k++) {
569 memcpy(q,
template[i].input + temp,
572 n =
template[
i].tap[
k];
573 if (k ==
template[i].np - 1 && enc)
578 sg_set_buf(&sg[k], q,
template[i].tap[k]);
584 memset(q, 0,
template[i].tap[k]);
588 sg_set_buf(&sgout[k], q,
592 temp +=
template[
i].tap[
k];
597 pr_err(
"alg: aead%s: Failed to set authsize to %u on chunk test %d for %s\n",
598 d, authsize, j, algo);
604 sg[k - 1].
length + authsize >
610 sg[k - 1].
length += authsize;
613 sgout[k - 1].
length += authsize;
618 for (k = 0, temp = 0; k <
template[
i].anp; k++) {
625 template[i].assoc + temp,
626 template[i].atap[k]),
627 template[i].atap[k]);
628 temp +=
template[
i].atap[
k];
631 aead_request_set_crypt(req, sg, (diff_dst) ? sgout : sg,
635 aead_request_set_assoc(req, asg,
template[i].alen);
638 crypto_aead_encrypt(req) :
639 crypto_aead_decrypt(req);
643 if (
template[i].novrfy) {
645 pr_err(
"alg: aead%s: %s failed on chunk test %d for %s: ret was 0, expected -EBADMSG\n",
656 if (!ret && !(ret = result.
err)) {
661 if (
template[i].novrfy)
666 pr_err(
"alg: aead%s: %s failed on chunk test %d for %s: ret=%d\n",
667 d, e, j, algo, -ret);
672 for (k = 0, temp = 0; k <
template[
i].np; k++) {
680 n =
template[
i].tap[
k];
681 if (k ==
template[i].np - 1)
682 n += enc ? authsize : -authsize;
684 if (
memcmp(q,
template[i].result + temp, n)) {
685 pr_err(
"alg: aead%s: Chunk test %d failed on %s at page %u for %s\n",
692 if (k ==
template[i].np - 1 && !enc) {
694 memcmp(q,
template[i].input +
705 pr_err(
"alg: aead%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n",
706 d, j, e, k, algo, n);
711 temp +=
template[
i].tap[
k];
719 aead_request_free(req);
723 testmgr_free_buf(xoutbuf);
725 testmgr_free_buf(axbuf);
727 testmgr_free_buf(xbuf);
732 static int test_aead(
struct crypto_aead *tfm,
int enc,
738 ret = __test_aead(tfm, enc,
template, tcount,
false);
743 return __test_aead(tfm, enc,
template, tcount,
true);
749 const char *algo = crypto_tfm_alg_driver_name(crypto_cipher_tfm(tfm));
750 unsigned int i,
j,
k;
757 if (testmgr_alloc_buf(xbuf))
766 for (i = 0; i < tcount; i++) {
777 memcpy(data,
template[i].input,
template[i].ilen);
779 crypto_cipher_clear_flags(tfm, ~0);
783 ret = crypto_cipher_setkey(tfm,
template[i].key,
785 if (!ret ==
template[i].fail) {
787 "on test %d for %s: flags=%x\n", j,
788 algo, crypto_cipher_get_flags(tfm));
793 for (k = 0; k <
template[
i].ilen;
794 k += crypto_cipher_blocksize(tfm)) {
796 crypto_cipher_encrypt_one(tfm, data + k,
799 crypto_cipher_decrypt_one(tfm, data + k,
804 if (
memcmp(q,
template[i].result,
template[i].rlen)) {
806 "on %s for %s\n", j, e, algo);
807 hexdump(q,
template[i].rlen);
816 testmgr_free_buf(xbuf);
826 crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm));
840 if (testmgr_alloc_buf(xbuf))
843 if (diff_dst && testmgr_alloc_buf(xoutbuf))
858 req = ablkcipher_request_alloc(tfm,
GFP_KERNEL);
860 pr_err(
"alg: skcipher%s: Failed to allocate request for %s\n",
866 tcrypt_complete, &result);
869 for (i = 0; i < tcount; i++) {
875 if (!(
template[i].np) || (
template[i].also_non_np)) {
883 memcpy(data,
template[i].input,
template[i].ilen);
885 crypto_ablkcipher_clear_flags(tfm, ~0);
887 crypto_ablkcipher_set_flags(
890 ret = crypto_ablkcipher_setkey(tfm,
template[i].key,
892 if (!ret ==
template[i].fail) {
893 pr_err(
"alg: skcipher%s: setkey failed on test %d for %s: flags=%x\n",
895 crypto_ablkcipher_get_flags(tfm));
906 ablkcipher_request_set_crypt(req, sg,
907 (diff_dst) ? sgout : sg,
908 template[i].ilen, iv);
910 crypto_ablkcipher_encrypt(req) :
911 crypto_ablkcipher_decrypt(req);
920 if (!ret && !((ret = result.
err))) {
926 pr_err(
"alg: skcipher%s: %s failed on test %d for %s: ret=%d\n",
927 d, e, j, algo, -ret);
932 if (
memcmp(q,
template[i].result,
template[i].rlen)) {
933 pr_err(
"alg: skcipher%s: Test %d failed on %s for %s\n",
935 hexdump(q,
template[i].rlen);
943 for (i = 0; i < tcount; i++) {
950 if (
template[i].np) {
953 crypto_ablkcipher_clear_flags(tfm, ~0);
955 crypto_ablkcipher_set_flags(
958 ret = crypto_ablkcipher_setkey(tfm,
template[i].key,
960 if (!ret ==
template[i].fail) {
961 pr_err(
"alg: skcipher%s: setkey failed on chunk test %d for %s: flags=%x\n",
963 crypto_ablkcipher_get_flags(tfm));
973 for (k = 0; k <
template[
i].np; k++) {
981 memcpy(q,
template[i].input + temp,
986 q[
template[
i].tap[
k]] = 0;
988 sg_set_buf(&sg[k], q,
template[i].tap[k]);
993 sg_set_buf(&sgout[k], q,
996 memset(q, 0,
template[i].tap[k]);
999 q[
template[
i].tap[
k]] = 0;
1002 temp +=
template[
i].tap[
k];
1005 ablkcipher_request_set_crypt(req, sg,
1006 (diff_dst) ? sgout : sg,
1007 template[i].ilen, iv);
1010 crypto_ablkcipher_encrypt(req) :
1011 crypto_ablkcipher_decrypt(req);
1020 if (!ret && !((ret = result.
err))) {
1026 pr_err(
"alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n",
1027 d, e, j, algo, -ret);
1033 for (k = 0; k <
template[
i].np; k++) {
1041 if (
memcmp(q,
template[i].result + temp,
1042 template[i].tap[k])) {
1043 pr_err(
"alg: skcipher%s: Chunk test %d failed on %s at page %u for %s\n",
1045 hexdump(q,
template[i].tap[k]);
1049 q +=
template[
i].tap[
k];
1053 pr_err(
"alg: skcipher%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n",
1054 d, j, e, k, algo, n);
1058 temp +=
template[
i].tap[
k];
1066 ablkcipher_request_free(req);
1068 testmgr_free_buf(xoutbuf);
1070 testmgr_free_buf(xbuf);
1081 ret = __test_skcipher(tfm, enc,
template, tcount,
false);
1086 return __test_skcipher(tfm, enc,
template, tcount,
true);
1090 struct comp_testvec *dtemplate,
int ctcount,
int dtcount)
1092 const char *algo = crypto_tfm_alg_driver_name(crypto_comp_tfm(tfm));
1097 for (i = 0; i < ctcount; i++) {
1101 memset(result, 0,
sizeof (result));
1103 ilen = ctemplate[
i].
inlen;
1104 ret = crypto_comp_compress(tfm, ctemplate[i].input,
1105 ilen, result, &dlen);
1108 "on test %d for %s: ret=%d\n", i + 1, algo,
1113 if (dlen != ctemplate[i].
outlen) {
1115 "failed for %s: output len = %d\n", i + 1, algo,
1121 if (
memcmp(result, ctemplate[i].output, dlen)) {
1123 "failed for %s\n", i + 1, algo);
1124 hexdump(result, dlen);
1130 for (i = 0; i < dtcount; i++) {
1134 memset(result, 0,
sizeof (result));
1136 ilen = dtemplate[
i].
inlen;
1137 ret = crypto_comp_decompress(tfm, dtemplate[i].input,
1138 ilen, result, &dlen);
1141 "on test %d for %s: ret=%d\n", i + 1, algo,
1146 if (dlen != dtemplate[i].outlen) {
1148 "failed for %s: output len = %d\n", i + 1, algo,
1154 if (
memcmp(result, dtemplate[i].output, dlen)) {
1156 "failed for %s\n", i + 1, algo);
1157 hexdump(result, dlen);
1174 const char *algo = crypto_tfm_alg_driver_name(crypto_pcomp_tfm(tfm));
1179 for (i = 0; i < ctcount; i++) {
1181 unsigned int produced = 0;
1183 res = crypto_compress_setup(tfm, ctemplate[i].
params,
1186 pr_err(
"alg: pcomp: compression setup failed on test "
1187 "%d for %s: error=%d\n", i + 1, algo, res);
1191 res = crypto_compress_init(tfm);
1193 pr_err(
"alg: pcomp: compression init failed on test "
1194 "%d for %s: error=%d\n", i + 1, algo, res);
1198 memset(result, 0,
sizeof(result));
1205 res = crypto_compress_update(tfm, &req);
1207 pr_err(
"alg: pcomp: compression update failed on test "
1208 "%d for %s: error=%d\n", i + 1, algo, res);
1217 res = crypto_compress_update(tfm, &req);
1219 pr_err(
"alg: pcomp: compression update failed on test "
1220 "%d for %s: error=%d\n", i + 1, algo, res);
1229 res = crypto_compress_final(tfm, &req);
1231 pr_err(
"alg: pcomp: compression final failed on test "
1232 "%d for %s: error=%d\n", i + 1, algo, res);
1238 pr_err(
"alg: comp: Compression test %d failed for %s: "
1239 "output len = %d (expected %d)\n", i + 1, algo,
1245 if (produced != ctemplate[i].outlen) {
1246 pr_err(
"alg: comp: Compression test %d failed for %s: "
1247 "returned len = %u (expected %d)\n", i + 1,
1248 algo, produced, ctemplate[i].outlen);
1252 if (
memcmp(result, ctemplate[i].output, ctemplate[i].outlen)) {
1253 pr_err(
"alg: pcomp: Compression test %d failed for "
1254 "%s\n", i + 1, algo);
1255 hexdump(result, ctemplate[i].outlen);
1260 for (i = 0; i < dtcount; i++) {
1262 unsigned int produced = 0;
1264 res = crypto_decompress_setup(tfm, dtemplate[i].
params,
1267 pr_err(
"alg: pcomp: decompression setup failed on "
1268 "test %d for %s: error=%d\n", i + 1, algo, res);
1272 res = crypto_decompress_init(tfm);
1274 pr_err(
"alg: pcomp: decompression init failed on test "
1275 "%d for %s: error=%d\n", i + 1, algo, res);
1279 memset(result, 0,
sizeof(result));
1286 res = crypto_decompress_update(tfm, &req);
1288 pr_err(
"alg: pcomp: decompression update failed on "
1289 "test %d for %s: error=%d\n", i + 1, algo, res);
1298 res = crypto_decompress_update(tfm, &req);
1300 pr_err(
"alg: pcomp: decompression update failed on "
1301 "test %d for %s: error=%d\n", i + 1, algo, res);
1310 res = crypto_decompress_final(tfm, &req);
1312 pr_err(
"alg: pcomp: decompression final failed on "
1313 "test %d for %s: error=%d\n", i + 1, algo, res);
1320 pr_err(
"alg: comp: Decompression test %d failed for "
1321 "%s: output len = %d (expected %d)\n", i + 1,
1327 if (produced != dtemplate[i].outlen) {
1328 pr_err(
"alg: comp: Decompression test %d failed for "
1329 "%s: returned len = %u (expected %d)\n", i + 1,
1330 algo, produced, dtemplate[i].outlen);
1334 if (
memcmp(result, dtemplate[i].output, dtemplate[i].outlen)) {
1335 pr_err(
"alg: pcomp: Decompression test %d failed for "
1336 "%s\n", i + 1, algo);
1337 hexdump(result, dtemplate[i].outlen);
1347 unsigned int tcount)
1349 const char *algo = crypto_tfm_alg_driver_name(crypto_rng_tfm(tfm));
1350 int err = 0,
i,
j, seedsize;
1354 seedsize = crypto_rng_seedsize(tfm);
1363 for (i = 0; i < tcount; i++) {
1366 memcpy(seed,
template[i].
v,
template[i].vlen);
1367 memcpy(seed +
template[i].vlen,
template[i].key,
1369 memcpy(seed +
template[i].vlen +
template[i].klen,
1370 template[i].dt,
template[i].dtlen);
1372 err = crypto_rng_reset(tfm, seed, seedsize);
1379 for (j = 0; j <
template[
i].loops; j++) {
1380 err = crypto_rng_get_bytes(tfm, result,
1382 if (err !=
template[i].rlen) {
1384 "the correct amount of random data for "
1385 "%s (requested %d, got %d)\n", algo,
1386 template[i].rlen, err);
1391 err =
memcmp(result,
template[i].result,
1396 hexdump(result,
template[i].rlen);
1416 "%ld\n", driver, PTR_ERR(tfm));
1417 return PTR_ERR(tfm);
1432 crypto_free_aead(tfm);
1436 static int alg_test_cipher(
const struct alg_test_desc *desc,
1437 const char *driver,
u32 type,
u32 mask)
1442 tfm = crypto_alloc_cipher(driver, type, mask);
1445 "%s: %ld\n", driver, PTR_ERR(tfm));
1446 return PTR_ERR(tfm);
1461 crypto_free_cipher(tfm);
1465 static int alg_test_skcipher(
const struct alg_test_desc *desc,
1466 const char *driver,
u32 type,
u32 mask)
1474 "%s: %ld\n", driver, PTR_ERR(tfm));
1475 return PTR_ERR(tfm);
1490 crypto_free_ablkcipher(tfm);
1494 static int alg_test_comp(
const struct alg_test_desc *desc,
const char *driver,
1500 tfm = crypto_alloc_comp(driver, type, mask);
1503 "%ld\n", driver, PTR_ERR(tfm));
1504 return PTR_ERR(tfm);
1507 err = test_comp(tfm, desc->
suite.
comp.comp.vecs,
1512 crypto_free_comp(tfm);
1516 static int alg_test_pcomp(
const struct alg_test_desc *desc,
const char *driver,
1524 pr_err(
"alg: pcomp: Failed to load transform for %s: %ld\n",
1525 driver, PTR_ERR(tfm));
1526 return PTR_ERR(tfm);
1529 err = test_pcomp(tfm, desc->
suite.
pcomp.comp.vecs,
1534 crypto_free_pcomp(tfm);
1538 static int alg_test_hash(
const struct alg_test_desc *desc,
const char *driver,
1547 "%ld\n", driver, PTR_ERR(tfm));
1548 return PTR_ERR(tfm);
1551 err = test_hash(tfm, desc->
suite.
hash.vecs,
1554 err = test_hash(tfm, desc->
suite.
hash.vecs,
1557 crypto_free_ahash(tfm);
1561 static int alg_test_crc32c(
const struct alg_test_desc *desc,
1562 const char *driver,
u32 type,
u32 mask)
1568 err = alg_test_hash(desc, driver, type, mask);
1575 "%ld\n", driver, PTR_ERR(tfm));
1583 char ctx[crypto_shash_descsize(tfm)];
1593 "%s: %d\n", driver, err);
1597 if (val != ~420553207) {
1599 "%d\n", driver, val);
1604 crypto_free_shash(tfm);
1610 static int alg_test_cprng(
const struct alg_test_desc *desc,
const char *driver,
1616 rng = crypto_alloc_rng(driver, type, mask);
1619 "%ld\n", driver, PTR_ERR(rng));
1620 return PTR_ERR(rng);
1625 crypto_free_rng(rng);
1631 const char *driver,
u32 type,
u32 mask)
1639 .alg =
"__cbc-cast5-avx",
1640 .test = alg_test_null,
1654 .alg =
"__cbc-cast6-avx",
1655 .test = alg_test_null,
1669 .alg =
"__cbc-serpent-avx",
1670 .test = alg_test_null,
1684 .alg =
"__cbc-serpent-sse2",
1685 .test = alg_test_null,
1699 .alg =
"__cbc-twofish-avx",
1700 .test = alg_test_null,
1714 .alg =
"__driver-cbc-aes-aesni",
1715 .test = alg_test_null,
1730 .alg =
"__driver-cbc-cast5-avx",
1731 .test = alg_test_null,
1745 .alg =
"__driver-cbc-cast6-avx",
1746 .test = alg_test_null,
1760 .alg =
"__driver-cbc-serpent-avx",
1761 .test = alg_test_null,
1775 .alg =
"__driver-cbc-serpent-sse2",
1776 .test = alg_test_null,
1790 .alg =
"__driver-cbc-twofish-avx",
1791 .test = alg_test_null,
1805 .alg =
"__driver-ecb-aes-aesni",
1806 .test = alg_test_null,
1821 .alg =
"__driver-ecb-cast5-avx",
1822 .test = alg_test_null,
1836 .alg =
"__driver-ecb-cast6-avx",
1837 .test = alg_test_null,
1851 .alg =
"__driver-ecb-serpent-avx",
1852 .test = alg_test_null,
1866 .alg =
"__driver-ecb-serpent-sse2",
1867 .test = alg_test_null,
1881 .alg =
"__driver-ecb-twofish-avx",
1882 .test = alg_test_null,
1896 .alg =
"__ghash-pclmulqdqni",
1897 .test = alg_test_null,
1906 .alg =
"ansi_cprng",
1907 .test = alg_test_cprng,
1911 .vecs = ansi_cprng_aes_tv_template,
1916 .alg =
"authenc(hmac(sha1),cbc(aes))",
1917 .test = alg_test_aead,
1922 .vecs = hmac_sha1_aes_cbc_enc_tv_template,
1928 .alg =
"authenc(hmac(sha256),cbc(aes))",
1929 .test = alg_test_aead,
1934 .vecs = hmac_sha256_aes_cbc_enc_tv_template,
1940 .alg =
"authenc(hmac(sha512),cbc(aes))",
1941 .test = alg_test_aead,
1946 .vecs = hmac_sha512_aes_cbc_enc_tv_template,
1953 .test = alg_test_skcipher,
1958 .vecs = aes_cbc_enc_tv_template,
1962 .vecs = aes_cbc_dec_tv_template,
1968 .alg =
"cbc(anubis)",
1969 .test = alg_test_skcipher,
1973 .vecs = anubis_cbc_enc_tv_template,
1977 .vecs = anubis_cbc_dec_tv_template,
1983 .alg =
"cbc(blowfish)",
1984 .test = alg_test_skcipher,
1988 .vecs = bf_cbc_enc_tv_template,
1992 .vecs = bf_cbc_dec_tv_template,
1998 .alg =
"cbc(camellia)",
1999 .test = alg_test_skcipher,
2003 .vecs = camellia_cbc_enc_tv_template,
2007 .vecs = camellia_cbc_dec_tv_template,
2013 .alg =
"cbc(cast5)",
2014 .test = alg_test_skcipher,
2018 .vecs = cast5_cbc_enc_tv_template,
2022 .vecs = cast5_cbc_dec_tv_template,
2028 .alg =
"cbc(cast6)",
2029 .test = alg_test_skcipher,
2033 .vecs = cast6_cbc_enc_tv_template,
2037 .vecs = cast6_cbc_dec_tv_template,
2044 .test = alg_test_skcipher,
2048 .vecs = des_cbc_enc_tv_template,
2052 .vecs = des_cbc_dec_tv_template,
2058 .alg =
"cbc(des3_ede)",
2059 .test = alg_test_skcipher,
2064 .vecs = des3_ede_cbc_enc_tv_template,
2068 .vecs = des3_ede_cbc_dec_tv_template,
2074 .alg =
"cbc(serpent)",
2075 .test = alg_test_skcipher,
2079 .vecs = serpent_cbc_enc_tv_template,
2083 .vecs = serpent_cbc_dec_tv_template,
2089 .alg =
"cbc(twofish)",
2090 .test = alg_test_skcipher,
2094 .vecs = tf_cbc_enc_tv_template,
2098 .vecs = tf_cbc_dec_tv_template,
2105 .test = alg_test_aead,
2110 .vecs = aes_ccm_enc_tv_template,
2114 .vecs = aes_ccm_dec_tv_template,
2121 .test = alg_test_crc32c,
2125 .vecs = crc32c_tv_template,
2130 .alg =
"cryptd(__driver-cbc-aes-aesni)",
2131 .test = alg_test_null,
2146 .alg =
"cryptd(__driver-ecb-aes-aesni)",
2147 .test = alg_test_null,
2162 .alg =
"cryptd(__driver-ecb-cast5-avx)",
2163 .test = alg_test_null,
2177 .alg =
"cryptd(__driver-ecb-cast6-avx)",
2178 .test = alg_test_null,
2192 .alg =
"cryptd(__driver-ecb-serpent-avx)",
2193 .test = alg_test_null,
2207 .alg =
"cryptd(__driver-ecb-serpent-sse2)",
2208 .test = alg_test_null,
2222 .alg =
"cryptd(__driver-ecb-twofish-avx)",
2223 .test = alg_test_null,
2237 .alg =
"cryptd(__driver-gcm-aes-aesni)",
2238 .test = alg_test_null,
2253 .alg =
"cryptd(__ghash-pclmulqdqni)",
2254 .test = alg_test_null,
2264 .test = alg_test_skcipher,
2269 .vecs = aes_ctr_enc_tv_template,
2273 .vecs = aes_ctr_dec_tv_template,
2279 .alg =
"ctr(blowfish)",
2280 .test = alg_test_skcipher,
2284 .vecs = bf_ctr_enc_tv_template,
2288 .vecs = bf_ctr_dec_tv_template,
2294 .alg =
"ctr(camellia)",
2295 .test = alg_test_skcipher,
2299 .vecs = camellia_ctr_enc_tv_template,
2303 .vecs = camellia_ctr_dec_tv_template,
2309 .alg =
"ctr(cast5)",
2310 .test = alg_test_skcipher,
2314 .vecs = cast5_ctr_enc_tv_template,
2318 .vecs = cast5_ctr_dec_tv_template,
2324 .alg =
"ctr(cast6)",
2325 .test = alg_test_skcipher,
2329 .vecs = cast6_ctr_enc_tv_template,
2333 .vecs = cast6_ctr_dec_tv_template,
2339 .alg =
"ctr(serpent)",
2340 .test = alg_test_skcipher,
2344 .vecs = serpent_ctr_enc_tv_template,
2348 .vecs = serpent_ctr_dec_tv_template,
2354 .alg =
"ctr(twofish)",
2355 .test = alg_test_skcipher,
2359 .vecs = tf_ctr_enc_tv_template,
2363 .vecs = tf_ctr_dec_tv_template,
2369 .alg =
"cts(cbc(aes))",
2370 .test = alg_test_skcipher,
2374 .vecs = cts_mode_enc_tv_template,
2378 .vecs = cts_mode_dec_tv_template,
2385 .test = alg_test_comp,
2389 .vecs = deflate_comp_tv_template,
2393 .vecs = deflate_decomp_tv_template,
2399 .alg =
"ecb(__aes-aesni)",
2400 .test = alg_test_null,
2416 .test = alg_test_skcipher,
2421 .vecs = aes_enc_tv_template,
2425 .vecs = aes_dec_tv_template,
2431 .alg =
"ecb(anubis)",
2432 .test = alg_test_skcipher,
2436 .vecs = anubis_enc_tv_template,
2440 .vecs = anubis_dec_tv_template,
2447 .test = alg_test_skcipher,
2451 .vecs = arc4_enc_tv_template,
2455 .vecs = arc4_dec_tv_template,
2461 .alg =
"ecb(blowfish)",
2462 .test = alg_test_skcipher,
2466 .vecs = bf_enc_tv_template,
2470 .vecs = bf_dec_tv_template,
2476 .alg =
"ecb(camellia)",
2477 .test = alg_test_skcipher,
2481 .vecs = camellia_enc_tv_template,
2485 .vecs = camellia_dec_tv_template,
2491 .alg =
"ecb(cast5)",
2492 .test = alg_test_skcipher,
2496 .vecs = cast5_enc_tv_template,
2500 .vecs = cast5_dec_tv_template,
2506 .alg =
"ecb(cast6)",
2507 .test = alg_test_skcipher,
2511 .vecs = cast6_enc_tv_template,
2515 .vecs = cast6_dec_tv_template,
2522 .test = alg_test_skcipher,
2527 .vecs = des_enc_tv_template,
2531 .vecs = des_dec_tv_template,
2537 .alg =
"ecb(des3_ede)",
2538 .test = alg_test_skcipher,
2543 .vecs = des3_ede_enc_tv_template,
2547 .vecs = des3_ede_dec_tv_template,
2553 .alg =
"ecb(khazad)",
2554 .test = alg_test_skcipher,
2558 .vecs = khazad_enc_tv_template,
2562 .vecs = khazad_dec_tv_template,
2569 .test = alg_test_skcipher,
2573 .vecs = seed_enc_tv_template,
2577 .vecs = seed_dec_tv_template,
2583 .alg =
"ecb(serpent)",
2584 .test = alg_test_skcipher,
2588 .vecs = serpent_enc_tv_template,
2592 .vecs = serpent_dec_tv_template,
2599 .test = alg_test_skcipher,
2603 .vecs = tea_enc_tv_template,
2607 .vecs = tea_dec_tv_template,
2613 .alg =
"ecb(tnepres)",
2614 .test = alg_test_skcipher,
2618 .vecs = tnepres_enc_tv_template,
2622 .vecs = tnepres_dec_tv_template,
2628 .alg =
"ecb(twofish)",
2629 .test = alg_test_skcipher,
2633 .vecs = tf_enc_tv_template,
2637 .vecs = tf_dec_tv_template,
2644 .test = alg_test_skcipher,
2648 .vecs = xeta_enc_tv_template,
2652 .vecs = xeta_dec_tv_template,
2659 .test = alg_test_skcipher,
2663 .vecs = xtea_enc_tv_template,
2667 .vecs = xtea_dec_tv_template,
2674 .test = alg_test_aead,
2679 .vecs = aes_gcm_enc_tv_template,
2683 .vecs = aes_gcm_dec_tv_template,
2690 .test = alg_test_hash,
2694 .vecs = ghash_tv_template,
2699 .alg =
"hmac(crc32)",
2700 .test = alg_test_hash,
2703 .vecs = bfin_crc_tv_template,
2709 .test = alg_test_hash,
2712 .vecs = hmac_md5_tv_template,
2717 .alg =
"hmac(rmd128)",
2718 .test = alg_test_hash,
2721 .vecs = hmac_rmd128_tv_template,
2726 .alg =
"hmac(rmd160)",
2727 .test = alg_test_hash,
2730 .vecs = hmac_rmd160_tv_template,
2735 .alg =
"hmac(sha1)",
2736 .test = alg_test_hash,
2740 .vecs = hmac_sha1_tv_template,
2745 .alg =
"hmac(sha224)",
2746 .test = alg_test_hash,
2750 .vecs = hmac_sha224_tv_template,
2755 .alg =
"hmac(sha256)",
2756 .test = alg_test_hash,
2760 .vecs = hmac_sha256_tv_template,
2765 .alg =
"hmac(sha384)",
2766 .test = alg_test_hash,
2770 .vecs = hmac_sha384_tv_template,
2775 .alg =
"hmac(sha512)",
2776 .test = alg_test_hash,
2780 .vecs = hmac_sha512_tv_template,
2786 .test = alg_test_skcipher,
2790 .vecs = aes_lrw_enc_tv_template,
2794 .vecs = aes_lrw_dec_tv_template,
2800 .alg =
"lrw(camellia)",
2801 .test = alg_test_skcipher,
2805 .vecs = camellia_lrw_enc_tv_template,
2809 .vecs = camellia_lrw_dec_tv_template,
2815 .alg =
"lrw(cast6)",
2816 .test = alg_test_skcipher,
2820 .vecs = cast6_lrw_enc_tv_template,
2824 .vecs = cast6_lrw_dec_tv_template,
2830 .alg =
"lrw(serpent)",
2831 .test = alg_test_skcipher,
2835 .vecs = serpent_lrw_enc_tv_template,
2839 .vecs = serpent_lrw_dec_tv_template,
2845 .alg =
"lrw(twofish)",
2846 .test = alg_test_skcipher,
2850 .vecs = tf_lrw_enc_tv_template,
2854 .vecs = tf_lrw_dec_tv_template,
2861 .test = alg_test_comp,
2865 .vecs = lzo_comp_tv_template,
2869 .vecs = lzo_decomp_tv_template,
2876 .test = alg_test_hash,
2879 .vecs = md4_tv_template,
2885 .test = alg_test_hash,
2888 .vecs = md5_tv_template,
2893 .alg =
"michael_mic",
2894 .test = alg_test_hash,
2897 .vecs = michael_mic_tv_template,
2903 .test = alg_test_skcipher,
2908 .vecs = aes_ofb_enc_tv_template,
2912 .vecs = aes_ofb_dec_tv_template,
2918 .alg =
"pcbc(fcrypt)",
2919 .test = alg_test_skcipher,
2923 .vecs = fcrypt_pcbc_enc_tv_template,
2927 .vecs = fcrypt_pcbc_dec_tv_template,
2933 .alg =
"rfc3686(ctr(aes))",
2934 .test = alg_test_skcipher,
2939 .vecs = aes_ctr_rfc3686_enc_tv_template,
2943 .vecs = aes_ctr_rfc3686_dec_tv_template,
2949 .alg =
"rfc4106(gcm(aes))",
2950 .test = alg_test_aead,
2954 .vecs = aes_gcm_rfc4106_enc_tv_template,
2958 .vecs = aes_gcm_rfc4106_dec_tv_template,
2966 .alg =
"rfc4309(ccm(aes))",
2967 .test = alg_test_aead,
2972 .vecs = aes_ccm_rfc4309_enc_tv_template,
2976 .vecs = aes_ccm_rfc4309_dec_tv_template,
2983 .test = alg_test_hash,
2986 .vecs = rmd128_tv_template,
2992 .test = alg_test_hash,
2995 .vecs = rmd160_tv_template,
3001 .test = alg_test_hash,
3004 .vecs = rmd256_tv_template,
3010 .test = alg_test_hash,
3013 .vecs = rmd320_tv_template,
3019 .test = alg_test_skcipher,
3023 .vecs = salsa20_stream_enc_tv_template,
3030 .test = alg_test_hash,
3034 .vecs = sha1_tv_template,
3040 .test = alg_test_hash,
3044 .vecs = sha224_tv_template,
3050 .test = alg_test_hash,
3054 .vecs = sha256_tv_template,
3060 .test = alg_test_hash,
3064 .vecs = sha384_tv_template,
3070 .test = alg_test_hash,
3074 .vecs = sha512_tv_template,
3080 .test = alg_test_hash,
3083 .vecs = tgr128_tv_template,
3089 .test = alg_test_hash,
3092 .vecs = tgr160_tv_template,
3098 .test = alg_test_hash,
3101 .vecs = tgr192_tv_template,
3107 .test = alg_test_hash,
3110 .vecs = aes_vmac128_tv_template,
3116 .test = alg_test_hash,
3119 .vecs = wp256_tv_template,
3125 .test = alg_test_hash,
3128 .vecs = wp384_tv_template,
3134 .test = alg_test_hash,
3137 .vecs = wp512_tv_template,
3143 .test = alg_test_hash,
3146 .vecs = aes_xcbc128_tv_template,
3152 .test = alg_test_skcipher,
3157 .vecs = aes_xts_enc_tv_template,
3161 .vecs = aes_xts_dec_tv_template,
3167 .alg =
"xts(camellia)",
3168 .test = alg_test_skcipher,
3172 .vecs = camellia_xts_enc_tv_template,
3176 .vecs = camellia_xts_dec_tv_template,
3182 .alg =
"xts(cast6)",
3183 .test = alg_test_skcipher,
3187 .vecs = cast6_xts_enc_tv_template,
3191 .vecs = cast6_xts_dec_tv_template,
3197 .alg =
"xts(serpent)",
3198 .test = alg_test_skcipher,
3202 .vecs = serpent_xts_enc_tv_template,
3206 .vecs = serpent_xts_dec_tv_template,
3212 .alg =
"xts(twofish)",
3213 .test = alg_test_skcipher,
3217 .vecs = tf_xts_enc_tv_template,
3221 .vecs = tf_xts_dec_tv_template,
3228 .test = alg_test_pcomp,
3232 .vecs = zlib_comp_tv_template,
3236 .vecs = zlib_decomp_tv_template,
3244 static int alg_find_test(
const char *alg)
3249 while (start < end) {
3250 int i = (start +
end) / 2;
3251 int diff =
strcmp(alg_test_descs[i].alg, alg);
3278 if (
snprintf(nalg,
sizeof(nalg),
"ecb(%s)", alg) >=
3282 i = alg_find_test(nalg);
3289 rc = alg_test_cipher(alg_test_descs + i, driver, type, mask);
3293 i = alg_find_test(alg);
3294 j = alg_find_test(driver);
3298 if (
fips_enabled && ((i >= 0 && !alg_test_descs[i].fips_allowed) ||
3299 (j >= 0 && !alg_test_descs[j].fips_allowed)))
3304 rc |= alg_test_descs[
i].
test(alg_test_descs + i, driver,
3307 rc |= alg_test_descs[
j].
test(alg_test_descs + j, driver,
3312 panic(
"%s: %s alg self test failed in fips mode!\n", driver, alg);