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 #include <crypto/hash.h>
26 #include <linux/err.h>
27 #include <linux/init.h>
28 #include <linux/gfp.h>
29 #include <linux/module.h>
30 #include <linux/scatterlist.h>
31 #include <linux/string.h>
32 #include <linux/moduleparam.h>
33 #include <linux/jiffies.h>
34 #include <linux/timex.h>
35 #include <linux/interrupt.h>
40 * Need slab memory for testing (size in number of pages).
45 * Used by test_cipher_speed()
51 * Used by test_cipher_speed()
53 static unsigned int sec
;
55 static char *alg
= NULL
;
59 static char *tvmem
[TVMEMSIZE
];
61 static char *check
[] = {
62 "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256",
63 "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
64 "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
65 "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
66 "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320",
67 "lzo", "cts", "zlib", NULL
70 static int test_cipher_jiffies(struct blkcipher_desc
*desc
, int enc
,
71 struct scatterlist
*sg
, int blen
, int sec
)
73 unsigned long start
, end
;
77 for (start
= jiffies
, end
= start
+ sec
* HZ
, bcount
= 0;
78 time_before(jiffies
, end
); bcount
++) {
80 ret
= crypto_blkcipher_encrypt(desc
, sg
, sg
, blen
);
82 ret
= crypto_blkcipher_decrypt(desc
, sg
, sg
, blen
);
88 printk("%d operations in %d seconds (%ld bytes)\n",
89 bcount
, sec
, (long)bcount
* blen
);
93 static int test_cipher_cycles(struct blkcipher_desc
*desc
, int enc
,
94 struct scatterlist
*sg
, int blen
)
96 unsigned long cycles
= 0;
103 for (i
= 0; i
< 4; i
++) {
105 ret
= crypto_blkcipher_encrypt(desc
, sg
, sg
, blen
);
107 ret
= crypto_blkcipher_decrypt(desc
, sg
, sg
, blen
);
113 /* The real thing. */
114 for (i
= 0; i
< 8; i
++) {
117 start
= get_cycles();
119 ret
= crypto_blkcipher_encrypt(desc
, sg
, sg
, blen
);
121 ret
= crypto_blkcipher_decrypt(desc
, sg
, sg
, blen
);
127 cycles
+= end
- start
;
134 printk("1 operation in %lu cycles (%d bytes)\n",
135 (cycles
+ 4) / 8, blen
);
140 static u32 block_sizes
[] = { 16, 64, 256, 1024, 8192, 0 };
142 static void test_cipher_speed(const char *algo
, int enc
, unsigned int sec
,
143 struct cipher_speed_template
*template,
144 unsigned int tcount
, u8
*keysize
)
146 unsigned int ret
, i
, j
, iv_len
;
149 struct crypto_blkcipher
*tfm
;
150 struct blkcipher_desc desc
;
159 printk("\ntesting speed of %s %s\n", algo
, e
);
161 tfm
= crypto_alloc_blkcipher(algo
, 0, CRYPTO_ALG_ASYNC
);
164 printk("failed to load transform for %s: %ld\n", algo
,
174 b_size
= block_sizes
;
176 struct scatterlist sg
[TVMEMSIZE
];
178 if ((*keysize
+ *b_size
) > TVMEMSIZE
* PAGE_SIZE
) {
179 printk("template (%u) too big for "
180 "tvmem (%lu)\n", *keysize
+ *b_size
,
181 TVMEMSIZE
* PAGE_SIZE
);
185 printk("test %u (%d bit key, %d byte blocks): ", i
,
186 *keysize
* 8, *b_size
);
188 memset(tvmem
[0], 0xff, PAGE_SIZE
);
190 /* set key, plain text and IV */
192 for (j
= 0; j
< tcount
; j
++) {
193 if (template[j
].klen
== *keysize
) {
194 key
= template[j
].key
;
199 ret
= crypto_blkcipher_setkey(tfm
, key
, *keysize
);
201 printk("setkey() failed flags=%x\n",
202 crypto_blkcipher_get_flags(tfm
));
206 sg_init_table(sg
, TVMEMSIZE
);
207 sg_set_buf(sg
, tvmem
[0] + *keysize
,
208 PAGE_SIZE
- *keysize
);
209 for (j
= 1; j
< TVMEMSIZE
; j
++) {
210 sg_set_buf(sg
+ j
, tvmem
[j
], PAGE_SIZE
);
211 memset (tvmem
[j
], 0xff, PAGE_SIZE
);
214 iv_len
= crypto_blkcipher_ivsize(tfm
);
216 memset(&iv
, 0xff, iv_len
);
217 crypto_blkcipher_set_iv(tfm
, iv
, iv_len
);
221 ret
= test_cipher_jiffies(&desc
, enc
, sg
,
224 ret
= test_cipher_cycles(&desc
, enc
, sg
,
228 printk("%s() failed flags=%x\n", e
, desc
.flags
);
238 crypto_free_blkcipher(tfm
);
241 static int test_hash_jiffies_digest(struct hash_desc
*desc
,
242 struct scatterlist
*sg
, int blen
,
245 unsigned long start
, end
;
249 for (start
= jiffies
, end
= start
+ sec
* HZ
, bcount
= 0;
250 time_before(jiffies
, end
); bcount
++) {
251 ret
= crypto_hash_digest(desc
, sg
, blen
, out
);
256 printk("%6u opers/sec, %9lu bytes/sec\n",
257 bcount
/ sec
, ((long)bcount
* blen
) / sec
);
262 static int test_hash_jiffies(struct hash_desc
*desc
, struct scatterlist
*sg
,
263 int blen
, int plen
, char *out
, int sec
)
265 unsigned long start
, end
;
270 return test_hash_jiffies_digest(desc
, sg
, blen
, out
, sec
);
272 for (start
= jiffies
, end
= start
+ sec
* HZ
, bcount
= 0;
273 time_before(jiffies
, end
); bcount
++) {
274 ret
= crypto_hash_init(desc
);
277 for (pcount
= 0; pcount
< blen
; pcount
+= plen
) {
278 ret
= crypto_hash_update(desc
, sg
, plen
);
282 /* we assume there is enough space in 'out' for the result */
283 ret
= crypto_hash_final(desc
, out
);
288 printk("%6u opers/sec, %9lu bytes/sec\n",
289 bcount
/ sec
, ((long)bcount
* blen
) / sec
);
294 static int test_hash_cycles_digest(struct hash_desc
*desc
,
295 struct scatterlist
*sg
, int blen
, char *out
)
297 unsigned long cycles
= 0;
304 for (i
= 0; i
< 4; i
++) {
305 ret
= crypto_hash_digest(desc
, sg
, blen
, out
);
310 /* The real thing. */
311 for (i
= 0; i
< 8; i
++) {
314 start
= get_cycles();
316 ret
= crypto_hash_digest(desc
, sg
, blen
, out
);
322 cycles
+= end
- start
;
331 printk("%6lu cycles/operation, %4lu cycles/byte\n",
332 cycles
/ 8, cycles
/ (8 * blen
));
337 static int test_hash_cycles(struct hash_desc
*desc
, struct scatterlist
*sg
,
338 int blen
, int plen
, char *out
)
340 unsigned long cycles
= 0;
345 return test_hash_cycles_digest(desc
, sg
, blen
, out
);
350 for (i
= 0; i
< 4; i
++) {
351 ret
= crypto_hash_init(desc
);
354 for (pcount
= 0; pcount
< blen
; pcount
+= plen
) {
355 ret
= crypto_hash_update(desc
, sg
, plen
);
359 ret
= crypto_hash_final(desc
, out
);
364 /* The real thing. */
365 for (i
= 0; i
< 8; i
++) {
368 start
= get_cycles();
370 ret
= crypto_hash_init(desc
);
373 for (pcount
= 0; pcount
< blen
; pcount
+= plen
) {
374 ret
= crypto_hash_update(desc
, sg
, plen
);
378 ret
= crypto_hash_final(desc
, out
);
384 cycles
+= end
- start
;
393 printk("%6lu cycles/operation, %4lu cycles/byte\n",
394 cycles
/ 8, cycles
/ (8 * blen
));
399 static void test_hash_sg_init(struct scatterlist
*sg
)
403 sg_init_table(sg
, TVMEMSIZE
);
404 for (i
= 0; i
< TVMEMSIZE
; i
++) {
405 sg_set_buf(sg
+ i
, tvmem
[i
], PAGE_SIZE
);
406 memset(tvmem
[i
], 0xff, PAGE_SIZE
);
410 static void test_hash_speed(const char *algo
, unsigned int sec
,
411 struct hash_speed
*speed
)
413 struct scatterlist sg
[TVMEMSIZE
];
414 struct crypto_hash
*tfm
;
415 struct hash_desc desc
;
416 static char output
[1024];
420 printk(KERN_INFO
"\ntesting speed of %s\n", algo
);
422 tfm
= crypto_alloc_hash(algo
, 0, CRYPTO_ALG_ASYNC
);
425 printk(KERN_ERR
"failed to load transform for %s: %ld\n", algo
,
433 if (crypto_hash_digestsize(tfm
) > sizeof(output
)) {
434 printk(KERN_ERR
"digestsize(%u) > outputbuffer(%zu)\n",
435 crypto_hash_digestsize(tfm
), sizeof(output
));
439 test_hash_sg_init(sg
);
440 for (i
= 0; speed
[i
].blen
!= 0; i
++) {
441 if (speed
[i
].blen
> TVMEMSIZE
* PAGE_SIZE
) {
443 "template (%u) too big for tvmem (%lu)\n",
444 speed
[i
].blen
, TVMEMSIZE
* PAGE_SIZE
);
449 crypto_hash_setkey(tfm
, tvmem
[0], speed
[i
].klen
);
451 printk(KERN_INFO
"test%3u "
452 "(%5u byte blocks,%5u bytes per update,%4u updates): ",
453 i
, speed
[i
].blen
, speed
[i
].plen
, speed
[i
].blen
/ speed
[i
].plen
);
456 ret
= test_hash_jiffies(&desc
, sg
, speed
[i
].blen
,
457 speed
[i
].plen
, output
, sec
);
459 ret
= test_hash_cycles(&desc
, sg
, speed
[i
].blen
,
460 speed
[i
].plen
, output
);
463 printk(KERN_ERR
"hashing failed ret=%d\n", ret
);
469 crypto_free_hash(tfm
);
472 struct tcrypt_result
{
473 struct completion completion
;
477 static void tcrypt_complete(struct crypto_async_request
*req
, int err
)
479 struct tcrypt_result
*res
= req
->data
;
481 if (err
== -EINPROGRESS
)
485 complete(&res
->completion
);
488 static inline int do_one_ahash_op(struct ahash_request
*req
, int ret
)
490 if (ret
== -EINPROGRESS
|| ret
== -EBUSY
) {
491 struct tcrypt_result
*tr
= req
->base
.data
;
493 ret
= wait_for_completion_interruptible(&tr
->completion
);
496 INIT_COMPLETION(tr
->completion
);
501 static int test_ahash_jiffies_digest(struct ahash_request
*req
, int blen
,
504 unsigned long start
, end
;
508 for (start
= jiffies
, end
= start
+ sec
* HZ
, bcount
= 0;
509 time_before(jiffies
, end
); bcount
++) {
510 ret
= do_one_ahash_op(req
, crypto_ahash_digest(req
));
515 printk("%6u opers/sec, %9lu bytes/sec\n",
516 bcount
/ sec
, ((long)bcount
* blen
) / sec
);
521 static int test_ahash_jiffies(struct ahash_request
*req
, int blen
,
522 int plen
, char *out
, int sec
)
524 unsigned long start
, end
;
529 return test_ahash_jiffies_digest(req
, blen
, out
, sec
);
531 for (start
= jiffies
, end
= start
+ sec
* HZ
, bcount
= 0;
532 time_before(jiffies
, end
); bcount
++) {
533 ret
= crypto_ahash_init(req
);
536 for (pcount
= 0; pcount
< blen
; pcount
+= plen
) {
537 ret
= do_one_ahash_op(req
, crypto_ahash_update(req
));
541 /* we assume there is enough space in 'out' for the result */
542 ret
= do_one_ahash_op(req
, crypto_ahash_final(req
));
547 pr_cont("%6u opers/sec, %9lu bytes/sec\n",
548 bcount
/ sec
, ((long)bcount
* blen
) / sec
);
553 static int test_ahash_cycles_digest(struct ahash_request
*req
, int blen
,
556 unsigned long cycles
= 0;
560 for (i
= 0; i
< 4; i
++) {
561 ret
= do_one_ahash_op(req
, crypto_ahash_digest(req
));
566 /* The real thing. */
567 for (i
= 0; i
< 8; i
++) {
570 start
= get_cycles();
572 ret
= do_one_ahash_op(req
, crypto_ahash_digest(req
));
578 cycles
+= end
- start
;
585 pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
586 cycles
/ 8, cycles
/ (8 * blen
));
591 static int test_ahash_cycles(struct ahash_request
*req
, int blen
,
594 unsigned long cycles
= 0;
598 return test_ahash_cycles_digest(req
, blen
, out
);
601 for (i
= 0; i
< 4; i
++) {
602 ret
= crypto_ahash_init(req
);
605 for (pcount
= 0; pcount
< blen
; pcount
+= plen
) {
606 ret
= do_one_ahash_op(req
, crypto_ahash_update(req
));
610 ret
= do_one_ahash_op(req
, crypto_ahash_final(req
));
615 /* The real thing. */
616 for (i
= 0; i
< 8; i
++) {
619 start
= get_cycles();
621 ret
= crypto_ahash_init(req
);
624 for (pcount
= 0; pcount
< blen
; pcount
+= plen
) {
625 ret
= do_one_ahash_op(req
, crypto_ahash_update(req
));
629 ret
= do_one_ahash_op(req
, crypto_ahash_final(req
));
635 cycles
+= end
- start
;
642 pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
643 cycles
/ 8, cycles
/ (8 * blen
));
648 static void test_ahash_speed(const char *algo
, unsigned int sec
,
649 struct hash_speed
*speed
)
651 struct scatterlist sg
[TVMEMSIZE
];
652 struct tcrypt_result tresult
;
653 struct ahash_request
*req
;
654 struct crypto_ahash
*tfm
;
655 static char output
[1024];
658 printk(KERN_INFO
"\ntesting speed of async %s\n", algo
);
660 tfm
= crypto_alloc_ahash(algo
, 0, 0);
662 pr_err("failed to load transform for %s: %ld\n",
667 if (crypto_ahash_digestsize(tfm
) > sizeof(output
)) {
668 pr_err("digestsize(%u) > outputbuffer(%zu)\n",
669 crypto_ahash_digestsize(tfm
), sizeof(output
));
673 test_hash_sg_init(sg
);
674 req
= ahash_request_alloc(tfm
, GFP_KERNEL
);
676 pr_err("ahash request allocation failure\n");
680 init_completion(&tresult
.completion
);
681 ahash_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
682 tcrypt_complete
, &tresult
);
684 for (i
= 0; speed
[i
].blen
!= 0; i
++) {
685 if (speed
[i
].blen
> TVMEMSIZE
* PAGE_SIZE
) {
686 pr_err("template (%u) too big for tvmem (%lu)\n",
687 speed
[i
].blen
, TVMEMSIZE
* PAGE_SIZE
);
692 "(%5u byte blocks,%5u bytes per update,%4u updates): ",
693 i
, speed
[i
].blen
, speed
[i
].plen
, speed
[i
].blen
/ speed
[i
].plen
);
695 ahash_request_set_crypt(req
, sg
, output
, speed
[i
].plen
);
698 ret
= test_ahash_jiffies(req
, speed
[i
].blen
,
699 speed
[i
].plen
, output
, sec
);
701 ret
= test_ahash_cycles(req
, speed
[i
].blen
,
702 speed
[i
].plen
, output
);
705 pr_err("hashing failed ret=%d\n", ret
);
710 ahash_request_free(req
);
713 crypto_free_ahash(tfm
);
716 static inline int do_one_acipher_op(struct ablkcipher_request
*req
, int ret
)
718 if (ret
== -EINPROGRESS
|| ret
== -EBUSY
) {
719 struct tcrypt_result
*tr
= req
->base
.data
;
721 ret
= wait_for_completion_interruptible(&tr
->completion
);
724 INIT_COMPLETION(tr
->completion
);
730 static int test_acipher_jiffies(struct ablkcipher_request
*req
, int enc
,
733 unsigned long start
, end
;
737 for (start
= jiffies
, end
= start
+ sec
* HZ
, bcount
= 0;
738 time_before(jiffies
, end
); bcount
++) {
740 ret
= do_one_acipher_op(req
,
741 crypto_ablkcipher_encrypt(req
));
743 ret
= do_one_acipher_op(req
,
744 crypto_ablkcipher_decrypt(req
));
750 pr_cont("%d operations in %d seconds (%ld bytes)\n",
751 bcount
, sec
, (long)bcount
* blen
);
755 static int test_acipher_cycles(struct ablkcipher_request
*req
, int enc
,
758 unsigned long cycles
= 0;
763 for (i
= 0; i
< 4; i
++) {
765 ret
= do_one_acipher_op(req
,
766 crypto_ablkcipher_encrypt(req
));
768 ret
= do_one_acipher_op(req
,
769 crypto_ablkcipher_decrypt(req
));
775 /* The real thing. */
776 for (i
= 0; i
< 8; i
++) {
779 start
= get_cycles();
781 ret
= do_one_acipher_op(req
,
782 crypto_ablkcipher_encrypt(req
));
784 ret
= do_one_acipher_op(req
,
785 crypto_ablkcipher_decrypt(req
));
791 cycles
+= end
- start
;
796 pr_cont("1 operation in %lu cycles (%d bytes)\n",
797 (cycles
+ 4) / 8, blen
);
802 static void test_acipher_speed(const char *algo
, int enc
, unsigned int sec
,
803 struct cipher_speed_template
*template,
804 unsigned int tcount
, u8
*keysize
)
806 unsigned int ret
, i
, j
, k
, iv_len
;
807 struct tcrypt_result tresult
;
810 struct ablkcipher_request
*req
;
811 struct crypto_ablkcipher
*tfm
;
820 pr_info("\ntesting speed of async %s %s\n", algo
, e
);
822 init_completion(&tresult
.completion
);
824 tfm
= crypto_alloc_ablkcipher(algo
, 0, 0);
827 pr_err("failed to load transform for %s: %ld\n", algo
,
832 req
= ablkcipher_request_alloc(tfm
, GFP_KERNEL
);
834 pr_err("tcrypt: skcipher: Failed to allocate request for %s\n",
839 ablkcipher_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
840 tcrypt_complete
, &tresult
);
844 b_size
= block_sizes
;
847 struct scatterlist sg
[TVMEMSIZE
];
849 if ((*keysize
+ *b_size
) > TVMEMSIZE
* PAGE_SIZE
) {
850 pr_err("template (%u) too big for "
851 "tvmem (%lu)\n", *keysize
+ *b_size
,
852 TVMEMSIZE
* PAGE_SIZE
);
856 pr_info("test %u (%d bit key, %d byte blocks): ", i
,
857 *keysize
* 8, *b_size
);
859 memset(tvmem
[0], 0xff, PAGE_SIZE
);
861 /* set key, plain text and IV */
863 for (j
= 0; j
< tcount
; j
++) {
864 if (template[j
].klen
== *keysize
) {
865 key
= template[j
].key
;
870 crypto_ablkcipher_clear_flags(tfm
, ~0);
872 ret
= crypto_ablkcipher_setkey(tfm
, key
, *keysize
);
874 pr_err("setkey() failed flags=%x\n",
875 crypto_ablkcipher_get_flags(tfm
));
879 sg_init_table(sg
, TVMEMSIZE
);
881 k
= *keysize
+ *b_size
;
883 sg_set_buf(sg
, tvmem
[0] + *keysize
,
884 PAGE_SIZE
- *keysize
);
887 while (k
> PAGE_SIZE
) {
888 sg_set_buf(sg
+ j
, tvmem
[j
], PAGE_SIZE
);
889 memset(tvmem
[j
], 0xff, PAGE_SIZE
);
893 sg_set_buf(sg
+ j
, tvmem
[j
], k
);
894 memset(tvmem
[j
], 0xff, k
);
896 sg_set_buf(sg
, tvmem
[0] + *keysize
, *b_size
);
899 iv_len
= crypto_ablkcipher_ivsize(tfm
);
901 memset(&iv
, 0xff, iv_len
);
903 ablkcipher_request_set_crypt(req
, sg
, sg
, *b_size
, iv
);
906 ret
= test_acipher_jiffies(req
, enc
,
909 ret
= test_acipher_cycles(req
, enc
,
913 pr_err("%s() failed flags=%x\n", e
,
914 crypto_ablkcipher_get_flags(tfm
));
924 ablkcipher_request_free(req
);
926 crypto_free_ablkcipher(tfm
);
929 static void test_available(void)
934 printk("alg %s ", *name
);
935 printk(crypto_has_alg(*name
, 0, 0) ?
936 "found\n" : "not found\n");
941 static inline int tcrypt_test(const char *alg
)
945 ret
= alg_test(alg
, alg
, 0, 0);
946 /* non-fips algs return -EINVAL in fips mode */
947 if (fips_enabled
&& ret
== -EINVAL
)
952 static int do_test(int m
)
959 for (i
= 1; i
< 200; i
++)
964 ret
+= tcrypt_test("md5");
968 ret
+= tcrypt_test("sha1");
972 ret
+= tcrypt_test("ecb(des)");
973 ret
+= tcrypt_test("cbc(des)");
974 ret
+= tcrypt_test("ctr(des)");
978 ret
+= tcrypt_test("ecb(des3_ede)");
979 ret
+= tcrypt_test("cbc(des3_ede)");
980 ret
+= tcrypt_test("ctr(des3_ede)");
984 ret
+= tcrypt_test("md4");
988 ret
+= tcrypt_test("sha256");
992 ret
+= tcrypt_test("ecb(blowfish)");
993 ret
+= tcrypt_test("cbc(blowfish)");
994 ret
+= tcrypt_test("ctr(blowfish)");
998 ret
+= tcrypt_test("ecb(twofish)");
999 ret
+= tcrypt_test("cbc(twofish)");
1000 ret
+= tcrypt_test("ctr(twofish)");
1001 ret
+= tcrypt_test("lrw(twofish)");
1002 ret
+= tcrypt_test("xts(twofish)");
1006 ret
+= tcrypt_test("ecb(serpent)");
1007 ret
+= tcrypt_test("cbc(serpent)");
1008 ret
+= tcrypt_test("ctr(serpent)");
1009 ret
+= tcrypt_test("lrw(serpent)");
1010 ret
+= tcrypt_test("xts(serpent)");
1014 ret
+= tcrypt_test("ecb(aes)");
1015 ret
+= tcrypt_test("cbc(aes)");
1016 ret
+= tcrypt_test("lrw(aes)");
1017 ret
+= tcrypt_test("xts(aes)");
1018 ret
+= tcrypt_test("ctr(aes)");
1019 ret
+= tcrypt_test("rfc3686(ctr(aes))");
1023 ret
+= tcrypt_test("sha384");
1027 ret
+= tcrypt_test("sha512");
1031 ret
+= tcrypt_test("deflate");
1035 ret
+= tcrypt_test("ecb(cast5)");
1036 ret
+= tcrypt_test("cbc(cast5)");
1037 ret
+= tcrypt_test("ctr(cast5)");
1041 ret
+= tcrypt_test("ecb(cast6)");
1042 ret
+= tcrypt_test("cbc(cast6)");
1043 ret
+= tcrypt_test("ctr(cast6)");
1044 ret
+= tcrypt_test("lrw(cast6)");
1045 ret
+= tcrypt_test("xts(cast6)");
1049 ret
+= tcrypt_test("ecb(arc4)");
1053 ret
+= tcrypt_test("michael_mic");
1057 ret
+= tcrypt_test("crc32c");
1061 ret
+= tcrypt_test("ecb(tea)");
1065 ret
+= tcrypt_test("ecb(xtea)");
1069 ret
+= tcrypt_test("ecb(khazad)");
1073 ret
+= tcrypt_test("wp512");
1077 ret
+= tcrypt_test("wp384");
1081 ret
+= tcrypt_test("wp256");
1085 ret
+= tcrypt_test("ecb(tnepres)");
1089 ret
+= tcrypt_test("ecb(anubis)");
1090 ret
+= tcrypt_test("cbc(anubis)");
1094 ret
+= tcrypt_test("tgr192");
1098 ret
+= tcrypt_test("tgr160");
1102 ret
+= tcrypt_test("tgr128");
1106 ret
+= tcrypt_test("ecb(xeta)");
1110 ret
+= tcrypt_test("pcbc(fcrypt)");
1114 ret
+= tcrypt_test("ecb(camellia)");
1115 ret
+= tcrypt_test("cbc(camellia)");
1116 ret
+= tcrypt_test("ctr(camellia)");
1117 ret
+= tcrypt_test("lrw(camellia)");
1118 ret
+= tcrypt_test("xts(camellia)");
1122 ret
+= tcrypt_test("sha224");
1126 ret
+= tcrypt_test("salsa20");
1130 ret
+= tcrypt_test("gcm(aes)");
1134 ret
+= tcrypt_test("lzo");
1138 ret
+= tcrypt_test("ccm(aes)");
1142 ret
+= tcrypt_test("cts(cbc(aes))");
1146 ret
+= tcrypt_test("rmd128");
1150 ret
+= tcrypt_test("rmd160");
1154 ret
+= tcrypt_test("rmd256");
1158 ret
+= tcrypt_test("rmd320");
1162 ret
+= tcrypt_test("ecb(seed)");
1166 ret
+= tcrypt_test("zlib");
1170 ret
+= tcrypt_test("rfc4309(ccm(aes))");
1174 ret
+= tcrypt_test("ghash");
1178 ret
+= tcrypt_test("hmac(md5)");
1182 ret
+= tcrypt_test("hmac(sha1)");
1186 ret
+= tcrypt_test("hmac(sha256)");
1190 ret
+= tcrypt_test("hmac(sha384)");
1194 ret
+= tcrypt_test("hmac(sha512)");
1198 ret
+= tcrypt_test("hmac(sha224)");
1202 ret
+= tcrypt_test("xcbc(aes)");
1206 ret
+= tcrypt_test("hmac(rmd128)");
1210 ret
+= tcrypt_test("hmac(rmd160)");
1214 ret
+= tcrypt_test("vmac(aes)");
1218 ret
+= tcrypt_test("hmac(crc32)");
1222 ret
+= tcrypt_test("ansi_cprng");
1226 ret
+= tcrypt_test("rfc4106(gcm(aes))");
1230 ret
+= tcrypt_test("rfc4543(gcm(aes))");
1234 ret
+= tcrypt_test("cmac(aes)");
1238 ret
+= tcrypt_test("cmac(des3_ede)");
1242 test_cipher_speed("ecb(aes)", ENCRYPT
, sec
, NULL
, 0,
1243 speed_template_16_24_32
);
1244 test_cipher_speed("ecb(aes)", DECRYPT
, sec
, NULL
, 0,
1245 speed_template_16_24_32
);
1246 test_cipher_speed("cbc(aes)", ENCRYPT
, sec
, NULL
, 0,
1247 speed_template_16_24_32
);
1248 test_cipher_speed("cbc(aes)", DECRYPT
, sec
, NULL
, 0,
1249 speed_template_16_24_32
);
1250 test_cipher_speed("lrw(aes)", ENCRYPT
, sec
, NULL
, 0,
1251 speed_template_32_40_48
);
1252 test_cipher_speed("lrw(aes)", DECRYPT
, sec
, NULL
, 0,
1253 speed_template_32_40_48
);
1254 test_cipher_speed("xts(aes)", ENCRYPT
, sec
, NULL
, 0,
1255 speed_template_32_48_64
);
1256 test_cipher_speed("xts(aes)", DECRYPT
, sec
, NULL
, 0,
1257 speed_template_32_48_64
);
1258 test_cipher_speed("ctr(aes)", ENCRYPT
, sec
, NULL
, 0,
1259 speed_template_16_24_32
);
1260 test_cipher_speed("ctr(aes)", DECRYPT
, sec
, NULL
, 0,
1261 speed_template_16_24_32
);
1265 test_cipher_speed("ecb(des3_ede)", ENCRYPT
, sec
,
1266 des3_speed_template
, DES3_SPEED_VECTORS
,
1268 test_cipher_speed("ecb(des3_ede)", DECRYPT
, sec
,
1269 des3_speed_template
, DES3_SPEED_VECTORS
,
1271 test_cipher_speed("cbc(des3_ede)", ENCRYPT
, sec
,
1272 des3_speed_template
, DES3_SPEED_VECTORS
,
1274 test_cipher_speed("cbc(des3_ede)", DECRYPT
, sec
,
1275 des3_speed_template
, DES3_SPEED_VECTORS
,
1280 test_cipher_speed("ecb(twofish)", ENCRYPT
, sec
, NULL
, 0,
1281 speed_template_16_24_32
);
1282 test_cipher_speed("ecb(twofish)", DECRYPT
, sec
, NULL
, 0,
1283 speed_template_16_24_32
);
1284 test_cipher_speed("cbc(twofish)", ENCRYPT
, sec
, NULL
, 0,
1285 speed_template_16_24_32
);
1286 test_cipher_speed("cbc(twofish)", DECRYPT
, sec
, NULL
, 0,
1287 speed_template_16_24_32
);
1288 test_cipher_speed("ctr(twofish)", ENCRYPT
, sec
, NULL
, 0,
1289 speed_template_16_24_32
);
1290 test_cipher_speed("ctr(twofish)", DECRYPT
, sec
, NULL
, 0,
1291 speed_template_16_24_32
);
1292 test_cipher_speed("lrw(twofish)", ENCRYPT
, sec
, NULL
, 0,
1293 speed_template_32_40_48
);
1294 test_cipher_speed("lrw(twofish)", DECRYPT
, sec
, NULL
, 0,
1295 speed_template_32_40_48
);
1296 test_cipher_speed("xts(twofish)", ENCRYPT
, sec
, NULL
, 0,
1297 speed_template_32_48_64
);
1298 test_cipher_speed("xts(twofish)", DECRYPT
, sec
, NULL
, 0,
1299 speed_template_32_48_64
);
1303 test_cipher_speed("ecb(blowfish)", ENCRYPT
, sec
, NULL
, 0,
1304 speed_template_8_32
);
1305 test_cipher_speed("ecb(blowfish)", DECRYPT
, sec
, NULL
, 0,
1306 speed_template_8_32
);
1307 test_cipher_speed("cbc(blowfish)", ENCRYPT
, sec
, NULL
, 0,
1308 speed_template_8_32
);
1309 test_cipher_speed("cbc(blowfish)", DECRYPT
, sec
, NULL
, 0,
1310 speed_template_8_32
);
1311 test_cipher_speed("ctr(blowfish)", ENCRYPT
, sec
, NULL
, 0,
1312 speed_template_8_32
);
1313 test_cipher_speed("ctr(blowfish)", DECRYPT
, sec
, NULL
, 0,
1314 speed_template_8_32
);
1318 test_cipher_speed("ecb(des)", ENCRYPT
, sec
, NULL
, 0,
1320 test_cipher_speed("ecb(des)", DECRYPT
, sec
, NULL
, 0,
1322 test_cipher_speed("cbc(des)", ENCRYPT
, sec
, NULL
, 0,
1324 test_cipher_speed("cbc(des)", DECRYPT
, sec
, NULL
, 0,
1329 test_cipher_speed("ecb(camellia)", ENCRYPT
, sec
, NULL
, 0,
1330 speed_template_16_24_32
);
1331 test_cipher_speed("ecb(camellia)", DECRYPT
, sec
, NULL
, 0,
1332 speed_template_16_24_32
);
1333 test_cipher_speed("cbc(camellia)", ENCRYPT
, sec
, NULL
, 0,
1334 speed_template_16_24_32
);
1335 test_cipher_speed("cbc(camellia)", DECRYPT
, sec
, NULL
, 0,
1336 speed_template_16_24_32
);
1337 test_cipher_speed("ctr(camellia)", ENCRYPT
, sec
, NULL
, 0,
1338 speed_template_16_24_32
);
1339 test_cipher_speed("ctr(camellia)", DECRYPT
, sec
, NULL
, 0,
1340 speed_template_16_24_32
);
1341 test_cipher_speed("lrw(camellia)", ENCRYPT
, sec
, NULL
, 0,
1342 speed_template_32_40_48
);
1343 test_cipher_speed("lrw(camellia)", DECRYPT
, sec
, NULL
, 0,
1344 speed_template_32_40_48
);
1345 test_cipher_speed("xts(camellia)", ENCRYPT
, sec
, NULL
, 0,
1346 speed_template_32_48_64
);
1347 test_cipher_speed("xts(camellia)", DECRYPT
, sec
, NULL
, 0,
1348 speed_template_32_48_64
);
1352 test_cipher_speed("salsa20", ENCRYPT
, sec
, NULL
, 0,
1353 speed_template_16_32
);
1357 test_cipher_speed("ecb(serpent)", ENCRYPT
, sec
, NULL
, 0,
1358 speed_template_16_32
);
1359 test_cipher_speed("ecb(serpent)", DECRYPT
, sec
, NULL
, 0,
1360 speed_template_16_32
);
1361 test_cipher_speed("cbc(serpent)", ENCRYPT
, sec
, NULL
, 0,
1362 speed_template_16_32
);
1363 test_cipher_speed("cbc(serpent)", DECRYPT
, sec
, NULL
, 0,
1364 speed_template_16_32
);
1365 test_cipher_speed("ctr(serpent)", ENCRYPT
, sec
, NULL
, 0,
1366 speed_template_16_32
);
1367 test_cipher_speed("ctr(serpent)", DECRYPT
, sec
, NULL
, 0,
1368 speed_template_16_32
);
1369 test_cipher_speed("lrw(serpent)", ENCRYPT
, sec
, NULL
, 0,
1370 speed_template_32_48
);
1371 test_cipher_speed("lrw(serpent)", DECRYPT
, sec
, NULL
, 0,
1372 speed_template_32_48
);
1373 test_cipher_speed("xts(serpent)", ENCRYPT
, sec
, NULL
, 0,
1374 speed_template_32_64
);
1375 test_cipher_speed("xts(serpent)", DECRYPT
, sec
, NULL
, 0,
1376 speed_template_32_64
);
1380 test_cipher_speed("ecb(arc4)", ENCRYPT
, sec
, NULL
, 0,
1385 test_cipher_speed("ecb(cast5)", ENCRYPT
, sec
, NULL
, 0,
1386 speed_template_8_16
);
1387 test_cipher_speed("ecb(cast5)", DECRYPT
, sec
, NULL
, 0,
1388 speed_template_8_16
);
1389 test_cipher_speed("cbc(cast5)", ENCRYPT
, sec
, NULL
, 0,
1390 speed_template_8_16
);
1391 test_cipher_speed("cbc(cast5)", DECRYPT
, sec
, NULL
, 0,
1392 speed_template_8_16
);
1393 test_cipher_speed("ctr(cast5)", ENCRYPT
, sec
, NULL
, 0,
1394 speed_template_8_16
);
1395 test_cipher_speed("ctr(cast5)", DECRYPT
, sec
, NULL
, 0,
1396 speed_template_8_16
);
1400 test_cipher_speed("ecb(cast6)", ENCRYPT
, sec
, NULL
, 0,
1401 speed_template_16_32
);
1402 test_cipher_speed("ecb(cast6)", DECRYPT
, sec
, NULL
, 0,
1403 speed_template_16_32
);
1404 test_cipher_speed("cbc(cast6)", ENCRYPT
, sec
, NULL
, 0,
1405 speed_template_16_32
);
1406 test_cipher_speed("cbc(cast6)", DECRYPT
, sec
, NULL
, 0,
1407 speed_template_16_32
);
1408 test_cipher_speed("ctr(cast6)", ENCRYPT
, sec
, NULL
, 0,
1409 speed_template_16_32
);
1410 test_cipher_speed("ctr(cast6)", DECRYPT
, sec
, NULL
, 0,
1411 speed_template_16_32
);
1412 test_cipher_speed("lrw(cast6)", ENCRYPT
, sec
, NULL
, 0,
1413 speed_template_32_48
);
1414 test_cipher_speed("lrw(cast6)", DECRYPT
, sec
, NULL
, 0,
1415 speed_template_32_48
);
1416 test_cipher_speed("xts(cast6)", ENCRYPT
, sec
, NULL
, 0,
1417 speed_template_32_64
);
1418 test_cipher_speed("xts(cast6)", DECRYPT
, sec
, NULL
, 0,
1419 speed_template_32_64
);
1426 test_hash_speed("md4", sec
, generic_hash_speed_template
);
1427 if (mode
> 300 && mode
< 400) break;
1430 test_hash_speed("md5", sec
, generic_hash_speed_template
);
1431 if (mode
> 300 && mode
< 400) break;
1434 test_hash_speed("sha1", sec
, generic_hash_speed_template
);
1435 if (mode
> 300 && mode
< 400) break;
1438 test_hash_speed("sha256", sec
, generic_hash_speed_template
);
1439 if (mode
> 300 && mode
< 400) break;
1442 test_hash_speed("sha384", sec
, generic_hash_speed_template
);
1443 if (mode
> 300 && mode
< 400) break;
1446 test_hash_speed("sha512", sec
, generic_hash_speed_template
);
1447 if (mode
> 300 && mode
< 400) break;
1450 test_hash_speed("wp256", sec
, generic_hash_speed_template
);
1451 if (mode
> 300 && mode
< 400) break;
1454 test_hash_speed("wp384", sec
, generic_hash_speed_template
);
1455 if (mode
> 300 && mode
< 400) break;
1458 test_hash_speed("wp512", sec
, generic_hash_speed_template
);
1459 if (mode
> 300 && mode
< 400) break;
1462 test_hash_speed("tgr128", sec
, generic_hash_speed_template
);
1463 if (mode
> 300 && mode
< 400) break;
1466 test_hash_speed("tgr160", sec
, generic_hash_speed_template
);
1467 if (mode
> 300 && mode
< 400) break;
1470 test_hash_speed("tgr192", sec
, generic_hash_speed_template
);
1471 if (mode
> 300 && mode
< 400) break;
1474 test_hash_speed("sha224", sec
, generic_hash_speed_template
);
1475 if (mode
> 300 && mode
< 400) break;
1478 test_hash_speed("rmd128", sec
, generic_hash_speed_template
);
1479 if (mode
> 300 && mode
< 400) break;
1482 test_hash_speed("rmd160", sec
, generic_hash_speed_template
);
1483 if (mode
> 300 && mode
< 400) break;
1486 test_hash_speed("rmd256", sec
, generic_hash_speed_template
);
1487 if (mode
> 300 && mode
< 400) break;
1490 test_hash_speed("rmd320", sec
, generic_hash_speed_template
);
1491 if (mode
> 300 && mode
< 400) break;
1494 test_hash_speed("ghash-generic", sec
, hash_speed_template_16
);
1495 if (mode
> 300 && mode
< 400) break;
1498 test_hash_speed("crc32c", sec
, generic_hash_speed_template
);
1499 if (mode
> 300 && mode
< 400) break;
1508 test_ahash_speed("md4", sec
, generic_hash_speed_template
);
1509 if (mode
> 400 && mode
< 500) break;
1512 test_ahash_speed("md5", sec
, generic_hash_speed_template
);
1513 if (mode
> 400 && mode
< 500) break;
1516 test_ahash_speed("sha1", sec
, generic_hash_speed_template
);
1517 if (mode
> 400 && mode
< 500) break;
1520 test_ahash_speed("sha256", sec
, generic_hash_speed_template
);
1521 if (mode
> 400 && mode
< 500) break;
1524 test_ahash_speed("sha384", sec
, generic_hash_speed_template
);
1525 if (mode
> 400 && mode
< 500) break;
1528 test_ahash_speed("sha512", sec
, generic_hash_speed_template
);
1529 if (mode
> 400 && mode
< 500) break;
1532 test_ahash_speed("wp256", sec
, generic_hash_speed_template
);
1533 if (mode
> 400 && mode
< 500) break;
1536 test_ahash_speed("wp384", sec
, generic_hash_speed_template
);
1537 if (mode
> 400 && mode
< 500) break;
1540 test_ahash_speed("wp512", sec
, generic_hash_speed_template
);
1541 if (mode
> 400 && mode
< 500) break;
1544 test_ahash_speed("tgr128", sec
, generic_hash_speed_template
);
1545 if (mode
> 400 && mode
< 500) break;
1548 test_ahash_speed("tgr160", sec
, generic_hash_speed_template
);
1549 if (mode
> 400 && mode
< 500) break;
1552 test_ahash_speed("tgr192", sec
, generic_hash_speed_template
);
1553 if (mode
> 400 && mode
< 500) break;
1556 test_ahash_speed("sha224", sec
, generic_hash_speed_template
);
1557 if (mode
> 400 && mode
< 500) break;
1560 test_ahash_speed("rmd128", sec
, generic_hash_speed_template
);
1561 if (mode
> 400 && mode
< 500) break;
1564 test_ahash_speed("rmd160", sec
, generic_hash_speed_template
);
1565 if (mode
> 400 && mode
< 500) break;
1568 test_ahash_speed("rmd256", sec
, generic_hash_speed_template
);
1569 if (mode
> 400 && mode
< 500) break;
1572 test_ahash_speed("rmd320", sec
, generic_hash_speed_template
);
1573 if (mode
> 400 && mode
< 500) break;
1579 test_acipher_speed("ecb(aes)", ENCRYPT
, sec
, NULL
, 0,
1580 speed_template_16_24_32
);
1581 test_acipher_speed("ecb(aes)", DECRYPT
, sec
, NULL
, 0,
1582 speed_template_16_24_32
);
1583 test_acipher_speed("cbc(aes)", ENCRYPT
, sec
, NULL
, 0,
1584 speed_template_16_24_32
);
1585 test_acipher_speed("cbc(aes)", DECRYPT
, sec
, NULL
, 0,
1586 speed_template_16_24_32
);
1587 test_acipher_speed("lrw(aes)", ENCRYPT
, sec
, NULL
, 0,
1588 speed_template_32_40_48
);
1589 test_acipher_speed("lrw(aes)", DECRYPT
, sec
, NULL
, 0,
1590 speed_template_32_40_48
);
1591 test_acipher_speed("xts(aes)", ENCRYPT
, sec
, NULL
, 0,
1592 speed_template_32_48_64
);
1593 test_acipher_speed("xts(aes)", DECRYPT
, sec
, NULL
, 0,
1594 speed_template_32_48_64
);
1595 test_acipher_speed("ctr(aes)", ENCRYPT
, sec
, NULL
, 0,
1596 speed_template_16_24_32
);
1597 test_acipher_speed("ctr(aes)", DECRYPT
, sec
, NULL
, 0,
1598 speed_template_16_24_32
);
1599 test_acipher_speed("cfb(aes)", ENCRYPT
, sec
, NULL
, 0,
1600 speed_template_16_24_32
);
1601 test_acipher_speed("cfb(aes)", DECRYPT
, sec
, NULL
, 0,
1602 speed_template_16_24_32
);
1603 test_acipher_speed("ofb(aes)", ENCRYPT
, sec
, NULL
, 0,
1604 speed_template_16_24_32
);
1605 test_acipher_speed("ofb(aes)", DECRYPT
, sec
, NULL
, 0,
1606 speed_template_16_24_32
);
1607 test_acipher_speed("rfc3686(ctr(aes))", ENCRYPT
, sec
, NULL
, 0,
1608 speed_template_20_28_36
);
1609 test_acipher_speed("rfc3686(ctr(aes))", DECRYPT
, sec
, NULL
, 0,
1610 speed_template_20_28_36
);
1614 test_acipher_speed("ecb(des3_ede)", ENCRYPT
, sec
,
1615 des3_speed_template
, DES3_SPEED_VECTORS
,
1617 test_acipher_speed("ecb(des3_ede)", DECRYPT
, sec
,
1618 des3_speed_template
, DES3_SPEED_VECTORS
,
1620 test_acipher_speed("cbc(des3_ede)", ENCRYPT
, sec
,
1621 des3_speed_template
, DES3_SPEED_VECTORS
,
1623 test_acipher_speed("cbc(des3_ede)", DECRYPT
, sec
,
1624 des3_speed_template
, DES3_SPEED_VECTORS
,
1626 test_acipher_speed("cfb(des3_ede)", ENCRYPT
, sec
,
1627 des3_speed_template
, DES3_SPEED_VECTORS
,
1629 test_acipher_speed("cfb(des3_ede)", DECRYPT
, sec
,
1630 des3_speed_template
, DES3_SPEED_VECTORS
,
1632 test_acipher_speed("ofb(des3_ede)", ENCRYPT
, sec
,
1633 des3_speed_template
, DES3_SPEED_VECTORS
,
1635 test_acipher_speed("ofb(des3_ede)", DECRYPT
, sec
,
1636 des3_speed_template
, DES3_SPEED_VECTORS
,
1641 test_acipher_speed("ecb(des)", ENCRYPT
, sec
, NULL
, 0,
1643 test_acipher_speed("ecb(des)", DECRYPT
, sec
, NULL
, 0,
1645 test_acipher_speed("cbc(des)", ENCRYPT
, sec
, NULL
, 0,
1647 test_acipher_speed("cbc(des)", DECRYPT
, sec
, NULL
, 0,
1649 test_acipher_speed("cfb(des)", ENCRYPT
, sec
, NULL
, 0,
1651 test_acipher_speed("cfb(des)", DECRYPT
, sec
, NULL
, 0,
1653 test_acipher_speed("ofb(des)", ENCRYPT
, sec
, NULL
, 0,
1655 test_acipher_speed("ofb(des)", DECRYPT
, sec
, NULL
, 0,
1660 test_acipher_speed("ecb(serpent)", ENCRYPT
, sec
, NULL
, 0,
1661 speed_template_16_32
);
1662 test_acipher_speed("ecb(serpent)", DECRYPT
, sec
, NULL
, 0,
1663 speed_template_16_32
);
1664 test_acipher_speed("cbc(serpent)", ENCRYPT
, sec
, NULL
, 0,
1665 speed_template_16_32
);
1666 test_acipher_speed("cbc(serpent)", DECRYPT
, sec
, NULL
, 0,
1667 speed_template_16_32
);
1668 test_acipher_speed("ctr(serpent)", ENCRYPT
, sec
, NULL
, 0,
1669 speed_template_16_32
);
1670 test_acipher_speed("ctr(serpent)", DECRYPT
, sec
, NULL
, 0,
1671 speed_template_16_32
);
1672 test_acipher_speed("lrw(serpent)", ENCRYPT
, sec
, NULL
, 0,
1673 speed_template_32_48
);
1674 test_acipher_speed("lrw(serpent)", DECRYPT
, sec
, NULL
, 0,
1675 speed_template_32_48
);
1676 test_acipher_speed("xts(serpent)", ENCRYPT
, sec
, NULL
, 0,
1677 speed_template_32_64
);
1678 test_acipher_speed("xts(serpent)", DECRYPT
, sec
, NULL
, 0,
1679 speed_template_32_64
);
1683 test_acipher_speed("ecb(twofish)", ENCRYPT
, sec
, NULL
, 0,
1684 speed_template_16_24_32
);
1685 test_acipher_speed("ecb(twofish)", DECRYPT
, sec
, NULL
, 0,
1686 speed_template_16_24_32
);
1687 test_acipher_speed("cbc(twofish)", ENCRYPT
, sec
, NULL
, 0,
1688 speed_template_16_24_32
);
1689 test_acipher_speed("cbc(twofish)", DECRYPT
, sec
, NULL
, 0,
1690 speed_template_16_24_32
);
1691 test_acipher_speed("ctr(twofish)", ENCRYPT
, sec
, NULL
, 0,
1692 speed_template_16_24_32
);
1693 test_acipher_speed("ctr(twofish)", DECRYPT
, sec
, NULL
, 0,
1694 speed_template_16_24_32
);
1695 test_acipher_speed("lrw(twofish)", ENCRYPT
, sec
, NULL
, 0,
1696 speed_template_32_40_48
);
1697 test_acipher_speed("lrw(twofish)", DECRYPT
, sec
, NULL
, 0,
1698 speed_template_32_40_48
);
1699 test_acipher_speed("xts(twofish)", ENCRYPT
, sec
, NULL
, 0,
1700 speed_template_32_48_64
);
1701 test_acipher_speed("xts(twofish)", DECRYPT
, sec
, NULL
, 0,
1702 speed_template_32_48_64
);
1706 test_acipher_speed("ecb(arc4)", ENCRYPT
, sec
, NULL
, 0,
1711 test_acipher_speed("ecb(cast5)", ENCRYPT
, sec
, NULL
, 0,
1712 speed_template_8_16
);
1713 test_acipher_speed("ecb(cast5)", DECRYPT
, sec
, NULL
, 0,
1714 speed_template_8_16
);
1715 test_acipher_speed("cbc(cast5)", ENCRYPT
, sec
, NULL
, 0,
1716 speed_template_8_16
);
1717 test_acipher_speed("cbc(cast5)", DECRYPT
, sec
, NULL
, 0,
1718 speed_template_8_16
);
1719 test_acipher_speed("ctr(cast5)", ENCRYPT
, sec
, NULL
, 0,
1720 speed_template_8_16
);
1721 test_acipher_speed("ctr(cast5)", DECRYPT
, sec
, NULL
, 0,
1722 speed_template_8_16
);
1726 test_acipher_speed("ecb(cast6)", ENCRYPT
, sec
, NULL
, 0,
1727 speed_template_16_32
);
1728 test_acipher_speed("ecb(cast6)", DECRYPT
, sec
, NULL
, 0,
1729 speed_template_16_32
);
1730 test_acipher_speed("cbc(cast6)", ENCRYPT
, sec
, NULL
, 0,
1731 speed_template_16_32
);
1732 test_acipher_speed("cbc(cast6)", DECRYPT
, sec
, NULL
, 0,
1733 speed_template_16_32
);
1734 test_acipher_speed("ctr(cast6)", ENCRYPT
, sec
, NULL
, 0,
1735 speed_template_16_32
);
1736 test_acipher_speed("ctr(cast6)", DECRYPT
, sec
, NULL
, 0,
1737 speed_template_16_32
);
1738 test_acipher_speed("lrw(cast6)", ENCRYPT
, sec
, NULL
, 0,
1739 speed_template_32_48
);
1740 test_acipher_speed("lrw(cast6)", DECRYPT
, sec
, NULL
, 0,
1741 speed_template_32_48
);
1742 test_acipher_speed("xts(cast6)", ENCRYPT
, sec
, NULL
, 0,
1743 speed_template_32_64
);
1744 test_acipher_speed("xts(cast6)", DECRYPT
, sec
, NULL
, 0,
1745 speed_template_32_64
);
1749 test_acipher_speed("ecb(camellia)", ENCRYPT
, sec
, NULL
, 0,
1750 speed_template_16_32
);
1751 test_acipher_speed("ecb(camellia)", DECRYPT
, sec
, NULL
, 0,
1752 speed_template_16_32
);
1753 test_acipher_speed("cbc(camellia)", ENCRYPT
, sec
, NULL
, 0,
1754 speed_template_16_32
);
1755 test_acipher_speed("cbc(camellia)", DECRYPT
, sec
, NULL
, 0,
1756 speed_template_16_32
);
1757 test_acipher_speed("ctr(camellia)", ENCRYPT
, sec
, NULL
, 0,
1758 speed_template_16_32
);
1759 test_acipher_speed("ctr(camellia)", DECRYPT
, sec
, NULL
, 0,
1760 speed_template_16_32
);
1761 test_acipher_speed("lrw(camellia)", ENCRYPT
, sec
, NULL
, 0,
1762 speed_template_32_48
);
1763 test_acipher_speed("lrw(camellia)", DECRYPT
, sec
, NULL
, 0,
1764 speed_template_32_48
);
1765 test_acipher_speed("xts(camellia)", ENCRYPT
, sec
, NULL
, 0,
1766 speed_template_32_64
);
1767 test_acipher_speed("xts(camellia)", DECRYPT
, sec
, NULL
, 0,
1768 speed_template_32_64
);
1772 test_acipher_speed("ecb(blowfish)", ENCRYPT
, sec
, NULL
, 0,
1773 speed_template_8_32
);
1774 test_acipher_speed("ecb(blowfish)", DECRYPT
, sec
, NULL
, 0,
1775 speed_template_8_32
);
1776 test_acipher_speed("cbc(blowfish)", ENCRYPT
, sec
, NULL
, 0,
1777 speed_template_8_32
);
1778 test_acipher_speed("cbc(blowfish)", DECRYPT
, sec
, NULL
, 0,
1779 speed_template_8_32
);
1780 test_acipher_speed("ctr(blowfish)", ENCRYPT
, sec
, NULL
, 0,
1781 speed_template_8_32
);
1782 test_acipher_speed("ctr(blowfish)", DECRYPT
, sec
, NULL
, 0,
1783 speed_template_8_32
);
1794 static int do_alg_test(const char *alg
, u32 type
, u32 mask
)
1796 return crypto_has_alg(alg
, type
, mask
?: CRYPTO_ALG_TYPE_MASK
) ?
1800 static int __init
tcrypt_mod_init(void)
1805 for (i
= 0; i
< TVMEMSIZE
; i
++) {
1806 tvmem
[i
] = (void *)__get_free_page(GFP_KERNEL
);
1812 err
= do_alg_test(alg
, type
, mask
);
1814 err
= do_test(mode
);
1817 printk(KERN_ERR
"tcrypt: one or more tests failed!\n");
1821 /* We intentionaly return -EAGAIN to prevent keeping the module,
1822 * unless we're running in fips mode. It does all its work from
1823 * init() and doesn't offer any runtime functionality, but in
1824 * the fips case, checking for a successful load is helpful.
1825 * => we don't need it in the memory, do we?
1832 for (i
= 0; i
< TVMEMSIZE
&& tvmem
[i
]; i
++)
1833 free_page((unsigned long)tvmem
[i
]);
1839 * If an init function is provided, an exit function must also be provided
1840 * to allow module unload.
1842 static void __exit
tcrypt_mod_fini(void) { }
1844 module_init(tcrypt_mod_init
);
1845 module_exit(tcrypt_mod_fini
);
1847 module_param(alg
, charp
, 0);
1848 module_param(type
, uint
, 0);
1849 module_param(mask
, uint
, 0);
1850 module_param(mode
, int, 0);
1851 module_param(sec
, uint
, 0);
1852 MODULE_PARM_DESC(sec
, "Length in seconds of speed tests "
1853 "(defaults to zero which uses CPU cycles instead)");
1855 MODULE_LICENSE("GPL");
1856 MODULE_DESCRIPTION("Quick & dirty crypto testing module");
1857 MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");