xref: /openbmc/linux/crypto/tcrypt.c (revision 14386d47)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Quick & dirty crypto testing module.
4  *
5  * This will only exist until we have a better testing mechanism
6  * (e.g. a char device).
7  *
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
11  *
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.
18  */
19 
20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21 
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>
36 #include "tcrypt.h"
37 
38 /*
39  * Need slab memory for testing (size in number of pages).
40  */
41 #define TVMEMSIZE	4
42 
43 /*
44 * Used by test_cipher_speed()
45 */
46 #define ENCRYPT 1
47 #define DECRYPT 0
48 
49 #define MAX_DIGEST_SIZE		64
50 
51 /*
52  * return a string with the driver name
53  */
54 #define get_driver_name(tfm_type, tfm) crypto_tfm_alg_driver_name(tfm_type ## _tfm(tfm))
55 
56 /*
57  * Used by test_cipher_speed()
58  */
59 static unsigned int sec;
60 
61 static char *alg;
62 static u32 type;
63 static u32 mask;
64 static int mode;
65 static u32 num_mb = 8;
66 static unsigned int klen;
67 static char *tvmem[TVMEMSIZE];
68 
69 static const int block_sizes[] = { 16, 64, 128, 256, 1024, 1420, 4096, 0 };
70 static const int aead_sizes[] = { 16, 64, 256, 512, 1024, 1420, 4096, 8192, 0 };
71 
72 #define XBUFSIZE 8
73 #define MAX_IVLEN 32
74 
75 static int testmgr_alloc_buf(char *buf[XBUFSIZE])
76 {
77 	int i;
78 
79 	for (i = 0; i < XBUFSIZE; i++) {
80 		buf[i] = (void *)__get_free_page(GFP_KERNEL);
81 		if (!buf[i])
82 			goto err_free_buf;
83 	}
84 
85 	return 0;
86 
87 err_free_buf:
88 	while (i-- > 0)
89 		free_page((unsigned long)buf[i]);
90 
91 	return -ENOMEM;
92 }
93 
94 static void testmgr_free_buf(char *buf[XBUFSIZE])
95 {
96 	int i;
97 
98 	for (i = 0; i < XBUFSIZE; i++)
99 		free_page((unsigned long)buf[i]);
100 }
101 
102 static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],
103 			 unsigned int buflen, const void *assoc,
104 			 unsigned int aad_size)
105 {
106 	int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE;
107 	int k, rem;
108 
109 	if (np > XBUFSIZE) {
110 		rem = PAGE_SIZE;
111 		np = XBUFSIZE;
112 	} else {
113 		rem = buflen % PAGE_SIZE;
114 	}
115 
116 	sg_init_table(sg, np + 1);
117 
118 	sg_set_buf(&sg[0], assoc, aad_size);
119 
120 	if (rem)
121 		np--;
122 	for (k = 0; k < np; k++)
123 		sg_set_buf(&sg[k + 1], xbuf[k], PAGE_SIZE);
124 
125 	if (rem)
126 		sg_set_buf(&sg[k + 1], xbuf[k], rem);
127 }
128 
129 static inline int do_one_aead_op(struct aead_request *req, int ret)
130 {
131 	struct crypto_wait *wait = req->base.data;
132 
133 	return crypto_wait_req(ret, wait);
134 }
135 
136 struct test_mb_aead_data {
137 	struct scatterlist sg[XBUFSIZE];
138 	struct scatterlist sgout[XBUFSIZE];
139 	struct aead_request *req;
140 	struct crypto_wait wait;
141 	char *xbuf[XBUFSIZE];
142 	char *xoutbuf[XBUFSIZE];
143 	char *axbuf[XBUFSIZE];
144 };
145 
146 static int do_mult_aead_op(struct test_mb_aead_data *data, int enc,
147 				u32 num_mb, int *rc)
148 {
149 	int i, err = 0;
150 
151 	/* Fire up a bunch of concurrent requests */
152 	for (i = 0; i < num_mb; i++) {
153 		if (enc == ENCRYPT)
154 			rc[i] = crypto_aead_encrypt(data[i].req);
155 		else
156 			rc[i] = crypto_aead_decrypt(data[i].req);
157 	}
158 
159 	/* Wait for all requests to finish */
160 	for (i = 0; i < num_mb; i++) {
161 		rc[i] = crypto_wait_req(rc[i], &data[i].wait);
162 
163 		if (rc[i]) {
164 			pr_info("concurrent request %d error %d\n", i, rc[i]);
165 			err = rc[i];
166 		}
167 	}
168 
169 	return err;
170 }
171 
172 static int test_mb_aead_jiffies(struct test_mb_aead_data *data, int enc,
173 				int blen, int secs, u32 num_mb)
174 {
175 	unsigned long start, end;
176 	int bcount;
177 	int ret = 0;
178 	int *rc;
179 
180 	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
181 	if (!rc)
182 		return -ENOMEM;
183 
184 	for (start = jiffies, end = start + secs * HZ, bcount = 0;
185 	     time_before(jiffies, end); bcount++) {
186 		ret = do_mult_aead_op(data, enc, num_mb, rc);
187 		if (ret)
188 			goto out;
189 	}
190 
191 	pr_cont("%d operations in %d seconds (%llu bytes)\n",
192 		bcount * num_mb, secs, (u64)bcount * blen * num_mb);
193 
194 out:
195 	kfree(rc);
196 	return ret;
197 }
198 
199 static int test_mb_aead_cycles(struct test_mb_aead_data *data, int enc,
200 			       int blen, u32 num_mb)
201 {
202 	unsigned long cycles = 0;
203 	int ret = 0;
204 	int i;
205 	int *rc;
206 
207 	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
208 	if (!rc)
209 		return -ENOMEM;
210 
211 	/* Warm-up run. */
212 	for (i = 0; i < 4; i++) {
213 		ret = do_mult_aead_op(data, enc, num_mb, rc);
214 		if (ret)
215 			goto out;
216 	}
217 
218 	/* The real thing. */
219 	for (i = 0; i < 8; i++) {
220 		cycles_t start, end;
221 
222 		start = get_cycles();
223 		ret = do_mult_aead_op(data, enc, num_mb, rc);
224 		end = get_cycles();
225 
226 		if (ret)
227 			goto out;
228 
229 		cycles += end - start;
230 	}
231 
232 	pr_cont("1 operation in %lu cycles (%d bytes)\n",
233 		(cycles + 4) / (8 * num_mb), blen);
234 
235 out:
236 	kfree(rc);
237 	return ret;
238 }
239 
240 static void test_mb_aead_speed(const char *algo, int enc, int secs,
241 			       struct aead_speed_template *template,
242 			       unsigned int tcount, u8 authsize,
243 			       unsigned int aad_size, u8 *keysize, u32 num_mb)
244 {
245 	struct test_mb_aead_data *data;
246 	struct crypto_aead *tfm;
247 	unsigned int i, j, iv_len;
248 	const int *b_size;
249 	const char *key;
250 	const char *e;
251 	void *assoc;
252 	char *iv;
253 	int ret;
254 
255 
256 	if (aad_size >= PAGE_SIZE) {
257 		pr_err("associate data length (%u) too big\n", aad_size);
258 		return;
259 	}
260 
261 	iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
262 	if (!iv)
263 		return;
264 
265 	if (enc == ENCRYPT)
266 		e = "encryption";
267 	else
268 		e = "decryption";
269 
270 	data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL);
271 	if (!data)
272 		goto out_free_iv;
273 
274 	tfm = crypto_alloc_aead(algo, 0, 0);
275 	if (IS_ERR(tfm)) {
276 		pr_err("failed to load transform for %s: %ld\n",
277 			algo, PTR_ERR(tfm));
278 		goto out_free_data;
279 	}
280 
281 	ret = crypto_aead_setauthsize(tfm, authsize);
282 	if (ret) {
283 		pr_err("alg: aead: Failed to setauthsize for %s: %d\n", algo,
284 		       ret);
285 		goto out_free_tfm;
286 	}
287 
288 	for (i = 0; i < num_mb; ++i)
289 		if (testmgr_alloc_buf(data[i].xbuf)) {
290 			while (i--)
291 				testmgr_free_buf(data[i].xbuf);
292 			goto out_free_tfm;
293 		}
294 
295 	for (i = 0; i < num_mb; ++i)
296 		if (testmgr_alloc_buf(data[i].axbuf)) {
297 			while (i--)
298 				testmgr_free_buf(data[i].axbuf);
299 			goto out_free_xbuf;
300 		}
301 
302 	for (i = 0; i < num_mb; ++i)
303 		if (testmgr_alloc_buf(data[i].xoutbuf)) {
304 			while (i--)
305 				testmgr_free_buf(data[i].xoutbuf);
306 			goto out_free_axbuf;
307 		}
308 
309 	for (i = 0; i < num_mb; ++i) {
310 		data[i].req = aead_request_alloc(tfm, GFP_KERNEL);
311 		if (!data[i].req) {
312 			pr_err("alg: aead: Failed to allocate request for %s\n",
313 			       algo);
314 			while (i--)
315 				aead_request_free(data[i].req);
316 			goto out_free_xoutbuf;
317 		}
318 	}
319 
320 	for (i = 0; i < num_mb; ++i) {
321 		crypto_init_wait(&data[i].wait);
322 		aead_request_set_callback(data[i].req,
323 					  CRYPTO_TFM_REQ_MAY_BACKLOG,
324 					  crypto_req_done, &data[i].wait);
325 	}
326 
327 	pr_info("testing speed of multibuffer %s (%s) %s\n", algo,
328 		get_driver_name(crypto_aead, tfm), e);
329 
330 	i = 0;
331 	do {
332 		b_size = aead_sizes;
333 		do {
334 			int bs = round_up(*b_size, crypto_aead_blocksize(tfm));
335 
336 			if (bs + authsize > XBUFSIZE * PAGE_SIZE) {
337 				pr_err("template (%u) too big for buffer (%lu)\n",
338 				       authsize + bs,
339 				       XBUFSIZE * PAGE_SIZE);
340 				goto out;
341 			}
342 
343 			pr_info("test %u (%d bit key, %d byte blocks): ", i,
344 				*keysize * 8, bs);
345 
346 			/* Set up tfm global state, i.e. the key */
347 
348 			memset(tvmem[0], 0xff, PAGE_SIZE);
349 			key = tvmem[0];
350 			for (j = 0; j < tcount; j++) {
351 				if (template[j].klen == *keysize) {
352 					key = template[j].key;
353 					break;
354 				}
355 			}
356 
357 			crypto_aead_clear_flags(tfm, ~0);
358 
359 			ret = crypto_aead_setkey(tfm, key, *keysize);
360 			if (ret) {
361 				pr_err("setkey() failed flags=%x\n",
362 				       crypto_aead_get_flags(tfm));
363 				goto out;
364 			}
365 
366 			iv_len = crypto_aead_ivsize(tfm);
367 			if (iv_len)
368 				memset(iv, 0xff, iv_len);
369 
370 			/* Now setup per request stuff, i.e. buffers */
371 
372 			for (j = 0; j < num_mb; ++j) {
373 				struct test_mb_aead_data *cur = &data[j];
374 
375 				assoc = cur->axbuf[0];
376 				memset(assoc, 0xff, aad_size);
377 
378 				sg_init_aead(cur->sg, cur->xbuf,
379 					     bs + (enc ? 0 : authsize),
380 					     assoc, aad_size);
381 
382 				sg_init_aead(cur->sgout, cur->xoutbuf,
383 					     bs + (enc ? authsize : 0),
384 					     assoc, aad_size);
385 
386 				aead_request_set_ad(cur->req, aad_size);
387 
388 				if (!enc) {
389 
390 					aead_request_set_crypt(cur->req,
391 							       cur->sgout,
392 							       cur->sg,
393 							       bs, iv);
394 					ret = crypto_aead_encrypt(cur->req);
395 					ret = do_one_aead_op(cur->req, ret);
396 
397 					if (ret) {
398 						pr_err("calculating auth failed (%d)\n",
399 						       ret);
400 						break;
401 					}
402 				}
403 
404 				aead_request_set_crypt(cur->req, cur->sg,
405 						       cur->sgout, bs +
406 						       (enc ? 0 : authsize),
407 						       iv);
408 
409 			}
410 
411 			if (secs) {
412 				ret = test_mb_aead_jiffies(data, enc, bs,
413 							   secs, num_mb);
414 				cond_resched();
415 			} else {
416 				ret = test_mb_aead_cycles(data, enc, bs,
417 							  num_mb);
418 			}
419 
420 			if (ret) {
421 				pr_err("%s() failed return code=%d\n", e, ret);
422 				break;
423 			}
424 			b_size++;
425 			i++;
426 		} while (*b_size);
427 		keysize++;
428 	} while (*keysize);
429 
430 out:
431 	for (i = 0; i < num_mb; ++i)
432 		aead_request_free(data[i].req);
433 out_free_xoutbuf:
434 	for (i = 0; i < num_mb; ++i)
435 		testmgr_free_buf(data[i].xoutbuf);
436 out_free_axbuf:
437 	for (i = 0; i < num_mb; ++i)
438 		testmgr_free_buf(data[i].axbuf);
439 out_free_xbuf:
440 	for (i = 0; i < num_mb; ++i)
441 		testmgr_free_buf(data[i].xbuf);
442 out_free_tfm:
443 	crypto_free_aead(tfm);
444 out_free_data:
445 	kfree(data);
446 out_free_iv:
447 	kfree(iv);
448 }
449 
450 static int test_aead_jiffies(struct aead_request *req, int enc,
451 				int blen, int secs)
452 {
453 	unsigned long start, end;
454 	int bcount;
455 	int ret;
456 
457 	for (start = jiffies, end = start + secs * HZ, bcount = 0;
458 	     time_before(jiffies, end); bcount++) {
459 		if (enc)
460 			ret = do_one_aead_op(req, crypto_aead_encrypt(req));
461 		else
462 			ret = do_one_aead_op(req, crypto_aead_decrypt(req));
463 
464 		if (ret)
465 			return ret;
466 	}
467 
468 	pr_cont("%d operations in %d seconds (%llu bytes)\n",
469 	        bcount, secs, (u64)bcount * blen);
470 	return 0;
471 }
472 
473 static int test_aead_cycles(struct aead_request *req, int enc, int blen)
474 {
475 	unsigned long cycles = 0;
476 	int ret = 0;
477 	int i;
478 
479 	/* Warm-up run. */
480 	for (i = 0; i < 4; i++) {
481 		if (enc)
482 			ret = do_one_aead_op(req, crypto_aead_encrypt(req));
483 		else
484 			ret = do_one_aead_op(req, crypto_aead_decrypt(req));
485 
486 		if (ret)
487 			goto out;
488 	}
489 
490 	/* The real thing. */
491 	for (i = 0; i < 8; i++) {
492 		cycles_t start, end;
493 
494 		start = get_cycles();
495 		if (enc)
496 			ret = do_one_aead_op(req, crypto_aead_encrypt(req));
497 		else
498 			ret = do_one_aead_op(req, crypto_aead_decrypt(req));
499 		end = get_cycles();
500 
501 		if (ret)
502 			goto out;
503 
504 		cycles += end - start;
505 	}
506 
507 out:
508 	if (ret == 0)
509 		pr_cont("1 operation in %lu cycles (%d bytes)\n",
510 			(cycles + 4) / 8, blen);
511 
512 	return ret;
513 }
514 
515 static void test_aead_speed(const char *algo, int enc, unsigned int secs,
516 			    struct aead_speed_template *template,
517 			    unsigned int tcount, u8 authsize,
518 			    unsigned int aad_size, u8 *keysize)
519 {
520 	unsigned int i, j;
521 	struct crypto_aead *tfm;
522 	int ret = -ENOMEM;
523 	const char *key;
524 	struct aead_request *req;
525 	struct scatterlist *sg;
526 	struct scatterlist *sgout;
527 	const char *e;
528 	void *assoc;
529 	char *iv;
530 	char *xbuf[XBUFSIZE];
531 	char *xoutbuf[XBUFSIZE];
532 	char *axbuf[XBUFSIZE];
533 	const int *b_size;
534 	unsigned int iv_len;
535 	struct crypto_wait wait;
536 
537 	iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
538 	if (!iv)
539 		return;
540 
541 	if (aad_size >= PAGE_SIZE) {
542 		pr_err("associate data length (%u) too big\n", aad_size);
543 		goto out_noxbuf;
544 	}
545 
546 	if (enc == ENCRYPT)
547 		e = "encryption";
548 	else
549 		e = "decryption";
550 
551 	if (testmgr_alloc_buf(xbuf))
552 		goto out_noxbuf;
553 	if (testmgr_alloc_buf(axbuf))
554 		goto out_noaxbuf;
555 	if (testmgr_alloc_buf(xoutbuf))
556 		goto out_nooutbuf;
557 
558 	sg = kmalloc(sizeof(*sg) * 9 * 2, GFP_KERNEL);
559 	if (!sg)
560 		goto out_nosg;
561 	sgout = &sg[9];
562 
563 	tfm = crypto_alloc_aead(algo, 0, 0);
564 	if (IS_ERR(tfm)) {
565 		pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo,
566 		       PTR_ERR(tfm));
567 		goto out_notfm;
568 	}
569 
570 	ret = crypto_aead_setauthsize(tfm, authsize);
571 	if (ret) {
572 		pr_err("alg: aead: Failed to setauthsize for %s: %d\n", algo,
573 		       ret);
574 		goto out_noreq;
575 	}
576 
577 	crypto_init_wait(&wait);
578 	pr_info("testing speed of %s (%s) %s\n", algo,
579 		get_driver_name(crypto_aead, tfm), e);
580 
581 	req = aead_request_alloc(tfm, GFP_KERNEL);
582 	if (!req) {
583 		pr_err("alg: aead: Failed to allocate request for %s\n",
584 		       algo);
585 		goto out_noreq;
586 	}
587 
588 	aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
589 				  crypto_req_done, &wait);
590 
591 	i = 0;
592 	do {
593 		b_size = aead_sizes;
594 		do {
595 			u32 bs = round_up(*b_size, crypto_aead_blocksize(tfm));
596 
597 			assoc = axbuf[0];
598 			memset(assoc, 0xff, aad_size);
599 
600 			if ((*keysize + bs) > TVMEMSIZE * PAGE_SIZE) {
601 				pr_err("template (%u) too big for tvmem (%lu)\n",
602 				       *keysize + bs,
603 					TVMEMSIZE * PAGE_SIZE);
604 				goto out;
605 			}
606 
607 			key = tvmem[0];
608 			for (j = 0; j < tcount; j++) {
609 				if (template[j].klen == *keysize) {
610 					key = template[j].key;
611 					break;
612 				}
613 			}
614 
615 			ret = crypto_aead_setkey(tfm, key, *keysize);
616 			if (ret) {
617 				pr_err("setkey() failed flags=%x: %d\n",
618 					crypto_aead_get_flags(tfm), ret);
619 				goto out;
620 			}
621 
622 			iv_len = crypto_aead_ivsize(tfm);
623 			if (iv_len)
624 				memset(iv, 0xff, iv_len);
625 
626 			crypto_aead_clear_flags(tfm, ~0);
627 			pr_info("test %u (%d bit key, %d byte blocks): ",
628 				i, *keysize * 8, bs);
629 
630 			memset(tvmem[0], 0xff, PAGE_SIZE);
631 
632 			sg_init_aead(sg, xbuf, bs + (enc ? 0 : authsize),
633 				     assoc, aad_size);
634 
635 			sg_init_aead(sgout, xoutbuf,
636 				     bs + (enc ? authsize : 0), assoc,
637 				     aad_size);
638 
639 			aead_request_set_ad(req, aad_size);
640 
641 			if (!enc) {
642 
643 				/*
644 				 * For decryption we need a proper auth so
645 				 * we do the encryption path once with buffers
646 				 * reversed (input <-> output) to calculate it
647 				 */
648 				aead_request_set_crypt(req, sgout, sg,
649 						       bs, iv);
650 				ret = do_one_aead_op(req,
651 						     crypto_aead_encrypt(req));
652 
653 				if (ret) {
654 					pr_err("calculating auth failed (%d)\n",
655 					       ret);
656 					break;
657 				}
658 			}
659 
660 			aead_request_set_crypt(req, sg, sgout,
661 					       bs + (enc ? 0 : authsize),
662 					       iv);
663 
664 			if (secs) {
665 				ret = test_aead_jiffies(req, enc, bs,
666 							secs);
667 				cond_resched();
668 			} else {
669 				ret = test_aead_cycles(req, enc, bs);
670 			}
671 
672 			if (ret) {
673 				pr_err("%s() failed return code=%d\n", e, ret);
674 				break;
675 			}
676 			b_size++;
677 			i++;
678 		} while (*b_size);
679 		keysize++;
680 	} while (*keysize);
681 
682 out:
683 	aead_request_free(req);
684 out_noreq:
685 	crypto_free_aead(tfm);
686 out_notfm:
687 	kfree(sg);
688 out_nosg:
689 	testmgr_free_buf(xoutbuf);
690 out_nooutbuf:
691 	testmgr_free_buf(axbuf);
692 out_noaxbuf:
693 	testmgr_free_buf(xbuf);
694 out_noxbuf:
695 	kfree(iv);
696 }
697 
698 static void test_hash_sg_init(struct scatterlist *sg)
699 {
700 	int i;
701 
702 	sg_init_table(sg, TVMEMSIZE);
703 	for (i = 0; i < TVMEMSIZE; i++) {
704 		sg_set_buf(sg + i, tvmem[i], PAGE_SIZE);
705 		memset(tvmem[i], 0xff, PAGE_SIZE);
706 	}
707 }
708 
709 static inline int do_one_ahash_op(struct ahash_request *req, int ret)
710 {
711 	struct crypto_wait *wait = req->base.data;
712 
713 	return crypto_wait_req(ret, wait);
714 }
715 
716 static int test_ahash_jiffies_digest(struct ahash_request *req, int blen,
717 				     char *out, int secs)
718 {
719 	unsigned long start, end;
720 	int bcount;
721 	int ret;
722 
723 	for (start = jiffies, end = start + secs * HZ, bcount = 0;
724 	     time_before(jiffies, end); bcount++) {
725 		ret = do_one_ahash_op(req, crypto_ahash_digest(req));
726 		if (ret)
727 			return ret;
728 	}
729 
730 	pr_cont("%6u opers/sec, %9lu bytes/sec\n",
731 		bcount / secs, ((long)bcount * blen) / secs);
732 
733 	return 0;
734 }
735 
736 static int test_ahash_jiffies(struct ahash_request *req, int blen,
737 			      int plen, char *out, int secs)
738 {
739 	unsigned long start, end;
740 	int bcount, pcount;
741 	int ret;
742 
743 	if (plen == blen)
744 		return test_ahash_jiffies_digest(req, blen, out, secs);
745 
746 	for (start = jiffies, end = start + secs * HZ, bcount = 0;
747 	     time_before(jiffies, end); bcount++) {
748 		ret = do_one_ahash_op(req, crypto_ahash_init(req));
749 		if (ret)
750 			return ret;
751 		for (pcount = 0; pcount < blen; pcount += plen) {
752 			ret = do_one_ahash_op(req, crypto_ahash_update(req));
753 			if (ret)
754 				return ret;
755 		}
756 		/* we assume there is enough space in 'out' for the result */
757 		ret = do_one_ahash_op(req, crypto_ahash_final(req));
758 		if (ret)
759 			return ret;
760 	}
761 
762 	pr_cont("%6u opers/sec, %9lu bytes/sec\n",
763 		bcount / secs, ((long)bcount * blen) / secs);
764 
765 	return 0;
766 }
767 
768 static int test_ahash_cycles_digest(struct ahash_request *req, int blen,
769 				    char *out)
770 {
771 	unsigned long cycles = 0;
772 	int ret, i;
773 
774 	/* Warm-up run. */
775 	for (i = 0; i < 4; i++) {
776 		ret = do_one_ahash_op(req, crypto_ahash_digest(req));
777 		if (ret)
778 			goto out;
779 	}
780 
781 	/* The real thing. */
782 	for (i = 0; i < 8; i++) {
783 		cycles_t start, end;
784 
785 		start = get_cycles();
786 
787 		ret = do_one_ahash_op(req, crypto_ahash_digest(req));
788 		if (ret)
789 			goto out;
790 
791 		end = get_cycles();
792 
793 		cycles += end - start;
794 	}
795 
796 out:
797 	if (ret)
798 		return ret;
799 
800 	pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
801 		cycles / 8, cycles / (8 * blen));
802 
803 	return 0;
804 }
805 
806 static int test_ahash_cycles(struct ahash_request *req, int blen,
807 			     int plen, char *out)
808 {
809 	unsigned long cycles = 0;
810 	int i, pcount, ret;
811 
812 	if (plen == blen)
813 		return test_ahash_cycles_digest(req, blen, out);
814 
815 	/* Warm-up run. */
816 	for (i = 0; i < 4; i++) {
817 		ret = do_one_ahash_op(req, crypto_ahash_init(req));
818 		if (ret)
819 			goto out;
820 		for (pcount = 0; pcount < blen; pcount += plen) {
821 			ret = do_one_ahash_op(req, crypto_ahash_update(req));
822 			if (ret)
823 				goto out;
824 		}
825 		ret = do_one_ahash_op(req, crypto_ahash_final(req));
826 		if (ret)
827 			goto out;
828 	}
829 
830 	/* The real thing. */
831 	for (i = 0; i < 8; i++) {
832 		cycles_t start, end;
833 
834 		start = get_cycles();
835 
836 		ret = do_one_ahash_op(req, crypto_ahash_init(req));
837 		if (ret)
838 			goto out;
839 		for (pcount = 0; pcount < blen; pcount += plen) {
840 			ret = do_one_ahash_op(req, crypto_ahash_update(req));
841 			if (ret)
842 				goto out;
843 		}
844 		ret = do_one_ahash_op(req, crypto_ahash_final(req));
845 		if (ret)
846 			goto out;
847 
848 		end = get_cycles();
849 
850 		cycles += end - start;
851 	}
852 
853 out:
854 	if (ret)
855 		return ret;
856 
857 	pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
858 		cycles / 8, cycles / (8 * blen));
859 
860 	return 0;
861 }
862 
863 static void test_ahash_speed_common(const char *algo, unsigned int secs,
864 				    struct hash_speed *speed, unsigned mask)
865 {
866 	struct scatterlist sg[TVMEMSIZE];
867 	struct crypto_wait wait;
868 	struct ahash_request *req;
869 	struct crypto_ahash *tfm;
870 	char *output;
871 	int i, ret;
872 
873 	tfm = crypto_alloc_ahash(algo, 0, mask);
874 	if (IS_ERR(tfm)) {
875 		pr_err("failed to load transform for %s: %ld\n",
876 		       algo, PTR_ERR(tfm));
877 		return;
878 	}
879 
880 	pr_info("testing speed of async %s (%s)\n", algo,
881 		get_driver_name(crypto_ahash, tfm));
882 
883 	if (crypto_ahash_digestsize(tfm) > MAX_DIGEST_SIZE) {
884 		pr_err("digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm),
885 		       MAX_DIGEST_SIZE);
886 		goto out;
887 	}
888 
889 	test_hash_sg_init(sg);
890 	req = ahash_request_alloc(tfm, GFP_KERNEL);
891 	if (!req) {
892 		pr_err("ahash request allocation failure\n");
893 		goto out;
894 	}
895 
896 	crypto_init_wait(&wait);
897 	ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
898 				   crypto_req_done, &wait);
899 
900 	output = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL);
901 	if (!output)
902 		goto out_nomem;
903 
904 	for (i = 0; speed[i].blen != 0; i++) {
905 		if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
906 			pr_err("template (%u) too big for tvmem (%lu)\n",
907 			       speed[i].blen, TVMEMSIZE * PAGE_SIZE);
908 			break;
909 		}
910 
911 		if (klen)
912 			crypto_ahash_setkey(tfm, tvmem[0], klen);
913 
914 		pr_info("test%3u "
915 			"(%5u byte blocks,%5u bytes per update,%4u updates): ",
916 			i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
917 
918 		ahash_request_set_crypt(req, sg, output, speed[i].plen);
919 
920 		if (secs) {
921 			ret = test_ahash_jiffies(req, speed[i].blen,
922 						 speed[i].plen, output, secs);
923 			cond_resched();
924 		} else {
925 			ret = test_ahash_cycles(req, speed[i].blen,
926 						speed[i].plen, output);
927 		}
928 
929 		if (ret) {
930 			pr_err("hashing failed ret=%d\n", ret);
931 			break;
932 		}
933 	}
934 
935 	kfree(output);
936 
937 out_nomem:
938 	ahash_request_free(req);
939 
940 out:
941 	crypto_free_ahash(tfm);
942 }
943 
944 static void test_ahash_speed(const char *algo, unsigned int secs,
945 			     struct hash_speed *speed)
946 {
947 	return test_ahash_speed_common(algo, secs, speed, 0);
948 }
949 
950 static void test_hash_speed(const char *algo, unsigned int secs,
951 			    struct hash_speed *speed)
952 {
953 	return test_ahash_speed_common(algo, secs, speed, CRYPTO_ALG_ASYNC);
954 }
955 
956 struct test_mb_skcipher_data {
957 	struct scatterlist sg[XBUFSIZE];
958 	struct skcipher_request *req;
959 	struct crypto_wait wait;
960 	char *xbuf[XBUFSIZE];
961 };
962 
963 static int do_mult_acipher_op(struct test_mb_skcipher_data *data, int enc,
964 				u32 num_mb, int *rc)
965 {
966 	int i, err = 0;
967 
968 	/* Fire up a bunch of concurrent requests */
969 	for (i = 0; i < num_mb; i++) {
970 		if (enc == ENCRYPT)
971 			rc[i] = crypto_skcipher_encrypt(data[i].req);
972 		else
973 			rc[i] = crypto_skcipher_decrypt(data[i].req);
974 	}
975 
976 	/* Wait for all requests to finish */
977 	for (i = 0; i < num_mb; i++) {
978 		rc[i] = crypto_wait_req(rc[i], &data[i].wait);
979 
980 		if (rc[i]) {
981 			pr_info("concurrent request %d error %d\n", i, rc[i]);
982 			err = rc[i];
983 		}
984 	}
985 
986 	return err;
987 }
988 
989 static int test_mb_acipher_jiffies(struct test_mb_skcipher_data *data, int enc,
990 				int blen, int secs, u32 num_mb)
991 {
992 	unsigned long start, end;
993 	int bcount;
994 	int ret = 0;
995 	int *rc;
996 
997 	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
998 	if (!rc)
999 		return -ENOMEM;
1000 
1001 	for (start = jiffies, end = start + secs * HZ, bcount = 0;
1002 	     time_before(jiffies, end); bcount++) {
1003 		ret = do_mult_acipher_op(data, enc, num_mb, rc);
1004 		if (ret)
1005 			goto out;
1006 	}
1007 
1008 	pr_cont("%d operations in %d seconds (%llu bytes)\n",
1009 		bcount * num_mb, secs, (u64)bcount * blen * num_mb);
1010 
1011 out:
1012 	kfree(rc);
1013 	return ret;
1014 }
1015 
1016 static int test_mb_acipher_cycles(struct test_mb_skcipher_data *data, int enc,
1017 			       int blen, u32 num_mb)
1018 {
1019 	unsigned long cycles = 0;
1020 	int ret = 0;
1021 	int i;
1022 	int *rc;
1023 
1024 	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
1025 	if (!rc)
1026 		return -ENOMEM;
1027 
1028 	/* Warm-up run. */
1029 	for (i = 0; i < 4; i++) {
1030 		ret = do_mult_acipher_op(data, enc, num_mb, rc);
1031 		if (ret)
1032 			goto out;
1033 	}
1034 
1035 	/* The real thing. */
1036 	for (i = 0; i < 8; i++) {
1037 		cycles_t start, end;
1038 
1039 		start = get_cycles();
1040 		ret = do_mult_acipher_op(data, enc, num_mb, rc);
1041 		end = get_cycles();
1042 
1043 		if (ret)
1044 			goto out;
1045 
1046 		cycles += end - start;
1047 	}
1048 
1049 	pr_cont("1 operation in %lu cycles (%d bytes)\n",
1050 		(cycles + 4) / (8 * num_mb), blen);
1051 
1052 out:
1053 	kfree(rc);
1054 	return ret;
1055 }
1056 
1057 static void test_mb_skcipher_speed(const char *algo, int enc, int secs,
1058 				   struct cipher_speed_template *template,
1059 				   unsigned int tcount, u8 *keysize, u32 num_mb)
1060 {
1061 	struct test_mb_skcipher_data *data;
1062 	struct crypto_skcipher *tfm;
1063 	unsigned int i, j, iv_len;
1064 	const int *b_size;
1065 	const char *key;
1066 	const char *e;
1067 	char iv[128];
1068 	int ret;
1069 
1070 	if (enc == ENCRYPT)
1071 		e = "encryption";
1072 	else
1073 		e = "decryption";
1074 
1075 	data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL);
1076 	if (!data)
1077 		return;
1078 
1079 	tfm = crypto_alloc_skcipher(algo, 0, 0);
1080 	if (IS_ERR(tfm)) {
1081 		pr_err("failed to load transform for %s: %ld\n",
1082 			algo, PTR_ERR(tfm));
1083 		goto out_free_data;
1084 	}
1085 
1086 	for (i = 0; i < num_mb; ++i)
1087 		if (testmgr_alloc_buf(data[i].xbuf)) {
1088 			while (i--)
1089 				testmgr_free_buf(data[i].xbuf);
1090 			goto out_free_tfm;
1091 		}
1092 
1093 	for (i = 0; i < num_mb; ++i) {
1094 		data[i].req = skcipher_request_alloc(tfm, GFP_KERNEL);
1095 		if (!data[i].req) {
1096 			pr_err("alg: skcipher: Failed to allocate request for %s\n",
1097 			       algo);
1098 			while (i--)
1099 				skcipher_request_free(data[i].req);
1100 			goto out_free_xbuf;
1101 		}
1102 	}
1103 
1104 	for (i = 0; i < num_mb; ++i) {
1105 		skcipher_request_set_callback(data[i].req,
1106 					      CRYPTO_TFM_REQ_MAY_BACKLOG,
1107 					      crypto_req_done, &data[i].wait);
1108 		crypto_init_wait(&data[i].wait);
1109 	}
1110 
1111 	pr_info("testing speed of multibuffer %s (%s) %s\n", algo,
1112 		get_driver_name(crypto_skcipher, tfm), e);
1113 
1114 	i = 0;
1115 	do {
1116 		b_size = block_sizes;
1117 		do {
1118 			u32 bs = round_up(*b_size, crypto_skcipher_blocksize(tfm));
1119 
1120 			if (bs > XBUFSIZE * PAGE_SIZE) {
1121 				pr_err("template (%u) too big for buffer (%lu)\n",
1122 				       bs, XBUFSIZE * PAGE_SIZE);
1123 				goto out;
1124 			}
1125 
1126 			pr_info("test %u (%d bit key, %d byte blocks): ", i,
1127 				*keysize * 8, bs);
1128 
1129 			/* Set up tfm global state, i.e. the key */
1130 
1131 			memset(tvmem[0], 0xff, PAGE_SIZE);
1132 			key = tvmem[0];
1133 			for (j = 0; j < tcount; j++) {
1134 				if (template[j].klen == *keysize) {
1135 					key = template[j].key;
1136 					break;
1137 				}
1138 			}
1139 
1140 			crypto_skcipher_clear_flags(tfm, ~0);
1141 
1142 			ret = crypto_skcipher_setkey(tfm, key, *keysize);
1143 			if (ret) {
1144 				pr_err("setkey() failed flags=%x\n",
1145 				       crypto_skcipher_get_flags(tfm));
1146 				goto out;
1147 			}
1148 
1149 			iv_len = crypto_skcipher_ivsize(tfm);
1150 			if (iv_len)
1151 				memset(&iv, 0xff, iv_len);
1152 
1153 			/* Now setup per request stuff, i.e. buffers */
1154 
1155 			for (j = 0; j < num_mb; ++j) {
1156 				struct test_mb_skcipher_data *cur = &data[j];
1157 				unsigned int k = bs;
1158 				unsigned int pages = DIV_ROUND_UP(k, PAGE_SIZE);
1159 				unsigned int p = 0;
1160 
1161 				sg_init_table(cur->sg, pages);
1162 
1163 				while (k > PAGE_SIZE) {
1164 					sg_set_buf(cur->sg + p, cur->xbuf[p],
1165 						   PAGE_SIZE);
1166 					memset(cur->xbuf[p], 0xff, PAGE_SIZE);
1167 					p++;
1168 					k -= PAGE_SIZE;
1169 				}
1170 
1171 				sg_set_buf(cur->sg + p, cur->xbuf[p], k);
1172 				memset(cur->xbuf[p], 0xff, k);
1173 
1174 				skcipher_request_set_crypt(cur->req, cur->sg,
1175 							   cur->sg, bs, iv);
1176 			}
1177 
1178 			if (secs) {
1179 				ret = test_mb_acipher_jiffies(data, enc,
1180 							      bs, secs,
1181 							      num_mb);
1182 				cond_resched();
1183 			} else {
1184 				ret = test_mb_acipher_cycles(data, enc,
1185 							     bs, num_mb);
1186 			}
1187 
1188 			if (ret) {
1189 				pr_err("%s() failed flags=%x\n", e,
1190 				       crypto_skcipher_get_flags(tfm));
1191 				break;
1192 			}
1193 			b_size++;
1194 			i++;
1195 		} while (*b_size);
1196 		keysize++;
1197 	} while (*keysize);
1198 
1199 out:
1200 	for (i = 0; i < num_mb; ++i)
1201 		skcipher_request_free(data[i].req);
1202 out_free_xbuf:
1203 	for (i = 0; i < num_mb; ++i)
1204 		testmgr_free_buf(data[i].xbuf);
1205 out_free_tfm:
1206 	crypto_free_skcipher(tfm);
1207 out_free_data:
1208 	kfree(data);
1209 }
1210 
1211 static inline int do_one_acipher_op(struct skcipher_request *req, int ret)
1212 {
1213 	struct crypto_wait *wait = req->base.data;
1214 
1215 	return crypto_wait_req(ret, wait);
1216 }
1217 
1218 static int test_acipher_jiffies(struct skcipher_request *req, int enc,
1219 				int blen, int secs)
1220 {
1221 	unsigned long start, end;
1222 	int bcount;
1223 	int ret;
1224 
1225 	for (start = jiffies, end = start + secs * HZ, bcount = 0;
1226 	     time_before(jiffies, end); bcount++) {
1227 		if (enc)
1228 			ret = do_one_acipher_op(req,
1229 						crypto_skcipher_encrypt(req));
1230 		else
1231 			ret = do_one_acipher_op(req,
1232 						crypto_skcipher_decrypt(req));
1233 
1234 		if (ret)
1235 			return ret;
1236 	}
1237 
1238 	pr_cont("%d operations in %d seconds (%llu bytes)\n",
1239 		bcount, secs, (u64)bcount * blen);
1240 	return 0;
1241 }
1242 
1243 static int test_acipher_cycles(struct skcipher_request *req, int enc,
1244 			       int blen)
1245 {
1246 	unsigned long cycles = 0;
1247 	int ret = 0;
1248 	int i;
1249 
1250 	/* Warm-up run. */
1251 	for (i = 0; i < 4; i++) {
1252 		if (enc)
1253 			ret = do_one_acipher_op(req,
1254 						crypto_skcipher_encrypt(req));
1255 		else
1256 			ret = do_one_acipher_op(req,
1257 						crypto_skcipher_decrypt(req));
1258 
1259 		if (ret)
1260 			goto out;
1261 	}
1262 
1263 	/* The real thing. */
1264 	for (i = 0; i < 8; i++) {
1265 		cycles_t start, end;
1266 
1267 		start = get_cycles();
1268 		if (enc)
1269 			ret = do_one_acipher_op(req,
1270 						crypto_skcipher_encrypt(req));
1271 		else
1272 			ret = do_one_acipher_op(req,
1273 						crypto_skcipher_decrypt(req));
1274 		end = get_cycles();
1275 
1276 		if (ret)
1277 			goto out;
1278 
1279 		cycles += end - start;
1280 	}
1281 
1282 out:
1283 	if (ret == 0)
1284 		pr_cont("1 operation in %lu cycles (%d bytes)\n",
1285 			(cycles + 4) / 8, blen);
1286 
1287 	return ret;
1288 }
1289 
1290 static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
1291 				struct cipher_speed_template *template,
1292 				unsigned int tcount, u8 *keysize, bool async)
1293 {
1294 	unsigned int ret, i, j, k, iv_len;
1295 	struct crypto_wait wait;
1296 	const char *key;
1297 	char iv[128];
1298 	struct skcipher_request *req;
1299 	struct crypto_skcipher *tfm;
1300 	const int *b_size;
1301 	const char *e;
1302 
1303 	if (enc == ENCRYPT)
1304 		e = "encryption";
1305 	else
1306 		e = "decryption";
1307 
1308 	crypto_init_wait(&wait);
1309 
1310 	tfm = crypto_alloc_skcipher(algo, 0, async ? 0 : CRYPTO_ALG_ASYNC);
1311 
1312 	if (IS_ERR(tfm)) {
1313 		pr_err("failed to load transform for %s: %ld\n", algo,
1314 		       PTR_ERR(tfm));
1315 		return;
1316 	}
1317 
1318 	pr_info("testing speed of %s %s (%s) %s\n", async ? "async" : "sync",
1319 		algo, get_driver_name(crypto_skcipher, tfm), e);
1320 
1321 	req = skcipher_request_alloc(tfm, GFP_KERNEL);
1322 	if (!req) {
1323 		pr_err("skcipher: Failed to allocate request for %s\n", algo);
1324 		goto out;
1325 	}
1326 
1327 	skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
1328 				      crypto_req_done, &wait);
1329 
1330 	i = 0;
1331 	do {
1332 		b_size = block_sizes;
1333 
1334 		do {
1335 			u32 bs = round_up(*b_size, crypto_skcipher_blocksize(tfm));
1336 			struct scatterlist sg[TVMEMSIZE];
1337 
1338 			if ((*keysize + bs) > TVMEMSIZE * PAGE_SIZE) {
1339 				pr_err("template (%u) too big for "
1340 				       "tvmem (%lu)\n", *keysize + bs,
1341 				       TVMEMSIZE * PAGE_SIZE);
1342 				goto out_free_req;
1343 			}
1344 
1345 			pr_info("test %u (%d bit key, %d byte blocks): ", i,
1346 				*keysize * 8, bs);
1347 
1348 			memset(tvmem[0], 0xff, PAGE_SIZE);
1349 
1350 			/* set key, plain text and IV */
1351 			key = tvmem[0];
1352 			for (j = 0; j < tcount; j++) {
1353 				if (template[j].klen == *keysize) {
1354 					key = template[j].key;
1355 					break;
1356 				}
1357 			}
1358 
1359 			crypto_skcipher_clear_flags(tfm, ~0);
1360 
1361 			ret = crypto_skcipher_setkey(tfm, key, *keysize);
1362 			if (ret) {
1363 				pr_err("setkey() failed flags=%x\n",
1364 					crypto_skcipher_get_flags(tfm));
1365 				goto out_free_req;
1366 			}
1367 
1368 			k = *keysize + bs;
1369 			sg_init_table(sg, DIV_ROUND_UP(k, PAGE_SIZE));
1370 
1371 			if (k > PAGE_SIZE) {
1372 				sg_set_buf(sg, tvmem[0] + *keysize,
1373 				   PAGE_SIZE - *keysize);
1374 				k -= PAGE_SIZE;
1375 				j = 1;
1376 				while (k > PAGE_SIZE) {
1377 					sg_set_buf(sg + j, tvmem[j], PAGE_SIZE);
1378 					memset(tvmem[j], 0xff, PAGE_SIZE);
1379 					j++;
1380 					k -= PAGE_SIZE;
1381 				}
1382 				sg_set_buf(sg + j, tvmem[j], k);
1383 				memset(tvmem[j], 0xff, k);
1384 			} else {
1385 				sg_set_buf(sg, tvmem[0] + *keysize, bs);
1386 			}
1387 
1388 			iv_len = crypto_skcipher_ivsize(tfm);
1389 			if (iv_len)
1390 				memset(&iv, 0xff, iv_len);
1391 
1392 			skcipher_request_set_crypt(req, sg, sg, bs, iv);
1393 
1394 			if (secs) {
1395 				ret = test_acipher_jiffies(req, enc,
1396 							   bs, secs);
1397 				cond_resched();
1398 			} else {
1399 				ret = test_acipher_cycles(req, enc,
1400 							  bs);
1401 			}
1402 
1403 			if (ret) {
1404 				pr_err("%s() failed flags=%x\n", e,
1405 				       crypto_skcipher_get_flags(tfm));
1406 				break;
1407 			}
1408 			b_size++;
1409 			i++;
1410 		} while (*b_size);
1411 		keysize++;
1412 	} while (*keysize);
1413 
1414 out_free_req:
1415 	skcipher_request_free(req);
1416 out:
1417 	crypto_free_skcipher(tfm);
1418 }
1419 
1420 static void test_acipher_speed(const char *algo, int enc, unsigned int secs,
1421 			       struct cipher_speed_template *template,
1422 			       unsigned int tcount, u8 *keysize)
1423 {
1424 	return test_skcipher_speed(algo, enc, secs, template, tcount, keysize,
1425 				   true);
1426 }
1427 
1428 static void test_cipher_speed(const char *algo, int enc, unsigned int secs,
1429 			      struct cipher_speed_template *template,
1430 			      unsigned int tcount, u8 *keysize)
1431 {
1432 	return test_skcipher_speed(algo, enc, secs, template, tcount, keysize,
1433 				   false);
1434 }
1435 
1436 static inline int tcrypt_test(const char *alg)
1437 {
1438 	int ret;
1439 
1440 	pr_debug("testing %s\n", alg);
1441 
1442 	ret = alg_test(alg, alg, 0, 0);
1443 	/* non-fips algs return -EINVAL or -ECANCELED in fips mode */
1444 	if (fips_enabled && (ret == -EINVAL || ret == -ECANCELED))
1445 		ret = 0;
1446 	return ret;
1447 }
1448 
1449 static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
1450 {
1451 	int i;
1452 	int ret = 0;
1453 
1454 	switch (m) {
1455 	case 0:
1456 		if (alg) {
1457 			if (!crypto_has_alg(alg, type,
1458 					    mask ?: CRYPTO_ALG_TYPE_MASK))
1459 				ret = -ENOENT;
1460 			break;
1461 		}
1462 
1463 		for (i = 1; i < 200; i++)
1464 			ret = min(ret, do_test(NULL, 0, 0, i, num_mb));
1465 		break;
1466 
1467 	case 1:
1468 		ret = min(ret, tcrypt_test("md5"));
1469 		break;
1470 
1471 	case 2:
1472 		ret = min(ret, tcrypt_test("sha1"));
1473 		break;
1474 
1475 	case 3:
1476 		ret = min(ret, tcrypt_test("ecb(des)"));
1477 		ret = min(ret, tcrypt_test("cbc(des)"));
1478 		ret = min(ret, tcrypt_test("ctr(des)"));
1479 		break;
1480 
1481 	case 4:
1482 		ret = min(ret, tcrypt_test("ecb(des3_ede)"));
1483 		ret = min(ret, tcrypt_test("cbc(des3_ede)"));
1484 		ret = min(ret, tcrypt_test("ctr(des3_ede)"));
1485 		break;
1486 
1487 	case 5:
1488 		ret = min(ret, tcrypt_test("md4"));
1489 		break;
1490 
1491 	case 6:
1492 		ret = min(ret, tcrypt_test("sha256"));
1493 		break;
1494 
1495 	case 7:
1496 		ret = min(ret, tcrypt_test("ecb(blowfish)"));
1497 		ret = min(ret, tcrypt_test("cbc(blowfish)"));
1498 		ret = min(ret, tcrypt_test("ctr(blowfish)"));
1499 		break;
1500 
1501 	case 8:
1502 		ret = min(ret, tcrypt_test("ecb(twofish)"));
1503 		ret = min(ret, tcrypt_test("cbc(twofish)"));
1504 		ret = min(ret, tcrypt_test("ctr(twofish)"));
1505 		ret = min(ret, tcrypt_test("lrw(twofish)"));
1506 		ret = min(ret, tcrypt_test("xts(twofish)"));
1507 		break;
1508 
1509 	case 9:
1510 		ret = min(ret, tcrypt_test("ecb(serpent)"));
1511 		ret = min(ret, tcrypt_test("cbc(serpent)"));
1512 		ret = min(ret, tcrypt_test("ctr(serpent)"));
1513 		ret = min(ret, tcrypt_test("lrw(serpent)"));
1514 		ret = min(ret, tcrypt_test("xts(serpent)"));
1515 		break;
1516 
1517 	case 10:
1518 		ret = min(ret, tcrypt_test("ecb(aes)"));
1519 		ret = min(ret, tcrypt_test("cbc(aes)"));
1520 		ret = min(ret, tcrypt_test("lrw(aes)"));
1521 		ret = min(ret, tcrypt_test("xts(aes)"));
1522 		ret = min(ret, tcrypt_test("ctr(aes)"));
1523 		ret = min(ret, tcrypt_test("rfc3686(ctr(aes))"));
1524 		ret = min(ret, tcrypt_test("ofb(aes)"));
1525 		ret = min(ret, tcrypt_test("cfb(aes)"));
1526 		ret = min(ret, tcrypt_test("xctr(aes)"));
1527 		break;
1528 
1529 	case 11:
1530 		ret = min(ret, tcrypt_test("sha384"));
1531 		break;
1532 
1533 	case 12:
1534 		ret = min(ret, tcrypt_test("sha512"));
1535 		break;
1536 
1537 	case 13:
1538 		ret = min(ret, tcrypt_test("deflate"));
1539 		break;
1540 
1541 	case 14:
1542 		ret = min(ret, tcrypt_test("ecb(cast5)"));
1543 		ret = min(ret, tcrypt_test("cbc(cast5)"));
1544 		ret = min(ret, tcrypt_test("ctr(cast5)"));
1545 		break;
1546 
1547 	case 15:
1548 		ret = min(ret, tcrypt_test("ecb(cast6)"));
1549 		ret = min(ret, tcrypt_test("cbc(cast6)"));
1550 		ret = min(ret, tcrypt_test("ctr(cast6)"));
1551 		ret = min(ret, tcrypt_test("lrw(cast6)"));
1552 		ret = min(ret, tcrypt_test("xts(cast6)"));
1553 		break;
1554 
1555 	case 16:
1556 		ret = min(ret, tcrypt_test("ecb(arc4)"));
1557 		break;
1558 
1559 	case 17:
1560 		ret = min(ret, tcrypt_test("michael_mic"));
1561 		break;
1562 
1563 	case 18:
1564 		ret = min(ret, tcrypt_test("crc32c"));
1565 		break;
1566 
1567 	case 19:
1568 		ret = min(ret, tcrypt_test("ecb(tea)"));
1569 		break;
1570 
1571 	case 20:
1572 		ret = min(ret, tcrypt_test("ecb(xtea)"));
1573 		break;
1574 
1575 	case 21:
1576 		ret = min(ret, tcrypt_test("ecb(khazad)"));
1577 		break;
1578 
1579 	case 22:
1580 		ret = min(ret, tcrypt_test("wp512"));
1581 		break;
1582 
1583 	case 23:
1584 		ret = min(ret, tcrypt_test("wp384"));
1585 		break;
1586 
1587 	case 24:
1588 		ret = min(ret, tcrypt_test("wp256"));
1589 		break;
1590 
1591 	case 26:
1592 		ret = min(ret, tcrypt_test("ecb(anubis)"));
1593 		ret = min(ret, tcrypt_test("cbc(anubis)"));
1594 		break;
1595 
1596 	case 30:
1597 		ret = min(ret, tcrypt_test("ecb(xeta)"));
1598 		break;
1599 
1600 	case 31:
1601 		ret = min(ret, tcrypt_test("pcbc(fcrypt)"));
1602 		break;
1603 
1604 	case 32:
1605 		ret = min(ret, tcrypt_test("ecb(camellia)"));
1606 		ret = min(ret, tcrypt_test("cbc(camellia)"));
1607 		ret = min(ret, tcrypt_test("ctr(camellia)"));
1608 		ret = min(ret, tcrypt_test("lrw(camellia)"));
1609 		ret = min(ret, tcrypt_test("xts(camellia)"));
1610 		break;
1611 
1612 	case 33:
1613 		ret = min(ret, tcrypt_test("sha224"));
1614 		break;
1615 
1616 	case 35:
1617 		ret = min(ret, tcrypt_test("gcm(aes)"));
1618 		break;
1619 
1620 	case 36:
1621 		ret = min(ret, tcrypt_test("lzo"));
1622 		break;
1623 
1624 	case 37:
1625 		ret = min(ret, tcrypt_test("ccm(aes)"));
1626 		break;
1627 
1628 	case 38:
1629 		ret = min(ret, tcrypt_test("cts(cbc(aes))"));
1630 		break;
1631 
1632         case 39:
1633 		ret = min(ret, tcrypt_test("xxhash64"));
1634 		break;
1635 
1636         case 40:
1637 		ret = min(ret, tcrypt_test("rmd160"));
1638 		break;
1639 
1640 	case 42:
1641 		ret = min(ret, tcrypt_test("blake2b-512"));
1642 		break;
1643 
1644 	case 43:
1645 		ret = min(ret, tcrypt_test("ecb(seed)"));
1646 		break;
1647 
1648 	case 45:
1649 		ret = min(ret, tcrypt_test("rfc4309(ccm(aes))"));
1650 		break;
1651 
1652 	case 46:
1653 		ret = min(ret, tcrypt_test("ghash"));
1654 		break;
1655 
1656 	case 47:
1657 		ret = min(ret, tcrypt_test("crct10dif"));
1658 		break;
1659 
1660 	case 48:
1661 		ret = min(ret, tcrypt_test("sha3-224"));
1662 		break;
1663 
1664 	case 49:
1665 		ret = min(ret, tcrypt_test("sha3-256"));
1666 		break;
1667 
1668 	case 50:
1669 		ret = min(ret, tcrypt_test("sha3-384"));
1670 		break;
1671 
1672 	case 51:
1673 		ret = min(ret, tcrypt_test("sha3-512"));
1674 		break;
1675 
1676 	case 52:
1677 		ret = min(ret, tcrypt_test("sm3"));
1678 		break;
1679 
1680 	case 53:
1681 		ret = min(ret, tcrypt_test("streebog256"));
1682 		break;
1683 
1684 	case 54:
1685 		ret = min(ret, tcrypt_test("streebog512"));
1686 		break;
1687 
1688 	case 55:
1689 		ret = min(ret, tcrypt_test("gcm(sm4)"));
1690 		break;
1691 
1692 	case 56:
1693 		ret = min(ret, tcrypt_test("ccm(sm4)"));
1694 		break;
1695 
1696 	case 57:
1697 		ret = min(ret, tcrypt_test("polyval"));
1698 		break;
1699 
1700 	case 58:
1701 		ret = min(ret, tcrypt_test("gcm(aria)"));
1702 		break;
1703 
1704 	case 59:
1705 		ret = min(ret, tcrypt_test("cts(cbc(sm4))"));
1706 		break;
1707 
1708 	case 100:
1709 		ret = min(ret, tcrypt_test("hmac(md5)"));
1710 		break;
1711 
1712 	case 101:
1713 		ret = min(ret, tcrypt_test("hmac(sha1)"));
1714 		break;
1715 
1716 	case 102:
1717 		ret = min(ret, tcrypt_test("hmac(sha256)"));
1718 		break;
1719 
1720 	case 103:
1721 		ret = min(ret, tcrypt_test("hmac(sha384)"));
1722 		break;
1723 
1724 	case 104:
1725 		ret = min(ret, tcrypt_test("hmac(sha512)"));
1726 		break;
1727 
1728 	case 105:
1729 		ret = min(ret, tcrypt_test("hmac(sha224)"));
1730 		break;
1731 
1732 	case 106:
1733 		ret = min(ret, tcrypt_test("xcbc(aes)"));
1734 		break;
1735 
1736 	case 108:
1737 		ret = min(ret, tcrypt_test("hmac(rmd160)"));
1738 		break;
1739 
1740 	case 109:
1741 		ret = min(ret, tcrypt_test("vmac64(aes)"));
1742 		break;
1743 
1744 	case 111:
1745 		ret = min(ret, tcrypt_test("hmac(sha3-224)"));
1746 		break;
1747 
1748 	case 112:
1749 		ret = min(ret, tcrypt_test("hmac(sha3-256)"));
1750 		break;
1751 
1752 	case 113:
1753 		ret = min(ret, tcrypt_test("hmac(sha3-384)"));
1754 		break;
1755 
1756 	case 114:
1757 		ret = min(ret, tcrypt_test("hmac(sha3-512)"));
1758 		break;
1759 
1760 	case 115:
1761 		ret = min(ret, tcrypt_test("hmac(streebog256)"));
1762 		break;
1763 
1764 	case 116:
1765 		ret = min(ret, tcrypt_test("hmac(streebog512)"));
1766 		break;
1767 
1768 	case 150:
1769 		ret = min(ret, tcrypt_test("ansi_cprng"));
1770 		break;
1771 
1772 	case 151:
1773 		ret = min(ret, tcrypt_test("rfc4106(gcm(aes))"));
1774 		break;
1775 
1776 	case 152:
1777 		ret = min(ret, tcrypt_test("rfc4543(gcm(aes))"));
1778 		break;
1779 
1780 	case 153:
1781 		ret = min(ret, tcrypt_test("cmac(aes)"));
1782 		break;
1783 
1784 	case 154:
1785 		ret = min(ret, tcrypt_test("cmac(des3_ede)"));
1786 		break;
1787 
1788 	case 155:
1789 		ret = min(ret, tcrypt_test("authenc(hmac(sha1),cbc(aes))"));
1790 		break;
1791 
1792 	case 156:
1793 		ret = min(ret, tcrypt_test("authenc(hmac(md5),ecb(cipher_null))"));
1794 		break;
1795 
1796 	case 157:
1797 		ret = min(ret, tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))"));
1798 		break;
1799 
1800 	case 158:
1801 		ret = min(ret, tcrypt_test("cbcmac(sm4)"));
1802 		break;
1803 
1804 	case 159:
1805 		ret = min(ret, tcrypt_test("cmac(sm4)"));
1806 		break;
1807 
1808 	case 160:
1809 		ret = min(ret, tcrypt_test("xcbc(sm4)"));
1810 		break;
1811 
1812 	case 181:
1813 		ret = min(ret, tcrypt_test("authenc(hmac(sha1),cbc(des))"));
1814 		break;
1815 	case 182:
1816 		ret = min(ret, tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))"));
1817 		break;
1818 	case 183:
1819 		ret = min(ret, tcrypt_test("authenc(hmac(sha224),cbc(des))"));
1820 		break;
1821 	case 184:
1822 		ret = min(ret, tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))"));
1823 		break;
1824 	case 185:
1825 		ret = min(ret, tcrypt_test("authenc(hmac(sha256),cbc(des))"));
1826 		break;
1827 	case 186:
1828 		ret = min(ret, tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))"));
1829 		break;
1830 	case 187:
1831 		ret = min(ret, tcrypt_test("authenc(hmac(sha384),cbc(des))"));
1832 		break;
1833 	case 188:
1834 		ret = min(ret, tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))"));
1835 		break;
1836 	case 189:
1837 		ret = min(ret, tcrypt_test("authenc(hmac(sha512),cbc(des))"));
1838 		break;
1839 	case 190:
1840 		ret = min(ret, tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))"));
1841 		break;
1842 	case 191:
1843 		ret = min(ret, tcrypt_test("ecb(sm4)"));
1844 		ret = min(ret, tcrypt_test("cbc(sm4)"));
1845 		ret = min(ret, tcrypt_test("cfb(sm4)"));
1846 		ret = min(ret, tcrypt_test("ctr(sm4)"));
1847 		ret = min(ret, tcrypt_test("xts(sm4)"));
1848 		break;
1849 	case 192:
1850 		ret = min(ret, tcrypt_test("ecb(aria)"));
1851 		ret = min(ret, tcrypt_test("cbc(aria)"));
1852 		ret = min(ret, tcrypt_test("cfb(aria)"));
1853 		ret = min(ret, tcrypt_test("ctr(aria)"));
1854 		break;
1855 	case 200:
1856 		test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
1857 				speed_template_16_24_32);
1858 		test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
1859 				speed_template_16_24_32);
1860 		test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
1861 				speed_template_16_24_32);
1862 		test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
1863 				speed_template_16_24_32);
1864 		test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
1865 				speed_template_32_40_48);
1866 		test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
1867 				speed_template_32_40_48);
1868 		test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
1869 				speed_template_32_64);
1870 		test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
1871 				speed_template_32_64);
1872 		test_cipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
1873 				speed_template_16_24_32);
1874 		test_cipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
1875 				speed_template_16_24_32);
1876 		test_cipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
1877 				speed_template_16_24_32);
1878 		test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
1879 				speed_template_16_24_32);
1880 		test_cipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
1881 				speed_template_16_24_32);
1882 		test_cipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
1883 				speed_template_16_24_32);
1884 		break;
1885 
1886 	case 201:
1887 		test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec,
1888 				des3_speed_template, DES3_SPEED_VECTORS,
1889 				speed_template_24);
1890 		test_cipher_speed("ecb(des3_ede)", DECRYPT, sec,
1891 				des3_speed_template, DES3_SPEED_VECTORS,
1892 				speed_template_24);
1893 		test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec,
1894 				des3_speed_template, DES3_SPEED_VECTORS,
1895 				speed_template_24);
1896 		test_cipher_speed("cbc(des3_ede)", DECRYPT, sec,
1897 				des3_speed_template, DES3_SPEED_VECTORS,
1898 				speed_template_24);
1899 		test_cipher_speed("ctr(des3_ede)", ENCRYPT, sec,
1900 				des3_speed_template, DES3_SPEED_VECTORS,
1901 				speed_template_24);
1902 		test_cipher_speed("ctr(des3_ede)", DECRYPT, sec,
1903 				des3_speed_template, DES3_SPEED_VECTORS,
1904 				speed_template_24);
1905 		break;
1906 
1907 	case 202:
1908 		test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
1909 				speed_template_16_24_32);
1910 		test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
1911 				speed_template_16_24_32);
1912 		test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
1913 				speed_template_16_24_32);
1914 		test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
1915 				speed_template_16_24_32);
1916 		test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
1917 				speed_template_16_24_32);
1918 		test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
1919 				speed_template_16_24_32);
1920 		test_cipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
1921 				speed_template_32_40_48);
1922 		test_cipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
1923 				speed_template_32_40_48);
1924 		test_cipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
1925 				speed_template_32_48_64);
1926 		test_cipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
1927 				speed_template_32_48_64);
1928 		break;
1929 
1930 	case 203:
1931 		test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
1932 				  speed_template_8_32);
1933 		test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
1934 				  speed_template_8_32);
1935 		test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
1936 				  speed_template_8_32);
1937 		test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
1938 				  speed_template_8_32);
1939 		test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
1940 				  speed_template_8_32);
1941 		test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
1942 				  speed_template_8_32);
1943 		break;
1944 
1945 	case 204:
1946 		test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
1947 				  speed_template_8);
1948 		test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
1949 				  speed_template_8);
1950 		test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
1951 				  speed_template_8);
1952 		test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
1953 				  speed_template_8);
1954 		break;
1955 
1956 	case 205:
1957 		test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
1958 				speed_template_16_24_32);
1959 		test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
1960 				speed_template_16_24_32);
1961 		test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
1962 				speed_template_16_24_32);
1963 		test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
1964 				speed_template_16_24_32);
1965 		test_cipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
1966 				speed_template_16_24_32);
1967 		test_cipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
1968 				speed_template_16_24_32);
1969 		test_cipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
1970 				speed_template_32_40_48);
1971 		test_cipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
1972 				speed_template_32_40_48);
1973 		test_cipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
1974 				speed_template_32_48_64);
1975 		test_cipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
1976 				speed_template_32_48_64);
1977 		break;
1978 
1979 	case 207:
1980 		test_cipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
1981 				  speed_template_16_32);
1982 		test_cipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
1983 				  speed_template_16_32);
1984 		test_cipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
1985 				  speed_template_16_32);
1986 		test_cipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
1987 				  speed_template_16_32);
1988 		test_cipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
1989 				  speed_template_16_32);
1990 		test_cipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
1991 				  speed_template_16_32);
1992 		test_cipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
1993 				  speed_template_32_48);
1994 		test_cipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
1995 				  speed_template_32_48);
1996 		test_cipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
1997 				  speed_template_32_64);
1998 		test_cipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
1999 				  speed_template_32_64);
2000 		break;
2001 
2002 	case 208:
2003 		test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
2004 				  speed_template_8);
2005 		break;
2006 
2007 	case 209:
2008 		test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
2009 				  speed_template_8_16);
2010 		test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
2011 				  speed_template_8_16);
2012 		test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
2013 				  speed_template_8_16);
2014 		test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
2015 				  speed_template_8_16);
2016 		test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
2017 				  speed_template_8_16);
2018 		test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
2019 				  speed_template_8_16);
2020 		break;
2021 
2022 	case 210:
2023 		test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
2024 				  speed_template_16_32);
2025 		test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
2026 				  speed_template_16_32);
2027 		test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
2028 				  speed_template_16_32);
2029 		test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
2030 				  speed_template_16_32);
2031 		test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
2032 				  speed_template_16_32);
2033 		test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
2034 				  speed_template_16_32);
2035 		test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
2036 				  speed_template_32_48);
2037 		test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
2038 				  speed_template_32_48);
2039 		test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
2040 				  speed_template_32_64);
2041 		test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
2042 				  speed_template_32_64);
2043 		break;
2044 
2045 	case 211:
2046 		test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec,
2047 				NULL, 0, 16, 16, aead_speed_template_20);
2048 		test_aead_speed("gcm(aes)", ENCRYPT, sec,
2049 				NULL, 0, 16, 8, speed_template_16_24_32);
2050 		test_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec,
2051 				NULL, 0, 16, 16, aead_speed_template_20);
2052 		test_aead_speed("gcm(aes)", DECRYPT, sec,
2053 				NULL, 0, 16, 8, speed_template_16_24_32);
2054 		break;
2055 
2056 	case 212:
2057 		test_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec,
2058 				NULL, 0, 16, 16, aead_speed_template_19);
2059 		test_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec,
2060 				NULL, 0, 16, 16, aead_speed_template_19);
2061 		break;
2062 
2063 	case 213:
2064 		test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, sec,
2065 				NULL, 0, 16, 8, aead_speed_template_36);
2066 		test_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT, sec,
2067 				NULL, 0, 16, 8, aead_speed_template_36);
2068 		break;
2069 
2070 	case 214:
2071 		test_cipher_speed("chacha20", ENCRYPT, sec, NULL, 0,
2072 				  speed_template_32);
2073 		break;
2074 
2075 	case 215:
2076 		test_mb_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec, NULL,
2077 				   0, 16, 16, aead_speed_template_20, num_mb);
2078 		test_mb_aead_speed("gcm(aes)", ENCRYPT, sec, NULL, 0, 16, 8,
2079 				   speed_template_16_24_32, num_mb);
2080 		test_mb_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec, NULL,
2081 				   0, 16, 16, aead_speed_template_20, num_mb);
2082 		test_mb_aead_speed("gcm(aes)", DECRYPT, sec, NULL, 0, 16, 8,
2083 				   speed_template_16_24_32, num_mb);
2084 		break;
2085 
2086 	case 216:
2087 		test_mb_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec, NULL, 0,
2088 				   16, 16, aead_speed_template_19, num_mb);
2089 		test_mb_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec, NULL, 0,
2090 				   16, 16, aead_speed_template_19, num_mb);
2091 		break;
2092 
2093 	case 217:
2094 		test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT,
2095 				   sec, NULL, 0, 16, 8, aead_speed_template_36,
2096 				   num_mb);
2097 		test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT,
2098 				   sec, NULL, 0, 16, 8, aead_speed_template_36,
2099 				   num_mb);
2100 		break;
2101 
2102 	case 218:
2103 		test_cipher_speed("ecb(sm4)", ENCRYPT, sec, NULL, 0,
2104 				speed_template_16);
2105 		test_cipher_speed("ecb(sm4)", DECRYPT, sec, NULL, 0,
2106 				speed_template_16);
2107 		test_cipher_speed("cbc(sm4)", ENCRYPT, sec, NULL, 0,
2108 				speed_template_16);
2109 		test_cipher_speed("cbc(sm4)", DECRYPT, sec, NULL, 0,
2110 				speed_template_16);
2111 		test_cipher_speed("cts(cbc(sm4))", ENCRYPT, sec, NULL, 0,
2112 				speed_template_16);
2113 		test_cipher_speed("cts(cbc(sm4))", DECRYPT, sec, NULL, 0,
2114 				speed_template_16);
2115 		test_cipher_speed("cfb(sm4)", ENCRYPT, sec, NULL, 0,
2116 				speed_template_16);
2117 		test_cipher_speed("cfb(sm4)", DECRYPT, sec, NULL, 0,
2118 				speed_template_16);
2119 		test_cipher_speed("ctr(sm4)", ENCRYPT, sec, NULL, 0,
2120 				speed_template_16);
2121 		test_cipher_speed("ctr(sm4)", DECRYPT, sec, NULL, 0,
2122 				speed_template_16);
2123 		test_cipher_speed("xts(sm4)", ENCRYPT, sec, NULL, 0,
2124 				speed_template_32);
2125 		test_cipher_speed("xts(sm4)", DECRYPT, sec, NULL, 0,
2126 				speed_template_32);
2127 		break;
2128 
2129 	case 219:
2130 		test_cipher_speed("adiantum(xchacha12,aes)", ENCRYPT, sec, NULL,
2131 				  0, speed_template_32);
2132 		test_cipher_speed("adiantum(xchacha12,aes)", DECRYPT, sec, NULL,
2133 				  0, speed_template_32);
2134 		test_cipher_speed("adiantum(xchacha20,aes)", ENCRYPT, sec, NULL,
2135 				  0, speed_template_32);
2136 		test_cipher_speed("adiantum(xchacha20,aes)", DECRYPT, sec, NULL,
2137 				  0, speed_template_32);
2138 		break;
2139 
2140 	case 220:
2141 		test_acipher_speed("essiv(cbc(aes),sha256)",
2142 				  ENCRYPT, sec, NULL, 0,
2143 				  speed_template_16_24_32);
2144 		test_acipher_speed("essiv(cbc(aes),sha256)",
2145 				  DECRYPT, sec, NULL, 0,
2146 				  speed_template_16_24_32);
2147 		break;
2148 
2149 	case 221:
2150 		test_aead_speed("aegis128", ENCRYPT, sec,
2151 				NULL, 0, 16, 8, speed_template_16);
2152 		test_aead_speed("aegis128", DECRYPT, sec,
2153 				NULL, 0, 16, 8, speed_template_16);
2154 		break;
2155 
2156 	case 222:
2157 		test_aead_speed("gcm(sm4)", ENCRYPT, sec,
2158 				NULL, 0, 16, 8, speed_template_16);
2159 		test_aead_speed("gcm(sm4)", DECRYPT, sec,
2160 				NULL, 0, 16, 8, speed_template_16);
2161 		break;
2162 
2163 	case 223:
2164 		test_aead_speed("rfc4309(ccm(sm4))", ENCRYPT, sec,
2165 				NULL, 0, 16, 16, aead_speed_template_19);
2166 		test_aead_speed("rfc4309(ccm(sm4))", DECRYPT, sec,
2167 				NULL, 0, 16, 16, aead_speed_template_19);
2168 		break;
2169 
2170 	case 224:
2171 		test_mb_aead_speed("gcm(sm4)", ENCRYPT, sec, NULL, 0, 16, 8,
2172 				   speed_template_16, num_mb);
2173 		test_mb_aead_speed("gcm(sm4)", DECRYPT, sec, NULL, 0, 16, 8,
2174 				   speed_template_16, num_mb);
2175 		break;
2176 
2177 	case 225:
2178 		test_mb_aead_speed("rfc4309(ccm(sm4))", ENCRYPT, sec, NULL, 0,
2179 				   16, 16, aead_speed_template_19, num_mb);
2180 		test_mb_aead_speed("rfc4309(ccm(sm4))", DECRYPT, sec, NULL, 0,
2181 				   16, 16, aead_speed_template_19, num_mb);
2182 		break;
2183 
2184 	case 226:
2185 		test_cipher_speed("hctr2(aes)", ENCRYPT, sec, NULL,
2186 				  0, speed_template_32);
2187 		break;
2188 
2189 	case 227:
2190 		test_cipher_speed("ecb(aria)", ENCRYPT, sec, NULL, 0,
2191 				  speed_template_16_24_32);
2192 		test_cipher_speed("ecb(aria)", DECRYPT, sec, NULL, 0,
2193 				  speed_template_16_24_32);
2194 		test_cipher_speed("cbc(aria)", ENCRYPT, sec, NULL, 0,
2195 				  speed_template_16_24_32);
2196 		test_cipher_speed("cbc(aria)", DECRYPT, sec, NULL, 0,
2197 				  speed_template_16_24_32);
2198 		test_cipher_speed("cfb(aria)", ENCRYPT, sec, NULL, 0,
2199 				  speed_template_16_24_32);
2200 		test_cipher_speed("cfb(aria)", DECRYPT, sec, NULL, 0,
2201 				  speed_template_16_24_32);
2202 		test_cipher_speed("ctr(aria)", ENCRYPT, sec, NULL, 0,
2203 				  speed_template_16_24_32);
2204 		test_cipher_speed("ctr(aria)", DECRYPT, sec, NULL, 0,
2205 				  speed_template_16_24_32);
2206 		break;
2207 
2208 	case 228:
2209 		test_aead_speed("gcm(aria)", ENCRYPT, sec,
2210 				NULL, 0, 16, 8, speed_template_16_24_32);
2211 		test_aead_speed("gcm(aria)", DECRYPT, sec,
2212 				NULL, 0, 16, 8, speed_template_16_24_32);
2213 		break;
2214 
2215 	case 229:
2216 		test_mb_aead_speed("gcm(aria)", ENCRYPT, sec, NULL, 0, 16, 8,
2217 				   speed_template_16, num_mb);
2218 		test_mb_aead_speed("gcm(aria)", DECRYPT, sec, NULL, 0, 16, 8,
2219 				   speed_template_16, num_mb);
2220 		break;
2221 
2222 	case 300:
2223 		if (alg) {
2224 			test_hash_speed(alg, sec, generic_hash_speed_template);
2225 			break;
2226 		}
2227 		fallthrough;
2228 	case 301:
2229 		test_hash_speed("md4", sec, generic_hash_speed_template);
2230 		if (mode > 300 && mode < 400) break;
2231 		fallthrough;
2232 	case 302:
2233 		test_hash_speed("md5", sec, generic_hash_speed_template);
2234 		if (mode > 300 && mode < 400) break;
2235 		fallthrough;
2236 	case 303:
2237 		test_hash_speed("sha1", sec, generic_hash_speed_template);
2238 		if (mode > 300 && mode < 400) break;
2239 		fallthrough;
2240 	case 304:
2241 		test_hash_speed("sha256", sec, generic_hash_speed_template);
2242 		if (mode > 300 && mode < 400) break;
2243 		fallthrough;
2244 	case 305:
2245 		test_hash_speed("sha384", sec, generic_hash_speed_template);
2246 		if (mode > 300 && mode < 400) break;
2247 		fallthrough;
2248 	case 306:
2249 		test_hash_speed("sha512", sec, generic_hash_speed_template);
2250 		if (mode > 300 && mode < 400) break;
2251 		fallthrough;
2252 	case 307:
2253 		test_hash_speed("wp256", sec, generic_hash_speed_template);
2254 		if (mode > 300 && mode < 400) break;
2255 		fallthrough;
2256 	case 308:
2257 		test_hash_speed("wp384", sec, generic_hash_speed_template);
2258 		if (mode > 300 && mode < 400) break;
2259 		fallthrough;
2260 	case 309:
2261 		test_hash_speed("wp512", sec, generic_hash_speed_template);
2262 		if (mode > 300 && mode < 400) break;
2263 		fallthrough;
2264 	case 313:
2265 		test_hash_speed("sha224", sec, generic_hash_speed_template);
2266 		if (mode > 300 && mode < 400) break;
2267 		fallthrough;
2268 	case 314:
2269 		test_hash_speed("xxhash64", sec, generic_hash_speed_template);
2270 		if (mode > 300 && mode < 400) break;
2271 		fallthrough;
2272 	case 315:
2273 		test_hash_speed("rmd160", sec, generic_hash_speed_template);
2274 		if (mode > 300 && mode < 400) break;
2275 		fallthrough;
2276 	case 317:
2277 		test_hash_speed("blake2b-512", sec, generic_hash_speed_template);
2278 		if (mode > 300 && mode < 400) break;
2279 		fallthrough;
2280 	case 318:
2281 		klen = 16;
2282 		test_hash_speed("ghash", sec, generic_hash_speed_template);
2283 		if (mode > 300 && mode < 400) break;
2284 		fallthrough;
2285 	case 319:
2286 		test_hash_speed("crc32c", sec, generic_hash_speed_template);
2287 		if (mode > 300 && mode < 400) break;
2288 		fallthrough;
2289 	case 320:
2290 		test_hash_speed("crct10dif", sec, generic_hash_speed_template);
2291 		if (mode > 300 && mode < 400) break;
2292 		fallthrough;
2293 	case 321:
2294 		test_hash_speed("poly1305", sec, poly1305_speed_template);
2295 		if (mode > 300 && mode < 400) break;
2296 		fallthrough;
2297 	case 322:
2298 		test_hash_speed("sha3-224", sec, generic_hash_speed_template);
2299 		if (mode > 300 && mode < 400) break;
2300 		fallthrough;
2301 	case 323:
2302 		test_hash_speed("sha3-256", sec, generic_hash_speed_template);
2303 		if (mode > 300 && mode < 400) break;
2304 		fallthrough;
2305 	case 324:
2306 		test_hash_speed("sha3-384", sec, generic_hash_speed_template);
2307 		if (mode > 300 && mode < 400) break;
2308 		fallthrough;
2309 	case 325:
2310 		test_hash_speed("sha3-512", sec, generic_hash_speed_template);
2311 		if (mode > 300 && mode < 400) break;
2312 		fallthrough;
2313 	case 326:
2314 		test_hash_speed("sm3", sec, generic_hash_speed_template);
2315 		if (mode > 300 && mode < 400) break;
2316 		fallthrough;
2317 	case 327:
2318 		test_hash_speed("streebog256", sec,
2319 				generic_hash_speed_template);
2320 		if (mode > 300 && mode < 400) break;
2321 		fallthrough;
2322 	case 328:
2323 		test_hash_speed("streebog512", sec,
2324 				generic_hash_speed_template);
2325 		if (mode > 300 && mode < 400) break;
2326 		fallthrough;
2327 	case 399:
2328 		break;
2329 
2330 	case 400:
2331 		if (alg) {
2332 			test_ahash_speed(alg, sec, generic_hash_speed_template);
2333 			break;
2334 		}
2335 		fallthrough;
2336 	case 401:
2337 		test_ahash_speed("md4", sec, generic_hash_speed_template);
2338 		if (mode > 400 && mode < 500) break;
2339 		fallthrough;
2340 	case 402:
2341 		test_ahash_speed("md5", sec, generic_hash_speed_template);
2342 		if (mode > 400 && mode < 500) break;
2343 		fallthrough;
2344 	case 403:
2345 		test_ahash_speed("sha1", sec, generic_hash_speed_template);
2346 		if (mode > 400 && mode < 500) break;
2347 		fallthrough;
2348 	case 404:
2349 		test_ahash_speed("sha256", sec, generic_hash_speed_template);
2350 		if (mode > 400 && mode < 500) break;
2351 		fallthrough;
2352 	case 405:
2353 		test_ahash_speed("sha384", sec, generic_hash_speed_template);
2354 		if (mode > 400 && mode < 500) break;
2355 		fallthrough;
2356 	case 406:
2357 		test_ahash_speed("sha512", sec, generic_hash_speed_template);
2358 		if (mode > 400 && mode < 500) break;
2359 		fallthrough;
2360 	case 407:
2361 		test_ahash_speed("wp256", sec, generic_hash_speed_template);
2362 		if (mode > 400 && mode < 500) break;
2363 		fallthrough;
2364 	case 408:
2365 		test_ahash_speed("wp384", sec, generic_hash_speed_template);
2366 		if (mode > 400 && mode < 500) break;
2367 		fallthrough;
2368 	case 409:
2369 		test_ahash_speed("wp512", sec, generic_hash_speed_template);
2370 		if (mode > 400 && mode < 500) break;
2371 		fallthrough;
2372 	case 413:
2373 		test_ahash_speed("sha224", sec, generic_hash_speed_template);
2374 		if (mode > 400 && mode < 500) break;
2375 		fallthrough;
2376 	case 414:
2377 		test_ahash_speed("xxhash64", sec, generic_hash_speed_template);
2378 		if (mode > 400 && mode < 500) break;
2379 		fallthrough;
2380 	case 415:
2381 		test_ahash_speed("rmd160", sec, generic_hash_speed_template);
2382 		if (mode > 400 && mode < 500) break;
2383 		fallthrough;
2384 	case 417:
2385 		test_ahash_speed("blake2b-512", sec, generic_hash_speed_template);
2386 		if (mode > 400 && mode < 500) break;
2387 		fallthrough;
2388 	case 418:
2389 		test_ahash_speed("sha3-224", sec, generic_hash_speed_template);
2390 		if (mode > 400 && mode < 500) break;
2391 		fallthrough;
2392 	case 419:
2393 		test_ahash_speed("sha3-256", sec, generic_hash_speed_template);
2394 		if (mode > 400 && mode < 500) break;
2395 		fallthrough;
2396 	case 420:
2397 		test_ahash_speed("sha3-384", sec, generic_hash_speed_template);
2398 		if (mode > 400 && mode < 500) break;
2399 		fallthrough;
2400 	case 421:
2401 		test_ahash_speed("sha3-512", sec, generic_hash_speed_template);
2402 		if (mode > 400 && mode < 500) break;
2403 		fallthrough;
2404 	case 422:
2405 		test_ahash_speed("sm3", sec, generic_hash_speed_template);
2406 		if (mode > 400 && mode < 500) break;
2407 		fallthrough;
2408 	case 499:
2409 		break;
2410 
2411 	case 500:
2412 		test_acipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
2413 				   speed_template_16_24_32);
2414 		test_acipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
2415 				   speed_template_16_24_32);
2416 		test_acipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
2417 				   speed_template_16_24_32);
2418 		test_acipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
2419 				   speed_template_16_24_32);
2420 		test_acipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
2421 				   speed_template_32_40_48);
2422 		test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
2423 				   speed_template_32_40_48);
2424 		test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
2425 				   speed_template_32_64);
2426 		test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
2427 				   speed_template_32_64);
2428 		test_acipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
2429 				   speed_template_16_24_32);
2430 		test_acipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
2431 				   speed_template_16_24_32);
2432 		test_acipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
2433 				   speed_template_16_24_32);
2434 		test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
2435 				   speed_template_16_24_32);
2436 		test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
2437 				   speed_template_16_24_32);
2438 		test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
2439 				   speed_template_16_24_32);
2440 		test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0,
2441 				   speed_template_16_24_32);
2442 		test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0,
2443 				   speed_template_16_24_32);
2444 		test_acipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL, 0,
2445 				   speed_template_20_28_36);
2446 		test_acipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL, 0,
2447 				   speed_template_20_28_36);
2448 		break;
2449 
2450 	case 501:
2451 		test_acipher_speed("ecb(des3_ede)", ENCRYPT, sec,
2452 				   des3_speed_template, DES3_SPEED_VECTORS,
2453 				   speed_template_24);
2454 		test_acipher_speed("ecb(des3_ede)", DECRYPT, sec,
2455 				   des3_speed_template, DES3_SPEED_VECTORS,
2456 				   speed_template_24);
2457 		test_acipher_speed("cbc(des3_ede)", ENCRYPT, sec,
2458 				   des3_speed_template, DES3_SPEED_VECTORS,
2459 				   speed_template_24);
2460 		test_acipher_speed("cbc(des3_ede)", DECRYPT, sec,
2461 				   des3_speed_template, DES3_SPEED_VECTORS,
2462 				   speed_template_24);
2463 		test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec,
2464 				   des3_speed_template, DES3_SPEED_VECTORS,
2465 				   speed_template_24);
2466 		test_acipher_speed("cfb(des3_ede)", DECRYPT, sec,
2467 				   des3_speed_template, DES3_SPEED_VECTORS,
2468 				   speed_template_24);
2469 		test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec,
2470 				   des3_speed_template, DES3_SPEED_VECTORS,
2471 				   speed_template_24);
2472 		test_acipher_speed("ofb(des3_ede)", DECRYPT, sec,
2473 				   des3_speed_template, DES3_SPEED_VECTORS,
2474 				   speed_template_24);
2475 		break;
2476 
2477 	case 502:
2478 		test_acipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
2479 				   speed_template_8);
2480 		test_acipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
2481 				   speed_template_8);
2482 		test_acipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
2483 				   speed_template_8);
2484 		test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
2485 				   speed_template_8);
2486 		test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0,
2487 				   speed_template_8);
2488 		test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0,
2489 				   speed_template_8);
2490 		test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0,
2491 				   speed_template_8);
2492 		test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0,
2493 				   speed_template_8);
2494 		break;
2495 
2496 	case 503:
2497 		test_acipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
2498 				   speed_template_16_32);
2499 		test_acipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
2500 				   speed_template_16_32);
2501 		test_acipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
2502 				   speed_template_16_32);
2503 		test_acipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
2504 				   speed_template_16_32);
2505 		test_acipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
2506 				   speed_template_16_32);
2507 		test_acipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
2508 				   speed_template_16_32);
2509 		test_acipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
2510 				   speed_template_32_48);
2511 		test_acipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
2512 				   speed_template_32_48);
2513 		test_acipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
2514 				   speed_template_32_64);
2515 		test_acipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
2516 				   speed_template_32_64);
2517 		break;
2518 
2519 	case 504:
2520 		test_acipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
2521 				   speed_template_16_24_32);
2522 		test_acipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
2523 				   speed_template_16_24_32);
2524 		test_acipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
2525 				   speed_template_16_24_32);
2526 		test_acipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
2527 				   speed_template_16_24_32);
2528 		test_acipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
2529 				   speed_template_16_24_32);
2530 		test_acipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
2531 				   speed_template_16_24_32);
2532 		test_acipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
2533 				   speed_template_32_40_48);
2534 		test_acipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
2535 				   speed_template_32_40_48);
2536 		test_acipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
2537 				   speed_template_32_48_64);
2538 		test_acipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
2539 				   speed_template_32_48_64);
2540 		break;
2541 
2542 	case 505:
2543 		test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
2544 				   speed_template_8);
2545 		break;
2546 
2547 	case 506:
2548 		test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
2549 				   speed_template_8_16);
2550 		test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
2551 				   speed_template_8_16);
2552 		test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
2553 				   speed_template_8_16);
2554 		test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
2555 				   speed_template_8_16);
2556 		test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
2557 				   speed_template_8_16);
2558 		test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
2559 				   speed_template_8_16);
2560 		break;
2561 
2562 	case 507:
2563 		test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
2564 				   speed_template_16_32);
2565 		test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
2566 				   speed_template_16_32);
2567 		test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
2568 				   speed_template_16_32);
2569 		test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
2570 				   speed_template_16_32);
2571 		test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
2572 				   speed_template_16_32);
2573 		test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
2574 				   speed_template_16_32);
2575 		test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
2576 				   speed_template_32_48);
2577 		test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
2578 				   speed_template_32_48);
2579 		test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
2580 				   speed_template_32_64);
2581 		test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
2582 				   speed_template_32_64);
2583 		break;
2584 
2585 	case 508:
2586 		test_acipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
2587 				   speed_template_16_32);
2588 		test_acipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
2589 				   speed_template_16_32);
2590 		test_acipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
2591 				   speed_template_16_32);
2592 		test_acipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
2593 				   speed_template_16_32);
2594 		test_acipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
2595 				   speed_template_16_32);
2596 		test_acipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
2597 				   speed_template_16_32);
2598 		test_acipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
2599 				   speed_template_32_48);
2600 		test_acipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
2601 				   speed_template_32_48);
2602 		test_acipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
2603 				   speed_template_32_64);
2604 		test_acipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
2605 				   speed_template_32_64);
2606 		break;
2607 
2608 	case 509:
2609 		test_acipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
2610 				   speed_template_8_32);
2611 		test_acipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
2612 				   speed_template_8_32);
2613 		test_acipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
2614 				   speed_template_8_32);
2615 		test_acipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
2616 				   speed_template_8_32);
2617 		test_acipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
2618 				   speed_template_8_32);
2619 		test_acipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
2620 				   speed_template_8_32);
2621 		break;
2622 
2623 	case 518:
2624 		test_acipher_speed("ecb(sm4)", ENCRYPT, sec, NULL, 0,
2625 				speed_template_16);
2626 		test_acipher_speed("ecb(sm4)", DECRYPT, sec, NULL, 0,
2627 				speed_template_16);
2628 		test_acipher_speed("cbc(sm4)", ENCRYPT, sec, NULL, 0,
2629 				speed_template_16);
2630 		test_acipher_speed("cbc(sm4)", DECRYPT, sec, NULL, 0,
2631 				speed_template_16);
2632 		test_acipher_speed("cfb(sm4)", ENCRYPT, sec, NULL, 0,
2633 				speed_template_16);
2634 		test_acipher_speed("cfb(sm4)", DECRYPT, sec, NULL, 0,
2635 				speed_template_16);
2636 		test_acipher_speed("ctr(sm4)", ENCRYPT, sec, NULL, 0,
2637 				speed_template_16);
2638 		test_acipher_speed("ctr(sm4)", DECRYPT, sec, NULL, 0,
2639 				speed_template_16);
2640 		test_acipher_speed("xts(sm4)", ENCRYPT, sec, NULL, 0,
2641 				speed_template_32);
2642 		test_acipher_speed("xts(sm4)", DECRYPT, sec, NULL, 0,
2643 				speed_template_32);
2644 		break;
2645 
2646 	case 519:
2647 		test_acipher_speed("ecb(aria)", ENCRYPT, sec, NULL, 0,
2648 				   speed_template_16_24_32);
2649 		test_acipher_speed("ecb(aria)", DECRYPT, sec, NULL, 0,
2650 				   speed_template_16_24_32);
2651 		test_acipher_speed("ctr(aria)", ENCRYPT, sec, NULL, 0,
2652 				   speed_template_16_24_32);
2653 		test_acipher_speed("ctr(aria)", DECRYPT, sec, NULL, 0,
2654 				   speed_template_16_24_32);
2655 		break;
2656 
2657 	case 600:
2658 		test_mb_skcipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
2659 				       speed_template_16_24_32, num_mb);
2660 		test_mb_skcipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
2661 				       speed_template_16_24_32, num_mb);
2662 		test_mb_skcipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
2663 				       speed_template_16_24_32, num_mb);
2664 		test_mb_skcipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
2665 				       speed_template_16_24_32, num_mb);
2666 		test_mb_skcipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
2667 				       speed_template_32_40_48, num_mb);
2668 		test_mb_skcipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
2669 				       speed_template_32_40_48, num_mb);
2670 		test_mb_skcipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
2671 				       speed_template_32_64, num_mb);
2672 		test_mb_skcipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
2673 				       speed_template_32_64, num_mb);
2674 		test_mb_skcipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
2675 				       speed_template_16_24_32, num_mb);
2676 		test_mb_skcipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
2677 				       speed_template_16_24_32, num_mb);
2678 		test_mb_skcipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
2679 				       speed_template_16_24_32, num_mb);
2680 		test_mb_skcipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
2681 				       speed_template_16_24_32, num_mb);
2682 		test_mb_skcipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
2683 				       speed_template_16_24_32, num_mb);
2684 		test_mb_skcipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
2685 				       speed_template_16_24_32, num_mb);
2686 		test_mb_skcipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0,
2687 				       speed_template_16_24_32, num_mb);
2688 		test_mb_skcipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0,
2689 				       speed_template_16_24_32, num_mb);
2690 		test_mb_skcipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL,
2691 				       0, speed_template_20_28_36, num_mb);
2692 		test_mb_skcipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL,
2693 				       0, speed_template_20_28_36, num_mb);
2694 		break;
2695 
2696 	case 601:
2697 		test_mb_skcipher_speed("ecb(des3_ede)", ENCRYPT, sec,
2698 				       des3_speed_template, DES3_SPEED_VECTORS,
2699 				       speed_template_24, num_mb);
2700 		test_mb_skcipher_speed("ecb(des3_ede)", DECRYPT, sec,
2701 				       des3_speed_template, DES3_SPEED_VECTORS,
2702 				       speed_template_24, num_mb);
2703 		test_mb_skcipher_speed("cbc(des3_ede)", ENCRYPT, sec,
2704 				       des3_speed_template, DES3_SPEED_VECTORS,
2705 				       speed_template_24, num_mb);
2706 		test_mb_skcipher_speed("cbc(des3_ede)", DECRYPT, sec,
2707 				       des3_speed_template, DES3_SPEED_VECTORS,
2708 				       speed_template_24, num_mb);
2709 		test_mb_skcipher_speed("cfb(des3_ede)", ENCRYPT, sec,
2710 				       des3_speed_template, DES3_SPEED_VECTORS,
2711 				       speed_template_24, num_mb);
2712 		test_mb_skcipher_speed("cfb(des3_ede)", DECRYPT, sec,
2713 				       des3_speed_template, DES3_SPEED_VECTORS,
2714 				       speed_template_24, num_mb);
2715 		test_mb_skcipher_speed("ofb(des3_ede)", ENCRYPT, sec,
2716 				       des3_speed_template, DES3_SPEED_VECTORS,
2717 				       speed_template_24, num_mb);
2718 		test_mb_skcipher_speed("ofb(des3_ede)", DECRYPT, sec,
2719 				       des3_speed_template, DES3_SPEED_VECTORS,
2720 				       speed_template_24, num_mb);
2721 		break;
2722 
2723 	case 602:
2724 		test_mb_skcipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
2725 				       speed_template_8, num_mb);
2726 		test_mb_skcipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
2727 				       speed_template_8, num_mb);
2728 		test_mb_skcipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
2729 				       speed_template_8, num_mb);
2730 		test_mb_skcipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
2731 				       speed_template_8, num_mb);
2732 		test_mb_skcipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0,
2733 				       speed_template_8, num_mb);
2734 		test_mb_skcipher_speed("cfb(des)", DECRYPT, sec, NULL, 0,
2735 				       speed_template_8, num_mb);
2736 		test_mb_skcipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0,
2737 				       speed_template_8, num_mb);
2738 		test_mb_skcipher_speed("ofb(des)", DECRYPT, sec, NULL, 0,
2739 				       speed_template_8, num_mb);
2740 		break;
2741 
2742 	case 603:
2743 		test_mb_skcipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
2744 				       speed_template_16_32, num_mb);
2745 		test_mb_skcipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
2746 				       speed_template_16_32, num_mb);
2747 		test_mb_skcipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
2748 				       speed_template_16_32, num_mb);
2749 		test_mb_skcipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
2750 				       speed_template_16_32, num_mb);
2751 		test_mb_skcipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
2752 				       speed_template_16_32, num_mb);
2753 		test_mb_skcipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
2754 				       speed_template_16_32, num_mb);
2755 		test_mb_skcipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
2756 				       speed_template_32_48, num_mb);
2757 		test_mb_skcipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
2758 				       speed_template_32_48, num_mb);
2759 		test_mb_skcipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
2760 				       speed_template_32_64, num_mb);
2761 		test_mb_skcipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
2762 				       speed_template_32_64, num_mb);
2763 		break;
2764 
2765 	case 604:
2766 		test_mb_skcipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
2767 				       speed_template_16_24_32, num_mb);
2768 		test_mb_skcipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
2769 				       speed_template_16_24_32, num_mb);
2770 		test_mb_skcipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
2771 				       speed_template_16_24_32, num_mb);
2772 		test_mb_skcipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
2773 				       speed_template_16_24_32, num_mb);
2774 		test_mb_skcipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
2775 				       speed_template_16_24_32, num_mb);
2776 		test_mb_skcipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
2777 				       speed_template_16_24_32, num_mb);
2778 		test_mb_skcipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
2779 				       speed_template_32_40_48, num_mb);
2780 		test_mb_skcipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
2781 				       speed_template_32_40_48, num_mb);
2782 		test_mb_skcipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
2783 				       speed_template_32_48_64, num_mb);
2784 		test_mb_skcipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
2785 				       speed_template_32_48_64, num_mb);
2786 		break;
2787 
2788 	case 605:
2789 		test_mb_skcipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
2790 				       speed_template_8, num_mb);
2791 		break;
2792 
2793 	case 606:
2794 		test_mb_skcipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
2795 				       speed_template_8_16, num_mb);
2796 		test_mb_skcipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
2797 				       speed_template_8_16, num_mb);
2798 		test_mb_skcipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
2799 				       speed_template_8_16, num_mb);
2800 		test_mb_skcipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
2801 				       speed_template_8_16, num_mb);
2802 		test_mb_skcipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
2803 				       speed_template_8_16, num_mb);
2804 		test_mb_skcipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
2805 				       speed_template_8_16, num_mb);
2806 		break;
2807 
2808 	case 607:
2809 		test_mb_skcipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
2810 				       speed_template_16_32, num_mb);
2811 		test_mb_skcipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
2812 				       speed_template_16_32, num_mb);
2813 		test_mb_skcipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
2814 				       speed_template_16_32, num_mb);
2815 		test_mb_skcipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
2816 				       speed_template_16_32, num_mb);
2817 		test_mb_skcipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
2818 				       speed_template_16_32, num_mb);
2819 		test_mb_skcipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
2820 				       speed_template_16_32, num_mb);
2821 		test_mb_skcipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
2822 				       speed_template_32_48, num_mb);
2823 		test_mb_skcipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
2824 				       speed_template_32_48, num_mb);
2825 		test_mb_skcipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
2826 				       speed_template_32_64, num_mb);
2827 		test_mb_skcipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
2828 				       speed_template_32_64, num_mb);
2829 		break;
2830 
2831 	case 608:
2832 		test_mb_skcipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
2833 				       speed_template_16_32, num_mb);
2834 		test_mb_skcipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
2835 				       speed_template_16_32, num_mb);
2836 		test_mb_skcipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
2837 				       speed_template_16_32, num_mb);
2838 		test_mb_skcipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
2839 				       speed_template_16_32, num_mb);
2840 		test_mb_skcipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
2841 				       speed_template_16_32, num_mb);
2842 		test_mb_skcipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
2843 				       speed_template_16_32, num_mb);
2844 		test_mb_skcipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
2845 				       speed_template_32_48, num_mb);
2846 		test_mb_skcipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
2847 				       speed_template_32_48, num_mb);
2848 		test_mb_skcipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
2849 				       speed_template_32_64, num_mb);
2850 		test_mb_skcipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
2851 				       speed_template_32_64, num_mb);
2852 		break;
2853 
2854 	case 609:
2855 		test_mb_skcipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
2856 				       speed_template_8_32, num_mb);
2857 		test_mb_skcipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
2858 				       speed_template_8_32, num_mb);
2859 		test_mb_skcipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
2860 				       speed_template_8_32, num_mb);
2861 		test_mb_skcipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
2862 				       speed_template_8_32, num_mb);
2863 		test_mb_skcipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
2864 				       speed_template_8_32, num_mb);
2865 		test_mb_skcipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
2866 				       speed_template_8_32, num_mb);
2867 		break;
2868 
2869 	case 610:
2870 		test_mb_skcipher_speed("ecb(aria)", ENCRYPT, sec, NULL, 0,
2871 				       speed_template_16_32, num_mb);
2872 		test_mb_skcipher_speed("ecb(aria)", DECRYPT, sec, NULL, 0,
2873 				       speed_template_16_32, num_mb);
2874 		test_mb_skcipher_speed("ctr(aria)", ENCRYPT, sec, NULL, 0,
2875 				       speed_template_16_32, num_mb);
2876 		test_mb_skcipher_speed("ctr(aria)", DECRYPT, sec, NULL, 0,
2877 				       speed_template_16_32, num_mb);
2878 		break;
2879 
2880 	}
2881 
2882 	return ret;
2883 }
2884 
2885 static int __init tcrypt_mod_init(void)
2886 {
2887 	int err = -ENOMEM;
2888 	int i;
2889 
2890 	for (i = 0; i < TVMEMSIZE; i++) {
2891 		tvmem[i] = (void *)__get_free_page(GFP_KERNEL);
2892 		if (!tvmem[i])
2893 			goto err_free_tv;
2894 	}
2895 
2896 	err = do_test(alg, type, mask, mode, num_mb);
2897 
2898 	if (err) {
2899 		pr_err("one or more tests failed!\n");
2900 		goto err_free_tv;
2901 	} else {
2902 		pr_debug("all tests passed\n");
2903 	}
2904 
2905 	/* We intentionaly return -EAGAIN to prevent keeping the module,
2906 	 * unless we're running in fips mode. It does all its work from
2907 	 * init() and doesn't offer any runtime functionality, but in
2908 	 * the fips case, checking for a successful load is helpful.
2909 	 * => we don't need it in the memory, do we?
2910 	 *                                        -- mludvig
2911 	 */
2912 	if (!fips_enabled)
2913 		err = -EAGAIN;
2914 
2915 err_free_tv:
2916 	for (i = 0; i < TVMEMSIZE && tvmem[i]; i++)
2917 		free_page((unsigned long)tvmem[i]);
2918 
2919 	return err;
2920 }
2921 
2922 /*
2923  * If an init function is provided, an exit function must also be provided
2924  * to allow module unload.
2925  */
2926 static void __exit tcrypt_mod_fini(void) { }
2927 
2928 late_initcall(tcrypt_mod_init);
2929 module_exit(tcrypt_mod_fini);
2930 
2931 module_param(alg, charp, 0);
2932 module_param(type, uint, 0);
2933 module_param(mask, uint, 0);
2934 module_param(mode, int, 0);
2935 module_param(sec, uint, 0);
2936 MODULE_PARM_DESC(sec, "Length in seconds of speed tests "
2937 		      "(defaults to zero which uses CPU cycles instead)");
2938 module_param(num_mb, uint, 0000);
2939 MODULE_PARM_DESC(num_mb, "Number of concurrent requests to be used in mb speed tests (defaults to 8)");
2940 module_param(klen, uint, 0);
2941 MODULE_PARM_DESC(klen, "Key length (defaults to 0)");
2942 
2943 MODULE_LICENSE("GPL");
2944 MODULE_DESCRIPTION("Quick & dirty crypto testing module");
2945 MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
2946