2 * Quick & dirty crypto testing module.
4 * This will only exist until we have a better testing mechanism
5 * (e.g. a char device).
7 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
8 * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
9 * Copyright (c) 2007 Nokia Siemens Networks
11 * Updated RFC4106 AES-GCM testing.
12 * Authors: Aidan O'Mahony (aidan.o.mahony@intel.com)
13 * Adrian Hoban <adrian.hoban@intel.com>
14 * Gabriele Paoloni <gabriele.paoloni@intel.com>
15 * Tadeusz Struk (tadeusz.struk@intel.com)
16 * Copyright (c) 2010, Intel Corporation.
18 * This program is free software; you can redistribute it and/or modify it
19 * under the terms of the GNU General Public License as published by the Free
20 * Software Foundation; either version 2 of the License, or (at your option)
25 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
27 #include <crypto/aead.h>
28 #include <crypto/hash.h>
29 #include <crypto/skcipher.h>
30 #include <linux/err.h>
31 #include <linux/fips.h>
32 #include <linux/init.h>
33 #include <linux/gfp.h>
34 #include <linux/module.h>
35 #include <linux/scatterlist.h>
36 #include <linux/string.h>
37 #include <linux/moduleparam.h>
38 #include <linux/jiffies.h>
39 #include <linux/timex.h>
40 #include <linux/interrupt.h>
44 * Need slab memory for testing (size in number of pages).
49 * Used by test_cipher_speed()
54 #define MAX_DIGEST_SIZE 64
57 * return a string with the driver name
59 #define get_driver_name(tfm_type, tfm) crypto_tfm_alg_driver_name(tfm_type ## _tfm(tfm))
62 * Used by test_cipher_speed()
64 static unsigned int sec;
66 static char *alg = NULL;
70 static char *tvmem[TVMEMSIZE];
72 static char *check[] = {
73 "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", "sm3",
74 "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
75 "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
76 "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
77 "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320",
78 "lzo", "cts", "zlib", "sha3-224", "sha3-256", "sha3-384", "sha3-512",
82 static inline int do_one_aead_op(struct aead_request *req, int ret)
84 struct crypto_wait *wait = req->base.data;
86 return crypto_wait_req(ret, wait);
89 static int test_aead_jiffies(struct aead_request *req, int enc,
92 unsigned long start, end;
96 for (start = jiffies, end = start + secs * HZ, bcount = 0;
97 time_before(jiffies, end); bcount++) {
99 ret = do_one_aead_op(req, crypto_aead_encrypt(req));
101 ret = do_one_aead_op(req, crypto_aead_decrypt(req));
107 printk("%d operations in %d seconds (%ld bytes)\n",
108 bcount, secs, (long)bcount * blen);
112 static int test_aead_cycles(struct aead_request *req, int enc, int blen)
114 unsigned long cycles = 0;
119 for (i = 0; i < 4; i++) {
121 ret = do_one_aead_op(req, crypto_aead_encrypt(req));
123 ret = do_one_aead_op(req, crypto_aead_decrypt(req));
129 /* The real thing. */
130 for (i = 0; i < 8; i++) {
133 start = get_cycles();
135 ret = do_one_aead_op(req, crypto_aead_encrypt(req));
137 ret = do_one_aead_op(req, crypto_aead_decrypt(req));
143 cycles += end - start;
148 printk("1 operation in %lu cycles (%d bytes)\n",
149 (cycles + 4) / 8, blen);
154 static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 };
155 static u32 aead_sizes[] = { 16, 64, 256, 512, 1024, 2048, 4096, 8192, 0 };
160 static int testmgr_alloc_buf(char *buf[XBUFSIZE])
164 for (i = 0; i < XBUFSIZE; i++) {
165 buf[i] = (void *)__get_free_page(GFP_KERNEL);
174 free_page((unsigned long)buf[i]);
179 static void testmgr_free_buf(char *buf[XBUFSIZE])
183 for (i = 0; i < XBUFSIZE; i++)
184 free_page((unsigned long)buf[i]);
187 static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],
188 unsigned int buflen, const void *assoc,
189 unsigned int aad_size)
191 int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE;
198 rem = buflen % PAGE_SIZE;
201 sg_init_table(sg, np + 1);
203 sg_set_buf(&sg[0], assoc, aad_size);
207 for (k = 0; k < np; k++)
208 sg_set_buf(&sg[k + 1], xbuf[k], PAGE_SIZE);
211 sg_set_buf(&sg[k + 1], xbuf[k], rem);
214 static void test_aead_speed(const char *algo, int enc, unsigned int secs,
215 struct aead_speed_template *template,
216 unsigned int tcount, u8 authsize,
217 unsigned int aad_size, u8 *keysize)
220 struct crypto_aead *tfm;
223 struct aead_request *req;
224 struct scatterlist *sg;
225 struct scatterlist *sgout;
229 char *xbuf[XBUFSIZE];
230 char *xoutbuf[XBUFSIZE];
231 char *axbuf[XBUFSIZE];
232 unsigned int *b_size;
234 struct crypto_wait wait;
236 iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
240 if (aad_size >= PAGE_SIZE) {
241 pr_err("associate data length (%u) too big\n", aad_size);
250 if (testmgr_alloc_buf(xbuf))
252 if (testmgr_alloc_buf(axbuf))
254 if (testmgr_alloc_buf(xoutbuf))
257 sg = kmalloc(sizeof(*sg) * 9 * 2, GFP_KERNEL);
262 tfm = crypto_alloc_aead(algo, 0, 0);
265 pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo,
270 crypto_init_wait(&wait);
271 printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo,
272 get_driver_name(crypto_aead, tfm), e);
274 req = aead_request_alloc(tfm, GFP_KERNEL);
276 pr_err("alg: aead: Failed to allocate request for %s\n",
281 aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
282 crypto_req_done, &wait);
289 memset(assoc, 0xff, aad_size);
291 if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
292 pr_err("template (%u) too big for tvmem (%lu)\n",
294 TVMEMSIZE * PAGE_SIZE);
299 for (j = 0; j < tcount; j++) {
300 if (template[j].klen == *keysize) {
301 key = template[j].key;
305 ret = crypto_aead_setkey(tfm, key, *keysize);
306 ret = crypto_aead_setauthsize(tfm, authsize);
308 iv_len = crypto_aead_ivsize(tfm);
310 memset(iv, 0xff, iv_len);
312 crypto_aead_clear_flags(tfm, ~0);
313 printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ",
314 i, *keysize * 8, *b_size);
317 memset(tvmem[0], 0xff, PAGE_SIZE);
320 pr_err("setkey() failed flags=%x\n",
321 crypto_aead_get_flags(tfm));
325 sg_init_aead(sg, xbuf, *b_size + (enc ? 0 : authsize),
328 sg_init_aead(sgout, xoutbuf,
329 *b_size + (enc ? authsize : 0), assoc,
332 aead_request_set_crypt(req, sg, sgout,
333 *b_size + (enc ? 0 : authsize),
335 aead_request_set_ad(req, aad_size);
338 ret = test_aead_jiffies(req, enc, *b_size,
341 ret = test_aead_cycles(req, enc, *b_size);
344 pr_err("%s() failed return code=%d\n", e, ret);
354 aead_request_free(req);
356 crypto_free_aead(tfm);
360 testmgr_free_buf(xoutbuf);
362 testmgr_free_buf(axbuf);
364 testmgr_free_buf(xbuf);
369 static void test_hash_sg_init(struct scatterlist *sg)
373 sg_init_table(sg, TVMEMSIZE);
374 for (i = 0; i < TVMEMSIZE; i++) {
375 sg_set_buf(sg + i, tvmem[i], PAGE_SIZE);
376 memset(tvmem[i], 0xff, PAGE_SIZE);
380 static inline int do_one_ahash_op(struct ahash_request *req, int ret)
382 struct crypto_wait *wait = req->base.data;
384 return crypto_wait_req(ret, wait);
387 struct test_mb_ahash_data {
388 struct scatterlist sg[TVMEMSIZE];
390 struct ahash_request *req;
391 struct crypto_wait wait;
392 char *xbuf[XBUFSIZE];
395 static void test_mb_ahash_speed(const char *algo, unsigned int sec,
396 struct hash_speed *speed)
398 struct test_mb_ahash_data *data;
399 struct crypto_ahash *tfm;
400 unsigned long start, end;
401 unsigned long cycles;
402 unsigned int i, j, k;
405 data = kzalloc(sizeof(*data) * 8, GFP_KERNEL);
409 tfm = crypto_alloc_ahash(algo, 0, 0);
411 pr_err("failed to load transform for %s: %ld\n",
416 for (i = 0; i < 8; ++i) {
417 if (testmgr_alloc_buf(data[i].xbuf))
420 crypto_init_wait(&data[i].wait);
422 data[i].req = ahash_request_alloc(tfm, GFP_KERNEL);
424 pr_err("alg: hash: Failed to allocate request for %s\n",
429 ahash_request_set_callback(data[i].req, 0, crypto_req_done,
431 test_hash_sg_init(data[i].sg);
434 pr_info("\ntesting speed of multibuffer %s (%s)\n", algo,
435 get_driver_name(crypto_ahash, tfm));
437 for (i = 0; speed[i].blen != 0; i++) {
438 /* For some reason this only tests digests. */
439 if (speed[i].blen != speed[i].plen)
442 if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
443 pr_err("template (%u) too big for tvmem (%lu)\n",
444 speed[i].blen, TVMEMSIZE * PAGE_SIZE);
449 crypto_ahash_setkey(tfm, tvmem[0], speed[i].klen);
451 for (k = 0; k < 8; k++)
452 ahash_request_set_crypt(data[k].req, data[k].sg,
453 data[k].result, speed[i].blen);
456 "(%5u byte blocks,%5u bytes per update,%4u updates): ",
457 i, speed[i].blen, speed[i].plen,
458 speed[i].blen / speed[i].plen);
460 start = get_cycles();
462 for (k = 0; k < 8; k++) {
463 ret = crypto_ahash_digest(data[k].req);
464 if (ret == -EINPROGRESS) {
472 crypto_req_done(&data[k].req->base, 0);
475 for (j = 0; j < k; j++) {
476 struct crypto_wait *wait = &data[j].wait;
479 wait_ret = crypto_wait_req(-EINPROGRESS, wait);
485 cycles = end - start;
486 pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
487 cycles, cycles / (8 * speed[i].blen));
490 pr_err("At least one hashing failed ret=%d\n", ret);
496 for (k = 0; k < 8; ++k)
497 ahash_request_free(data[k].req);
499 for (k = 0; k < 8; ++k)
500 testmgr_free_buf(data[k].xbuf);
502 crypto_free_ahash(tfm);
508 static int test_ahash_jiffies_digest(struct ahash_request *req, int blen,
511 unsigned long start, end;
515 for (start = jiffies, end = start + secs * HZ, bcount = 0;
516 time_before(jiffies, end); bcount++) {
517 ret = do_one_ahash_op(req, crypto_ahash_digest(req));
522 printk("%6u opers/sec, %9lu bytes/sec\n",
523 bcount / secs, ((long)bcount * blen) / secs);
528 static int test_ahash_jiffies(struct ahash_request *req, int blen,
529 int plen, char *out, int secs)
531 unsigned long start, end;
536 return test_ahash_jiffies_digest(req, blen, out, secs);
538 for (start = jiffies, end = start + secs * HZ, bcount = 0;
539 time_before(jiffies, end); bcount++) {
540 ret = do_one_ahash_op(req, crypto_ahash_init(req));
543 for (pcount = 0; pcount < blen; pcount += plen) {
544 ret = do_one_ahash_op(req, crypto_ahash_update(req));
548 /* we assume there is enough space in 'out' for the result */
549 ret = do_one_ahash_op(req, crypto_ahash_final(req));
554 pr_cont("%6u opers/sec, %9lu bytes/sec\n",
555 bcount / secs, ((long)bcount * blen) / secs);
560 static int test_ahash_cycles_digest(struct ahash_request *req, int blen,
563 unsigned long cycles = 0;
567 for (i = 0; i < 4; i++) {
568 ret = do_one_ahash_op(req, crypto_ahash_digest(req));
573 /* The real thing. */
574 for (i = 0; i < 8; i++) {
577 start = get_cycles();
579 ret = do_one_ahash_op(req, crypto_ahash_digest(req));
585 cycles += end - start;
592 pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
593 cycles / 8, cycles / (8 * blen));
598 static int test_ahash_cycles(struct ahash_request *req, int blen,
601 unsigned long cycles = 0;
605 return test_ahash_cycles_digest(req, blen, out);
608 for (i = 0; i < 4; i++) {
609 ret = do_one_ahash_op(req, crypto_ahash_init(req));
612 for (pcount = 0; pcount < blen; pcount += plen) {
613 ret = do_one_ahash_op(req, crypto_ahash_update(req));
617 ret = do_one_ahash_op(req, crypto_ahash_final(req));
622 /* The real thing. */
623 for (i = 0; i < 8; i++) {
626 start = get_cycles();
628 ret = do_one_ahash_op(req, crypto_ahash_init(req));
631 for (pcount = 0; pcount < blen; pcount += plen) {
632 ret = do_one_ahash_op(req, crypto_ahash_update(req));
636 ret = do_one_ahash_op(req, crypto_ahash_final(req));
642 cycles += end - start;
649 pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
650 cycles / 8, cycles / (8 * blen));
655 static void test_ahash_speed_common(const char *algo, unsigned int secs,
656 struct hash_speed *speed, unsigned mask)
658 struct scatterlist sg[TVMEMSIZE];
659 struct crypto_wait wait;
660 struct ahash_request *req;
661 struct crypto_ahash *tfm;
665 tfm = crypto_alloc_ahash(algo, 0, mask);
667 pr_err("failed to load transform for %s: %ld\n",
672 printk(KERN_INFO "\ntesting speed of async %s (%s)\n", algo,
673 get_driver_name(crypto_ahash, tfm));
675 if (crypto_ahash_digestsize(tfm) > MAX_DIGEST_SIZE) {
676 pr_err("digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm),
681 test_hash_sg_init(sg);
682 req = ahash_request_alloc(tfm, GFP_KERNEL);
684 pr_err("ahash request allocation failure\n");
688 crypto_init_wait(&wait);
689 ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
690 crypto_req_done, &wait);
692 output = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL);
696 for (i = 0; speed[i].blen != 0; i++) {
697 if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
698 pr_err("template (%u) too big for tvmem (%lu)\n",
699 speed[i].blen, TVMEMSIZE * PAGE_SIZE);
704 "(%5u byte blocks,%5u bytes per update,%4u updates): ",
705 i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
707 ahash_request_set_crypt(req, sg, output, speed[i].plen);
710 ret = test_ahash_jiffies(req, speed[i].blen,
711 speed[i].plen, output, secs);
713 ret = test_ahash_cycles(req, speed[i].blen,
714 speed[i].plen, output);
717 pr_err("hashing failed ret=%d\n", ret);
725 ahash_request_free(req);
728 crypto_free_ahash(tfm);
731 static void test_ahash_speed(const char *algo, unsigned int secs,
732 struct hash_speed *speed)
734 return test_ahash_speed_common(algo, secs, speed, 0);
737 static void test_hash_speed(const char *algo, unsigned int secs,
738 struct hash_speed *speed)
740 return test_ahash_speed_common(algo, secs, speed, CRYPTO_ALG_ASYNC);
743 static inline int do_one_acipher_op(struct skcipher_request *req, int ret)
745 struct crypto_wait *wait = req->base.data;
747 return crypto_wait_req(ret, wait);
750 static int test_acipher_jiffies(struct skcipher_request *req, int enc,
753 unsigned long start, end;
757 for (start = jiffies, end = start + secs * HZ, bcount = 0;
758 time_before(jiffies, end); bcount++) {
760 ret = do_one_acipher_op(req,
761 crypto_skcipher_encrypt(req));
763 ret = do_one_acipher_op(req,
764 crypto_skcipher_decrypt(req));
770 pr_cont("%d operations in %d seconds (%ld bytes)\n",
771 bcount, secs, (long)bcount * blen);
775 static int test_acipher_cycles(struct skcipher_request *req, int enc,
778 unsigned long cycles = 0;
783 for (i = 0; i < 4; i++) {
785 ret = do_one_acipher_op(req,
786 crypto_skcipher_encrypt(req));
788 ret = do_one_acipher_op(req,
789 crypto_skcipher_decrypt(req));
795 /* The real thing. */
796 for (i = 0; i < 8; i++) {
799 start = get_cycles();
801 ret = do_one_acipher_op(req,
802 crypto_skcipher_encrypt(req));
804 ret = do_one_acipher_op(req,
805 crypto_skcipher_decrypt(req));
811 cycles += end - start;
816 pr_cont("1 operation in %lu cycles (%d bytes)\n",
817 (cycles + 4) / 8, blen);
822 static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
823 struct cipher_speed_template *template,
824 unsigned int tcount, u8 *keysize, bool async)
826 unsigned int ret, i, j, k, iv_len;
827 struct crypto_wait wait;
830 struct skcipher_request *req;
831 struct crypto_skcipher *tfm;
840 crypto_init_wait(&wait);
842 tfm = crypto_alloc_skcipher(algo, 0, async ? 0 : CRYPTO_ALG_ASYNC);
845 pr_err("failed to load transform for %s: %ld\n", algo,
850 pr_info("\ntesting speed of async %s (%s) %s\n", algo,
851 get_driver_name(crypto_skcipher, tfm), e);
853 req = skcipher_request_alloc(tfm, GFP_KERNEL);
855 pr_err("tcrypt: skcipher: Failed to allocate request for %s\n",
860 skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
861 crypto_req_done, &wait);
865 b_size = block_sizes;
868 struct scatterlist sg[TVMEMSIZE];
870 if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
871 pr_err("template (%u) too big for "
872 "tvmem (%lu)\n", *keysize + *b_size,
873 TVMEMSIZE * PAGE_SIZE);
877 pr_info("test %u (%d bit key, %d byte blocks): ", i,
878 *keysize * 8, *b_size);
880 memset(tvmem[0], 0xff, PAGE_SIZE);
882 /* set key, plain text and IV */
884 for (j = 0; j < tcount; j++) {
885 if (template[j].klen == *keysize) {
886 key = template[j].key;
891 crypto_skcipher_clear_flags(tfm, ~0);
893 ret = crypto_skcipher_setkey(tfm, key, *keysize);
895 pr_err("setkey() failed flags=%x\n",
896 crypto_skcipher_get_flags(tfm));
900 k = *keysize + *b_size;
901 sg_init_table(sg, DIV_ROUND_UP(k, PAGE_SIZE));
904 sg_set_buf(sg, tvmem[0] + *keysize,
905 PAGE_SIZE - *keysize);
908 while (k > PAGE_SIZE) {
909 sg_set_buf(sg + j, tvmem[j], PAGE_SIZE);
910 memset(tvmem[j], 0xff, PAGE_SIZE);
914 sg_set_buf(sg + j, tvmem[j], k);
915 memset(tvmem[j], 0xff, k);
917 sg_set_buf(sg, tvmem[0] + *keysize, *b_size);
920 iv_len = crypto_skcipher_ivsize(tfm);
922 memset(&iv, 0xff, iv_len);
924 skcipher_request_set_crypt(req, sg, sg, *b_size, iv);
927 ret = test_acipher_jiffies(req, enc,
930 ret = test_acipher_cycles(req, enc,
934 pr_err("%s() failed flags=%x\n", e,
935 crypto_skcipher_get_flags(tfm));
945 skcipher_request_free(req);
947 crypto_free_skcipher(tfm);
950 static void test_acipher_speed(const char *algo, int enc, unsigned int secs,
951 struct cipher_speed_template *template,
952 unsigned int tcount, u8 *keysize)
954 return test_skcipher_speed(algo, enc, secs, template, tcount, keysize,
958 static void test_cipher_speed(const char *algo, int enc, unsigned int secs,
959 struct cipher_speed_template *template,
960 unsigned int tcount, u8 *keysize)
962 return test_skcipher_speed(algo, enc, secs, template, tcount, keysize,
966 static void test_available(void)
971 printk("alg %s ", *name);
972 printk(crypto_has_alg(*name, 0, 0) ?
973 "found\n" : "not found\n");
978 static inline int tcrypt_test(const char *alg)
982 pr_debug("testing %s\n", alg);
984 ret = alg_test(alg, alg, 0, 0);
985 /* non-fips algs return -EINVAL in fips mode */
986 if (fips_enabled && ret == -EINVAL)
991 static int do_test(const char *alg, u32 type, u32 mask, int m)
999 if (!crypto_has_alg(alg, type,
1000 mask ?: CRYPTO_ALG_TYPE_MASK))
1005 for (i = 1; i < 200; i++)
1006 ret += do_test(NULL, 0, 0, i);
1010 ret += tcrypt_test("md5");
1014 ret += tcrypt_test("sha1");
1018 ret += tcrypt_test("ecb(des)");
1019 ret += tcrypt_test("cbc(des)");
1020 ret += tcrypt_test("ctr(des)");
1024 ret += tcrypt_test("ecb(des3_ede)");
1025 ret += tcrypt_test("cbc(des3_ede)");
1026 ret += tcrypt_test("ctr(des3_ede)");
1030 ret += tcrypt_test("md4");
1034 ret += tcrypt_test("sha256");
1038 ret += tcrypt_test("ecb(blowfish)");
1039 ret += tcrypt_test("cbc(blowfish)");
1040 ret += tcrypt_test("ctr(blowfish)");
1044 ret += tcrypt_test("ecb(twofish)");
1045 ret += tcrypt_test("cbc(twofish)");
1046 ret += tcrypt_test("ctr(twofish)");
1047 ret += tcrypt_test("lrw(twofish)");
1048 ret += tcrypt_test("xts(twofish)");
1052 ret += tcrypt_test("ecb(serpent)");
1053 ret += tcrypt_test("cbc(serpent)");
1054 ret += tcrypt_test("ctr(serpent)");
1055 ret += tcrypt_test("lrw(serpent)");
1056 ret += tcrypt_test("xts(serpent)");
1060 ret += tcrypt_test("ecb(aes)");
1061 ret += tcrypt_test("cbc(aes)");
1062 ret += tcrypt_test("lrw(aes)");
1063 ret += tcrypt_test("xts(aes)");
1064 ret += tcrypt_test("ctr(aes)");
1065 ret += tcrypt_test("rfc3686(ctr(aes))");
1069 ret += tcrypt_test("sha384");
1073 ret += tcrypt_test("sha512");
1077 ret += tcrypt_test("deflate");
1081 ret += tcrypt_test("ecb(cast5)");
1082 ret += tcrypt_test("cbc(cast5)");
1083 ret += tcrypt_test("ctr(cast5)");
1087 ret += tcrypt_test("ecb(cast6)");
1088 ret += tcrypt_test("cbc(cast6)");
1089 ret += tcrypt_test("ctr(cast6)");
1090 ret += tcrypt_test("lrw(cast6)");
1091 ret += tcrypt_test("xts(cast6)");
1095 ret += tcrypt_test("ecb(arc4)");
1099 ret += tcrypt_test("michael_mic");
1103 ret += tcrypt_test("crc32c");
1107 ret += tcrypt_test("ecb(tea)");
1111 ret += tcrypt_test("ecb(xtea)");
1115 ret += tcrypt_test("ecb(khazad)");
1119 ret += tcrypt_test("wp512");
1123 ret += tcrypt_test("wp384");
1127 ret += tcrypt_test("wp256");
1131 ret += tcrypt_test("ecb(tnepres)");
1135 ret += tcrypt_test("ecb(anubis)");
1136 ret += tcrypt_test("cbc(anubis)");
1140 ret += tcrypt_test("tgr192");
1144 ret += tcrypt_test("tgr160");
1148 ret += tcrypt_test("tgr128");
1152 ret += tcrypt_test("ecb(xeta)");
1156 ret += tcrypt_test("pcbc(fcrypt)");
1160 ret += tcrypt_test("ecb(camellia)");
1161 ret += tcrypt_test("cbc(camellia)");
1162 ret += tcrypt_test("ctr(camellia)");
1163 ret += tcrypt_test("lrw(camellia)");
1164 ret += tcrypt_test("xts(camellia)");
1168 ret += tcrypt_test("sha224");
1172 ret += tcrypt_test("salsa20");
1176 ret += tcrypt_test("gcm(aes)");
1180 ret += tcrypt_test("lzo");
1184 ret += tcrypt_test("ccm(aes)");
1188 ret += tcrypt_test("cts(cbc(aes))");
1192 ret += tcrypt_test("rmd128");
1196 ret += tcrypt_test("rmd160");
1200 ret += tcrypt_test("rmd256");
1204 ret += tcrypt_test("rmd320");
1208 ret += tcrypt_test("ecb(seed)");
1212 ret += tcrypt_test("zlib");
1216 ret += tcrypt_test("rfc4309(ccm(aes))");
1220 ret += tcrypt_test("ghash");
1224 ret += tcrypt_test("crct10dif");
1228 ret += tcrypt_test("sha3-224");
1232 ret += tcrypt_test("sha3-256");
1236 ret += tcrypt_test("sha3-384");
1240 ret += tcrypt_test("sha3-512");
1244 ret += tcrypt_test("sm3");
1248 ret += tcrypt_test("hmac(md5)");
1252 ret += tcrypt_test("hmac(sha1)");
1256 ret += tcrypt_test("hmac(sha256)");
1260 ret += tcrypt_test("hmac(sha384)");
1264 ret += tcrypt_test("hmac(sha512)");
1268 ret += tcrypt_test("hmac(sha224)");
1272 ret += tcrypt_test("xcbc(aes)");
1276 ret += tcrypt_test("hmac(rmd128)");
1280 ret += tcrypt_test("hmac(rmd160)");
1284 ret += tcrypt_test("vmac(aes)");
1288 ret += tcrypt_test("hmac(crc32)");
1292 ret += tcrypt_test("hmac(sha3-224)");
1296 ret += tcrypt_test("hmac(sha3-256)");
1300 ret += tcrypt_test("hmac(sha3-384)");
1304 ret += tcrypt_test("hmac(sha3-512)");
1308 ret += tcrypt_test("ansi_cprng");
1312 ret += tcrypt_test("rfc4106(gcm(aes))");
1316 ret += tcrypt_test("rfc4543(gcm(aes))");
1320 ret += tcrypt_test("cmac(aes)");
1324 ret += tcrypt_test("cmac(des3_ede)");
1328 ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))");
1332 ret += tcrypt_test("authenc(hmac(md5),ecb(cipher_null))");
1336 ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))");
1339 ret += tcrypt_test("authenc(hmac(sha1),cbc(des))");
1342 ret += tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))");
1345 ret += tcrypt_test("authenc(hmac(sha224),cbc(des))");
1348 ret += tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))");
1351 ret += tcrypt_test("authenc(hmac(sha256),cbc(des))");
1354 ret += tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))");
1357 ret += tcrypt_test("authenc(hmac(sha384),cbc(des))");
1360 ret += tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))");
1363 ret += tcrypt_test("authenc(hmac(sha512),cbc(des))");
1366 ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))");
1369 test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
1370 speed_template_16_24_32);
1371 test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
1372 speed_template_16_24_32);
1373 test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
1374 speed_template_16_24_32);
1375 test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
1376 speed_template_16_24_32);
1377 test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
1378 speed_template_32_40_48);
1379 test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
1380 speed_template_32_40_48);
1381 test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
1382 speed_template_32_64);
1383 test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
1384 speed_template_32_64);
1385 test_cipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
1386 speed_template_16_24_32);
1387 test_cipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
1388 speed_template_16_24_32);
1389 test_cipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
1390 speed_template_16_24_32);
1391 test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
1392 speed_template_16_24_32);
1396 test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec,
1397 des3_speed_template, DES3_SPEED_VECTORS,
1399 test_cipher_speed("ecb(des3_ede)", DECRYPT, sec,
1400 des3_speed_template, DES3_SPEED_VECTORS,
1402 test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec,
1403 des3_speed_template, DES3_SPEED_VECTORS,
1405 test_cipher_speed("cbc(des3_ede)", DECRYPT, sec,
1406 des3_speed_template, DES3_SPEED_VECTORS,
1408 test_cipher_speed("ctr(des3_ede)", ENCRYPT, sec,
1409 des3_speed_template, DES3_SPEED_VECTORS,
1411 test_cipher_speed("ctr(des3_ede)", DECRYPT, sec,
1412 des3_speed_template, DES3_SPEED_VECTORS,
1417 test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
1418 speed_template_16_24_32);
1419 test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
1420 speed_template_16_24_32);
1421 test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
1422 speed_template_16_24_32);
1423 test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
1424 speed_template_16_24_32);
1425 test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
1426 speed_template_16_24_32);
1427 test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
1428 speed_template_16_24_32);
1429 test_cipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
1430 speed_template_32_40_48);
1431 test_cipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
1432 speed_template_32_40_48);
1433 test_cipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
1434 speed_template_32_48_64);
1435 test_cipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
1436 speed_template_32_48_64);
1440 test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
1441 speed_template_8_32);
1442 test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
1443 speed_template_8_32);
1444 test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
1445 speed_template_8_32);
1446 test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
1447 speed_template_8_32);
1448 test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
1449 speed_template_8_32);
1450 test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
1451 speed_template_8_32);
1455 test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
1457 test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
1459 test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
1461 test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
1466 test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
1467 speed_template_16_24_32);
1468 test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
1469 speed_template_16_24_32);
1470 test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
1471 speed_template_16_24_32);
1472 test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
1473 speed_template_16_24_32);
1474 test_cipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
1475 speed_template_16_24_32);
1476 test_cipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
1477 speed_template_16_24_32);
1478 test_cipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
1479 speed_template_32_40_48);
1480 test_cipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
1481 speed_template_32_40_48);
1482 test_cipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
1483 speed_template_32_48_64);
1484 test_cipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
1485 speed_template_32_48_64);
1489 test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0,
1490 speed_template_16_32);
1494 test_cipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
1495 speed_template_16_32);
1496 test_cipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
1497 speed_template_16_32);
1498 test_cipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
1499 speed_template_16_32);
1500 test_cipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
1501 speed_template_16_32);
1502 test_cipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
1503 speed_template_16_32);
1504 test_cipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
1505 speed_template_16_32);
1506 test_cipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
1507 speed_template_32_48);
1508 test_cipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
1509 speed_template_32_48);
1510 test_cipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
1511 speed_template_32_64);
1512 test_cipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
1513 speed_template_32_64);
1517 test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
1522 test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
1523 speed_template_8_16);
1524 test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
1525 speed_template_8_16);
1526 test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
1527 speed_template_8_16);
1528 test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
1529 speed_template_8_16);
1530 test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
1531 speed_template_8_16);
1532 test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
1533 speed_template_8_16);
1537 test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
1538 speed_template_16_32);
1539 test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
1540 speed_template_16_32);
1541 test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
1542 speed_template_16_32);
1543 test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
1544 speed_template_16_32);
1545 test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
1546 speed_template_16_32);
1547 test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
1548 speed_template_16_32);
1549 test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
1550 speed_template_32_48);
1551 test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
1552 speed_template_32_48);
1553 test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
1554 speed_template_32_64);
1555 test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
1556 speed_template_32_64);
1560 test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec,
1561 NULL, 0, 16, 16, aead_speed_template_20);
1562 test_aead_speed("gcm(aes)", ENCRYPT, sec,
1563 NULL, 0, 16, 8, speed_template_16_24_32);
1567 test_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec,
1568 NULL, 0, 16, 16, aead_speed_template_19);
1572 test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, sec,
1573 NULL, 0, 16, 8, aead_speed_template_36);
1577 test_cipher_speed("chacha20", ENCRYPT, sec, NULL, 0,
1583 test_hash_speed(alg, sec, generic_hash_speed_template);
1588 test_hash_speed("md4", sec, generic_hash_speed_template);
1589 if (mode > 300 && mode < 400) break;
1592 test_hash_speed("md5", sec, generic_hash_speed_template);
1593 if (mode > 300 && mode < 400) break;
1596 test_hash_speed("sha1", sec, generic_hash_speed_template);
1597 if (mode > 300 && mode < 400) break;
1600 test_hash_speed("sha256", sec, generic_hash_speed_template);
1601 if (mode > 300 && mode < 400) break;
1604 test_hash_speed("sha384", sec, generic_hash_speed_template);
1605 if (mode > 300 && mode < 400) break;
1608 test_hash_speed("sha512", sec, generic_hash_speed_template);
1609 if (mode > 300 && mode < 400) break;
1612 test_hash_speed("wp256", sec, generic_hash_speed_template);
1613 if (mode > 300 && mode < 400) break;
1616 test_hash_speed("wp384", sec, generic_hash_speed_template);
1617 if (mode > 300 && mode < 400) break;
1620 test_hash_speed("wp512", sec, generic_hash_speed_template);
1621 if (mode > 300 && mode < 400) break;
1624 test_hash_speed("tgr128", sec, generic_hash_speed_template);
1625 if (mode > 300 && mode < 400) break;
1628 test_hash_speed("tgr160", sec, generic_hash_speed_template);
1629 if (mode > 300 && mode < 400) break;
1632 test_hash_speed("tgr192", sec, generic_hash_speed_template);
1633 if (mode > 300 && mode < 400) break;
1636 test_hash_speed("sha224", sec, generic_hash_speed_template);
1637 if (mode > 300 && mode < 400) break;
1640 test_hash_speed("rmd128", sec, generic_hash_speed_template);
1641 if (mode > 300 && mode < 400) break;
1644 test_hash_speed("rmd160", sec, generic_hash_speed_template);
1645 if (mode > 300 && mode < 400) break;
1648 test_hash_speed("rmd256", sec, generic_hash_speed_template);
1649 if (mode > 300 && mode < 400) break;
1652 test_hash_speed("rmd320", sec, generic_hash_speed_template);
1653 if (mode > 300 && mode < 400) break;
1656 test_hash_speed("ghash-generic", sec, hash_speed_template_16);
1657 if (mode > 300 && mode < 400) break;
1660 test_hash_speed("crc32c", sec, generic_hash_speed_template);
1661 if (mode > 300 && mode < 400) break;
1664 test_hash_speed("crct10dif", sec, generic_hash_speed_template);
1665 if (mode > 300 && mode < 400) break;
1668 test_hash_speed("poly1305", sec, poly1305_speed_template);
1669 if (mode > 300 && mode < 400) break;
1672 test_hash_speed("sha3-224", sec, generic_hash_speed_template);
1673 if (mode > 300 && mode < 400) break;
1676 test_hash_speed("sha3-256", sec, generic_hash_speed_template);
1677 if (mode > 300 && mode < 400) break;
1680 test_hash_speed("sha3-384", sec, generic_hash_speed_template);
1681 if (mode > 300 && mode < 400) break;
1684 test_hash_speed("sha3-512", sec, generic_hash_speed_template);
1685 if (mode > 300 && mode < 400) break;
1688 test_hash_speed("sm3", sec, generic_hash_speed_template);
1689 if (mode > 300 && mode < 400) break;
1696 test_ahash_speed(alg, sec, generic_hash_speed_template);
1701 test_ahash_speed("md4", sec, generic_hash_speed_template);
1702 if (mode > 400 && mode < 500) break;
1705 test_ahash_speed("md5", sec, generic_hash_speed_template);
1706 if (mode > 400 && mode < 500) break;
1709 test_ahash_speed("sha1", sec, generic_hash_speed_template);
1710 if (mode > 400 && mode < 500) break;
1713 test_ahash_speed("sha256", sec, generic_hash_speed_template);
1714 if (mode > 400 && mode < 500) break;
1717 test_ahash_speed("sha384", sec, generic_hash_speed_template);
1718 if (mode > 400 && mode < 500) break;
1721 test_ahash_speed("sha512", sec, generic_hash_speed_template);
1722 if (mode > 400 && mode < 500) break;
1725 test_ahash_speed("wp256", sec, generic_hash_speed_template);
1726 if (mode > 400 && mode < 500) break;
1729 test_ahash_speed("wp384", sec, generic_hash_speed_template);
1730 if (mode > 400 && mode < 500) break;
1733 test_ahash_speed("wp512", sec, generic_hash_speed_template);
1734 if (mode > 400 && mode < 500) break;
1737 test_ahash_speed("tgr128", sec, generic_hash_speed_template);
1738 if (mode > 400 && mode < 500) break;
1741 test_ahash_speed("tgr160", sec, generic_hash_speed_template);
1742 if (mode > 400 && mode < 500) break;
1745 test_ahash_speed("tgr192", sec, generic_hash_speed_template);
1746 if (mode > 400 && mode < 500) break;
1749 test_ahash_speed("sha224", sec, generic_hash_speed_template);
1750 if (mode > 400 && mode < 500) break;
1753 test_ahash_speed("rmd128", sec, generic_hash_speed_template);
1754 if (mode > 400 && mode < 500) break;
1757 test_ahash_speed("rmd160", sec, generic_hash_speed_template);
1758 if (mode > 400 && mode < 500) break;
1761 test_ahash_speed("rmd256", sec, generic_hash_speed_template);
1762 if (mode > 400 && mode < 500) break;
1765 test_ahash_speed("rmd320", sec, generic_hash_speed_template);
1766 if (mode > 400 && mode < 500) break;
1769 test_ahash_speed("sha3-224", sec, generic_hash_speed_template);
1770 if (mode > 400 && mode < 500) break;
1773 test_ahash_speed("sha3-256", sec, generic_hash_speed_template);
1774 if (mode > 400 && mode < 500) break;
1777 test_ahash_speed("sha3-384", sec, generic_hash_speed_template);
1778 if (mode > 400 && mode < 500) break;
1781 test_ahash_speed("sha3-512", sec, generic_hash_speed_template);
1782 if (mode > 400 && mode < 500) break;
1785 test_mb_ahash_speed("sha1", sec, generic_hash_speed_template);
1786 if (mode > 400 && mode < 500) break;
1789 test_mb_ahash_speed("sha256", sec, generic_hash_speed_template);
1790 if (mode > 400 && mode < 500) break;
1793 test_mb_ahash_speed("sha512", sec, generic_hash_speed_template);
1794 if (mode > 400 && mode < 500) break;
1797 test_mb_ahash_speed("sm3", sec, generic_hash_speed_template);
1798 if (mode > 400 && mode < 500) break;
1804 test_acipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
1805 speed_template_16_24_32);
1806 test_acipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
1807 speed_template_16_24_32);
1808 test_acipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
1809 speed_template_16_24_32);
1810 test_acipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
1811 speed_template_16_24_32);
1812 test_acipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
1813 speed_template_32_40_48);
1814 test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
1815 speed_template_32_40_48);
1816 test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
1817 speed_template_32_64);
1818 test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
1819 speed_template_32_64);
1820 test_acipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
1821 speed_template_16_24_32);
1822 test_acipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
1823 speed_template_16_24_32);
1824 test_acipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
1825 speed_template_16_24_32);
1826 test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
1827 speed_template_16_24_32);
1828 test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
1829 speed_template_16_24_32);
1830 test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
1831 speed_template_16_24_32);
1832 test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0,
1833 speed_template_16_24_32);
1834 test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0,
1835 speed_template_16_24_32);
1836 test_acipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL, 0,
1837 speed_template_20_28_36);
1838 test_acipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL, 0,
1839 speed_template_20_28_36);
1843 test_acipher_speed("ecb(des3_ede)", ENCRYPT, sec,
1844 des3_speed_template, DES3_SPEED_VECTORS,
1846 test_acipher_speed("ecb(des3_ede)", DECRYPT, sec,
1847 des3_speed_template, DES3_SPEED_VECTORS,
1849 test_acipher_speed("cbc(des3_ede)", ENCRYPT, sec,
1850 des3_speed_template, DES3_SPEED_VECTORS,
1852 test_acipher_speed("cbc(des3_ede)", DECRYPT, sec,
1853 des3_speed_template, DES3_SPEED_VECTORS,
1855 test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec,
1856 des3_speed_template, DES3_SPEED_VECTORS,
1858 test_acipher_speed("cfb(des3_ede)", DECRYPT, sec,
1859 des3_speed_template, DES3_SPEED_VECTORS,
1861 test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec,
1862 des3_speed_template, DES3_SPEED_VECTORS,
1864 test_acipher_speed("ofb(des3_ede)", DECRYPT, sec,
1865 des3_speed_template, DES3_SPEED_VECTORS,
1870 test_acipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
1872 test_acipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
1874 test_acipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
1876 test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
1878 test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0,
1880 test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0,
1882 test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0,
1884 test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0,
1889 test_acipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
1890 speed_template_16_32);
1891 test_acipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
1892 speed_template_16_32);
1893 test_acipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
1894 speed_template_16_32);
1895 test_acipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
1896 speed_template_16_32);
1897 test_acipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
1898 speed_template_16_32);
1899 test_acipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
1900 speed_template_16_32);
1901 test_acipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
1902 speed_template_32_48);
1903 test_acipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
1904 speed_template_32_48);
1905 test_acipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
1906 speed_template_32_64);
1907 test_acipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
1908 speed_template_32_64);
1912 test_acipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
1913 speed_template_16_24_32);
1914 test_acipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
1915 speed_template_16_24_32);
1916 test_acipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
1917 speed_template_16_24_32);
1918 test_acipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
1919 speed_template_16_24_32);
1920 test_acipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
1921 speed_template_16_24_32);
1922 test_acipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
1923 speed_template_16_24_32);
1924 test_acipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
1925 speed_template_32_40_48);
1926 test_acipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
1927 speed_template_32_40_48);
1928 test_acipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
1929 speed_template_32_48_64);
1930 test_acipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
1931 speed_template_32_48_64);
1935 test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
1940 test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
1941 speed_template_8_16);
1942 test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
1943 speed_template_8_16);
1944 test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
1945 speed_template_8_16);
1946 test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
1947 speed_template_8_16);
1948 test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
1949 speed_template_8_16);
1950 test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
1951 speed_template_8_16);
1955 test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
1956 speed_template_16_32);
1957 test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
1958 speed_template_16_32);
1959 test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
1960 speed_template_16_32);
1961 test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
1962 speed_template_16_32);
1963 test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
1964 speed_template_16_32);
1965 test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
1966 speed_template_16_32);
1967 test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
1968 speed_template_32_48);
1969 test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
1970 speed_template_32_48);
1971 test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
1972 speed_template_32_64);
1973 test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
1974 speed_template_32_64);
1978 test_acipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
1979 speed_template_16_32);
1980 test_acipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
1981 speed_template_16_32);
1982 test_acipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
1983 speed_template_16_32);
1984 test_acipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
1985 speed_template_16_32);
1986 test_acipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
1987 speed_template_16_32);
1988 test_acipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
1989 speed_template_16_32);
1990 test_acipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
1991 speed_template_32_48);
1992 test_acipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
1993 speed_template_32_48);
1994 test_acipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
1995 speed_template_32_64);
1996 test_acipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
1997 speed_template_32_64);
2001 test_acipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
2002 speed_template_8_32);
2003 test_acipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
2004 speed_template_8_32);
2005 test_acipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
2006 speed_template_8_32);
2007 test_acipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
2008 speed_template_8_32);
2009 test_acipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
2010 speed_template_8_32);
2011 test_acipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
2012 speed_template_8_32);
2023 static int __init tcrypt_mod_init(void)
2028 for (i = 0; i < TVMEMSIZE; i++) {
2029 tvmem[i] = (void *)__get_free_page(GFP_KERNEL);
2034 err = do_test(alg, type, mask, mode);
2037 printk(KERN_ERR "tcrypt: one or more tests failed!\n");
2040 pr_debug("all tests passed\n");
2043 /* We intentionaly return -EAGAIN to prevent keeping the module,
2044 * unless we're running in fips mode. It does all its work from
2045 * init() and doesn't offer any runtime functionality, but in
2046 * the fips case, checking for a successful load is helpful.
2047 * => we don't need it in the memory, do we?
2054 for (i = 0; i < TVMEMSIZE && tvmem[i]; i++)
2055 free_page((unsigned long)tvmem[i]);
2061 * If an init function is provided, an exit function must also be provided
2062 * to allow module unload.
2064 static void __exit tcrypt_mod_fini(void) { }
2066 module_init(tcrypt_mod_init);
2067 module_exit(tcrypt_mod_fini);
2069 module_param(alg, charp, 0);
2070 module_param(type, uint, 0);
2071 module_param(mask, uint, 0);
2072 module_param(mode, int, 0);
2073 module_param(sec, uint, 0);
2074 MODULE_PARM_DESC(sec, "Length in seconds of speed tests "
2075 "(defaults to zero which uses CPU cycles instead)");
2077 MODULE_LICENSE("GPL");
2078 MODULE_DESCRIPTION("Quick & dirty crypto testing module");
2079 MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");