2 * Quick & dirty crypto testing module.
4 * This will only exist until we have a better testing mechanism
5 * (e.g. a char device).
7 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
8 * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
9 * Copyright (c) 2007 Nokia Siemens Networks
11 * Updated RFC4106 AES-GCM testing.
12 * Authors: Aidan O'Mahony (aidan.o.mahony@intel.com)
13 * Adrian Hoban <adrian.hoban@intel.com>
14 * Gabriele Paoloni <gabriele.paoloni@intel.com>
15 * Tadeusz Struk (tadeusz.struk@intel.com)
16 * Copyright (c) 2010, Intel Corporation.
18 * This program is free software; you can redistribute it and/or modify it
19 * under the terms of the GNU General Public License as published by the Free
20 * Software Foundation; either version 2 of the License, or (at your option)
25 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
27 #include <crypto/aead.h>
28 #include <crypto/hash.h>
29 #include <crypto/skcipher.h>
30 #include <linux/err.h>
31 #include <linux/fips.h>
32 #include <linux/init.h>
33 #include <linux/gfp.h>
34 #include <linux/module.h>
35 #include <linux/scatterlist.h>
36 #include <linux/string.h>
37 #include <linux/moduleparam.h>
38 #include <linux/jiffies.h>
39 #include <linux/timex.h>
40 #include <linux/interrupt.h>
44 * Need slab memory for testing (size in number of pages).
49 * Used by test_cipher_speed()
54 #define MAX_DIGEST_SIZE 64
57 * return a string with the driver name
59 #define get_driver_name(tfm_type, tfm) crypto_tfm_alg_driver_name(tfm_type ## _tfm(tfm))
62 * Used by test_cipher_speed()
64 static unsigned int sec
;
66 static char *alg
= NULL
;
70 static u32 num_mb
= 8;
71 static char *tvmem
[TVMEMSIZE
];
73 static char *check
[] = {
74 "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", "sm3",
75 "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
76 "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
77 "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
78 "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320",
79 "lzo", "cts", "sha3-224", "sha3-256", "sha3-384", "sha3-512",
80 "streebog256", "streebog512",
84 static u32 block_sizes
[] = { 16, 64, 256, 1024, 1472, 8192, 0 };
85 static u32 aead_sizes
[] = { 16, 64, 256, 512, 1024, 2048, 4096, 8192, 0 };
90 static int testmgr_alloc_buf(char *buf
[XBUFSIZE
])
94 for (i
= 0; i
< XBUFSIZE
; i
++) {
95 buf
[i
] = (void *)__get_free_page(GFP_KERNEL
);
104 free_page((unsigned long)buf
[i
]);
109 static void testmgr_free_buf(char *buf
[XBUFSIZE
])
113 for (i
= 0; i
< XBUFSIZE
; i
++)
114 free_page((unsigned long)buf
[i
]);
117 static void sg_init_aead(struct scatterlist
*sg
, char *xbuf
[XBUFSIZE
],
118 unsigned int buflen
, const void *assoc
,
119 unsigned int aad_size
)
121 int np
= (buflen
+ PAGE_SIZE
- 1)/PAGE_SIZE
;
128 rem
= buflen
% PAGE_SIZE
;
131 sg_init_table(sg
, np
+ 1);
133 sg_set_buf(&sg
[0], assoc
, aad_size
);
137 for (k
= 0; k
< np
; k
++)
138 sg_set_buf(&sg
[k
+ 1], xbuf
[k
], PAGE_SIZE
);
141 sg_set_buf(&sg
[k
+ 1], xbuf
[k
], rem
);
144 static inline int do_one_aead_op(struct aead_request
*req
, int ret
)
146 struct crypto_wait
*wait
= req
->base
.data
;
148 return crypto_wait_req(ret
, wait
);
151 struct test_mb_aead_data
{
152 struct scatterlist sg
[XBUFSIZE
];
153 struct scatterlist sgout
[XBUFSIZE
];
154 struct aead_request
*req
;
155 struct crypto_wait wait
;
156 char *xbuf
[XBUFSIZE
];
157 char *xoutbuf
[XBUFSIZE
];
158 char *axbuf
[XBUFSIZE
];
161 static int do_mult_aead_op(struct test_mb_aead_data
*data
, int enc
,
166 /* Fire up a bunch of concurrent requests */
167 for (i
= 0; i
< num_mb
; i
++) {
169 rc
[i
] = crypto_aead_encrypt(data
[i
].req
);
171 rc
[i
] = crypto_aead_decrypt(data
[i
].req
);
174 /* Wait for all requests to finish */
175 for (i
= 0; i
< num_mb
; i
++) {
176 rc
[i
] = crypto_wait_req(rc
[i
], &data
[i
].wait
);
179 pr_info("concurrent request %d error %d\n", i
, rc
[i
]);
187 static int test_mb_aead_jiffies(struct test_mb_aead_data
*data
, int enc
,
188 int blen
, int secs
, u32 num_mb
)
190 unsigned long start
, end
;
195 rc
= kcalloc(num_mb
, sizeof(*rc
), GFP_KERNEL
);
199 for (start
= jiffies
, end
= start
+ secs
* HZ
, bcount
= 0;
200 time_before(jiffies
, end
); bcount
++) {
201 ret
= do_mult_aead_op(data
, enc
, num_mb
, rc
);
206 pr_cont("%d operations in %d seconds (%ld bytes)\n",
207 bcount
* num_mb
, secs
, (long)bcount
* blen
* num_mb
);
214 static int test_mb_aead_cycles(struct test_mb_aead_data
*data
, int enc
,
215 int blen
, u32 num_mb
)
217 unsigned long cycles
= 0;
222 rc
= kcalloc(num_mb
, sizeof(*rc
), GFP_KERNEL
);
227 for (i
= 0; i
< 4; i
++) {
228 ret
= do_mult_aead_op(data
, enc
, num_mb
, rc
);
233 /* The real thing. */
234 for (i
= 0; i
< 8; i
++) {
237 start
= get_cycles();
238 ret
= do_mult_aead_op(data
, enc
, num_mb
, rc
);
244 cycles
+= end
- start
;
247 pr_cont("1 operation in %lu cycles (%d bytes)\n",
248 (cycles
+ 4) / (8 * num_mb
), blen
);
255 static void test_mb_aead_speed(const char *algo
, int enc
, int secs
,
256 struct aead_speed_template
*template,
257 unsigned int tcount
, u8 authsize
,
258 unsigned int aad_size
, u8
*keysize
, u32 num_mb
)
260 struct test_mb_aead_data
*data
;
261 struct crypto_aead
*tfm
;
262 unsigned int i
, j
, iv_len
;
271 if (aad_size
>= PAGE_SIZE
) {
272 pr_err("associate data length (%u) too big\n", aad_size
);
276 iv
= kzalloc(MAX_IVLEN
, GFP_KERNEL
);
285 data
= kcalloc(num_mb
, sizeof(*data
), GFP_KERNEL
);
289 tfm
= crypto_alloc_aead(algo
, 0, 0);
291 pr_err("failed to load transform for %s: %ld\n",
296 ret
= crypto_aead_setauthsize(tfm
, authsize
);
298 for (i
= 0; i
< num_mb
; ++i
)
299 if (testmgr_alloc_buf(data
[i
].xbuf
)) {
301 testmgr_free_buf(data
[i
].xbuf
);
305 for (i
= 0; i
< num_mb
; ++i
)
306 if (testmgr_alloc_buf(data
[i
].axbuf
)) {
308 testmgr_free_buf(data
[i
].axbuf
);
312 for (i
= 0; i
< num_mb
; ++i
)
313 if (testmgr_alloc_buf(data
[i
].xoutbuf
)) {
315 testmgr_free_buf(data
[i
].xoutbuf
);
319 for (i
= 0; i
< num_mb
; ++i
) {
320 data
[i
].req
= aead_request_alloc(tfm
, GFP_KERNEL
);
322 pr_err("alg: skcipher: Failed to allocate request for %s\n",
325 aead_request_free(data
[i
].req
);
326 goto out_free_xoutbuf
;
330 for (i
= 0; i
< num_mb
; ++i
) {
331 crypto_init_wait(&data
[i
].wait
);
332 aead_request_set_callback(data
[i
].req
,
333 CRYPTO_TFM_REQ_MAY_BACKLOG
,
334 crypto_req_done
, &data
[i
].wait
);
337 pr_info("\ntesting speed of multibuffer %s (%s) %s\n", algo
,
338 get_driver_name(crypto_aead
, tfm
), e
);
344 if (*b_size
+ authsize
> XBUFSIZE
* PAGE_SIZE
) {
345 pr_err("template (%u) too big for buffer (%lu)\n",
347 XBUFSIZE
* PAGE_SIZE
);
351 pr_info("test %u (%d bit key, %d byte blocks): ", i
,
352 *keysize
* 8, *b_size
);
354 /* Set up tfm global state, i.e. the key */
356 memset(tvmem
[0], 0xff, PAGE_SIZE
);
358 for (j
= 0; j
< tcount
; j
++) {
359 if (template[j
].klen
== *keysize
) {
360 key
= template[j
].key
;
365 crypto_aead_clear_flags(tfm
, ~0);
367 ret
= crypto_aead_setkey(tfm
, key
, *keysize
);
369 pr_err("setkey() failed flags=%x\n",
370 crypto_aead_get_flags(tfm
));
374 iv_len
= crypto_aead_ivsize(tfm
);
376 memset(iv
, 0xff, iv_len
);
378 /* Now setup per request stuff, i.e. buffers */
380 for (j
= 0; j
< num_mb
; ++j
) {
381 struct test_mb_aead_data
*cur
= &data
[j
];
383 assoc
= cur
->axbuf
[0];
384 memset(assoc
, 0xff, aad_size
);
386 sg_init_aead(cur
->sg
, cur
->xbuf
,
387 *b_size
+ (enc
? 0 : authsize
),
390 sg_init_aead(cur
->sgout
, cur
->xoutbuf
,
391 *b_size
+ (enc
? authsize
: 0),
394 aead_request_set_ad(cur
->req
, aad_size
);
398 aead_request_set_crypt(cur
->req
,
402 ret
= crypto_aead_encrypt(cur
->req
);
403 ret
= do_one_aead_op(cur
->req
, ret
);
406 pr_err("calculating auth failed failed (%d)\n",
412 aead_request_set_crypt(cur
->req
, cur
->sg
,
413 cur
->sgout
, *b_size
+
414 (enc
? 0 : authsize
),
420 ret
= test_mb_aead_jiffies(data
, enc
, *b_size
,
424 ret
= test_mb_aead_cycles(data
, enc
, *b_size
,
429 pr_err("%s() failed return code=%d\n", e
, ret
);
439 for (i
= 0; i
< num_mb
; ++i
)
440 aead_request_free(data
[i
].req
);
442 for (i
= 0; i
< num_mb
; ++i
)
443 testmgr_free_buf(data
[i
].xoutbuf
);
445 for (i
= 0; i
< num_mb
; ++i
)
446 testmgr_free_buf(data
[i
].axbuf
);
448 for (i
= 0; i
< num_mb
; ++i
)
449 testmgr_free_buf(data
[i
].xbuf
);
451 crypto_free_aead(tfm
);
458 static int test_aead_jiffies(struct aead_request
*req
, int enc
,
461 unsigned long start
, end
;
465 for (start
= jiffies
, end
= start
+ secs
* HZ
, bcount
= 0;
466 time_before(jiffies
, end
); bcount
++) {
468 ret
= do_one_aead_op(req
, crypto_aead_encrypt(req
));
470 ret
= do_one_aead_op(req
, crypto_aead_decrypt(req
));
476 printk("%d operations in %d seconds (%ld bytes)\n",
477 bcount
, secs
, (long)bcount
* blen
);
481 static int test_aead_cycles(struct aead_request
*req
, int enc
, int blen
)
483 unsigned long cycles
= 0;
488 for (i
= 0; i
< 4; i
++) {
490 ret
= do_one_aead_op(req
, crypto_aead_encrypt(req
));
492 ret
= do_one_aead_op(req
, crypto_aead_decrypt(req
));
498 /* The real thing. */
499 for (i
= 0; i
< 8; i
++) {
502 start
= get_cycles();
504 ret
= do_one_aead_op(req
, crypto_aead_encrypt(req
));
506 ret
= do_one_aead_op(req
, crypto_aead_decrypt(req
));
512 cycles
+= end
- start
;
517 printk("1 operation in %lu cycles (%d bytes)\n",
518 (cycles
+ 4) / 8, blen
);
523 static void test_aead_speed(const char *algo
, int enc
, unsigned int secs
,
524 struct aead_speed_template
*template,
525 unsigned int tcount
, u8 authsize
,
526 unsigned int aad_size
, u8
*keysize
)
529 struct crypto_aead
*tfm
;
532 struct aead_request
*req
;
533 struct scatterlist
*sg
;
534 struct scatterlist
*sgout
;
538 char *xbuf
[XBUFSIZE
];
539 char *xoutbuf
[XBUFSIZE
];
540 char *axbuf
[XBUFSIZE
];
541 unsigned int *b_size
;
543 struct crypto_wait wait
;
545 iv
= kzalloc(MAX_IVLEN
, GFP_KERNEL
);
549 if (aad_size
>= PAGE_SIZE
) {
550 pr_err("associate data length (%u) too big\n", aad_size
);
559 if (testmgr_alloc_buf(xbuf
))
561 if (testmgr_alloc_buf(axbuf
))
563 if (testmgr_alloc_buf(xoutbuf
))
566 sg
= kmalloc(sizeof(*sg
) * 9 * 2, GFP_KERNEL
);
571 tfm
= crypto_alloc_aead(algo
, 0, 0);
574 pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo
,
579 crypto_init_wait(&wait
);
580 printk(KERN_INFO
"\ntesting speed of %s (%s) %s\n", algo
,
581 get_driver_name(crypto_aead
, tfm
), e
);
583 req
= aead_request_alloc(tfm
, GFP_KERNEL
);
585 pr_err("alg: aead: Failed to allocate request for %s\n",
590 aead_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
591 crypto_req_done
, &wait
);
598 memset(assoc
, 0xff, aad_size
);
600 if ((*keysize
+ *b_size
) > 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, *b_size
);
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
, *b_size
+ (enc
? 0 : authsize
),
637 sg_init_aead(sgout
, xoutbuf
,
638 *b_size
+ (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 failed (%d)\n",
662 aead_request_set_crypt(req
, sg
, sgout
,
663 *b_size
+ (enc
? 0 : authsize
),
667 ret
= test_aead_jiffies(req
, enc
, *b_size
,
671 ret
= test_aead_cycles(req
, enc
, *b_size
);
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], speed
[i
].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], speed
[i
].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 if (*b_size
> XBUFSIZE
* PAGE_SIZE
) {
1324 pr_err("template (%u) too big for buffer (%lu)\n",
1325 *b_size
, XBUFSIZE
* PAGE_SIZE
);
1329 pr_info("test %u (%d bit key, %d byte blocks): ", i
,
1330 *keysize
* 8, *b_size
);
1332 /* Set up tfm global state, i.e. the key */
1334 memset(tvmem
[0], 0xff, PAGE_SIZE
);
1336 for (j
= 0; j
< tcount
; j
++) {
1337 if (template[j
].klen
== *keysize
) {
1338 key
= template[j
].key
;
1343 crypto_skcipher_clear_flags(tfm
, ~0);
1345 ret
= crypto_skcipher_setkey(tfm
, key
, *keysize
);
1347 pr_err("setkey() failed flags=%x\n",
1348 crypto_skcipher_get_flags(tfm
));
1352 iv_len
= crypto_skcipher_ivsize(tfm
);
1354 memset(&iv
, 0xff, iv_len
);
1356 /* Now setup per request stuff, i.e. buffers */
1358 for (j
= 0; j
< num_mb
; ++j
) {
1359 struct test_mb_skcipher_data
*cur
= &data
[j
];
1360 unsigned int k
= *b_size
;
1361 unsigned int pages
= DIV_ROUND_UP(k
, PAGE_SIZE
);
1364 sg_init_table(cur
->sg
, pages
);
1366 while (k
> PAGE_SIZE
) {
1367 sg_set_buf(cur
->sg
+ p
, cur
->xbuf
[p
],
1369 memset(cur
->xbuf
[p
], 0xff, PAGE_SIZE
);
1374 sg_set_buf(cur
->sg
+ p
, cur
->xbuf
[p
], k
);
1375 memset(cur
->xbuf
[p
], 0xff, k
);
1377 skcipher_request_set_crypt(cur
->req
, cur
->sg
,
1383 ret
= test_mb_acipher_jiffies(data
, enc
,
1388 ret
= test_mb_acipher_cycles(data
, enc
,
1393 pr_err("%s() failed flags=%x\n", e
,
1394 crypto_skcipher_get_flags(tfm
));
1404 for (i
= 0; i
< num_mb
; ++i
)
1405 skcipher_request_free(data
[i
].req
);
1407 for (i
= 0; i
< num_mb
; ++i
)
1408 testmgr_free_buf(data
[i
].xbuf
);
1410 crypto_free_skcipher(tfm
);
1415 static inline int do_one_acipher_op(struct skcipher_request
*req
, int ret
)
1417 struct crypto_wait
*wait
= req
->base
.data
;
1419 return crypto_wait_req(ret
, wait
);
1422 static int test_acipher_jiffies(struct skcipher_request
*req
, int enc
,
1425 unsigned long start
, end
;
1429 for (start
= jiffies
, end
= start
+ secs
* HZ
, bcount
= 0;
1430 time_before(jiffies
, end
); bcount
++) {
1432 ret
= do_one_acipher_op(req
,
1433 crypto_skcipher_encrypt(req
));
1435 ret
= do_one_acipher_op(req
,
1436 crypto_skcipher_decrypt(req
));
1442 pr_cont("%d operations in %d seconds (%ld bytes)\n",
1443 bcount
, secs
, (long)bcount
* blen
);
1447 static int test_acipher_cycles(struct skcipher_request
*req
, int enc
,
1450 unsigned long cycles
= 0;
1455 for (i
= 0; i
< 4; i
++) {
1457 ret
= do_one_acipher_op(req
,
1458 crypto_skcipher_encrypt(req
));
1460 ret
= do_one_acipher_op(req
,
1461 crypto_skcipher_decrypt(req
));
1467 /* The real thing. */
1468 for (i
= 0; i
< 8; i
++) {
1469 cycles_t start
, end
;
1471 start
= get_cycles();
1473 ret
= do_one_acipher_op(req
,
1474 crypto_skcipher_encrypt(req
));
1476 ret
= do_one_acipher_op(req
,
1477 crypto_skcipher_decrypt(req
));
1483 cycles
+= end
- start
;
1488 pr_cont("1 operation in %lu cycles (%d bytes)\n",
1489 (cycles
+ 4) / 8, blen
);
1494 static void test_skcipher_speed(const char *algo
, int enc
, unsigned int secs
,
1495 struct cipher_speed_template
*template,
1496 unsigned int tcount
, u8
*keysize
, bool async
)
1498 unsigned int ret
, i
, j
, k
, iv_len
;
1499 struct crypto_wait wait
;
1502 struct skcipher_request
*req
;
1503 struct crypto_skcipher
*tfm
;
1512 crypto_init_wait(&wait
);
1514 tfm
= crypto_alloc_skcipher(algo
, 0, async
? 0 : CRYPTO_ALG_ASYNC
);
1517 pr_err("failed to load transform for %s: %ld\n", algo
,
1522 pr_info("\ntesting speed of async %s (%s) %s\n", algo
,
1523 get_driver_name(crypto_skcipher
, tfm
), e
);
1525 req
= skcipher_request_alloc(tfm
, GFP_KERNEL
);
1527 pr_err("tcrypt: skcipher: Failed to allocate request for %s\n",
1532 skcipher_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
1533 crypto_req_done
, &wait
);
1537 b_size
= block_sizes
;
1540 struct scatterlist sg
[TVMEMSIZE
];
1542 if ((*keysize
+ *b_size
) > TVMEMSIZE
* PAGE_SIZE
) {
1543 pr_err("template (%u) too big for "
1544 "tvmem (%lu)\n", *keysize
+ *b_size
,
1545 TVMEMSIZE
* PAGE_SIZE
);
1549 pr_info("test %u (%d bit key, %d byte blocks): ", i
,
1550 *keysize
* 8, *b_size
);
1552 memset(tvmem
[0], 0xff, PAGE_SIZE
);
1554 /* set key, plain text and IV */
1556 for (j
= 0; j
< tcount
; j
++) {
1557 if (template[j
].klen
== *keysize
) {
1558 key
= template[j
].key
;
1563 crypto_skcipher_clear_flags(tfm
, ~0);
1565 ret
= crypto_skcipher_setkey(tfm
, key
, *keysize
);
1567 pr_err("setkey() failed flags=%x\n",
1568 crypto_skcipher_get_flags(tfm
));
1572 k
= *keysize
+ *b_size
;
1573 sg_init_table(sg
, DIV_ROUND_UP(k
, PAGE_SIZE
));
1575 if (k
> PAGE_SIZE
) {
1576 sg_set_buf(sg
, tvmem
[0] + *keysize
,
1577 PAGE_SIZE
- *keysize
);
1580 while (k
> PAGE_SIZE
) {
1581 sg_set_buf(sg
+ j
, tvmem
[j
], PAGE_SIZE
);
1582 memset(tvmem
[j
], 0xff, PAGE_SIZE
);
1586 sg_set_buf(sg
+ j
, tvmem
[j
], k
);
1587 memset(tvmem
[j
], 0xff, k
);
1589 sg_set_buf(sg
, tvmem
[0] + *keysize
, *b_size
);
1592 iv_len
= crypto_skcipher_ivsize(tfm
);
1594 memset(&iv
, 0xff, iv_len
);
1596 skcipher_request_set_crypt(req
, sg
, sg
, *b_size
, iv
);
1599 ret
= test_acipher_jiffies(req
, enc
,
1603 ret
= test_acipher_cycles(req
, enc
,
1608 pr_err("%s() failed flags=%x\n", e
,
1609 crypto_skcipher_get_flags(tfm
));
1619 skcipher_request_free(req
);
1621 crypto_free_skcipher(tfm
);
1624 static void test_acipher_speed(const char *algo
, int enc
, unsigned int secs
,
1625 struct cipher_speed_template
*template,
1626 unsigned int tcount
, u8
*keysize
)
1628 return test_skcipher_speed(algo
, enc
, secs
, template, tcount
, keysize
,
1632 static void test_cipher_speed(const char *algo
, int enc
, unsigned int secs
,
1633 struct cipher_speed_template
*template,
1634 unsigned int tcount
, u8
*keysize
)
1636 return test_skcipher_speed(algo
, enc
, secs
, template, tcount
, keysize
,
1640 static void test_available(void)
1642 char **name
= check
;
1645 printk("alg %s ", *name
);
1646 printk(crypto_has_alg(*name
, 0, 0) ?
1647 "found\n" : "not found\n");
1652 static inline int tcrypt_test(const char *alg
)
1656 pr_debug("testing %s\n", alg
);
1658 ret
= alg_test(alg
, alg
, 0, 0);
1659 /* non-fips algs return -EINVAL in fips mode */
1660 if (fips_enabled
&& ret
== -EINVAL
)
1665 static int do_test(const char *alg
, u32 type
, u32 mask
, int m
, u32 num_mb
)
1673 if (!crypto_has_alg(alg
, type
,
1674 mask
?: CRYPTO_ALG_TYPE_MASK
))
1679 for (i
= 1; i
< 200; i
++)
1680 ret
+= do_test(NULL
, 0, 0, i
, num_mb
);
1684 ret
+= tcrypt_test("md5");
1688 ret
+= tcrypt_test("sha1");
1692 ret
+= tcrypt_test("ecb(des)");
1693 ret
+= tcrypt_test("cbc(des)");
1694 ret
+= tcrypt_test("ctr(des)");
1698 ret
+= tcrypt_test("ecb(des3_ede)");
1699 ret
+= tcrypt_test("cbc(des3_ede)");
1700 ret
+= tcrypt_test("ctr(des3_ede)");
1704 ret
+= tcrypt_test("md4");
1708 ret
+= tcrypt_test("sha256");
1712 ret
+= tcrypt_test("ecb(blowfish)");
1713 ret
+= tcrypt_test("cbc(blowfish)");
1714 ret
+= tcrypt_test("ctr(blowfish)");
1718 ret
+= tcrypt_test("ecb(twofish)");
1719 ret
+= tcrypt_test("cbc(twofish)");
1720 ret
+= tcrypt_test("ctr(twofish)");
1721 ret
+= tcrypt_test("lrw(twofish)");
1722 ret
+= tcrypt_test("xts(twofish)");
1726 ret
+= tcrypt_test("ecb(serpent)");
1727 ret
+= tcrypt_test("cbc(serpent)");
1728 ret
+= tcrypt_test("ctr(serpent)");
1729 ret
+= tcrypt_test("lrw(serpent)");
1730 ret
+= tcrypt_test("xts(serpent)");
1734 ret
+= tcrypt_test("ecb(aes)");
1735 ret
+= tcrypt_test("cbc(aes)");
1736 ret
+= tcrypt_test("lrw(aes)");
1737 ret
+= tcrypt_test("xts(aes)");
1738 ret
+= tcrypt_test("ctr(aes)");
1739 ret
+= tcrypt_test("rfc3686(ctr(aes))");
1740 ret
+= tcrypt_test("ofb(aes)");
1741 ret
+= tcrypt_test("cfb(aes)");
1745 ret
+= tcrypt_test("sha384");
1749 ret
+= tcrypt_test("sha512");
1753 ret
+= tcrypt_test("deflate");
1757 ret
+= tcrypt_test("ecb(cast5)");
1758 ret
+= tcrypt_test("cbc(cast5)");
1759 ret
+= tcrypt_test("ctr(cast5)");
1763 ret
+= tcrypt_test("ecb(cast6)");
1764 ret
+= tcrypt_test("cbc(cast6)");
1765 ret
+= tcrypt_test("ctr(cast6)");
1766 ret
+= tcrypt_test("lrw(cast6)");
1767 ret
+= tcrypt_test("xts(cast6)");
1771 ret
+= tcrypt_test("ecb(arc4)");
1775 ret
+= tcrypt_test("michael_mic");
1779 ret
+= tcrypt_test("crc32c");
1783 ret
+= tcrypt_test("ecb(tea)");
1787 ret
+= tcrypt_test("ecb(xtea)");
1791 ret
+= tcrypt_test("ecb(khazad)");
1795 ret
+= tcrypt_test("wp512");
1799 ret
+= tcrypt_test("wp384");
1803 ret
+= tcrypt_test("wp256");
1807 ret
+= tcrypt_test("ecb(tnepres)");
1811 ret
+= tcrypt_test("ecb(anubis)");
1812 ret
+= tcrypt_test("cbc(anubis)");
1816 ret
+= tcrypt_test("tgr192");
1820 ret
+= tcrypt_test("tgr160");
1824 ret
+= tcrypt_test("tgr128");
1828 ret
+= tcrypt_test("ecb(xeta)");
1832 ret
+= tcrypt_test("pcbc(fcrypt)");
1836 ret
+= tcrypt_test("ecb(camellia)");
1837 ret
+= tcrypt_test("cbc(camellia)");
1838 ret
+= tcrypt_test("ctr(camellia)");
1839 ret
+= tcrypt_test("lrw(camellia)");
1840 ret
+= tcrypt_test("xts(camellia)");
1844 ret
+= tcrypt_test("sha224");
1848 ret
+= tcrypt_test("salsa20");
1852 ret
+= tcrypt_test("gcm(aes)");
1856 ret
+= tcrypt_test("lzo");
1860 ret
+= tcrypt_test("ccm(aes)");
1864 ret
+= tcrypt_test("cts(cbc(aes))");
1868 ret
+= tcrypt_test("rmd128");
1872 ret
+= tcrypt_test("rmd160");
1876 ret
+= tcrypt_test("rmd256");
1880 ret
+= tcrypt_test("rmd320");
1884 ret
+= tcrypt_test("ecb(seed)");
1888 ret
+= tcrypt_test("rfc4309(ccm(aes))");
1892 ret
+= tcrypt_test("ghash");
1896 ret
+= tcrypt_test("crct10dif");
1900 ret
+= tcrypt_test("sha3-224");
1904 ret
+= tcrypt_test("sha3-256");
1908 ret
+= tcrypt_test("sha3-384");
1912 ret
+= tcrypt_test("sha3-512");
1916 ret
+= tcrypt_test("sm3");
1920 ret
+= tcrypt_test("streebog256");
1924 ret
+= tcrypt_test("streebog512");
1928 ret
+= tcrypt_test("hmac(md5)");
1932 ret
+= tcrypt_test("hmac(sha1)");
1936 ret
+= tcrypt_test("hmac(sha256)");
1940 ret
+= tcrypt_test("hmac(sha384)");
1944 ret
+= tcrypt_test("hmac(sha512)");
1948 ret
+= tcrypt_test("hmac(sha224)");
1952 ret
+= tcrypt_test("xcbc(aes)");
1956 ret
+= tcrypt_test("hmac(rmd128)");
1960 ret
+= tcrypt_test("hmac(rmd160)");
1964 ret
+= tcrypt_test("vmac64(aes)");
1968 ret
+= tcrypt_test("hmac(sha3-224)");
1972 ret
+= tcrypt_test("hmac(sha3-256)");
1976 ret
+= tcrypt_test("hmac(sha3-384)");
1980 ret
+= tcrypt_test("hmac(sha3-512)");
1984 ret
+= tcrypt_test("hmac(streebog256)");
1988 ret
+= tcrypt_test("hmac(streebog512)");
1992 ret
+= tcrypt_test("ansi_cprng");
1996 ret
+= tcrypt_test("rfc4106(gcm(aes))");
2000 ret
+= tcrypt_test("rfc4543(gcm(aes))");
2004 ret
+= tcrypt_test("cmac(aes)");
2008 ret
+= tcrypt_test("cmac(des3_ede)");
2012 ret
+= tcrypt_test("authenc(hmac(sha1),cbc(aes))");
2016 ret
+= tcrypt_test("authenc(hmac(md5),ecb(cipher_null))");
2020 ret
+= tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))");
2023 ret
+= tcrypt_test("authenc(hmac(sha1),cbc(des))");
2026 ret
+= tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))");
2029 ret
+= tcrypt_test("authenc(hmac(sha224),cbc(des))");
2032 ret
+= tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))");
2035 ret
+= tcrypt_test("authenc(hmac(sha256),cbc(des))");
2038 ret
+= tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))");
2041 ret
+= tcrypt_test("authenc(hmac(sha384),cbc(des))");
2044 ret
+= tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))");
2047 ret
+= tcrypt_test("authenc(hmac(sha512),cbc(des))");
2050 ret
+= tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))");
2053 ret
+= tcrypt_test("ecb(sm4)");
2054 ret
+= tcrypt_test("cbc(sm4)");
2055 ret
+= tcrypt_test("ctr(sm4)");
2058 test_cipher_speed("ecb(aes)", ENCRYPT
, sec
, NULL
, 0,
2059 speed_template_16_24_32
);
2060 test_cipher_speed("ecb(aes)", DECRYPT
, sec
, NULL
, 0,
2061 speed_template_16_24_32
);
2062 test_cipher_speed("cbc(aes)", ENCRYPT
, sec
, NULL
, 0,
2063 speed_template_16_24_32
);
2064 test_cipher_speed("cbc(aes)", DECRYPT
, sec
, NULL
, 0,
2065 speed_template_16_24_32
);
2066 test_cipher_speed("lrw(aes)", ENCRYPT
, sec
, NULL
, 0,
2067 speed_template_32_40_48
);
2068 test_cipher_speed("lrw(aes)", DECRYPT
, sec
, NULL
, 0,
2069 speed_template_32_40_48
);
2070 test_cipher_speed("xts(aes)", ENCRYPT
, sec
, NULL
, 0,
2071 speed_template_32_64
);
2072 test_cipher_speed("xts(aes)", DECRYPT
, sec
, NULL
, 0,
2073 speed_template_32_64
);
2074 test_cipher_speed("cts(cbc(aes))", ENCRYPT
, sec
, NULL
, 0,
2075 speed_template_16_24_32
);
2076 test_cipher_speed("cts(cbc(aes))", DECRYPT
, sec
, NULL
, 0,
2077 speed_template_16_24_32
);
2078 test_cipher_speed("ctr(aes)", ENCRYPT
, sec
, NULL
, 0,
2079 speed_template_16_24_32
);
2080 test_cipher_speed("ctr(aes)", DECRYPT
, sec
, NULL
, 0,
2081 speed_template_16_24_32
);
2082 test_cipher_speed("cfb(aes)", ENCRYPT
, sec
, NULL
, 0,
2083 speed_template_16_24_32
);
2084 test_cipher_speed("cfb(aes)", DECRYPT
, sec
, NULL
, 0,
2085 speed_template_16_24_32
);
2089 test_cipher_speed("ecb(des3_ede)", ENCRYPT
, sec
,
2090 des3_speed_template
, DES3_SPEED_VECTORS
,
2092 test_cipher_speed("ecb(des3_ede)", DECRYPT
, sec
,
2093 des3_speed_template
, DES3_SPEED_VECTORS
,
2095 test_cipher_speed("cbc(des3_ede)", ENCRYPT
, sec
,
2096 des3_speed_template
, DES3_SPEED_VECTORS
,
2098 test_cipher_speed("cbc(des3_ede)", DECRYPT
, sec
,
2099 des3_speed_template
, DES3_SPEED_VECTORS
,
2101 test_cipher_speed("ctr(des3_ede)", ENCRYPT
, sec
,
2102 des3_speed_template
, DES3_SPEED_VECTORS
,
2104 test_cipher_speed("ctr(des3_ede)", DECRYPT
, sec
,
2105 des3_speed_template
, DES3_SPEED_VECTORS
,
2110 test_cipher_speed("ecb(twofish)", ENCRYPT
, sec
, NULL
, 0,
2111 speed_template_16_24_32
);
2112 test_cipher_speed("ecb(twofish)", DECRYPT
, sec
, NULL
, 0,
2113 speed_template_16_24_32
);
2114 test_cipher_speed("cbc(twofish)", ENCRYPT
, sec
, NULL
, 0,
2115 speed_template_16_24_32
);
2116 test_cipher_speed("cbc(twofish)", DECRYPT
, sec
, NULL
, 0,
2117 speed_template_16_24_32
);
2118 test_cipher_speed("ctr(twofish)", ENCRYPT
, sec
, NULL
, 0,
2119 speed_template_16_24_32
);
2120 test_cipher_speed("ctr(twofish)", DECRYPT
, sec
, NULL
, 0,
2121 speed_template_16_24_32
);
2122 test_cipher_speed("lrw(twofish)", ENCRYPT
, sec
, NULL
, 0,
2123 speed_template_32_40_48
);
2124 test_cipher_speed("lrw(twofish)", DECRYPT
, sec
, NULL
, 0,
2125 speed_template_32_40_48
);
2126 test_cipher_speed("xts(twofish)", ENCRYPT
, sec
, NULL
, 0,
2127 speed_template_32_48_64
);
2128 test_cipher_speed("xts(twofish)", DECRYPT
, sec
, NULL
, 0,
2129 speed_template_32_48_64
);
2133 test_cipher_speed("ecb(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2134 speed_template_8_32
);
2135 test_cipher_speed("ecb(blowfish)", DECRYPT
, sec
, NULL
, 0,
2136 speed_template_8_32
);
2137 test_cipher_speed("cbc(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2138 speed_template_8_32
);
2139 test_cipher_speed("cbc(blowfish)", DECRYPT
, sec
, NULL
, 0,
2140 speed_template_8_32
);
2141 test_cipher_speed("ctr(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2142 speed_template_8_32
);
2143 test_cipher_speed("ctr(blowfish)", DECRYPT
, sec
, NULL
, 0,
2144 speed_template_8_32
);
2148 test_cipher_speed("ecb(des)", ENCRYPT
, sec
, NULL
, 0,
2150 test_cipher_speed("ecb(des)", DECRYPT
, sec
, NULL
, 0,
2152 test_cipher_speed("cbc(des)", ENCRYPT
, sec
, NULL
, 0,
2154 test_cipher_speed("cbc(des)", DECRYPT
, sec
, NULL
, 0,
2159 test_cipher_speed("ecb(camellia)", ENCRYPT
, sec
, NULL
, 0,
2160 speed_template_16_24_32
);
2161 test_cipher_speed("ecb(camellia)", DECRYPT
, sec
, NULL
, 0,
2162 speed_template_16_24_32
);
2163 test_cipher_speed("cbc(camellia)", ENCRYPT
, sec
, NULL
, 0,
2164 speed_template_16_24_32
);
2165 test_cipher_speed("cbc(camellia)", DECRYPT
, sec
, NULL
, 0,
2166 speed_template_16_24_32
);
2167 test_cipher_speed("ctr(camellia)", ENCRYPT
, sec
, NULL
, 0,
2168 speed_template_16_24_32
);
2169 test_cipher_speed("ctr(camellia)", DECRYPT
, sec
, NULL
, 0,
2170 speed_template_16_24_32
);
2171 test_cipher_speed("lrw(camellia)", ENCRYPT
, sec
, NULL
, 0,
2172 speed_template_32_40_48
);
2173 test_cipher_speed("lrw(camellia)", DECRYPT
, sec
, NULL
, 0,
2174 speed_template_32_40_48
);
2175 test_cipher_speed("xts(camellia)", ENCRYPT
, sec
, NULL
, 0,
2176 speed_template_32_48_64
);
2177 test_cipher_speed("xts(camellia)", DECRYPT
, sec
, NULL
, 0,
2178 speed_template_32_48_64
);
2182 test_cipher_speed("salsa20", ENCRYPT
, sec
, NULL
, 0,
2183 speed_template_16_32
);
2187 test_cipher_speed("ecb(serpent)", ENCRYPT
, sec
, NULL
, 0,
2188 speed_template_16_32
);
2189 test_cipher_speed("ecb(serpent)", DECRYPT
, sec
, NULL
, 0,
2190 speed_template_16_32
);
2191 test_cipher_speed("cbc(serpent)", ENCRYPT
, sec
, NULL
, 0,
2192 speed_template_16_32
);
2193 test_cipher_speed("cbc(serpent)", DECRYPT
, sec
, NULL
, 0,
2194 speed_template_16_32
);
2195 test_cipher_speed("ctr(serpent)", ENCRYPT
, sec
, NULL
, 0,
2196 speed_template_16_32
);
2197 test_cipher_speed("ctr(serpent)", DECRYPT
, sec
, NULL
, 0,
2198 speed_template_16_32
);
2199 test_cipher_speed("lrw(serpent)", ENCRYPT
, sec
, NULL
, 0,
2200 speed_template_32_48
);
2201 test_cipher_speed("lrw(serpent)", DECRYPT
, sec
, NULL
, 0,
2202 speed_template_32_48
);
2203 test_cipher_speed("xts(serpent)", ENCRYPT
, sec
, NULL
, 0,
2204 speed_template_32_64
);
2205 test_cipher_speed("xts(serpent)", DECRYPT
, sec
, NULL
, 0,
2206 speed_template_32_64
);
2210 test_cipher_speed("ecb(arc4)", ENCRYPT
, sec
, NULL
, 0,
2215 test_cipher_speed("ecb(cast5)", ENCRYPT
, sec
, NULL
, 0,
2216 speed_template_8_16
);
2217 test_cipher_speed("ecb(cast5)", DECRYPT
, sec
, NULL
, 0,
2218 speed_template_8_16
);
2219 test_cipher_speed("cbc(cast5)", ENCRYPT
, sec
, NULL
, 0,
2220 speed_template_8_16
);
2221 test_cipher_speed("cbc(cast5)", DECRYPT
, sec
, NULL
, 0,
2222 speed_template_8_16
);
2223 test_cipher_speed("ctr(cast5)", ENCRYPT
, sec
, NULL
, 0,
2224 speed_template_8_16
);
2225 test_cipher_speed("ctr(cast5)", DECRYPT
, sec
, NULL
, 0,
2226 speed_template_8_16
);
2230 test_cipher_speed("ecb(cast6)", ENCRYPT
, sec
, NULL
, 0,
2231 speed_template_16_32
);
2232 test_cipher_speed("ecb(cast6)", DECRYPT
, sec
, NULL
, 0,
2233 speed_template_16_32
);
2234 test_cipher_speed("cbc(cast6)", ENCRYPT
, sec
, NULL
, 0,
2235 speed_template_16_32
);
2236 test_cipher_speed("cbc(cast6)", DECRYPT
, sec
, NULL
, 0,
2237 speed_template_16_32
);
2238 test_cipher_speed("ctr(cast6)", ENCRYPT
, sec
, NULL
, 0,
2239 speed_template_16_32
);
2240 test_cipher_speed("ctr(cast6)", DECRYPT
, sec
, NULL
, 0,
2241 speed_template_16_32
);
2242 test_cipher_speed("lrw(cast6)", ENCRYPT
, sec
, NULL
, 0,
2243 speed_template_32_48
);
2244 test_cipher_speed("lrw(cast6)", DECRYPT
, sec
, NULL
, 0,
2245 speed_template_32_48
);
2246 test_cipher_speed("xts(cast6)", ENCRYPT
, sec
, NULL
, 0,
2247 speed_template_32_64
);
2248 test_cipher_speed("xts(cast6)", DECRYPT
, sec
, NULL
, 0,
2249 speed_template_32_64
);
2253 test_aead_speed("rfc4106(gcm(aes))", ENCRYPT
, sec
,
2254 NULL
, 0, 16, 16, aead_speed_template_20
);
2255 test_aead_speed("gcm(aes)", ENCRYPT
, sec
,
2256 NULL
, 0, 16, 8, speed_template_16_24_32
);
2257 test_aead_speed("rfc4106(gcm(aes))", DECRYPT
, sec
,
2258 NULL
, 0, 16, 16, aead_speed_template_20
);
2259 test_aead_speed("gcm(aes)", DECRYPT
, sec
,
2260 NULL
, 0, 16, 8, speed_template_16_24_32
);
2264 test_aead_speed("rfc4309(ccm(aes))", ENCRYPT
, sec
,
2265 NULL
, 0, 16, 16, aead_speed_template_19
);
2266 test_aead_speed("rfc4309(ccm(aes))", DECRYPT
, sec
,
2267 NULL
, 0, 16, 16, aead_speed_template_19
);
2271 test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT
, sec
,
2272 NULL
, 0, 16, 8, aead_speed_template_36
);
2273 test_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT
, sec
,
2274 NULL
, 0, 16, 8, aead_speed_template_36
);
2278 test_cipher_speed("chacha20", ENCRYPT
, sec
, NULL
, 0,
2283 test_mb_aead_speed("rfc4106(gcm(aes))", ENCRYPT
, sec
, NULL
,
2284 0, 16, 16, aead_speed_template_20
, num_mb
);
2285 test_mb_aead_speed("gcm(aes)", ENCRYPT
, sec
, NULL
, 0, 16, 8,
2286 speed_template_16_24_32
, num_mb
);
2287 test_mb_aead_speed("rfc4106(gcm(aes))", DECRYPT
, sec
, NULL
,
2288 0, 16, 16, aead_speed_template_20
, num_mb
);
2289 test_mb_aead_speed("gcm(aes)", DECRYPT
, sec
, NULL
, 0, 16, 8,
2290 speed_template_16_24_32
, num_mb
);
2294 test_mb_aead_speed("rfc4309(ccm(aes))", ENCRYPT
, sec
, NULL
, 0,
2295 16, 16, aead_speed_template_19
, num_mb
);
2296 test_mb_aead_speed("rfc4309(ccm(aes))", DECRYPT
, sec
, NULL
, 0,
2297 16, 16, aead_speed_template_19
, num_mb
);
2301 test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT
,
2302 sec
, NULL
, 0, 16, 8, aead_speed_template_36
,
2304 test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT
,
2305 sec
, NULL
, 0, 16, 8, aead_speed_template_36
,
2310 test_cipher_speed("ecb(sm4)", ENCRYPT
, sec
, NULL
, 0,
2312 test_cipher_speed("ecb(sm4)", DECRYPT
, sec
, NULL
, 0,
2314 test_cipher_speed("cbc(sm4)", ENCRYPT
, sec
, NULL
, 0,
2316 test_cipher_speed("cbc(sm4)", DECRYPT
, sec
, NULL
, 0,
2318 test_cipher_speed("ctr(sm4)", ENCRYPT
, sec
, NULL
, 0,
2320 test_cipher_speed("ctr(sm4)", DECRYPT
, sec
, NULL
, 0,
2325 test_cipher_speed("adiantum(xchacha12,aes)", ENCRYPT
, sec
, NULL
,
2326 0, speed_template_32
);
2327 test_cipher_speed("adiantum(xchacha12,aes)", DECRYPT
, sec
, NULL
,
2328 0, speed_template_32
);
2329 test_cipher_speed("adiantum(xchacha20,aes)", ENCRYPT
, sec
, NULL
,
2330 0, speed_template_32
);
2331 test_cipher_speed("adiantum(xchacha20,aes)", DECRYPT
, sec
, NULL
,
2332 0, speed_template_32
);
2337 test_hash_speed(alg
, sec
, generic_hash_speed_template
);
2342 test_hash_speed("md4", sec
, generic_hash_speed_template
);
2343 if (mode
> 300 && mode
< 400) break;
2346 test_hash_speed("md5", sec
, generic_hash_speed_template
);
2347 if (mode
> 300 && mode
< 400) break;
2350 test_hash_speed("sha1", sec
, generic_hash_speed_template
);
2351 if (mode
> 300 && mode
< 400) break;
2354 test_hash_speed("sha256", sec
, generic_hash_speed_template
);
2355 if (mode
> 300 && mode
< 400) break;
2358 test_hash_speed("sha384", sec
, generic_hash_speed_template
);
2359 if (mode
> 300 && mode
< 400) break;
2362 test_hash_speed("sha512", sec
, generic_hash_speed_template
);
2363 if (mode
> 300 && mode
< 400) break;
2366 test_hash_speed("wp256", sec
, generic_hash_speed_template
);
2367 if (mode
> 300 && mode
< 400) break;
2370 test_hash_speed("wp384", sec
, generic_hash_speed_template
);
2371 if (mode
> 300 && mode
< 400) break;
2374 test_hash_speed("wp512", sec
, generic_hash_speed_template
);
2375 if (mode
> 300 && mode
< 400) break;
2378 test_hash_speed("tgr128", sec
, generic_hash_speed_template
);
2379 if (mode
> 300 && mode
< 400) break;
2382 test_hash_speed("tgr160", sec
, generic_hash_speed_template
);
2383 if (mode
> 300 && mode
< 400) break;
2386 test_hash_speed("tgr192", sec
, generic_hash_speed_template
);
2387 if (mode
> 300 && mode
< 400) break;
2390 test_hash_speed("sha224", sec
, generic_hash_speed_template
);
2391 if (mode
> 300 && mode
< 400) break;
2394 test_hash_speed("rmd128", sec
, generic_hash_speed_template
);
2395 if (mode
> 300 && mode
< 400) break;
2398 test_hash_speed("rmd160", sec
, generic_hash_speed_template
);
2399 if (mode
> 300 && mode
< 400) break;
2402 test_hash_speed("rmd256", sec
, generic_hash_speed_template
);
2403 if (mode
> 300 && mode
< 400) break;
2406 test_hash_speed("rmd320", sec
, generic_hash_speed_template
);
2407 if (mode
> 300 && mode
< 400) break;
2410 test_hash_speed("ghash-generic", sec
, hash_speed_template_16
);
2411 if (mode
> 300 && mode
< 400) break;
2414 test_hash_speed("crc32c", sec
, generic_hash_speed_template
);
2415 if (mode
> 300 && mode
< 400) break;
2418 test_hash_speed("crct10dif", sec
, generic_hash_speed_template
);
2419 if (mode
> 300 && mode
< 400) break;
2422 test_hash_speed("poly1305", sec
, poly1305_speed_template
);
2423 if (mode
> 300 && mode
< 400) break;
2426 test_hash_speed("sha3-224", sec
, generic_hash_speed_template
);
2427 if (mode
> 300 && mode
< 400) break;
2430 test_hash_speed("sha3-256", sec
, generic_hash_speed_template
);
2431 if (mode
> 300 && mode
< 400) break;
2434 test_hash_speed("sha3-384", sec
, generic_hash_speed_template
);
2435 if (mode
> 300 && mode
< 400) break;
2438 test_hash_speed("sha3-512", sec
, generic_hash_speed_template
);
2439 if (mode
> 300 && mode
< 400) break;
2442 test_hash_speed("sm3", sec
, generic_hash_speed_template
);
2443 if (mode
> 300 && mode
< 400) break;
2446 test_hash_speed("streebog256", sec
,
2447 generic_hash_speed_template
);
2448 if (mode
> 300 && mode
< 400) break;
2451 test_hash_speed("streebog512", sec
,
2452 generic_hash_speed_template
);
2453 if (mode
> 300 && mode
< 400) break;
2460 test_ahash_speed(alg
, sec
, generic_hash_speed_template
);
2465 test_ahash_speed("md4", sec
, generic_hash_speed_template
);
2466 if (mode
> 400 && mode
< 500) break;
2469 test_ahash_speed("md5", sec
, generic_hash_speed_template
);
2470 if (mode
> 400 && mode
< 500) break;
2473 test_ahash_speed("sha1", sec
, generic_hash_speed_template
);
2474 if (mode
> 400 && mode
< 500) break;
2477 test_ahash_speed("sha256", sec
, generic_hash_speed_template
);
2478 if (mode
> 400 && mode
< 500) break;
2481 test_ahash_speed("sha384", sec
, generic_hash_speed_template
);
2482 if (mode
> 400 && mode
< 500) break;
2485 test_ahash_speed("sha512", sec
, generic_hash_speed_template
);
2486 if (mode
> 400 && mode
< 500) break;
2489 test_ahash_speed("wp256", sec
, generic_hash_speed_template
);
2490 if (mode
> 400 && mode
< 500) break;
2493 test_ahash_speed("wp384", sec
, generic_hash_speed_template
);
2494 if (mode
> 400 && mode
< 500) break;
2497 test_ahash_speed("wp512", sec
, generic_hash_speed_template
);
2498 if (mode
> 400 && mode
< 500) break;
2501 test_ahash_speed("tgr128", sec
, generic_hash_speed_template
);
2502 if (mode
> 400 && mode
< 500) break;
2505 test_ahash_speed("tgr160", sec
, generic_hash_speed_template
);
2506 if (mode
> 400 && mode
< 500) break;
2509 test_ahash_speed("tgr192", sec
, generic_hash_speed_template
);
2510 if (mode
> 400 && mode
< 500) break;
2513 test_ahash_speed("sha224", sec
, generic_hash_speed_template
);
2514 if (mode
> 400 && mode
< 500) break;
2517 test_ahash_speed("rmd128", sec
, generic_hash_speed_template
);
2518 if (mode
> 400 && mode
< 500) break;
2521 test_ahash_speed("rmd160", sec
, generic_hash_speed_template
);
2522 if (mode
> 400 && mode
< 500) break;
2525 test_ahash_speed("rmd256", sec
, generic_hash_speed_template
);
2526 if (mode
> 400 && mode
< 500) break;
2529 test_ahash_speed("rmd320", sec
, generic_hash_speed_template
);
2530 if (mode
> 400 && mode
< 500) break;
2533 test_ahash_speed("sha3-224", sec
, generic_hash_speed_template
);
2534 if (mode
> 400 && mode
< 500) break;
2537 test_ahash_speed("sha3-256", sec
, generic_hash_speed_template
);
2538 if (mode
> 400 && mode
< 500) break;
2541 test_ahash_speed("sha3-384", sec
, generic_hash_speed_template
);
2542 if (mode
> 400 && mode
< 500) break;
2545 test_ahash_speed("sha3-512", sec
, generic_hash_speed_template
);
2546 if (mode
> 400 && mode
< 500) break;
2549 test_mb_ahash_speed("sha1", sec
, generic_hash_speed_template
,
2551 if (mode
> 400 && mode
< 500) break;
2554 test_mb_ahash_speed("sha256", sec
, generic_hash_speed_template
,
2556 if (mode
> 400 && mode
< 500) break;
2559 test_mb_ahash_speed("sha512", sec
, generic_hash_speed_template
,
2561 if (mode
> 400 && mode
< 500) break;
2564 test_mb_ahash_speed("sm3", sec
, generic_hash_speed_template
,
2566 if (mode
> 400 && mode
< 500) break;
2569 test_mb_ahash_speed("streebog256", sec
,
2570 generic_hash_speed_template
, num_mb
);
2571 if (mode
> 400 && mode
< 500) break;
2574 test_mb_ahash_speed("streebog512", sec
,
2575 generic_hash_speed_template
, num_mb
);
2576 if (mode
> 400 && mode
< 500) break;
2582 test_acipher_speed("ecb(aes)", ENCRYPT
, sec
, NULL
, 0,
2583 speed_template_16_24_32
);
2584 test_acipher_speed("ecb(aes)", DECRYPT
, sec
, NULL
, 0,
2585 speed_template_16_24_32
);
2586 test_acipher_speed("cbc(aes)", ENCRYPT
, sec
, NULL
, 0,
2587 speed_template_16_24_32
);
2588 test_acipher_speed("cbc(aes)", DECRYPT
, sec
, NULL
, 0,
2589 speed_template_16_24_32
);
2590 test_acipher_speed("lrw(aes)", ENCRYPT
, sec
, NULL
, 0,
2591 speed_template_32_40_48
);
2592 test_acipher_speed("lrw(aes)", DECRYPT
, sec
, NULL
, 0,
2593 speed_template_32_40_48
);
2594 test_acipher_speed("xts(aes)", ENCRYPT
, sec
, NULL
, 0,
2595 speed_template_32_64
);
2596 test_acipher_speed("xts(aes)", DECRYPT
, sec
, NULL
, 0,
2597 speed_template_32_64
);
2598 test_acipher_speed("cts(cbc(aes))", ENCRYPT
, sec
, NULL
, 0,
2599 speed_template_16_24_32
);
2600 test_acipher_speed("cts(cbc(aes))", DECRYPT
, sec
, NULL
, 0,
2601 speed_template_16_24_32
);
2602 test_acipher_speed("ctr(aes)", ENCRYPT
, sec
, NULL
, 0,
2603 speed_template_16_24_32
);
2604 test_acipher_speed("ctr(aes)", DECRYPT
, sec
, NULL
, 0,
2605 speed_template_16_24_32
);
2606 test_acipher_speed("cfb(aes)", ENCRYPT
, sec
, NULL
, 0,
2607 speed_template_16_24_32
);
2608 test_acipher_speed("cfb(aes)", DECRYPT
, sec
, NULL
, 0,
2609 speed_template_16_24_32
);
2610 test_acipher_speed("ofb(aes)", ENCRYPT
, sec
, NULL
, 0,
2611 speed_template_16_24_32
);
2612 test_acipher_speed("ofb(aes)", DECRYPT
, sec
, NULL
, 0,
2613 speed_template_16_24_32
);
2614 test_acipher_speed("rfc3686(ctr(aes))", ENCRYPT
, sec
, NULL
, 0,
2615 speed_template_20_28_36
);
2616 test_acipher_speed("rfc3686(ctr(aes))", DECRYPT
, sec
, NULL
, 0,
2617 speed_template_20_28_36
);
2621 test_acipher_speed("ecb(des3_ede)", ENCRYPT
, sec
,
2622 des3_speed_template
, DES3_SPEED_VECTORS
,
2624 test_acipher_speed("ecb(des3_ede)", DECRYPT
, sec
,
2625 des3_speed_template
, DES3_SPEED_VECTORS
,
2627 test_acipher_speed("cbc(des3_ede)", ENCRYPT
, sec
,
2628 des3_speed_template
, DES3_SPEED_VECTORS
,
2630 test_acipher_speed("cbc(des3_ede)", DECRYPT
, sec
,
2631 des3_speed_template
, DES3_SPEED_VECTORS
,
2633 test_acipher_speed("cfb(des3_ede)", ENCRYPT
, sec
,
2634 des3_speed_template
, DES3_SPEED_VECTORS
,
2636 test_acipher_speed("cfb(des3_ede)", DECRYPT
, sec
,
2637 des3_speed_template
, DES3_SPEED_VECTORS
,
2639 test_acipher_speed("ofb(des3_ede)", ENCRYPT
, sec
,
2640 des3_speed_template
, DES3_SPEED_VECTORS
,
2642 test_acipher_speed("ofb(des3_ede)", DECRYPT
, sec
,
2643 des3_speed_template
, DES3_SPEED_VECTORS
,
2648 test_acipher_speed("ecb(des)", ENCRYPT
, sec
, NULL
, 0,
2650 test_acipher_speed("ecb(des)", DECRYPT
, sec
, NULL
, 0,
2652 test_acipher_speed("cbc(des)", ENCRYPT
, sec
, NULL
, 0,
2654 test_acipher_speed("cbc(des)", DECRYPT
, sec
, NULL
, 0,
2656 test_acipher_speed("cfb(des)", ENCRYPT
, sec
, NULL
, 0,
2658 test_acipher_speed("cfb(des)", DECRYPT
, sec
, NULL
, 0,
2660 test_acipher_speed("ofb(des)", ENCRYPT
, sec
, NULL
, 0,
2662 test_acipher_speed("ofb(des)", DECRYPT
, sec
, NULL
, 0,
2667 test_acipher_speed("ecb(serpent)", ENCRYPT
, sec
, NULL
, 0,
2668 speed_template_16_32
);
2669 test_acipher_speed("ecb(serpent)", DECRYPT
, sec
, NULL
, 0,
2670 speed_template_16_32
);
2671 test_acipher_speed("cbc(serpent)", ENCRYPT
, sec
, NULL
, 0,
2672 speed_template_16_32
);
2673 test_acipher_speed("cbc(serpent)", DECRYPT
, sec
, NULL
, 0,
2674 speed_template_16_32
);
2675 test_acipher_speed("ctr(serpent)", ENCRYPT
, sec
, NULL
, 0,
2676 speed_template_16_32
);
2677 test_acipher_speed("ctr(serpent)", DECRYPT
, sec
, NULL
, 0,
2678 speed_template_16_32
);
2679 test_acipher_speed("lrw(serpent)", ENCRYPT
, sec
, NULL
, 0,
2680 speed_template_32_48
);
2681 test_acipher_speed("lrw(serpent)", DECRYPT
, sec
, NULL
, 0,
2682 speed_template_32_48
);
2683 test_acipher_speed("xts(serpent)", ENCRYPT
, sec
, NULL
, 0,
2684 speed_template_32_64
);
2685 test_acipher_speed("xts(serpent)", DECRYPT
, sec
, NULL
, 0,
2686 speed_template_32_64
);
2690 test_acipher_speed("ecb(twofish)", ENCRYPT
, sec
, NULL
, 0,
2691 speed_template_16_24_32
);
2692 test_acipher_speed("ecb(twofish)", DECRYPT
, sec
, NULL
, 0,
2693 speed_template_16_24_32
);
2694 test_acipher_speed("cbc(twofish)", ENCRYPT
, sec
, NULL
, 0,
2695 speed_template_16_24_32
);
2696 test_acipher_speed("cbc(twofish)", DECRYPT
, sec
, NULL
, 0,
2697 speed_template_16_24_32
);
2698 test_acipher_speed("ctr(twofish)", ENCRYPT
, sec
, NULL
, 0,
2699 speed_template_16_24_32
);
2700 test_acipher_speed("ctr(twofish)", DECRYPT
, sec
, NULL
, 0,
2701 speed_template_16_24_32
);
2702 test_acipher_speed("lrw(twofish)", ENCRYPT
, sec
, NULL
, 0,
2703 speed_template_32_40_48
);
2704 test_acipher_speed("lrw(twofish)", DECRYPT
, sec
, NULL
, 0,
2705 speed_template_32_40_48
);
2706 test_acipher_speed("xts(twofish)", ENCRYPT
, sec
, NULL
, 0,
2707 speed_template_32_48_64
);
2708 test_acipher_speed("xts(twofish)", DECRYPT
, sec
, NULL
, 0,
2709 speed_template_32_48_64
);
2713 test_acipher_speed("ecb(arc4)", ENCRYPT
, sec
, NULL
, 0,
2718 test_acipher_speed("ecb(cast5)", ENCRYPT
, sec
, NULL
, 0,
2719 speed_template_8_16
);
2720 test_acipher_speed("ecb(cast5)", DECRYPT
, sec
, NULL
, 0,
2721 speed_template_8_16
);
2722 test_acipher_speed("cbc(cast5)", ENCRYPT
, sec
, NULL
, 0,
2723 speed_template_8_16
);
2724 test_acipher_speed("cbc(cast5)", DECRYPT
, sec
, NULL
, 0,
2725 speed_template_8_16
);
2726 test_acipher_speed("ctr(cast5)", ENCRYPT
, sec
, NULL
, 0,
2727 speed_template_8_16
);
2728 test_acipher_speed("ctr(cast5)", DECRYPT
, sec
, NULL
, 0,
2729 speed_template_8_16
);
2733 test_acipher_speed("ecb(cast6)", ENCRYPT
, sec
, NULL
, 0,
2734 speed_template_16_32
);
2735 test_acipher_speed("ecb(cast6)", DECRYPT
, sec
, NULL
, 0,
2736 speed_template_16_32
);
2737 test_acipher_speed("cbc(cast6)", ENCRYPT
, sec
, NULL
, 0,
2738 speed_template_16_32
);
2739 test_acipher_speed("cbc(cast6)", DECRYPT
, sec
, NULL
, 0,
2740 speed_template_16_32
);
2741 test_acipher_speed("ctr(cast6)", ENCRYPT
, sec
, NULL
, 0,
2742 speed_template_16_32
);
2743 test_acipher_speed("ctr(cast6)", DECRYPT
, sec
, NULL
, 0,
2744 speed_template_16_32
);
2745 test_acipher_speed("lrw(cast6)", ENCRYPT
, sec
, NULL
, 0,
2746 speed_template_32_48
);
2747 test_acipher_speed("lrw(cast6)", DECRYPT
, sec
, NULL
, 0,
2748 speed_template_32_48
);
2749 test_acipher_speed("xts(cast6)", ENCRYPT
, sec
, NULL
, 0,
2750 speed_template_32_64
);
2751 test_acipher_speed("xts(cast6)", DECRYPT
, sec
, NULL
, 0,
2752 speed_template_32_64
);
2756 test_acipher_speed("ecb(camellia)", ENCRYPT
, sec
, NULL
, 0,
2757 speed_template_16_32
);
2758 test_acipher_speed("ecb(camellia)", DECRYPT
, sec
, NULL
, 0,
2759 speed_template_16_32
);
2760 test_acipher_speed("cbc(camellia)", ENCRYPT
, sec
, NULL
, 0,
2761 speed_template_16_32
);
2762 test_acipher_speed("cbc(camellia)", DECRYPT
, sec
, NULL
, 0,
2763 speed_template_16_32
);
2764 test_acipher_speed("ctr(camellia)", ENCRYPT
, sec
, NULL
, 0,
2765 speed_template_16_32
);
2766 test_acipher_speed("ctr(camellia)", DECRYPT
, sec
, NULL
, 0,
2767 speed_template_16_32
);
2768 test_acipher_speed("lrw(camellia)", ENCRYPT
, sec
, NULL
, 0,
2769 speed_template_32_48
);
2770 test_acipher_speed("lrw(camellia)", DECRYPT
, sec
, NULL
, 0,
2771 speed_template_32_48
);
2772 test_acipher_speed("xts(camellia)", ENCRYPT
, sec
, NULL
, 0,
2773 speed_template_32_64
);
2774 test_acipher_speed("xts(camellia)", DECRYPT
, sec
, NULL
, 0,
2775 speed_template_32_64
);
2779 test_acipher_speed("ecb(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2780 speed_template_8_32
);
2781 test_acipher_speed("ecb(blowfish)", DECRYPT
, sec
, NULL
, 0,
2782 speed_template_8_32
);
2783 test_acipher_speed("cbc(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2784 speed_template_8_32
);
2785 test_acipher_speed("cbc(blowfish)", DECRYPT
, sec
, NULL
, 0,
2786 speed_template_8_32
);
2787 test_acipher_speed("ctr(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2788 speed_template_8_32
);
2789 test_acipher_speed("ctr(blowfish)", DECRYPT
, sec
, NULL
, 0,
2790 speed_template_8_32
);
2794 test_mb_skcipher_speed("ecb(aes)", ENCRYPT
, sec
, NULL
, 0,
2795 speed_template_16_24_32
, num_mb
);
2796 test_mb_skcipher_speed("ecb(aes)", DECRYPT
, sec
, NULL
, 0,
2797 speed_template_16_24_32
, num_mb
);
2798 test_mb_skcipher_speed("cbc(aes)", ENCRYPT
, sec
, NULL
, 0,
2799 speed_template_16_24_32
, num_mb
);
2800 test_mb_skcipher_speed("cbc(aes)", DECRYPT
, sec
, NULL
, 0,
2801 speed_template_16_24_32
, num_mb
);
2802 test_mb_skcipher_speed("lrw(aes)", ENCRYPT
, sec
, NULL
, 0,
2803 speed_template_32_40_48
, num_mb
);
2804 test_mb_skcipher_speed("lrw(aes)", DECRYPT
, sec
, NULL
, 0,
2805 speed_template_32_40_48
, num_mb
);
2806 test_mb_skcipher_speed("xts(aes)", ENCRYPT
, sec
, NULL
, 0,
2807 speed_template_32_64
, num_mb
);
2808 test_mb_skcipher_speed("xts(aes)", DECRYPT
, sec
, NULL
, 0,
2809 speed_template_32_64
, num_mb
);
2810 test_mb_skcipher_speed("cts(cbc(aes))", ENCRYPT
, sec
, NULL
, 0,
2811 speed_template_16_24_32
, num_mb
);
2812 test_mb_skcipher_speed("cts(cbc(aes))", DECRYPT
, sec
, NULL
, 0,
2813 speed_template_16_24_32
, num_mb
);
2814 test_mb_skcipher_speed("ctr(aes)", ENCRYPT
, sec
, NULL
, 0,
2815 speed_template_16_24_32
, num_mb
);
2816 test_mb_skcipher_speed("ctr(aes)", DECRYPT
, sec
, NULL
, 0,
2817 speed_template_16_24_32
, num_mb
);
2818 test_mb_skcipher_speed("cfb(aes)", ENCRYPT
, sec
, NULL
, 0,
2819 speed_template_16_24_32
, num_mb
);
2820 test_mb_skcipher_speed("cfb(aes)", DECRYPT
, sec
, NULL
, 0,
2821 speed_template_16_24_32
, num_mb
);
2822 test_mb_skcipher_speed("ofb(aes)", ENCRYPT
, sec
, NULL
, 0,
2823 speed_template_16_24_32
, num_mb
);
2824 test_mb_skcipher_speed("ofb(aes)", DECRYPT
, sec
, NULL
, 0,
2825 speed_template_16_24_32
, num_mb
);
2826 test_mb_skcipher_speed("rfc3686(ctr(aes))", ENCRYPT
, sec
, NULL
,
2827 0, speed_template_20_28_36
, num_mb
);
2828 test_mb_skcipher_speed("rfc3686(ctr(aes))", DECRYPT
, sec
, NULL
,
2829 0, speed_template_20_28_36
, num_mb
);
2833 test_mb_skcipher_speed("ecb(des3_ede)", ENCRYPT
, sec
,
2834 des3_speed_template
, DES3_SPEED_VECTORS
,
2835 speed_template_24
, num_mb
);
2836 test_mb_skcipher_speed("ecb(des3_ede)", DECRYPT
, sec
,
2837 des3_speed_template
, DES3_SPEED_VECTORS
,
2838 speed_template_24
, num_mb
);
2839 test_mb_skcipher_speed("cbc(des3_ede)", ENCRYPT
, sec
,
2840 des3_speed_template
, DES3_SPEED_VECTORS
,
2841 speed_template_24
, num_mb
);
2842 test_mb_skcipher_speed("cbc(des3_ede)", DECRYPT
, sec
,
2843 des3_speed_template
, DES3_SPEED_VECTORS
,
2844 speed_template_24
, num_mb
);
2845 test_mb_skcipher_speed("cfb(des3_ede)", ENCRYPT
, sec
,
2846 des3_speed_template
, DES3_SPEED_VECTORS
,
2847 speed_template_24
, num_mb
);
2848 test_mb_skcipher_speed("cfb(des3_ede)", DECRYPT
, sec
,
2849 des3_speed_template
, DES3_SPEED_VECTORS
,
2850 speed_template_24
, num_mb
);
2851 test_mb_skcipher_speed("ofb(des3_ede)", ENCRYPT
, sec
,
2852 des3_speed_template
, DES3_SPEED_VECTORS
,
2853 speed_template_24
, num_mb
);
2854 test_mb_skcipher_speed("ofb(des3_ede)", DECRYPT
, sec
,
2855 des3_speed_template
, DES3_SPEED_VECTORS
,
2856 speed_template_24
, num_mb
);
2860 test_mb_skcipher_speed("ecb(des)", ENCRYPT
, sec
, NULL
, 0,
2861 speed_template_8
, num_mb
);
2862 test_mb_skcipher_speed("ecb(des)", DECRYPT
, sec
, NULL
, 0,
2863 speed_template_8
, num_mb
);
2864 test_mb_skcipher_speed("cbc(des)", ENCRYPT
, sec
, NULL
, 0,
2865 speed_template_8
, num_mb
);
2866 test_mb_skcipher_speed("cbc(des)", DECRYPT
, sec
, NULL
, 0,
2867 speed_template_8
, num_mb
);
2868 test_mb_skcipher_speed("cfb(des)", ENCRYPT
, sec
, NULL
, 0,
2869 speed_template_8
, num_mb
);
2870 test_mb_skcipher_speed("cfb(des)", DECRYPT
, sec
, NULL
, 0,
2871 speed_template_8
, num_mb
);
2872 test_mb_skcipher_speed("ofb(des)", ENCRYPT
, sec
, NULL
, 0,
2873 speed_template_8
, num_mb
);
2874 test_mb_skcipher_speed("ofb(des)", DECRYPT
, sec
, NULL
, 0,
2875 speed_template_8
, num_mb
);
2879 test_mb_skcipher_speed("ecb(serpent)", ENCRYPT
, sec
, NULL
, 0,
2880 speed_template_16_32
, num_mb
);
2881 test_mb_skcipher_speed("ecb(serpent)", DECRYPT
, sec
, NULL
, 0,
2882 speed_template_16_32
, num_mb
);
2883 test_mb_skcipher_speed("cbc(serpent)", ENCRYPT
, sec
, NULL
, 0,
2884 speed_template_16_32
, num_mb
);
2885 test_mb_skcipher_speed("cbc(serpent)", DECRYPT
, sec
, NULL
, 0,
2886 speed_template_16_32
, num_mb
);
2887 test_mb_skcipher_speed("ctr(serpent)", ENCRYPT
, sec
, NULL
, 0,
2888 speed_template_16_32
, num_mb
);
2889 test_mb_skcipher_speed("ctr(serpent)", DECRYPT
, sec
, NULL
, 0,
2890 speed_template_16_32
, num_mb
);
2891 test_mb_skcipher_speed("lrw(serpent)", ENCRYPT
, sec
, NULL
, 0,
2892 speed_template_32_48
, num_mb
);
2893 test_mb_skcipher_speed("lrw(serpent)", DECRYPT
, sec
, NULL
, 0,
2894 speed_template_32_48
, num_mb
);
2895 test_mb_skcipher_speed("xts(serpent)", ENCRYPT
, sec
, NULL
, 0,
2896 speed_template_32_64
, num_mb
);
2897 test_mb_skcipher_speed("xts(serpent)", DECRYPT
, sec
, NULL
, 0,
2898 speed_template_32_64
, num_mb
);
2902 test_mb_skcipher_speed("ecb(twofish)", ENCRYPT
, sec
, NULL
, 0,
2903 speed_template_16_24_32
, num_mb
);
2904 test_mb_skcipher_speed("ecb(twofish)", DECRYPT
, sec
, NULL
, 0,
2905 speed_template_16_24_32
, num_mb
);
2906 test_mb_skcipher_speed("cbc(twofish)", ENCRYPT
, sec
, NULL
, 0,
2907 speed_template_16_24_32
, num_mb
);
2908 test_mb_skcipher_speed("cbc(twofish)", DECRYPT
, sec
, NULL
, 0,
2909 speed_template_16_24_32
, num_mb
);
2910 test_mb_skcipher_speed("ctr(twofish)", ENCRYPT
, sec
, NULL
, 0,
2911 speed_template_16_24_32
, num_mb
);
2912 test_mb_skcipher_speed("ctr(twofish)", DECRYPT
, sec
, NULL
, 0,
2913 speed_template_16_24_32
, num_mb
);
2914 test_mb_skcipher_speed("lrw(twofish)", ENCRYPT
, sec
, NULL
, 0,
2915 speed_template_32_40_48
, num_mb
);
2916 test_mb_skcipher_speed("lrw(twofish)", DECRYPT
, sec
, NULL
, 0,
2917 speed_template_32_40_48
, num_mb
);
2918 test_mb_skcipher_speed("xts(twofish)", ENCRYPT
, sec
, NULL
, 0,
2919 speed_template_32_48_64
, num_mb
);
2920 test_mb_skcipher_speed("xts(twofish)", DECRYPT
, sec
, NULL
, 0,
2921 speed_template_32_48_64
, num_mb
);
2925 test_mb_skcipher_speed("ecb(arc4)", ENCRYPT
, sec
, NULL
, 0,
2926 speed_template_8
, num_mb
);
2930 test_mb_skcipher_speed("ecb(cast5)", ENCRYPT
, sec
, NULL
, 0,
2931 speed_template_8_16
, num_mb
);
2932 test_mb_skcipher_speed("ecb(cast5)", DECRYPT
, sec
, NULL
, 0,
2933 speed_template_8_16
, num_mb
);
2934 test_mb_skcipher_speed("cbc(cast5)", ENCRYPT
, sec
, NULL
, 0,
2935 speed_template_8_16
, num_mb
);
2936 test_mb_skcipher_speed("cbc(cast5)", DECRYPT
, sec
, NULL
, 0,
2937 speed_template_8_16
, num_mb
);
2938 test_mb_skcipher_speed("ctr(cast5)", ENCRYPT
, sec
, NULL
, 0,
2939 speed_template_8_16
, num_mb
);
2940 test_mb_skcipher_speed("ctr(cast5)", DECRYPT
, sec
, NULL
, 0,
2941 speed_template_8_16
, num_mb
);
2945 test_mb_skcipher_speed("ecb(cast6)", ENCRYPT
, sec
, NULL
, 0,
2946 speed_template_16_32
, num_mb
);
2947 test_mb_skcipher_speed("ecb(cast6)", DECRYPT
, sec
, NULL
, 0,
2948 speed_template_16_32
, num_mb
);
2949 test_mb_skcipher_speed("cbc(cast6)", ENCRYPT
, sec
, NULL
, 0,
2950 speed_template_16_32
, num_mb
);
2951 test_mb_skcipher_speed("cbc(cast6)", DECRYPT
, sec
, NULL
, 0,
2952 speed_template_16_32
, num_mb
);
2953 test_mb_skcipher_speed("ctr(cast6)", ENCRYPT
, sec
, NULL
, 0,
2954 speed_template_16_32
, num_mb
);
2955 test_mb_skcipher_speed("ctr(cast6)", DECRYPT
, sec
, NULL
, 0,
2956 speed_template_16_32
, num_mb
);
2957 test_mb_skcipher_speed("lrw(cast6)", ENCRYPT
, sec
, NULL
, 0,
2958 speed_template_32_48
, num_mb
);
2959 test_mb_skcipher_speed("lrw(cast6)", DECRYPT
, sec
, NULL
, 0,
2960 speed_template_32_48
, num_mb
);
2961 test_mb_skcipher_speed("xts(cast6)", ENCRYPT
, sec
, NULL
, 0,
2962 speed_template_32_64
, num_mb
);
2963 test_mb_skcipher_speed("xts(cast6)", DECRYPT
, sec
, NULL
, 0,
2964 speed_template_32_64
, num_mb
);
2968 test_mb_skcipher_speed("ecb(camellia)", ENCRYPT
, sec
, NULL
, 0,
2969 speed_template_16_32
, num_mb
);
2970 test_mb_skcipher_speed("ecb(camellia)", DECRYPT
, sec
, NULL
, 0,
2971 speed_template_16_32
, num_mb
);
2972 test_mb_skcipher_speed("cbc(camellia)", ENCRYPT
, sec
, NULL
, 0,
2973 speed_template_16_32
, num_mb
);
2974 test_mb_skcipher_speed("cbc(camellia)", DECRYPT
, sec
, NULL
, 0,
2975 speed_template_16_32
, num_mb
);
2976 test_mb_skcipher_speed("ctr(camellia)", ENCRYPT
, sec
, NULL
, 0,
2977 speed_template_16_32
, num_mb
);
2978 test_mb_skcipher_speed("ctr(camellia)", DECRYPT
, sec
, NULL
, 0,
2979 speed_template_16_32
, num_mb
);
2980 test_mb_skcipher_speed("lrw(camellia)", ENCRYPT
, sec
, NULL
, 0,
2981 speed_template_32_48
, num_mb
);
2982 test_mb_skcipher_speed("lrw(camellia)", DECRYPT
, sec
, NULL
, 0,
2983 speed_template_32_48
, num_mb
);
2984 test_mb_skcipher_speed("xts(camellia)", ENCRYPT
, sec
, NULL
, 0,
2985 speed_template_32_64
, num_mb
);
2986 test_mb_skcipher_speed("xts(camellia)", DECRYPT
, sec
, NULL
, 0,
2987 speed_template_32_64
, num_mb
);
2991 test_mb_skcipher_speed("ecb(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2992 speed_template_8_32
, num_mb
);
2993 test_mb_skcipher_speed("ecb(blowfish)", DECRYPT
, sec
, NULL
, 0,
2994 speed_template_8_32
, num_mb
);
2995 test_mb_skcipher_speed("cbc(blowfish)", ENCRYPT
, sec
, NULL
, 0,
2996 speed_template_8_32
, num_mb
);
2997 test_mb_skcipher_speed("cbc(blowfish)", DECRYPT
, sec
, NULL
, 0,
2998 speed_template_8_32
, num_mb
);
2999 test_mb_skcipher_speed("ctr(blowfish)", ENCRYPT
, sec
, NULL
, 0,
3000 speed_template_8_32
, num_mb
);
3001 test_mb_skcipher_speed("ctr(blowfish)", DECRYPT
, sec
, NULL
, 0,
3002 speed_template_8_32
, num_mb
);
3013 static int __init
tcrypt_mod_init(void)
3018 for (i
= 0; i
< TVMEMSIZE
; i
++) {
3019 tvmem
[i
] = (void *)__get_free_page(GFP_KERNEL
);
3024 err
= do_test(alg
, type
, mask
, mode
, num_mb
);
3027 printk(KERN_ERR
"tcrypt: one or more tests failed!\n");
3030 pr_debug("all tests passed\n");
3033 /* We intentionaly return -EAGAIN to prevent keeping the module,
3034 * unless we're running in fips mode. It does all its work from
3035 * init() and doesn't offer any runtime functionality, but in
3036 * the fips case, checking for a successful load is helpful.
3037 * => we don't need it in the memory, do we?
3044 for (i
= 0; i
< TVMEMSIZE
&& tvmem
[i
]; i
++)
3045 free_page((unsigned long)tvmem
[i
]);
3051 * If an init function is provided, an exit function must also be provided
3052 * to allow module unload.
3054 static void __exit
tcrypt_mod_fini(void) { }
3056 module_init(tcrypt_mod_init
);
3057 module_exit(tcrypt_mod_fini
);
3059 module_param(alg
, charp
, 0);
3060 module_param(type
, uint
, 0);
3061 module_param(mask
, uint
, 0);
3062 module_param(mode
, int, 0);
3063 module_param(sec
, uint
, 0);
3064 MODULE_PARM_DESC(sec
, "Length in seconds of speed tests "
3065 "(defaults to zero which uses CPU cycles instead)");
3066 module_param(num_mb
, uint
, 0000);
3067 MODULE_PARM_DESC(num_mb
, "Number of concurrent requests to be used in mb speed tests (defaults to 8)");
3069 MODULE_LICENSE("GPL");
3070 MODULE_DESCRIPTION("Quick & dirty crypto testing module");
3071 MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");