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

source code of linux/crypto/tcrypt.c