1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Quick & dirty crypto testing module.
5 * This will only exist until we have a better testing mechanism
6 * (e.g. a char device).
8 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
9 * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
10 * Copyright (c) 2007 Nokia Siemens Networks
12 * Updated RFC4106 AES-GCM testing.
13 * Authors: Aidan O'Mahony (aidan.o.mahony@intel.com)
14 * Adrian Hoban <adrian.hoban@intel.com>
15 * Gabriele Paoloni <gabriele.paoloni@intel.com>
16 * Tadeusz Struk (tadeusz.struk@intel.com)
17 * Copyright (c) 2010, Intel Corporation.
20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22 #include <crypto/aead.h>
23 #include <crypto/hash.h>
24 #include <crypto/skcipher.h>
25 #include <linux/err.h>
26 #include <linux/fips.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>
39 * Need slab memory for testing (size in number of pages).
44 * Used by test_cipher_speed()
49 #define MAX_DIGEST_SIZE 64
52 * return a string with the driver name
54 #define get_driver_name(tfm_type, tfm) crypto_tfm_alg_driver_name(tfm_type ## _tfm(tfm))
57 * Used by test_cipher_speed()
59 static unsigned int sec
;
61 static char *alg
= NULL
;
65 static u32 num_mb
= 8;
66 static unsigned int klen
;
67 static char *tvmem
[TVMEMSIZE
];
69 static const char *check
[] = {
70 "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", "sm3",
71 "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
72 "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
73 "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
74 "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320",
75 "lzo", "lzo-rle", "cts", "sha3-224", "sha3-256", "sha3-384",
76 "sha3-512", "streebog256", "streebog512",
80 static const int block_sizes
[] = { 16, 64, 256, 1024, 1420, 4096, 0 };
81 static const int aead_sizes
[] = { 16, 64, 256, 512, 1024, 1420, 4096, 8192, 0 };
86 static int testmgr_alloc_buf(char *buf
[XBUFSIZE
])
90 for (i
= 0; i
< XBUFSIZE
; i
++) {
91 buf
[i
] = (void *)__get_free_page(GFP_KERNEL
);
100 free_page((unsigned long)buf
[i
]);
105 static void testmgr_free_buf(char *buf
[XBUFSIZE
])
109 for (i
= 0; i
< XBUFSIZE
; i
++)
110 free_page((unsigned long)buf
[i
]);
113 static void sg_init_aead(struct scatterlist
*sg
, char *xbuf
[XBUFSIZE
],
114 unsigned int buflen
, const void *assoc
,
115 unsigned int aad_size
)
117 int np
= (buflen
+ PAGE_SIZE
- 1)/PAGE_SIZE
;
124 rem
= buflen
% PAGE_SIZE
;
127 sg_init_table(sg
, np
+ 1);
129 sg_set_buf(&sg
[0], assoc
, aad_size
);
133 for (k
= 0; k
< np
; k
++)
134 sg_set_buf(&sg
[k
+ 1], xbuf
[k
], PAGE_SIZE
);
137 sg_set_buf(&sg
[k
+ 1], xbuf
[k
], rem
);
140 static inline int do_one_aead_op(struct aead_request
*req
, int ret
)
142 struct crypto_wait
*wait
= req
->base
.data
;
144 return crypto_wait_req(ret
, wait
);
147 struct test_mb_aead_data
{
148 struct scatterlist sg
[XBUFSIZE
];
149 struct scatterlist sgout
[XBUFSIZE
];
150 struct aead_request
*req
;
151 struct crypto_wait wait
;
152 char *xbuf
[XBUFSIZE
];
153 char *xoutbuf
[XBUFSIZE
];
154 char *axbuf
[XBUFSIZE
];
157 static int do_mult_aead_op(struct test_mb_aead_data
*data
, int enc
,
162 /* Fire up a bunch of concurrent requests */
163 for (i
= 0; i
< num_mb
; i
++) {
165 rc
[i
] = crypto_aead_encrypt(data
[i
].req
);
167 rc
[i
] = crypto_aead_decrypt(data
[i
].req
);
170 /* Wait for all requests to finish */
171 for (i
= 0; i
< num_mb
; i
++) {
172 rc
[i
] = crypto_wait_req(rc
[i
], &data
[i
].wait
);
175 pr_info("concurrent request %d error %d\n", i
, rc
[i
]);
183 static int test_mb_aead_jiffies(struct test_mb_aead_data
*data
, int enc
,
184 int blen
, int secs
, u32 num_mb
)
186 unsigned long start
, end
;
191 rc
= kcalloc(num_mb
, sizeof(*rc
), GFP_KERNEL
);
195 for (start
= jiffies
, end
= start
+ secs
* HZ
, bcount
= 0;
196 time_before(jiffies
, end
); bcount
++) {
197 ret
= do_mult_aead_op(data
, enc
, num_mb
, rc
);
202 pr_cont("%d operations in %d seconds (%ld bytes)\n",
203 bcount
* num_mb
, secs
, (long)bcount
* blen
* num_mb
);
210 static int test_mb_aead_cycles(struct test_mb_aead_data
*data
, int enc
,
211 int blen
, u32 num_mb
)
213 unsigned long cycles
= 0;
218 rc
= kcalloc(num_mb
, sizeof(*rc
), GFP_KERNEL
);
223 for (i
= 0; i
< 4; i
++) {
224 ret
= do_mult_aead_op(data
, enc
, num_mb
, rc
);
229 /* The real thing. */
230 for (i
= 0; i
< 8; i
++) {
233 start
= get_cycles();
234 ret
= do_mult_aead_op(data
, enc
, num_mb
, rc
);
240 cycles
+= end
- start
;
243 pr_cont("1 operation in %lu cycles (%d bytes)\n",
244 (cycles
+ 4) / (8 * num_mb
), blen
);
251 static void test_mb_aead_speed(const char *algo
, int enc
, int secs
,
252 struct aead_speed_template
*template,
253 unsigned int tcount
, u8 authsize
,
254 unsigned int aad_size
, u8
*keysize
, u32 num_mb
)
256 struct test_mb_aead_data
*data
;
257 struct crypto_aead
*tfm
;
258 unsigned int i
, j
, iv_len
;
267 if (aad_size
>= PAGE_SIZE
) {
268 pr_err("associate data length (%u) too big\n", aad_size
);
272 iv
= kzalloc(MAX_IVLEN
, GFP_KERNEL
);
281 data
= kcalloc(num_mb
, sizeof(*data
), GFP_KERNEL
);
285 tfm
= crypto_alloc_aead(algo
, 0, 0);
287 pr_err("failed to load transform for %s: %ld\n",
292 ret
= crypto_aead_setauthsize(tfm
, authsize
);
294 for (i
= 0; i
< num_mb
; ++i
)
295 if (testmgr_alloc_buf(data
[i
].xbuf
)) {
297 testmgr_free_buf(data
[i
].xbuf
);
301 for (i
= 0; i
< num_mb
; ++i
)
302 if (testmgr_alloc_buf(data
[i
].axbuf
)) {
304 testmgr_free_buf(data
[i
].axbuf
);
308 for (i
= 0; i
< num_mb
; ++i
)
309 if (testmgr_alloc_buf(data
[i
].xoutbuf
)) {
311 testmgr_free_buf(data
[i
].xoutbuf
);
315 for (i
= 0; i
< num_mb
; ++i
) {
316 data
[i
].req
= aead_request_alloc(tfm
, GFP_KERNEL
);
318 pr_err("alg: skcipher: Failed to allocate request for %s\n",
321 aead_request_free(data
[i
].req
);
322 goto out_free_xoutbuf
;
326 for (i
= 0; i
< num_mb
; ++i
) {
327 crypto_init_wait(&data
[i
].wait
);
328 aead_request_set_callback(data
[i
].req
,
329 CRYPTO_TFM_REQ_MAY_BACKLOG
,
330 crypto_req_done
, &data
[i
].wait
);
333 pr_info("\ntesting speed of multibuffer %s (%s) %s\n", algo
,
334 get_driver_name(crypto_aead
, tfm
), e
);
340 int bs
= round_up(*b_size
, crypto_aead_blocksize(tfm
));
342 if (bs
+ authsize
> XBUFSIZE
* PAGE_SIZE
) {
343 pr_err("template (%u) too big for buffer (%lu)\n",
345 XBUFSIZE
* PAGE_SIZE
);
349 pr_info("test %u (%d bit key, %d byte blocks): ", i
,
352 /* Set up tfm global state, i.e. the key */
354 memset(tvmem
[0], 0xff, PAGE_SIZE
);
356 for (j
= 0; j
< tcount
; j
++) {
357 if (template[j
].klen
== *keysize
) {
358 key
= template[j
].key
;
363 crypto_aead_clear_flags(tfm
, ~0);
365 ret
= crypto_aead_setkey(tfm
, key
, *keysize
);
367 pr_err("setkey() failed flags=%x\n",
368 crypto_aead_get_flags(tfm
));
372 iv_len
= crypto_aead_ivsize(tfm
);
374 memset(iv
, 0xff, iv_len
);
376 /* Now setup per request stuff, i.e. buffers */
378 for (j
= 0; j
< num_mb
; ++j
) {
379 struct test_mb_aead_data
*cur
= &data
[j
];
381 assoc
= cur
->axbuf
[0];
382 memset(assoc
, 0xff, aad_size
);
384 sg_init_aead(cur
->sg
, cur
->xbuf
,
385 bs
+ (enc
? 0 : authsize
),
388 sg_init_aead(cur
->sgout
, cur
->xoutbuf
,
389 bs
+ (enc
? authsize
: 0),
392 aead_request_set_ad(cur
->req
, aad_size
);
396 aead_request_set_crypt(cur
->req
,
400 ret
= crypto_aead_encrypt(cur
->req
);
401 ret
= do_one_aead_op(cur
->req
, ret
);
404 pr_err("calculating auth failed (%d)\n",
410 aead_request_set_crypt(cur
->req
, cur
->sg
,
412 (enc
? 0 : authsize
),
418 ret
= test_mb_aead_jiffies(data
, enc
, bs
,
422 ret
= test_mb_aead_cycles(data
, enc
, bs
,
427 pr_err("%s() failed return code=%d\n", e
, ret
);
437 for (i
= 0; i
< num_mb
; ++i
)
438 aead_request_free(data
[i
].req
);
440 for (i
= 0; i
< num_mb
; ++i
)
441 testmgr_free_buf(data
[i
].xoutbuf
);
443 for (i
= 0; i
< num_mb
; ++i
)
444 testmgr_free_buf(data
[i
].axbuf
);
446 for (i
= 0; i
< num_mb
; ++i
)
447 testmgr_free_buf(data
[i
].xbuf
);
449 crypto_free_aead(tfm
);
456 static int test_aead_jiffies(struct aead_request
*req
, int enc
,
459 unsigned long start
, end
;
463 for (start
= jiffies
, end
= start
+ secs
* HZ
, bcount
= 0;
464 time_before(jiffies
, end
); bcount
++) {
466 ret
= do_one_aead_op(req
, crypto_aead_encrypt(req
));
468 ret
= do_one_aead_op(req
, crypto_aead_decrypt(req
));
474 printk("%d operations in %d seconds (%ld bytes)\n",
475 bcount
, secs
, (long)bcount
* blen
);
479 static int test_aead_cycles(struct aead_request
*req
, int enc
, int blen
)
481 unsigned long cycles
= 0;
486 for (i
= 0; i
< 4; i
++) {
488 ret
= do_one_aead_op(req
, crypto_aead_encrypt(req
));
490 ret
= do_one_aead_op(req
, crypto_aead_decrypt(req
));
496 /* The real thing. */
497 for (i
= 0; i
< 8; i
++) {
500 start
= get_cycles();
502 ret
= do_one_aead_op(req
, crypto_aead_encrypt(req
));
504 ret
= do_one_aead_op(req
, crypto_aead_decrypt(req
));
510 cycles
+= end
- start
;
515 printk("1 operation in %lu cycles (%d bytes)\n",
516 (cycles
+ 4) / 8, blen
);
521 static void test_aead_speed(const char *algo
, int enc
, unsigned int secs
,
522 struct aead_speed_template
*template,
523 unsigned int tcount
, u8 authsize
,
524 unsigned int aad_size
, u8
*keysize
)
527 struct crypto_aead
*tfm
;
530 struct aead_request
*req
;
531 struct scatterlist
*sg
;
532 struct scatterlist
*sgout
;
536 char *xbuf
[XBUFSIZE
];
537 char *xoutbuf
[XBUFSIZE
];
538 char *axbuf
[XBUFSIZE
];
541 struct crypto_wait wait
;
543 iv
= kzalloc(MAX_IVLEN
, GFP_KERNEL
);
547 if (aad_size
>= PAGE_SIZE
) {
548 pr_err("associate data length (%u) too big\n", aad_size
);
557 if (testmgr_alloc_buf(xbuf
))
559 if (testmgr_alloc_buf(axbuf
))
561 if (testmgr_alloc_buf(xoutbuf
))
564 sg
= kmalloc(sizeof(*sg
) * 9 * 2, GFP_KERNEL
);
569 tfm
= crypto_alloc_aead(algo
, 0, 0);
572 pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo
,
577 crypto_init_wait(&wait
);
578 printk(KERN_INFO
"\ntesting speed of %s (%s) %s\n", algo
,
579 get_driver_name(crypto_aead
, tfm
), e
);
581 req
= aead_request_alloc(tfm
, GFP_KERNEL
);
583 pr_err("alg: aead: Failed to allocate request for %s\n",
588 aead_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
589 crypto_req_done
, &wait
);
595 u32 bs
= round_up(*b_size
, crypto_aead_blocksize(tfm
));
598 memset(assoc
, 0xff, aad_size
);
600 if ((*keysize
+ bs
) > TVMEMSIZE
* PAGE_SIZE
) {
601 pr_err("template (%u) too big for tvmem (%lu)\n",
603 TVMEMSIZE
* PAGE_SIZE
);
608 for (j
= 0; j
< tcount
; j
++) {
609 if (template[j
].klen
== *keysize
) {
610 key
= template[j
].key
;
614 ret
= crypto_aead_setkey(tfm
, key
, *keysize
);
615 ret
= crypto_aead_setauthsize(tfm
, authsize
);
617 iv_len
= crypto_aead_ivsize(tfm
);
619 memset(iv
, 0xff, iv_len
);
621 crypto_aead_clear_flags(tfm
, ~0);
622 printk(KERN_INFO
"test %u (%d bit key, %d byte blocks): ",
623 i
, *keysize
* 8, bs
);
626 memset(tvmem
[0], 0xff, PAGE_SIZE
);
629 pr_err("setkey() failed flags=%x\n",
630 crypto_aead_get_flags(tfm
));
634 sg_init_aead(sg
, xbuf
, bs
+ (enc
? 0 : authsize
),
637 sg_init_aead(sgout
, xoutbuf
,
638 bs
+ (enc
? authsize
: 0), assoc
,
641 aead_request_set_ad(req
, aad_size
);
646 * For decryption we need a proper auth so
647 * we do the encryption path once with buffers
648 * reversed (input <-> output) to calculate it
650 aead_request_set_crypt(req
, sgout
, sg
,
652 ret
= do_one_aead_op(req
,
653 crypto_aead_encrypt(req
));
656 pr_err("calculating auth failed (%d)\n",
662 aead_request_set_crypt(req
, sg
, sgout
,
663 bs
+ (enc
? 0 : authsize
),
667 ret
= test_aead_jiffies(req
, enc
, bs
,
671 ret
= test_aead_cycles(req
, enc
, bs
);
675 pr_err("%s() failed return code=%d\n", e
, ret
);
685 aead_request_free(req
);
687 crypto_free_aead(tfm
);
691 testmgr_free_buf(xoutbuf
);
693 testmgr_free_buf(axbuf
);
695 testmgr_free_buf(xbuf
);
700 static void test_hash_sg_init(struct scatterlist
*sg
)
704 sg_init_table(sg
, TVMEMSIZE
);
705 for (i
= 0; i
< TVMEMSIZE
; i
++) {
706 sg_set_buf(sg
+ i
, tvmem
[i
], PAGE_SIZE
);
707 memset(tvmem
[i
], 0xff, PAGE_SIZE
);
711 static inline int do_one_ahash_op(struct ahash_request
*req
, int ret
)
713 struct crypto_wait
*wait
= req
->base
.data
;
715 return crypto_wait_req(ret
, wait
);
718 struct test_mb_ahash_data
{
719 struct scatterlist sg
[XBUFSIZE
];
721 struct ahash_request
*req
;
722 struct crypto_wait wait
;
723 char *xbuf
[XBUFSIZE
];
726 static inline int do_mult_ahash_op(struct test_mb_ahash_data
*data
, u32 num_mb
,
731 /* Fire up a bunch of concurrent requests */
732 for (i
= 0; i
< num_mb
; i
++)
733 rc
[i
] = crypto_ahash_digest(data
[i
].req
);
735 /* Wait for all requests to finish */
736 for (i
= 0; i
< num_mb
; i
++) {
737 rc
[i
] = crypto_wait_req(rc
[i
], &data
[i
].wait
);
740 pr_info("concurrent request %d error %d\n", i
, rc
[i
]);
748 static int test_mb_ahash_jiffies(struct test_mb_ahash_data
*data
, int blen
,
749 int secs
, u32 num_mb
)
751 unsigned long start
, end
;
756 rc
= kcalloc(num_mb
, sizeof(*rc
), GFP_KERNEL
);
760 for (start
= jiffies
, end
= start
+ secs
* HZ
, bcount
= 0;
761 time_before(jiffies
, end
); bcount
++) {
762 ret
= do_mult_ahash_op(data
, num_mb
, rc
);
767 pr_cont("%d operations in %d seconds (%ld bytes)\n",
768 bcount
* num_mb
, secs
, (long)bcount
* blen
* num_mb
);
775 static int test_mb_ahash_cycles(struct test_mb_ahash_data
*data
, int blen
,
778 unsigned long cycles
= 0;
783 rc
= kcalloc(num_mb
, sizeof(*rc
), GFP_KERNEL
);
788 for (i
= 0; i
< 4; i
++) {
789 ret
= do_mult_ahash_op(data
, num_mb
, rc
);
794 /* The real thing. */
795 for (i
= 0; i
< 8; i
++) {
798 start
= get_cycles();
799 ret
= do_mult_ahash_op(data
, num_mb
, rc
);
805 cycles
+= end
- start
;
808 pr_cont("1 operation in %lu cycles (%d bytes)\n",
809 (cycles
+ 4) / (8 * num_mb
), blen
);
816 static void test_mb_ahash_speed(const char *algo
, unsigned int secs
,
817 struct hash_speed
*speed
, u32 num_mb
)
819 struct test_mb_ahash_data
*data
;
820 struct crypto_ahash
*tfm
;
821 unsigned int i
, j
, k
;
824 data
= kcalloc(num_mb
, sizeof(*data
), GFP_KERNEL
);
828 tfm
= crypto_alloc_ahash(algo
, 0, 0);
830 pr_err("failed to load transform for %s: %ld\n",
835 for (i
= 0; i
< num_mb
; ++i
) {
836 if (testmgr_alloc_buf(data
[i
].xbuf
))
839 crypto_init_wait(&data
[i
].wait
);
841 data
[i
].req
= ahash_request_alloc(tfm
, GFP_KERNEL
);
843 pr_err("alg: hash: Failed to allocate request for %s\n",
848 ahash_request_set_callback(data
[i
].req
, 0, crypto_req_done
,
851 sg_init_table(data
[i
].sg
, XBUFSIZE
);
852 for (j
= 0; j
< XBUFSIZE
; j
++) {
853 sg_set_buf(data
[i
].sg
+ j
, data
[i
].xbuf
[j
], PAGE_SIZE
);
854 memset(data
[i
].xbuf
[j
], 0xff, PAGE_SIZE
);
858 pr_info("\ntesting speed of multibuffer %s (%s)\n", algo
,
859 get_driver_name(crypto_ahash
, tfm
));
861 for (i
= 0; speed
[i
].blen
!= 0; i
++) {
862 /* For some reason this only tests digests. */
863 if (speed
[i
].blen
!= speed
[i
].plen
)
866 if (speed
[i
].blen
> XBUFSIZE
* PAGE_SIZE
) {
867 pr_err("template (%u) too big for tvmem (%lu)\n",
868 speed
[i
].blen
, XBUFSIZE
* PAGE_SIZE
);
873 crypto_ahash_setkey(tfm
, tvmem
[0], klen
);
875 for (k
= 0; k
< num_mb
; k
++)
876 ahash_request_set_crypt(data
[k
].req
, data
[k
].sg
,
877 data
[k
].result
, speed
[i
].blen
);
880 "(%5u byte blocks,%5u bytes per update,%4u updates): ",
881 i
, speed
[i
].blen
, speed
[i
].plen
,
882 speed
[i
].blen
/ speed
[i
].plen
);
885 ret
= test_mb_ahash_jiffies(data
, speed
[i
].blen
, secs
,
889 ret
= test_mb_ahash_cycles(data
, speed
[i
].blen
, num_mb
);
894 pr_err("At least one hashing failed ret=%d\n", ret
);
900 for (k
= 0; k
< num_mb
; ++k
)
901 ahash_request_free(data
[k
].req
);
903 for (k
= 0; k
< num_mb
; ++k
)
904 testmgr_free_buf(data
[k
].xbuf
);
906 crypto_free_ahash(tfm
);
912 static int test_ahash_jiffies_digest(struct ahash_request
*req
, int blen
,
915 unsigned long start
, end
;
919 for (start
= jiffies
, end
= start
+ secs
* HZ
, bcount
= 0;
920 time_before(jiffies
, end
); bcount
++) {
921 ret
= do_one_ahash_op(req
, crypto_ahash_digest(req
));
926 printk("%6u opers/sec, %9lu bytes/sec\n",
927 bcount
/ secs
, ((long)bcount
* blen
) / secs
);
932 static int test_ahash_jiffies(struct ahash_request
*req
, int blen
,
933 int plen
, char *out
, int secs
)
935 unsigned long start
, end
;
940 return test_ahash_jiffies_digest(req
, blen
, out
, secs
);
942 for (start
= jiffies
, end
= start
+ secs
* HZ
, bcount
= 0;
943 time_before(jiffies
, end
); bcount
++) {
944 ret
= do_one_ahash_op(req
, crypto_ahash_init(req
));
947 for (pcount
= 0; pcount
< blen
; pcount
+= plen
) {
948 ret
= do_one_ahash_op(req
, crypto_ahash_update(req
));
952 /* we assume there is enough space in 'out' for the result */
953 ret
= do_one_ahash_op(req
, crypto_ahash_final(req
));
958 pr_cont("%6u opers/sec, %9lu bytes/sec\n",
959 bcount
/ secs
, ((long)bcount
* blen
) / secs
);
964 static int test_ahash_cycles_digest(struct ahash_request
*req
, int blen
,
967 unsigned long cycles
= 0;
971 for (i
= 0; i
< 4; i
++) {
972 ret
= do_one_ahash_op(req
, crypto_ahash_digest(req
));
977 /* The real thing. */
978 for (i
= 0; i
< 8; i
++) {
981 start
= get_cycles();
983 ret
= do_one_ahash_op(req
, crypto_ahash_digest(req
));
989 cycles
+= end
- start
;
996 pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
997 cycles
/ 8, cycles
/ (8 * blen
));
1002 static int test_ahash_cycles(struct ahash_request
*req
, int blen
,
1003 int plen
, char *out
)
1005 unsigned long cycles
= 0;
1009 return test_ahash_cycles_digest(req
, blen
, out
);
1012 for (i
= 0; i
< 4; i
++) {
1013 ret
= do_one_ahash_op(req
, crypto_ahash_init(req
));
1016 for (pcount
= 0; pcount
< blen
; pcount
+= plen
) {
1017 ret
= do_one_ahash_op(req
, crypto_ahash_update(req
));
1021 ret
= do_one_ahash_op(req
, crypto_ahash_final(req
));
1026 /* The real thing. */
1027 for (i
= 0; i
< 8; i
++) {
1028 cycles_t start
, end
;
1030 start
= get_cycles();
1032 ret
= do_one_ahash_op(req
, crypto_ahash_init(req
));
1035 for (pcount
= 0; pcount
< blen
; pcount
+= plen
) {
1036 ret
= do_one_ahash_op(req
, crypto_ahash_update(req
));
1040 ret
= do_one_ahash_op(req
, crypto_ahash_final(req
));
1046 cycles
+= end
- start
;
1053 pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
1054 cycles
/ 8, cycles
/ (8 * blen
));
1059 static void test_ahash_speed_common(const char *algo
, unsigned int secs
,
1060 struct hash_speed
*speed
, unsigned mask
)
1062 struct scatterlist sg
[TVMEMSIZE
];
1063 struct crypto_wait wait
;
1064 struct ahash_request
*req
;
1065 struct crypto_ahash
*tfm
;
1069 tfm
= crypto_alloc_ahash(algo
, 0, mask
);
1071 pr_err("failed to load transform for %s: %ld\n",
1072 algo
, PTR_ERR(tfm
));
1076 printk(KERN_INFO
"\ntesting speed of async %s (%s)\n", algo
,
1077 get_driver_name(crypto_ahash
, tfm
));
1079 if (crypto_ahash_digestsize(tfm
) > MAX_DIGEST_SIZE
) {
1080 pr_err("digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm
),
1085 test_hash_sg_init(sg
);
1086 req
= ahash_request_alloc(tfm
, GFP_KERNEL
);
1088 pr_err("ahash request allocation failure\n");
1092 crypto_init_wait(&wait
);
1093 ahash_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
1094 crypto_req_done
, &wait
);
1096 output
= kmalloc(MAX_DIGEST_SIZE
, GFP_KERNEL
);
1100 for (i
= 0; speed
[i
].blen
!= 0; i
++) {
1101 if (speed
[i
].blen
> TVMEMSIZE
* PAGE_SIZE
) {
1102 pr_err("template (%u) too big for tvmem (%lu)\n",
1103 speed
[i
].blen
, TVMEMSIZE
* PAGE_SIZE
);
1108 crypto_ahash_setkey(tfm
, tvmem
[0], klen
);
1111 "(%5u byte blocks,%5u bytes per update,%4u updates): ",
1112 i
, speed
[i
].blen
, speed
[i
].plen
, speed
[i
].blen
/ speed
[i
].plen
);
1114 ahash_request_set_crypt(req
, sg
, output
, speed
[i
].plen
);
1117 ret
= test_ahash_jiffies(req
, speed
[i
].blen
,
1118 speed
[i
].plen
, output
, secs
);
1121 ret
= test_ahash_cycles(req
, speed
[i
].blen
,
1122 speed
[i
].plen
, output
);
1126 pr_err("hashing failed ret=%d\n", ret
);
1134 ahash_request_free(req
);
1137 crypto_free_ahash(tfm
);
1140 static void test_ahash_speed(const char *algo
, unsigned int secs
,
1141 struct hash_speed
*speed
)
1143 return test_ahash_speed_common(algo
, secs
, speed
, 0);
1146 static void test_hash_speed(const char *algo
, unsigned int secs
,
1147 struct hash_speed
*speed
)
1149 return test_ahash_speed_common(algo
, secs
, speed
, CRYPTO_ALG_ASYNC
);
1152 struct test_mb_skcipher_data
{
1153 struct scatterlist sg
[XBUFSIZE
];
1154 struct skcipher_request
*req
;
1155 struct crypto_wait wait
;
1156 char *xbuf
[XBUFSIZE
];
1159 static int do_mult_acipher_op(struct test_mb_skcipher_data
*data
, int enc
,
1160 u32 num_mb
, int *rc
)
1164 /* Fire up a bunch of concurrent requests */
1165 for (i
= 0; i
< num_mb
; i
++) {
1167 rc
[i
] = crypto_skcipher_encrypt(data
[i
].req
);
1169 rc
[i
] = crypto_skcipher_decrypt(data
[i
].req
);
1172 /* Wait for all requests to finish */
1173 for (i
= 0; i
< num_mb
; i
++) {
1174 rc
[i
] = crypto_wait_req(rc
[i
], &data
[i
].wait
);
1177 pr_info("concurrent request %d error %d\n", i
, rc
[i
]);
1185 static int test_mb_acipher_jiffies(struct test_mb_skcipher_data
*data
, int enc
,
1186 int blen
, int secs
, u32 num_mb
)
1188 unsigned long start
, end
;
1193 rc
= kcalloc(num_mb
, sizeof(*rc
), GFP_KERNEL
);
1197 for (start
= jiffies
, end
= start
+ secs
* HZ
, bcount
= 0;
1198 time_before(jiffies
, end
); bcount
++) {
1199 ret
= do_mult_acipher_op(data
, enc
, num_mb
, rc
);
1204 pr_cont("%d operations in %d seconds (%ld bytes)\n",
1205 bcount
* num_mb
, secs
, (long)bcount
* blen
* num_mb
);
1212 static int test_mb_acipher_cycles(struct test_mb_skcipher_data
*data
, int enc
,
1213 int blen
, u32 num_mb
)
1215 unsigned long cycles
= 0;
1220 rc
= kcalloc(num_mb
, sizeof(*rc
), GFP_KERNEL
);
1225 for (i
= 0; i
< 4; i
++) {
1226 ret
= do_mult_acipher_op(data
, enc
, num_mb
, rc
);
1231 /* The real thing. */
1232 for (i
= 0; i
< 8; i
++) {
1233 cycles_t start
, end
;
1235 start
= get_cycles();
1236 ret
= do_mult_acipher_op(data
, enc
, num_mb
, rc
);
1242 cycles
+= end
- start
;
1245 pr_cont("1 operation in %lu cycles (%d bytes)\n",
1246 (cycles
+ 4) / (8 * num_mb
), blen
);
1253 static void test_mb_skcipher_speed(const char *algo
, int enc
, int secs
,
1254 struct cipher_speed_template
*template,
1255 unsigned int tcount
, u8
*keysize
, u32 num_mb
)
1257 struct test_mb_skcipher_data
*data
;
1258 struct crypto_skcipher
*tfm
;
1259 unsigned int i
, j
, iv_len
;
1271 data
= kcalloc(num_mb
, sizeof(*data
), GFP_KERNEL
);
1275 tfm
= crypto_alloc_skcipher(algo
, 0, 0);
1277 pr_err("failed to load transform for %s: %ld\n",
1278 algo
, PTR_ERR(tfm
));
1282 for (i
= 0; i
< num_mb
; ++i
)
1283 if (testmgr_alloc_buf(data
[i
].xbuf
)) {
1285 testmgr_free_buf(data
[i
].xbuf
);
1290 for (i
= 0; i
< num_mb
; ++i
)
1291 if (testmgr_alloc_buf(data
[i
].xbuf
)) {
1293 testmgr_free_buf(data
[i
].xbuf
);
1298 for (i
= 0; i
< num_mb
; ++i
) {
1299 data
[i
].req
= skcipher_request_alloc(tfm
, GFP_KERNEL
);
1301 pr_err("alg: skcipher: Failed to allocate request for %s\n",
1304 skcipher_request_free(data
[i
].req
);
1309 for (i
= 0; i
< num_mb
; ++i
) {
1310 skcipher_request_set_callback(data
[i
].req
,
1311 CRYPTO_TFM_REQ_MAY_BACKLOG
,
1312 crypto_req_done
, &data
[i
].wait
);
1313 crypto_init_wait(&data
[i
].wait
);
1316 pr_info("\ntesting speed of multibuffer %s (%s) %s\n", algo
,
1317 get_driver_name(crypto_skcipher
, tfm
), e
);
1321 b_size
= block_sizes
;
1323 u32 bs
= round_up(*b_size
, crypto_skcipher_blocksize(tfm
));
1325 if (bs
> XBUFSIZE
* PAGE_SIZE
) {
1326 pr_err("template (%u) too big for buffer (%lu)\n",
1327 *b_size
, XBUFSIZE
* PAGE_SIZE
);
1331 pr_info("test %u (%d bit key, %d byte blocks): ", i
,
1334 /* Set up tfm global state, i.e. the key */
1336 memset(tvmem
[0], 0xff, PAGE_SIZE
);
1338 for (j
= 0; j
< tcount
; j
++) {
1339 if (template[j
].klen
== *keysize
) {
1340 key
= template[j
].key
;
1345 crypto_skcipher_clear_flags(tfm
, ~0);
1347 ret
= crypto_skcipher_setkey(tfm
, key
, *keysize
);
1349 pr_err("setkey() failed flags=%x\n",
1350 crypto_skcipher_get_flags(tfm
));
1354 iv_len
= crypto_skcipher_ivsize(tfm
);
1356 memset(&iv
, 0xff, iv_len
);
1358 /* Now setup per request stuff, i.e. buffers */
1360 for (j
= 0; j
< num_mb
; ++j
) {
1361 struct test_mb_skcipher_data
*cur
= &data
[j
];
1362 unsigned int k
= bs
;
1363 unsigned int pages
= DIV_ROUND_UP(k
, PAGE_SIZE
);
1366 sg_init_table(cur
->sg
, pages
);
1368 while (k
> PAGE_SIZE
) {
1369 sg_set_buf(cur
->sg
+ p
, cur
->xbuf
[p
],
1371 memset(cur
->xbuf
[p
], 0xff, PAGE_SIZE
);
1376 sg_set_buf(cur
->sg
+ p
, cur
->xbuf
[p
], k
);
1377 memset(cur
->xbuf
[p
], 0xff, k
);
1379 skcipher_request_set_crypt(cur
->req
, cur
->sg
,
1385 ret
= test_mb_acipher_jiffies(data
, enc
,
1390 ret
= test_mb_acipher_cycles(data
, enc
,
1395 pr_err("%s() failed flags=%x\n", e
,
1396 crypto_skcipher_get_flags(tfm
));
1406 for (i
= 0; i
< num_mb
; ++i
)
1407 skcipher_request_free(data
[i
].req
);
1409 for (i
= 0; i
< num_mb
; ++i
)
1410 testmgr_free_buf(data
[i
].xbuf
);
1412 crypto_free_skcipher(tfm
);
1417 static inline int do_one_acipher_op(struct skcipher_request
*req
, int ret
)
1419 struct crypto_wait
*wait
= req
->base
.data
;
1421 return crypto_wait_req(ret
, wait
);
1424 static int test_acipher_jiffies(struct skcipher_request
*req
, int enc
,
1427 unsigned long start
, end
;
1431 for (start
= jiffies
, end
= start
+ secs
* HZ
, bcount
= 0;
1432 time_before(jiffies
, end
); bcount
++) {
1434 ret
= do_one_acipher_op(req
,
1435 crypto_skcipher_encrypt(req
));
1437 ret
= do_one_acipher_op(req
,
1438 crypto_skcipher_decrypt(req
));
1444 pr_cont("%d operations in %d seconds (%ld bytes)\n",
1445 bcount
, secs
, (long)bcount
* blen
);
1449 static int test_acipher_cycles(struct skcipher_request
*req
, int enc
,
1452 unsigned long cycles
= 0;
1457 for (i
= 0; i
< 4; i
++) {
1459 ret
= do_one_acipher_op(req
,
1460 crypto_skcipher_encrypt(req
));
1462 ret
= do_one_acipher_op(req
,
1463 crypto_skcipher_decrypt(req
));
1469 /* The real thing. */
1470 for (i
= 0; i
< 8; i
++) {
1471 cycles_t start
, end
;
1473 start
= get_cycles();
1475 ret
= do_one_acipher_op(req
,
1476 crypto_skcipher_encrypt(req
));
1478 ret
= do_one_acipher_op(req
,
1479 crypto_skcipher_decrypt(req
));
1485 cycles
+= end
- start
;
1490 pr_cont("1 operation in %lu cycles (%d bytes)\n",
1491 (cycles
+ 4) / 8, blen
);
1496 static void test_skcipher_speed(const char *algo
, int enc
, unsigned int secs
,
1497 struct cipher_speed_template
*template,
1498 unsigned int tcount
, u8
*keysize
, bool async
)
1500 unsigned int ret
, i
, j
, k
, iv_len
;
1501 struct crypto_wait wait
;
1504 struct skcipher_request
*req
;
1505 struct crypto_skcipher
*tfm
;
1514 crypto_init_wait(&wait
);
1516 tfm
= crypto_alloc_skcipher(algo
, 0, async
? 0 : CRYPTO_ALG_ASYNC
);
1519 pr_err("failed to load transform for %s: %ld\n", algo
,
1524 pr_info("\ntesting speed of %s %s (%s) %s\n", async
? "async" : "sync",
1525 algo
, get_driver_name(crypto_skcipher
, tfm
), e
);
1527 req
= skcipher_request_alloc(tfm
, GFP_KERNEL
);
1529 pr_err("tcrypt: skcipher: Failed to allocate request for %s\n",
1534 skcipher_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
1535 crypto_req_done
, &wait
);
1539 b_size
= block_sizes
;
1542 u32 bs
= round_up(*b_size
, crypto_skcipher_blocksize(tfm
));
1543 struct scatterlist sg
[TVMEMSIZE
];
1545 if ((*keysize
+ bs
) > TVMEMSIZE
* PAGE_SIZE
) {
1546 pr_err("template (%u) too big for "
1547 "tvmem (%lu)\n", *keysize
+ bs
,
1548 TVMEMSIZE
* PAGE_SIZE
);
1552 pr_info("test %u (%d bit key, %d byte blocks): ", i
,
1555 memset(tvmem
[0], 0xff, PAGE_SIZE
);
1557 /* set key, plain text and IV */
1559 for (j
= 0; j
< tcount
; j
++) {
1560 if (template[j
].klen
== *keysize
) {
1561 key
= template[j
].key
;
1566 crypto_skcipher_clear_flags(tfm
, ~0);
1568 ret
= crypto_skcipher_setkey(tfm
, key
, *keysize
);
1570 pr_err("setkey() failed flags=%x\n",
1571 crypto_skcipher_get_flags(tfm
));
1576 sg_init_table(sg
, DIV_ROUND_UP(k
, PAGE_SIZE
));
1578 if (k
> PAGE_SIZE
) {
1579 sg_set_buf(sg
, tvmem
[0] + *keysize
,
1580 PAGE_SIZE
- *keysize
);
1583 while (k
> PAGE_SIZE
) {
1584 sg_set_buf(sg
+ j
, tvmem
[j
], PAGE_SIZE
);
1585 memset(tvmem
[j
], 0xff, PAGE_SIZE
);
1589 sg_set_buf(sg
+ j
, tvmem
[j
], k
);
1590 memset(tvmem
[j
], 0xff, k
);
1592 sg_set_buf(sg
, tvmem
[0] + *keysize
, bs
);
1595 iv_len
= crypto_skcipher_ivsize(tfm
);
1597 memset(&iv
, 0xff, iv_len
);
1599 skcipher_request_set_crypt(req
, sg
, sg
, bs
, iv
);
1602 ret
= test_acipher_jiffies(req
, enc
,
1606 ret
= test_acipher_cycles(req
, enc
,
1611 pr_err("%s() failed flags=%x\n", e
,
1612 crypto_skcipher_get_flags(tfm
));
1622 skcipher_request_free(req
);
1624 crypto_free_skcipher(tfm
);
1627 static void test_acipher_speed(const char *algo
, int enc
, unsigned int secs
,
1628 struct cipher_speed_template
*template,
1629 unsigned int tcount
, u8
*keysize
)
1631 return test_skcipher_speed(algo
, enc
, secs
, template, tcount
, keysize
,
1635 static void test_cipher_speed(const char *algo
, int enc
, unsigned int secs
,
1636 struct cipher_speed_template
*template,
1637 unsigned int tcount
, u8
*keysize
)
1639 return test_skcipher_speed(algo
, enc
, secs
, template, tcount
, keysize
,
1643 static void test_available(void)
1645 const char **name
= check
;
1648 printk("alg %s ", *name
);
1649 printk(crypto_has_alg(*name
, 0, 0) ?
1650 "found\n" : "not found\n");
1655 static inline int tcrypt_test(const char *alg
)
1659 pr_debug("testing %s\n", alg
);
1661 ret
= alg_test(alg
, alg
, 0, 0);
1662 /* non-fips algs return -EINVAL in fips mode */
1663 if (fips_enabled
&& ret
== -EINVAL
)
1668 static int do_test(const char *alg
, u32 type
, u32 mask
, int m
, u32 num_mb
)
1676 if (!crypto_has_alg(alg
, type
,
1677 mask
?: CRYPTO_ALG_TYPE_MASK
))
1682 for (i
= 1; i
< 200; i
++)
1683 ret
+= do_test(NULL
, 0, 0, i
, num_mb
);
1687 ret
+= tcrypt_test("md5");
1691 ret
+= tcrypt_test("sha1");
1695 ret
+= tcrypt_test("ecb(des)");
1696 ret
+= tcrypt_test("cbc(des)");
1697 ret
+= tcrypt_test("ctr(des)");
1701 ret
+= tcrypt_test("ecb(des3_ede)");
1702 ret
+= tcrypt_test("cbc(des3_ede)");
1703 ret
+= tcrypt_test("ctr(des3_ede)");
1707 ret
+= tcrypt_test("md4");
1711 ret
+= tcrypt_test("sha256");
1715 ret
+= tcrypt_test("ecb(blowfish)");
1716 ret
+= tcrypt_test("cbc(blowfish)");
1717 ret
+= tcrypt_test("ctr(blowfish)");
1721 ret
+= tcrypt_test("ecb(twofish)");
1722 ret
+= tcrypt_test("cbc(twofish)");
1723 ret
+= tcrypt_test("ctr(twofish)");
1724 ret
+= tcrypt_test("lrw(twofish)");
1725 ret
+= tcrypt_test("xts(twofish)");
1729 ret
+= tcrypt_test("ecb(serpent)");
1730 ret
+= tcrypt_test("cbc(serpent)");
1731 ret
+= tcrypt_test("ctr(serpent)");
1732 ret
+= tcrypt_test("lrw(serpent)");
1733 ret
+= tcrypt_test("xts(serpent)");
1737 ret
+= tcrypt_test("ecb(aes)");
1738 ret
+= tcrypt_test("cbc(aes)");
1739 ret
+= tcrypt_test("lrw(aes)");
1740 ret
+= tcrypt_test("xts(aes)");
1741 ret
+= tcrypt_test("ctr(aes)");
1742 ret
+= tcrypt_test("rfc3686(ctr(aes))");
1743 ret
+= tcrypt_test("ofb(aes)");
1744 ret
+= tcrypt_test("cfb(aes)");
1748 ret
+= tcrypt_test("sha384");
1752 ret
+= tcrypt_test("sha512");
1756 ret
+= tcrypt_test("deflate");
1760 ret
+= tcrypt_test("ecb(cast5)");
1761 ret
+= tcrypt_test("cbc(cast5)");
1762 ret
+= tcrypt_test("ctr(cast5)");
1766 ret
+= tcrypt_test("ecb(cast6)");
1767 ret
+= tcrypt_test("cbc(cast6)");
1768 ret
+= tcrypt_test("ctr(cast6)");
1769 ret
+= tcrypt_test("lrw(cast6)");
1770 ret
+= tcrypt_test("xts(cast6)");
1774 ret
+= tcrypt_test("ecb(arc4)");
1778 ret
+= tcrypt_test("michael_mic");
1782 ret
+= tcrypt_test("crc32c");
1786 ret
+= tcrypt_test("ecb(tea)");
1790 ret
+= tcrypt_test("ecb(xtea)");
1794 ret
+= tcrypt_test("ecb(khazad)");
1798 ret
+= tcrypt_test("wp512");
1802 ret
+= tcrypt_test("wp384");
1806 ret
+= tcrypt_test("wp256");
1810 ret
+= tcrypt_test("ecb(tnepres)");
1814 ret
+= tcrypt_test("ecb(anubis)");
1815 ret
+= tcrypt_test("cbc(anubis)");
1819 ret
+= tcrypt_test("tgr192");
1823 ret
+= tcrypt_test("tgr160");
1827 ret
+= tcrypt_test("tgr128");
1831 ret
+= tcrypt_test("ecb(xeta)");
1835 ret
+= tcrypt_test("pcbc(fcrypt)");
1839 ret
+= tcrypt_test("ecb(camellia)");
1840 ret
+= tcrypt_test("cbc(camellia)");
1841 ret
+= tcrypt_test("ctr(camellia)");
1842 ret
+= tcrypt_test("lrw(camellia)");
1843 ret
+= tcrypt_test("xts(camellia)");
1847 ret
+= tcrypt_test("sha224");
1851 ret
+= tcrypt_test("salsa20");
1855 ret
+= tcrypt_test("gcm(aes)");
1859 ret
+= tcrypt_test("lzo");
1863 ret
+= tcrypt_test("ccm(aes)");
1867 ret
+= tcrypt_test("cts(cbc(aes))");
1871 ret
+= tcrypt_test("rmd128");
1875 ret
+= tcrypt_test("rmd160");
1879 ret
+= tcrypt_test("rmd256");
1883 ret
+= tcrypt_test("rmd320");
1887 ret
+= tcrypt_test("ecb(seed)");
1891 ret
+= tcrypt_test("rfc4309(ccm(aes))");
1895 ret
+= tcrypt_test("ghash");
1899 ret
+= tcrypt_test("crct10dif");
1903 ret
+= tcrypt_test("sha3-224");
1907 ret
+= tcrypt_test("sha3-256");
1911 ret
+= tcrypt_test("sha3-384");
1915 ret
+= tcrypt_test("sha3-512");
1919 ret
+= tcrypt_test("sm3");
1923 ret
+= tcrypt_test("streebog256");
1927 ret
+= tcrypt_test("streebog512");
1931 ret
+= tcrypt_test("hmac(md5)");
1935 ret
+= tcrypt_test("hmac(sha1)");
1939 ret
+= tcrypt_test("hmac(sha256)");
1943 ret
+= tcrypt_test("hmac(sha384)");
1947 ret
+= tcrypt_test("hmac(sha512)");
1951 ret
+= tcrypt_test("hmac(sha224)");
1955 ret
+= tcrypt_test("xcbc(aes)");
1959 ret
+= tcrypt_test("hmac(rmd128)");
1963 ret
+= tcrypt_test("hmac(rmd160)");
1967 ret
+= tcrypt_test("vmac64(aes)");
1971 ret
+= tcrypt_test("hmac(sha3-224)");
1975 ret
+= tcrypt_test("hmac(sha3-256)");
1979 ret
+= tcrypt_test("hmac(sha3-384)");
1983 ret
+= tcrypt_test("hmac(sha3-512)");
1987 ret
+= tcrypt_test("hmac(streebog256)");
1991 ret
+= tcrypt_test("hmac(streebog512)");
1995 ret
+= tcrypt_test("ansi_cprng");
1999 ret
+= tcrypt_test("rfc4106(gcm(aes))");
2003 ret
+= tcrypt_test("rfc4543(gcm(aes))");
2007 ret
+= tcrypt_test("cmac(aes)");
2011 ret
+= tcrypt_test("cmac(des3_ede)");
2015 ret
+= tcrypt_test("authenc(hmac(sha1),cbc(aes))");
2019 ret
+= tcrypt_test("authenc(hmac(md5),ecb(cipher_null))");
2023 ret
+= tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))");
2026 ret
+= tcrypt_test("authenc(hmac(sha1),cbc(des))");
2029 ret
+= tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))");
2032 ret
+= tcrypt_test("authenc(hmac(sha224),cbc(des))");
2035 ret
+= tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))");
2038 ret
+= tcrypt_test("authenc(hmac(sha256),cbc(des))");
2041 ret
+= tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))");
2044 ret
+= tcrypt_test("authenc(hmac(sha384),cbc(des))");
2047 ret
+= tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))");
2050 ret
+= tcrypt_test("authenc(hmac(sha512),cbc(des))");
2053 ret
+= tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))");
2056 ret
+= tcrypt_test("ecb(sm4)");
2057 ret
+= tcrypt_test("cbc(sm4)");
2058 ret
+= tcrypt_test("ctr(sm4)");
2061 test_cipher_speed("ecb(aes)", ENCRYPT
, sec
, NULL
, 0,
2062 speed_template_16_24_32
);
2063 test_cipher_speed("ecb(aes)", DECRYPT
, sec
, NULL
, 0,
2064 speed_template_16_24_32
);
2065 test_cipher_speed("cbc(aes)", ENCRYPT
, sec
, NULL
, 0,
2066 speed_template_16_24_32
);
2067 test_cipher_speed("cbc(aes)", DECRYPT
, sec
, NULL
, 0,
2068 speed_template_16_24_32
);
2069 test_cipher_speed("lrw(aes)", ENCRYPT
, sec
, NULL
, 0,
2070 speed_template_32_40_48
);
2071 test_cipher_speed("lrw(aes)", DECRYPT
, sec
, NULL
, 0,
2072 speed_template_32_40_48
);
2073 test_cipher_speed("xts(aes)", ENCRYPT
, sec
, NULL
, 0,
2074 speed_template_32_64
);
2075 test_cipher_speed("xts(aes)", DECRYPT
, sec
, NULL
, 0,
2076 speed_template_32_64
);
2077 test_cipher_speed("cts(cbc(aes))", ENCRYPT
, sec
, NULL
, 0,
2078 speed_template_16_24_32
);
2079 test_cipher_speed("cts(cbc(aes))", DECRYPT
, sec
, NULL
, 0,
2080 speed_template_16_24_32
);
2081 test_cipher_speed("ctr(aes)", ENCRYPT
, sec
, NULL
, 0,
2082 speed_template_16_24_32
);
2083 test_cipher_speed("ctr(aes)", DECRYPT
, sec
, NULL
, 0,
2084 speed_template_16_24_32
);
2085 test_cipher_speed("cfb(aes)", ENCRYPT
, sec
, NULL
, 0,
2086 speed_template_16_24_32
);
2087 test_cipher_speed("cfb(aes)", DECRYPT
, sec
, NULL
, 0,
2088 speed_template_16_24_32
);
2092 test_cipher_speed("ecb(des3_ede)", ENCRYPT
, sec
,
2093 des3_speed_template
, DES3_SPEED_VECTORS
,
2095 test_cipher_speed("ecb(des3_ede)", DECRYPT
, sec
,
2096 des3_speed_template
, DES3_SPEED_VECTORS
,
2098 test_cipher_speed("cbc(des3_ede)", ENCRYPT
, sec
,
2099 des3_speed_template
, DES3_SPEED_VECTORS
,
2101 test_cipher_speed("cbc(des3_ede)", DECRYPT
, sec
,
2102 des3_speed_template
, DES3_SPEED_VECTORS
,
2104 test_cipher_speed("ctr(des3_ede)", ENCRYPT
, sec
,
2105 des3_speed_template
, DES3_SPEED_VECTORS
,
2107 test_cipher_speed("ctr(des3_ede)", DECRYPT
, sec
,
2108 des3_speed_template
, DES3_SPEED_VECTORS
,
2113 test_cipher_speed("ecb(twofish)", ENCRYPT
, sec
, NULL
, 0,
2114 speed_template_16_24_32
);
2115 test_cipher_speed("ecb(twofish)", DECRYPT
, sec
, NULL
, 0,
2116 speed_template_16_24_32
);
2117 test_cipher_speed("cbc(twofish)", ENCRYPT
, sec
, NULL
, 0,
2118 speed_template_16_24_32
);
2119 test_cipher_speed("cbc(twofish)", DECRYPT
, sec
, NULL
, 0,
2120 speed_template_16_24_32
);
2121 test_cipher_speed("ctr(twofish)", ENCRYPT
, sec
, NULL
, 0,
2122 speed_template_16_24_32
);
2123 test_cipher_speed("ctr(twofish)", DECRYPT
, sec
, NULL
, 0,
2124 speed_template_16_24_32
);
2125 test_cipher_speed("lrw(twofish)", ENCRYPT
, sec
, NULL
, 0,
2126 speed_template_32_40_48
);
2127 test_cipher_speed("lrw(twofish)", DECRYPT
, sec
, NULL
, 0,
2128 speed_template_32_40_48
);
2129 test_cipher_speed("xts(twofish)", ENCRYPT
, sec
, NULL
, 0,
2130 speed_template_32_48_64
);
2131 test_cipher_speed("xts(twofish)", DECRYPT
, sec
, NULL
, 0,
2132 speed_template_32_48_64
);
2136 test_cipher_speed("ecb(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2137 speed_template_8_32
);
2138 test_cipher_speed("ecb(blowfish)", DECRYPT
, sec
, NULL
, 0,
2139 speed_template_8_32
);
2140 test_cipher_speed("cbc(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2141 speed_template_8_32
);
2142 test_cipher_speed("cbc(blowfish)", DECRYPT
, sec
, NULL
, 0,
2143 speed_template_8_32
);
2144 test_cipher_speed("ctr(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2145 speed_template_8_32
);
2146 test_cipher_speed("ctr(blowfish)", DECRYPT
, sec
, NULL
, 0,
2147 speed_template_8_32
);
2151 test_cipher_speed("ecb(des)", ENCRYPT
, sec
, NULL
, 0,
2153 test_cipher_speed("ecb(des)", DECRYPT
, sec
, NULL
, 0,
2155 test_cipher_speed("cbc(des)", ENCRYPT
, sec
, NULL
, 0,
2157 test_cipher_speed("cbc(des)", DECRYPT
, sec
, NULL
, 0,
2162 test_cipher_speed("ecb(camellia)", ENCRYPT
, sec
, NULL
, 0,
2163 speed_template_16_24_32
);
2164 test_cipher_speed("ecb(camellia)", DECRYPT
, sec
, NULL
, 0,
2165 speed_template_16_24_32
);
2166 test_cipher_speed("cbc(camellia)", ENCRYPT
, sec
, NULL
, 0,
2167 speed_template_16_24_32
);
2168 test_cipher_speed("cbc(camellia)", DECRYPT
, sec
, NULL
, 0,
2169 speed_template_16_24_32
);
2170 test_cipher_speed("ctr(camellia)", ENCRYPT
, sec
, NULL
, 0,
2171 speed_template_16_24_32
);
2172 test_cipher_speed("ctr(camellia)", DECRYPT
, sec
, NULL
, 0,
2173 speed_template_16_24_32
);
2174 test_cipher_speed("lrw(camellia)", ENCRYPT
, sec
, NULL
, 0,
2175 speed_template_32_40_48
);
2176 test_cipher_speed("lrw(camellia)", DECRYPT
, sec
, NULL
, 0,
2177 speed_template_32_40_48
);
2178 test_cipher_speed("xts(camellia)", ENCRYPT
, sec
, NULL
, 0,
2179 speed_template_32_48_64
);
2180 test_cipher_speed("xts(camellia)", DECRYPT
, sec
, NULL
, 0,
2181 speed_template_32_48_64
);
2185 test_cipher_speed("salsa20", ENCRYPT
, sec
, NULL
, 0,
2186 speed_template_16_32
);
2190 test_cipher_speed("ecb(serpent)", ENCRYPT
, sec
, NULL
, 0,
2191 speed_template_16_32
);
2192 test_cipher_speed("ecb(serpent)", DECRYPT
, sec
, NULL
, 0,
2193 speed_template_16_32
);
2194 test_cipher_speed("cbc(serpent)", ENCRYPT
, sec
, NULL
, 0,
2195 speed_template_16_32
);
2196 test_cipher_speed("cbc(serpent)", DECRYPT
, sec
, NULL
, 0,
2197 speed_template_16_32
);
2198 test_cipher_speed("ctr(serpent)", ENCRYPT
, sec
, NULL
, 0,
2199 speed_template_16_32
);
2200 test_cipher_speed("ctr(serpent)", DECRYPT
, sec
, NULL
, 0,
2201 speed_template_16_32
);
2202 test_cipher_speed("lrw(serpent)", ENCRYPT
, sec
, NULL
, 0,
2203 speed_template_32_48
);
2204 test_cipher_speed("lrw(serpent)", DECRYPT
, sec
, NULL
, 0,
2205 speed_template_32_48
);
2206 test_cipher_speed("xts(serpent)", ENCRYPT
, sec
, NULL
, 0,
2207 speed_template_32_64
);
2208 test_cipher_speed("xts(serpent)", DECRYPT
, sec
, NULL
, 0,
2209 speed_template_32_64
);
2213 test_cipher_speed("ecb(arc4)", ENCRYPT
, sec
, NULL
, 0,
2218 test_cipher_speed("ecb(cast5)", ENCRYPT
, sec
, NULL
, 0,
2219 speed_template_8_16
);
2220 test_cipher_speed("ecb(cast5)", DECRYPT
, sec
, NULL
, 0,
2221 speed_template_8_16
);
2222 test_cipher_speed("cbc(cast5)", ENCRYPT
, sec
, NULL
, 0,
2223 speed_template_8_16
);
2224 test_cipher_speed("cbc(cast5)", DECRYPT
, sec
, NULL
, 0,
2225 speed_template_8_16
);
2226 test_cipher_speed("ctr(cast5)", ENCRYPT
, sec
, NULL
, 0,
2227 speed_template_8_16
);
2228 test_cipher_speed("ctr(cast5)", DECRYPT
, sec
, NULL
, 0,
2229 speed_template_8_16
);
2233 test_cipher_speed("ecb(cast6)", ENCRYPT
, sec
, NULL
, 0,
2234 speed_template_16_32
);
2235 test_cipher_speed("ecb(cast6)", DECRYPT
, sec
, NULL
, 0,
2236 speed_template_16_32
);
2237 test_cipher_speed("cbc(cast6)", ENCRYPT
, sec
, NULL
, 0,
2238 speed_template_16_32
);
2239 test_cipher_speed("cbc(cast6)", DECRYPT
, sec
, NULL
, 0,
2240 speed_template_16_32
);
2241 test_cipher_speed("ctr(cast6)", ENCRYPT
, sec
, NULL
, 0,
2242 speed_template_16_32
);
2243 test_cipher_speed("ctr(cast6)", DECRYPT
, sec
, NULL
, 0,
2244 speed_template_16_32
);
2245 test_cipher_speed("lrw(cast6)", ENCRYPT
, sec
, NULL
, 0,
2246 speed_template_32_48
);
2247 test_cipher_speed("lrw(cast6)", DECRYPT
, sec
, NULL
, 0,
2248 speed_template_32_48
);
2249 test_cipher_speed("xts(cast6)", ENCRYPT
, sec
, NULL
, 0,
2250 speed_template_32_64
);
2251 test_cipher_speed("xts(cast6)", DECRYPT
, sec
, NULL
, 0,
2252 speed_template_32_64
);
2256 test_aead_speed("rfc4106(gcm(aes))", ENCRYPT
, sec
,
2257 NULL
, 0, 16, 16, aead_speed_template_20
);
2258 test_aead_speed("gcm(aes)", ENCRYPT
, sec
,
2259 NULL
, 0, 16, 8, speed_template_16_24_32
);
2260 test_aead_speed("rfc4106(gcm(aes))", DECRYPT
, sec
,
2261 NULL
, 0, 16, 16, aead_speed_template_20
);
2262 test_aead_speed("gcm(aes)", DECRYPT
, sec
,
2263 NULL
, 0, 16, 8, speed_template_16_24_32
);
2267 test_aead_speed("rfc4309(ccm(aes))", ENCRYPT
, sec
,
2268 NULL
, 0, 16, 16, aead_speed_template_19
);
2269 test_aead_speed("rfc4309(ccm(aes))", DECRYPT
, sec
,
2270 NULL
, 0, 16, 16, aead_speed_template_19
);
2274 test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT
, sec
,
2275 NULL
, 0, 16, 8, aead_speed_template_36
);
2276 test_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT
, sec
,
2277 NULL
, 0, 16, 8, aead_speed_template_36
);
2281 test_cipher_speed("chacha20", ENCRYPT
, sec
, NULL
, 0,
2286 test_mb_aead_speed("rfc4106(gcm(aes))", ENCRYPT
, sec
, NULL
,
2287 0, 16, 16, aead_speed_template_20
, num_mb
);
2288 test_mb_aead_speed("gcm(aes)", ENCRYPT
, sec
, NULL
, 0, 16, 8,
2289 speed_template_16_24_32
, num_mb
);
2290 test_mb_aead_speed("rfc4106(gcm(aes))", DECRYPT
, sec
, NULL
,
2291 0, 16, 16, aead_speed_template_20
, num_mb
);
2292 test_mb_aead_speed("gcm(aes)", DECRYPT
, sec
, NULL
, 0, 16, 8,
2293 speed_template_16_24_32
, num_mb
);
2297 test_mb_aead_speed("rfc4309(ccm(aes))", ENCRYPT
, sec
, NULL
, 0,
2298 16, 16, aead_speed_template_19
, num_mb
);
2299 test_mb_aead_speed("rfc4309(ccm(aes))", DECRYPT
, sec
, NULL
, 0,
2300 16, 16, aead_speed_template_19
, num_mb
);
2304 test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT
,
2305 sec
, NULL
, 0, 16, 8, aead_speed_template_36
,
2307 test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT
,
2308 sec
, NULL
, 0, 16, 8, aead_speed_template_36
,
2313 test_cipher_speed("ecb(sm4)", ENCRYPT
, sec
, NULL
, 0,
2315 test_cipher_speed("ecb(sm4)", DECRYPT
, sec
, NULL
, 0,
2317 test_cipher_speed("cbc(sm4)", ENCRYPT
, sec
, NULL
, 0,
2319 test_cipher_speed("cbc(sm4)", DECRYPT
, sec
, NULL
, 0,
2321 test_cipher_speed("ctr(sm4)", ENCRYPT
, sec
, NULL
, 0,
2323 test_cipher_speed("ctr(sm4)", DECRYPT
, sec
, NULL
, 0,
2328 test_cipher_speed("adiantum(xchacha12,aes)", ENCRYPT
, sec
, NULL
,
2329 0, speed_template_32
);
2330 test_cipher_speed("adiantum(xchacha12,aes)", DECRYPT
, sec
, NULL
,
2331 0, speed_template_32
);
2332 test_cipher_speed("adiantum(xchacha20,aes)", ENCRYPT
, sec
, NULL
,
2333 0, speed_template_32
);
2334 test_cipher_speed("adiantum(xchacha20,aes)", DECRYPT
, sec
, NULL
,
2335 0, speed_template_32
);
2339 test_acipher_speed("essiv(cbc(aes),sha256)",
2340 ENCRYPT
, sec
, NULL
, 0,
2341 speed_template_16_24_32
);
2342 test_acipher_speed("essiv(cbc(aes),sha256)",
2343 DECRYPT
, sec
, NULL
, 0,
2344 speed_template_16_24_32
);
2348 test_aead_speed("aegis128", ENCRYPT
, sec
,
2349 NULL
, 0, 16, 8, speed_template_16
);
2350 test_aead_speed("aegis128", DECRYPT
, sec
,
2351 NULL
, 0, 16, 8, speed_template_16
);
2356 test_hash_speed(alg
, sec
, generic_hash_speed_template
);
2361 test_hash_speed("md4", sec
, generic_hash_speed_template
);
2362 if (mode
> 300 && mode
< 400) break;
2365 test_hash_speed("md5", sec
, generic_hash_speed_template
);
2366 if (mode
> 300 && mode
< 400) break;
2369 test_hash_speed("sha1", sec
, generic_hash_speed_template
);
2370 if (mode
> 300 && mode
< 400) break;
2373 test_hash_speed("sha256", sec
, generic_hash_speed_template
);
2374 if (mode
> 300 && mode
< 400) break;
2377 test_hash_speed("sha384", sec
, generic_hash_speed_template
);
2378 if (mode
> 300 && mode
< 400) break;
2381 test_hash_speed("sha512", sec
, generic_hash_speed_template
);
2382 if (mode
> 300 && mode
< 400) break;
2385 test_hash_speed("wp256", sec
, generic_hash_speed_template
);
2386 if (mode
> 300 && mode
< 400) break;
2389 test_hash_speed("wp384", sec
, generic_hash_speed_template
);
2390 if (mode
> 300 && mode
< 400) break;
2393 test_hash_speed("wp512", sec
, generic_hash_speed_template
);
2394 if (mode
> 300 && mode
< 400) break;
2397 test_hash_speed("tgr128", sec
, generic_hash_speed_template
);
2398 if (mode
> 300 && mode
< 400) break;
2401 test_hash_speed("tgr160", sec
, generic_hash_speed_template
);
2402 if (mode
> 300 && mode
< 400) break;
2405 test_hash_speed("tgr192", sec
, generic_hash_speed_template
);
2406 if (mode
> 300 && mode
< 400) break;
2409 test_hash_speed("sha224", sec
, generic_hash_speed_template
);
2410 if (mode
> 300 && mode
< 400) break;
2413 test_hash_speed("rmd128", sec
, generic_hash_speed_template
);
2414 if (mode
> 300 && mode
< 400) break;
2417 test_hash_speed("rmd160", sec
, generic_hash_speed_template
);
2418 if (mode
> 300 && mode
< 400) break;
2421 test_hash_speed("rmd256", sec
, generic_hash_speed_template
);
2422 if (mode
> 300 && mode
< 400) break;
2425 test_hash_speed("rmd320", sec
, generic_hash_speed_template
);
2426 if (mode
> 300 && mode
< 400) break;
2430 test_hash_speed("ghash", sec
, generic_hash_speed_template
);
2431 if (mode
> 300 && mode
< 400) break;
2434 test_hash_speed("crc32c", sec
, generic_hash_speed_template
);
2435 if (mode
> 300 && mode
< 400) break;
2438 test_hash_speed("crct10dif", sec
, generic_hash_speed_template
);
2439 if (mode
> 300 && mode
< 400) break;
2442 test_hash_speed("poly1305", sec
, poly1305_speed_template
);
2443 if (mode
> 300 && mode
< 400) break;
2446 test_hash_speed("sha3-224", sec
, generic_hash_speed_template
);
2447 if (mode
> 300 && mode
< 400) break;
2450 test_hash_speed("sha3-256", sec
, generic_hash_speed_template
);
2451 if (mode
> 300 && mode
< 400) break;
2454 test_hash_speed("sha3-384", sec
, generic_hash_speed_template
);
2455 if (mode
> 300 && mode
< 400) break;
2458 test_hash_speed("sha3-512", sec
, generic_hash_speed_template
);
2459 if (mode
> 300 && mode
< 400) break;
2462 test_hash_speed("sm3", sec
, generic_hash_speed_template
);
2463 if (mode
> 300 && mode
< 400) break;
2466 test_hash_speed("streebog256", sec
,
2467 generic_hash_speed_template
);
2468 if (mode
> 300 && mode
< 400) break;
2471 test_hash_speed("streebog512", sec
,
2472 generic_hash_speed_template
);
2473 if (mode
> 300 && mode
< 400) break;
2480 test_ahash_speed(alg
, sec
, generic_hash_speed_template
);
2485 test_ahash_speed("md4", sec
, generic_hash_speed_template
);
2486 if (mode
> 400 && mode
< 500) break;
2489 test_ahash_speed("md5", sec
, generic_hash_speed_template
);
2490 if (mode
> 400 && mode
< 500) break;
2493 test_ahash_speed("sha1", sec
, generic_hash_speed_template
);
2494 if (mode
> 400 && mode
< 500) break;
2497 test_ahash_speed("sha256", sec
, generic_hash_speed_template
);
2498 if (mode
> 400 && mode
< 500) break;
2501 test_ahash_speed("sha384", sec
, generic_hash_speed_template
);
2502 if (mode
> 400 && mode
< 500) break;
2505 test_ahash_speed("sha512", sec
, generic_hash_speed_template
);
2506 if (mode
> 400 && mode
< 500) break;
2509 test_ahash_speed("wp256", sec
, generic_hash_speed_template
);
2510 if (mode
> 400 && mode
< 500) break;
2513 test_ahash_speed("wp384", sec
, generic_hash_speed_template
);
2514 if (mode
> 400 && mode
< 500) break;
2517 test_ahash_speed("wp512", sec
, generic_hash_speed_template
);
2518 if (mode
> 400 && mode
< 500) break;
2521 test_ahash_speed("tgr128", sec
, generic_hash_speed_template
);
2522 if (mode
> 400 && mode
< 500) break;
2525 test_ahash_speed("tgr160", sec
, generic_hash_speed_template
);
2526 if (mode
> 400 && mode
< 500) break;
2529 test_ahash_speed("tgr192", sec
, generic_hash_speed_template
);
2530 if (mode
> 400 && mode
< 500) break;
2533 test_ahash_speed("sha224", sec
, generic_hash_speed_template
);
2534 if (mode
> 400 && mode
< 500) break;
2537 test_ahash_speed("rmd128", sec
, generic_hash_speed_template
);
2538 if (mode
> 400 && mode
< 500) break;
2541 test_ahash_speed("rmd160", sec
, generic_hash_speed_template
);
2542 if (mode
> 400 && mode
< 500) break;
2545 test_ahash_speed("rmd256", sec
, generic_hash_speed_template
);
2546 if (mode
> 400 && mode
< 500) break;
2549 test_ahash_speed("rmd320", sec
, generic_hash_speed_template
);
2550 if (mode
> 400 && mode
< 500) break;
2553 test_ahash_speed("sha3-224", sec
, generic_hash_speed_template
);
2554 if (mode
> 400 && mode
< 500) break;
2557 test_ahash_speed("sha3-256", sec
, generic_hash_speed_template
);
2558 if (mode
> 400 && mode
< 500) break;
2561 test_ahash_speed("sha3-384", sec
, generic_hash_speed_template
);
2562 if (mode
> 400 && mode
< 500) break;
2565 test_ahash_speed("sha3-512", sec
, generic_hash_speed_template
);
2566 if (mode
> 400 && mode
< 500) break;
2569 test_mb_ahash_speed("sha1", sec
, generic_hash_speed_template
,
2571 if (mode
> 400 && mode
< 500) break;
2574 test_mb_ahash_speed("sha256", sec
, generic_hash_speed_template
,
2576 if (mode
> 400 && mode
< 500) break;
2579 test_mb_ahash_speed("sha512", sec
, generic_hash_speed_template
,
2581 if (mode
> 400 && mode
< 500) break;
2584 test_mb_ahash_speed("sm3", sec
, generic_hash_speed_template
,
2586 if (mode
> 400 && mode
< 500) break;
2589 test_mb_ahash_speed("streebog256", sec
,
2590 generic_hash_speed_template
, num_mb
);
2591 if (mode
> 400 && mode
< 500) break;
2594 test_mb_ahash_speed("streebog512", sec
,
2595 generic_hash_speed_template
, num_mb
);
2596 if (mode
> 400 && mode
< 500) break;
2602 test_acipher_speed("ecb(aes)", ENCRYPT
, sec
, NULL
, 0,
2603 speed_template_16_24_32
);
2604 test_acipher_speed("ecb(aes)", DECRYPT
, sec
, NULL
, 0,
2605 speed_template_16_24_32
);
2606 test_acipher_speed("cbc(aes)", ENCRYPT
, sec
, NULL
, 0,
2607 speed_template_16_24_32
);
2608 test_acipher_speed("cbc(aes)", DECRYPT
, sec
, NULL
, 0,
2609 speed_template_16_24_32
);
2610 test_acipher_speed("lrw(aes)", ENCRYPT
, sec
, NULL
, 0,
2611 speed_template_32_40_48
);
2612 test_acipher_speed("lrw(aes)", DECRYPT
, sec
, NULL
, 0,
2613 speed_template_32_40_48
);
2614 test_acipher_speed("xts(aes)", ENCRYPT
, sec
, NULL
, 0,
2615 speed_template_32_64
);
2616 test_acipher_speed("xts(aes)", DECRYPT
, sec
, NULL
, 0,
2617 speed_template_32_64
);
2618 test_acipher_speed("cts(cbc(aes))", ENCRYPT
, sec
, NULL
, 0,
2619 speed_template_16_24_32
);
2620 test_acipher_speed("cts(cbc(aes))", DECRYPT
, sec
, NULL
, 0,
2621 speed_template_16_24_32
);
2622 test_acipher_speed("ctr(aes)", ENCRYPT
, sec
, NULL
, 0,
2623 speed_template_16_24_32
);
2624 test_acipher_speed("ctr(aes)", DECRYPT
, sec
, NULL
, 0,
2625 speed_template_16_24_32
);
2626 test_acipher_speed("cfb(aes)", ENCRYPT
, sec
, NULL
, 0,
2627 speed_template_16_24_32
);
2628 test_acipher_speed("cfb(aes)", DECRYPT
, sec
, NULL
, 0,
2629 speed_template_16_24_32
);
2630 test_acipher_speed("ofb(aes)", ENCRYPT
, sec
, NULL
, 0,
2631 speed_template_16_24_32
);
2632 test_acipher_speed("ofb(aes)", DECRYPT
, sec
, NULL
, 0,
2633 speed_template_16_24_32
);
2634 test_acipher_speed("rfc3686(ctr(aes))", ENCRYPT
, sec
, NULL
, 0,
2635 speed_template_20_28_36
);
2636 test_acipher_speed("rfc3686(ctr(aes))", DECRYPT
, sec
, NULL
, 0,
2637 speed_template_20_28_36
);
2641 test_acipher_speed("ecb(des3_ede)", ENCRYPT
, sec
,
2642 des3_speed_template
, DES3_SPEED_VECTORS
,
2644 test_acipher_speed("ecb(des3_ede)", DECRYPT
, sec
,
2645 des3_speed_template
, DES3_SPEED_VECTORS
,
2647 test_acipher_speed("cbc(des3_ede)", ENCRYPT
, sec
,
2648 des3_speed_template
, DES3_SPEED_VECTORS
,
2650 test_acipher_speed("cbc(des3_ede)", DECRYPT
, sec
,
2651 des3_speed_template
, DES3_SPEED_VECTORS
,
2653 test_acipher_speed("cfb(des3_ede)", ENCRYPT
, sec
,
2654 des3_speed_template
, DES3_SPEED_VECTORS
,
2656 test_acipher_speed("cfb(des3_ede)", DECRYPT
, sec
,
2657 des3_speed_template
, DES3_SPEED_VECTORS
,
2659 test_acipher_speed("ofb(des3_ede)", ENCRYPT
, sec
,
2660 des3_speed_template
, DES3_SPEED_VECTORS
,
2662 test_acipher_speed("ofb(des3_ede)", DECRYPT
, sec
,
2663 des3_speed_template
, DES3_SPEED_VECTORS
,
2668 test_acipher_speed("ecb(des)", ENCRYPT
, sec
, NULL
, 0,
2670 test_acipher_speed("ecb(des)", DECRYPT
, sec
, NULL
, 0,
2672 test_acipher_speed("cbc(des)", ENCRYPT
, sec
, NULL
, 0,
2674 test_acipher_speed("cbc(des)", DECRYPT
, sec
, NULL
, 0,
2676 test_acipher_speed("cfb(des)", ENCRYPT
, sec
, NULL
, 0,
2678 test_acipher_speed("cfb(des)", DECRYPT
, sec
, NULL
, 0,
2680 test_acipher_speed("ofb(des)", ENCRYPT
, sec
, NULL
, 0,
2682 test_acipher_speed("ofb(des)", DECRYPT
, sec
, NULL
, 0,
2687 test_acipher_speed("ecb(serpent)", ENCRYPT
, sec
, NULL
, 0,
2688 speed_template_16_32
);
2689 test_acipher_speed("ecb(serpent)", DECRYPT
, sec
, NULL
, 0,
2690 speed_template_16_32
);
2691 test_acipher_speed("cbc(serpent)", ENCRYPT
, sec
, NULL
, 0,
2692 speed_template_16_32
);
2693 test_acipher_speed("cbc(serpent)", DECRYPT
, sec
, NULL
, 0,
2694 speed_template_16_32
);
2695 test_acipher_speed("ctr(serpent)", ENCRYPT
, sec
, NULL
, 0,
2696 speed_template_16_32
);
2697 test_acipher_speed("ctr(serpent)", DECRYPT
, sec
, NULL
, 0,
2698 speed_template_16_32
);
2699 test_acipher_speed("lrw(serpent)", ENCRYPT
, sec
, NULL
, 0,
2700 speed_template_32_48
);
2701 test_acipher_speed("lrw(serpent)", DECRYPT
, sec
, NULL
, 0,
2702 speed_template_32_48
);
2703 test_acipher_speed("xts(serpent)", ENCRYPT
, sec
, NULL
, 0,
2704 speed_template_32_64
);
2705 test_acipher_speed("xts(serpent)", DECRYPT
, sec
, NULL
, 0,
2706 speed_template_32_64
);
2710 test_acipher_speed("ecb(twofish)", ENCRYPT
, sec
, NULL
, 0,
2711 speed_template_16_24_32
);
2712 test_acipher_speed("ecb(twofish)", DECRYPT
, sec
, NULL
, 0,
2713 speed_template_16_24_32
);
2714 test_acipher_speed("cbc(twofish)", ENCRYPT
, sec
, NULL
, 0,
2715 speed_template_16_24_32
);
2716 test_acipher_speed("cbc(twofish)", DECRYPT
, sec
, NULL
, 0,
2717 speed_template_16_24_32
);
2718 test_acipher_speed("ctr(twofish)", ENCRYPT
, sec
, NULL
, 0,
2719 speed_template_16_24_32
);
2720 test_acipher_speed("ctr(twofish)", DECRYPT
, sec
, NULL
, 0,
2721 speed_template_16_24_32
);
2722 test_acipher_speed("lrw(twofish)", ENCRYPT
, sec
, NULL
, 0,
2723 speed_template_32_40_48
);
2724 test_acipher_speed("lrw(twofish)", DECRYPT
, sec
, NULL
, 0,
2725 speed_template_32_40_48
);
2726 test_acipher_speed("xts(twofish)", ENCRYPT
, sec
, NULL
, 0,
2727 speed_template_32_48_64
);
2728 test_acipher_speed("xts(twofish)", DECRYPT
, sec
, NULL
, 0,
2729 speed_template_32_48_64
);
2733 test_acipher_speed("ecb(arc4)", ENCRYPT
, sec
, NULL
, 0,
2738 test_acipher_speed("ecb(cast5)", ENCRYPT
, sec
, NULL
, 0,
2739 speed_template_8_16
);
2740 test_acipher_speed("ecb(cast5)", DECRYPT
, sec
, NULL
, 0,
2741 speed_template_8_16
);
2742 test_acipher_speed("cbc(cast5)", ENCRYPT
, sec
, NULL
, 0,
2743 speed_template_8_16
);
2744 test_acipher_speed("cbc(cast5)", DECRYPT
, sec
, NULL
, 0,
2745 speed_template_8_16
);
2746 test_acipher_speed("ctr(cast5)", ENCRYPT
, sec
, NULL
, 0,
2747 speed_template_8_16
);
2748 test_acipher_speed("ctr(cast5)", DECRYPT
, sec
, NULL
, 0,
2749 speed_template_8_16
);
2753 test_acipher_speed("ecb(cast6)", ENCRYPT
, sec
, NULL
, 0,
2754 speed_template_16_32
);
2755 test_acipher_speed("ecb(cast6)", DECRYPT
, sec
, NULL
, 0,
2756 speed_template_16_32
);
2757 test_acipher_speed("cbc(cast6)", ENCRYPT
, sec
, NULL
, 0,
2758 speed_template_16_32
);
2759 test_acipher_speed("cbc(cast6)", DECRYPT
, sec
, NULL
, 0,
2760 speed_template_16_32
);
2761 test_acipher_speed("ctr(cast6)", ENCRYPT
, sec
, NULL
, 0,
2762 speed_template_16_32
);
2763 test_acipher_speed("ctr(cast6)", DECRYPT
, sec
, NULL
, 0,
2764 speed_template_16_32
);
2765 test_acipher_speed("lrw(cast6)", ENCRYPT
, sec
, NULL
, 0,
2766 speed_template_32_48
);
2767 test_acipher_speed("lrw(cast6)", DECRYPT
, sec
, NULL
, 0,
2768 speed_template_32_48
);
2769 test_acipher_speed("xts(cast6)", ENCRYPT
, sec
, NULL
, 0,
2770 speed_template_32_64
);
2771 test_acipher_speed("xts(cast6)", DECRYPT
, sec
, NULL
, 0,
2772 speed_template_32_64
);
2776 test_acipher_speed("ecb(camellia)", ENCRYPT
, sec
, NULL
, 0,
2777 speed_template_16_32
);
2778 test_acipher_speed("ecb(camellia)", DECRYPT
, sec
, NULL
, 0,
2779 speed_template_16_32
);
2780 test_acipher_speed("cbc(camellia)", ENCRYPT
, sec
, NULL
, 0,
2781 speed_template_16_32
);
2782 test_acipher_speed("cbc(camellia)", DECRYPT
, sec
, NULL
, 0,
2783 speed_template_16_32
);
2784 test_acipher_speed("ctr(camellia)", ENCRYPT
, sec
, NULL
, 0,
2785 speed_template_16_32
);
2786 test_acipher_speed("ctr(camellia)", DECRYPT
, sec
, NULL
, 0,
2787 speed_template_16_32
);
2788 test_acipher_speed("lrw(camellia)", ENCRYPT
, sec
, NULL
, 0,
2789 speed_template_32_48
);
2790 test_acipher_speed("lrw(camellia)", DECRYPT
, sec
, NULL
, 0,
2791 speed_template_32_48
);
2792 test_acipher_speed("xts(camellia)", ENCRYPT
, sec
, NULL
, 0,
2793 speed_template_32_64
);
2794 test_acipher_speed("xts(camellia)", DECRYPT
, sec
, NULL
, 0,
2795 speed_template_32_64
);
2799 test_acipher_speed("ecb(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2800 speed_template_8_32
);
2801 test_acipher_speed("ecb(blowfish)", DECRYPT
, sec
, NULL
, 0,
2802 speed_template_8_32
);
2803 test_acipher_speed("cbc(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2804 speed_template_8_32
);
2805 test_acipher_speed("cbc(blowfish)", DECRYPT
, sec
, NULL
, 0,
2806 speed_template_8_32
);
2807 test_acipher_speed("ctr(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2808 speed_template_8_32
);
2809 test_acipher_speed("ctr(blowfish)", DECRYPT
, sec
, NULL
, 0,
2810 speed_template_8_32
);
2814 test_mb_skcipher_speed("ecb(aes)", ENCRYPT
, sec
, NULL
, 0,
2815 speed_template_16_24_32
, num_mb
);
2816 test_mb_skcipher_speed("ecb(aes)", DECRYPT
, sec
, NULL
, 0,
2817 speed_template_16_24_32
, num_mb
);
2818 test_mb_skcipher_speed("cbc(aes)", ENCRYPT
, sec
, NULL
, 0,
2819 speed_template_16_24_32
, num_mb
);
2820 test_mb_skcipher_speed("cbc(aes)", DECRYPT
, sec
, NULL
, 0,
2821 speed_template_16_24_32
, num_mb
);
2822 test_mb_skcipher_speed("lrw(aes)", ENCRYPT
, sec
, NULL
, 0,
2823 speed_template_32_40_48
, num_mb
);
2824 test_mb_skcipher_speed("lrw(aes)", DECRYPT
, sec
, NULL
, 0,
2825 speed_template_32_40_48
, num_mb
);
2826 test_mb_skcipher_speed("xts(aes)", ENCRYPT
, sec
, NULL
, 0,
2827 speed_template_32_64
, num_mb
);
2828 test_mb_skcipher_speed("xts(aes)", DECRYPT
, sec
, NULL
, 0,
2829 speed_template_32_64
, num_mb
);
2830 test_mb_skcipher_speed("cts(cbc(aes))", ENCRYPT
, sec
, NULL
, 0,
2831 speed_template_16_24_32
, num_mb
);
2832 test_mb_skcipher_speed("cts(cbc(aes))", DECRYPT
, sec
, NULL
, 0,
2833 speed_template_16_24_32
, num_mb
);
2834 test_mb_skcipher_speed("ctr(aes)", ENCRYPT
, sec
, NULL
, 0,
2835 speed_template_16_24_32
, num_mb
);
2836 test_mb_skcipher_speed("ctr(aes)", DECRYPT
, sec
, NULL
, 0,
2837 speed_template_16_24_32
, num_mb
);
2838 test_mb_skcipher_speed("cfb(aes)", ENCRYPT
, sec
, NULL
, 0,
2839 speed_template_16_24_32
, num_mb
);
2840 test_mb_skcipher_speed("cfb(aes)", DECRYPT
, sec
, NULL
, 0,
2841 speed_template_16_24_32
, num_mb
);
2842 test_mb_skcipher_speed("ofb(aes)", ENCRYPT
, sec
, NULL
, 0,
2843 speed_template_16_24_32
, num_mb
);
2844 test_mb_skcipher_speed("ofb(aes)", DECRYPT
, sec
, NULL
, 0,
2845 speed_template_16_24_32
, num_mb
);
2846 test_mb_skcipher_speed("rfc3686(ctr(aes))", ENCRYPT
, sec
, NULL
,
2847 0, speed_template_20_28_36
, num_mb
);
2848 test_mb_skcipher_speed("rfc3686(ctr(aes))", DECRYPT
, sec
, NULL
,
2849 0, speed_template_20_28_36
, num_mb
);
2853 test_mb_skcipher_speed("ecb(des3_ede)", ENCRYPT
, sec
,
2854 des3_speed_template
, DES3_SPEED_VECTORS
,
2855 speed_template_24
, num_mb
);
2856 test_mb_skcipher_speed("ecb(des3_ede)", DECRYPT
, sec
,
2857 des3_speed_template
, DES3_SPEED_VECTORS
,
2858 speed_template_24
, num_mb
);
2859 test_mb_skcipher_speed("cbc(des3_ede)", ENCRYPT
, sec
,
2860 des3_speed_template
, DES3_SPEED_VECTORS
,
2861 speed_template_24
, num_mb
);
2862 test_mb_skcipher_speed("cbc(des3_ede)", DECRYPT
, sec
,
2863 des3_speed_template
, DES3_SPEED_VECTORS
,
2864 speed_template_24
, num_mb
);
2865 test_mb_skcipher_speed("cfb(des3_ede)", ENCRYPT
, sec
,
2866 des3_speed_template
, DES3_SPEED_VECTORS
,
2867 speed_template_24
, num_mb
);
2868 test_mb_skcipher_speed("cfb(des3_ede)", DECRYPT
, sec
,
2869 des3_speed_template
, DES3_SPEED_VECTORS
,
2870 speed_template_24
, num_mb
);
2871 test_mb_skcipher_speed("ofb(des3_ede)", ENCRYPT
, sec
,
2872 des3_speed_template
, DES3_SPEED_VECTORS
,
2873 speed_template_24
, num_mb
);
2874 test_mb_skcipher_speed("ofb(des3_ede)", DECRYPT
, sec
,
2875 des3_speed_template
, DES3_SPEED_VECTORS
,
2876 speed_template_24
, num_mb
);
2880 test_mb_skcipher_speed("ecb(des)", ENCRYPT
, sec
, NULL
, 0,
2881 speed_template_8
, num_mb
);
2882 test_mb_skcipher_speed("ecb(des)", DECRYPT
, sec
, NULL
, 0,
2883 speed_template_8
, num_mb
);
2884 test_mb_skcipher_speed("cbc(des)", ENCRYPT
, sec
, NULL
, 0,
2885 speed_template_8
, num_mb
);
2886 test_mb_skcipher_speed("cbc(des)", DECRYPT
, sec
, NULL
, 0,
2887 speed_template_8
, num_mb
);
2888 test_mb_skcipher_speed("cfb(des)", ENCRYPT
, sec
, NULL
, 0,
2889 speed_template_8
, num_mb
);
2890 test_mb_skcipher_speed("cfb(des)", DECRYPT
, sec
, NULL
, 0,
2891 speed_template_8
, num_mb
);
2892 test_mb_skcipher_speed("ofb(des)", ENCRYPT
, sec
, NULL
, 0,
2893 speed_template_8
, num_mb
);
2894 test_mb_skcipher_speed("ofb(des)", DECRYPT
, sec
, NULL
, 0,
2895 speed_template_8
, num_mb
);
2899 test_mb_skcipher_speed("ecb(serpent)", ENCRYPT
, sec
, NULL
, 0,
2900 speed_template_16_32
, num_mb
);
2901 test_mb_skcipher_speed("ecb(serpent)", DECRYPT
, sec
, NULL
, 0,
2902 speed_template_16_32
, num_mb
);
2903 test_mb_skcipher_speed("cbc(serpent)", ENCRYPT
, sec
, NULL
, 0,
2904 speed_template_16_32
, num_mb
);
2905 test_mb_skcipher_speed("cbc(serpent)", DECRYPT
, sec
, NULL
, 0,
2906 speed_template_16_32
, num_mb
);
2907 test_mb_skcipher_speed("ctr(serpent)", ENCRYPT
, sec
, NULL
, 0,
2908 speed_template_16_32
, num_mb
);
2909 test_mb_skcipher_speed("ctr(serpent)", DECRYPT
, sec
, NULL
, 0,
2910 speed_template_16_32
, num_mb
);
2911 test_mb_skcipher_speed("lrw(serpent)", ENCRYPT
, sec
, NULL
, 0,
2912 speed_template_32_48
, num_mb
);
2913 test_mb_skcipher_speed("lrw(serpent)", DECRYPT
, sec
, NULL
, 0,
2914 speed_template_32_48
, num_mb
);
2915 test_mb_skcipher_speed("xts(serpent)", ENCRYPT
, sec
, NULL
, 0,
2916 speed_template_32_64
, num_mb
);
2917 test_mb_skcipher_speed("xts(serpent)", DECRYPT
, sec
, NULL
, 0,
2918 speed_template_32_64
, num_mb
);
2922 test_mb_skcipher_speed("ecb(twofish)", ENCRYPT
, sec
, NULL
, 0,
2923 speed_template_16_24_32
, num_mb
);
2924 test_mb_skcipher_speed("ecb(twofish)", DECRYPT
, sec
, NULL
, 0,
2925 speed_template_16_24_32
, num_mb
);
2926 test_mb_skcipher_speed("cbc(twofish)", ENCRYPT
, sec
, NULL
, 0,
2927 speed_template_16_24_32
, num_mb
);
2928 test_mb_skcipher_speed("cbc(twofish)", DECRYPT
, sec
, NULL
, 0,
2929 speed_template_16_24_32
, num_mb
);
2930 test_mb_skcipher_speed("ctr(twofish)", ENCRYPT
, sec
, NULL
, 0,
2931 speed_template_16_24_32
, num_mb
);
2932 test_mb_skcipher_speed("ctr(twofish)", DECRYPT
, sec
, NULL
, 0,
2933 speed_template_16_24_32
, num_mb
);
2934 test_mb_skcipher_speed("lrw(twofish)", ENCRYPT
, sec
, NULL
, 0,
2935 speed_template_32_40_48
, num_mb
);
2936 test_mb_skcipher_speed("lrw(twofish)", DECRYPT
, sec
, NULL
, 0,
2937 speed_template_32_40_48
, num_mb
);
2938 test_mb_skcipher_speed("xts(twofish)", ENCRYPT
, sec
, NULL
, 0,
2939 speed_template_32_48_64
, num_mb
);
2940 test_mb_skcipher_speed("xts(twofish)", DECRYPT
, sec
, NULL
, 0,
2941 speed_template_32_48_64
, num_mb
);
2945 test_mb_skcipher_speed("ecb(arc4)", ENCRYPT
, sec
, NULL
, 0,
2946 speed_template_8
, num_mb
);
2950 test_mb_skcipher_speed("ecb(cast5)", ENCRYPT
, sec
, NULL
, 0,
2951 speed_template_8_16
, num_mb
);
2952 test_mb_skcipher_speed("ecb(cast5)", DECRYPT
, sec
, NULL
, 0,
2953 speed_template_8_16
, num_mb
);
2954 test_mb_skcipher_speed("cbc(cast5)", ENCRYPT
, sec
, NULL
, 0,
2955 speed_template_8_16
, num_mb
);
2956 test_mb_skcipher_speed("cbc(cast5)", DECRYPT
, sec
, NULL
, 0,
2957 speed_template_8_16
, num_mb
);
2958 test_mb_skcipher_speed("ctr(cast5)", ENCRYPT
, sec
, NULL
, 0,
2959 speed_template_8_16
, num_mb
);
2960 test_mb_skcipher_speed("ctr(cast5)", DECRYPT
, sec
, NULL
, 0,
2961 speed_template_8_16
, num_mb
);
2965 test_mb_skcipher_speed("ecb(cast6)", ENCRYPT
, sec
, NULL
, 0,
2966 speed_template_16_32
, num_mb
);
2967 test_mb_skcipher_speed("ecb(cast6)", DECRYPT
, sec
, NULL
, 0,
2968 speed_template_16_32
, num_mb
);
2969 test_mb_skcipher_speed("cbc(cast6)", ENCRYPT
, sec
, NULL
, 0,
2970 speed_template_16_32
, num_mb
);
2971 test_mb_skcipher_speed("cbc(cast6)", DECRYPT
, sec
, NULL
, 0,
2972 speed_template_16_32
, num_mb
);
2973 test_mb_skcipher_speed("ctr(cast6)", ENCRYPT
, sec
, NULL
, 0,
2974 speed_template_16_32
, num_mb
);
2975 test_mb_skcipher_speed("ctr(cast6)", DECRYPT
, sec
, NULL
, 0,
2976 speed_template_16_32
, num_mb
);
2977 test_mb_skcipher_speed("lrw(cast6)", ENCRYPT
, sec
, NULL
, 0,
2978 speed_template_32_48
, num_mb
);
2979 test_mb_skcipher_speed("lrw(cast6)", DECRYPT
, sec
, NULL
, 0,
2980 speed_template_32_48
, num_mb
);
2981 test_mb_skcipher_speed("xts(cast6)", ENCRYPT
, sec
, NULL
, 0,
2982 speed_template_32_64
, num_mb
);
2983 test_mb_skcipher_speed("xts(cast6)", DECRYPT
, sec
, NULL
, 0,
2984 speed_template_32_64
, num_mb
);
2988 test_mb_skcipher_speed("ecb(camellia)", ENCRYPT
, sec
, NULL
, 0,
2989 speed_template_16_32
, num_mb
);
2990 test_mb_skcipher_speed("ecb(camellia)", DECRYPT
, sec
, NULL
, 0,
2991 speed_template_16_32
, num_mb
);
2992 test_mb_skcipher_speed("cbc(camellia)", ENCRYPT
, sec
, NULL
, 0,
2993 speed_template_16_32
, num_mb
);
2994 test_mb_skcipher_speed("cbc(camellia)", DECRYPT
, sec
, NULL
, 0,
2995 speed_template_16_32
, num_mb
);
2996 test_mb_skcipher_speed("ctr(camellia)", ENCRYPT
, sec
, NULL
, 0,
2997 speed_template_16_32
, num_mb
);
2998 test_mb_skcipher_speed("ctr(camellia)", DECRYPT
, sec
, NULL
, 0,
2999 speed_template_16_32
, num_mb
);
3000 test_mb_skcipher_speed("lrw(camellia)", ENCRYPT
, sec
, NULL
, 0,
3001 speed_template_32_48
, num_mb
);
3002 test_mb_skcipher_speed("lrw(camellia)", DECRYPT
, sec
, NULL
, 0,
3003 speed_template_32_48
, num_mb
);
3004 test_mb_skcipher_speed("xts(camellia)", ENCRYPT
, sec
, NULL
, 0,
3005 speed_template_32_64
, num_mb
);
3006 test_mb_skcipher_speed("xts(camellia)", DECRYPT
, sec
, NULL
, 0,
3007 speed_template_32_64
, num_mb
);
3011 test_mb_skcipher_speed("ecb(blowfish)", ENCRYPT
, sec
, NULL
, 0,
3012 speed_template_8_32
, num_mb
);
3013 test_mb_skcipher_speed("ecb(blowfish)", DECRYPT
, sec
, NULL
, 0,
3014 speed_template_8_32
, num_mb
);
3015 test_mb_skcipher_speed("cbc(blowfish)", ENCRYPT
, sec
, NULL
, 0,
3016 speed_template_8_32
, num_mb
);
3017 test_mb_skcipher_speed("cbc(blowfish)", DECRYPT
, sec
, NULL
, 0,
3018 speed_template_8_32
, num_mb
);
3019 test_mb_skcipher_speed("ctr(blowfish)", ENCRYPT
, sec
, NULL
, 0,
3020 speed_template_8_32
, num_mb
);
3021 test_mb_skcipher_speed("ctr(blowfish)", DECRYPT
, sec
, NULL
, 0,
3022 speed_template_8_32
, num_mb
);
3033 static int __init
tcrypt_mod_init(void)
3038 for (i
= 0; i
< TVMEMSIZE
; i
++) {
3039 tvmem
[i
] = (void *)__get_free_page(GFP_KERNEL
);
3044 err
= do_test(alg
, type
, mask
, mode
, num_mb
);
3047 printk(KERN_ERR
"tcrypt: one or more tests failed!\n");
3050 pr_debug("all tests passed\n");
3053 /* We intentionaly return -EAGAIN to prevent keeping the module,
3054 * unless we're running in fips mode. It does all its work from
3055 * init() and doesn't offer any runtime functionality, but in
3056 * the fips case, checking for a successful load is helpful.
3057 * => we don't need it in the memory, do we?
3064 for (i
= 0; i
< TVMEMSIZE
&& tvmem
[i
]; i
++)
3065 free_page((unsigned long)tvmem
[i
]);
3071 * If an init function is provided, an exit function must also be provided
3072 * to allow module unload.
3074 static void __exit
tcrypt_mod_fini(void) { }
3076 late_initcall(tcrypt_mod_init
);
3077 module_exit(tcrypt_mod_fini
);
3079 module_param(alg
, charp
, 0);
3080 module_param(type
, uint
, 0);
3081 module_param(mask
, uint
, 0);
3082 module_param(mode
, int, 0);
3083 module_param(sec
, uint
, 0);
3084 MODULE_PARM_DESC(sec
, "Length in seconds of speed tests "
3085 "(defaults to zero which uses CPU cycles instead)");
3086 module_param(num_mb
, uint
, 0000);
3087 MODULE_PARM_DESC(num_mb
, "Number of concurrent requests to be used in mb speed tests (defaults to 8)");
3088 module_param(klen
, uint
, 0);
3089 MODULE_PARM_DESC(klen
, "Key length (defaults to 0)");
3091 MODULE_LICENSE("GPL");
3092 MODULE_DESCRIPTION("Quick & dirty crypto testing module");
3093 MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");