]>
Commit | Line | Data |
---|---|---|
ef2736fc | 1 | /* |
1da177e4 LT |
2 | * Quick & dirty crypto testing module. |
3 | * | |
4 | * This will only exist until we have a better testing mechanism | |
5 | * (e.g. a char device). | |
6 | * | |
7 | * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> | |
8 | * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org> | |
e3a4ea4f | 9 | * Copyright (c) 2007 Nokia Siemens Networks |
1da177e4 | 10 | * |
69435b94 AH |
11 | * Updated RFC4106 AES-GCM testing. |
12 | * Authors: Aidan O'Mahony (aidan.o.mahony@intel.com) | |
13 | * Adrian Hoban <adrian.hoban@intel.com> | |
14 | * Gabriele Paoloni <gabriele.paoloni@intel.com> | |
15 | * Tadeusz Struk (tadeusz.struk@intel.com) | |
16 | * Copyright (c) 2010, Intel Corporation. | |
17 | * | |
1da177e4 LT |
18 | * This program is free software; you can redistribute it and/or modify it |
19 | * under the terms of the GNU General Public License as published by the Free | |
ef2736fc | 20 | * Software Foundation; either version 2 of the License, or (at your option) |
1da177e4 LT |
21 | * any later version. |
22 | * | |
1da177e4 LT |
23 | */ |
24 | ||
76512f2d RV |
25 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
26 | ||
1ce5a04d | 27 | #include <crypto/aead.h> |
18e33e6d | 28 | #include <crypto/hash.h> |
7166e589 | 29 | #include <crypto/skcipher.h> |
cba83564 | 30 | #include <linux/err.h> |
daf0944c | 31 | #include <linux/fips.h> |
1da177e4 | 32 | #include <linux/init.h> |
5a0e3ad6 | 33 | #include <linux/gfp.h> |
1da177e4 | 34 | #include <linux/module.h> |
378f058c | 35 | #include <linux/scatterlist.h> |
1da177e4 | 36 | #include <linux/string.h> |
1da177e4 | 37 | #include <linux/moduleparam.h> |
ebfd9bcf | 38 | #include <linux/jiffies.h> |
6a17944c HX |
39 | #include <linux/timex.h> |
40 | #include <linux/interrupt.h> | |
1da177e4 LT |
41 | #include "tcrypt.h" |
42 | ||
43 | /* | |
f139cfa7 | 44 | * Need slab memory for testing (size in number of pages). |
1da177e4 | 45 | */ |
f139cfa7 | 46 | #define TVMEMSIZE 4 |
1da177e4 LT |
47 | |
48 | /* | |
da7f033d | 49 | * Used by test_cipher_speed() |
1da177e4 LT |
50 | */ |
51 | #define ENCRYPT 1 | |
52 | #define DECRYPT 0 | |
1da177e4 | 53 | |
f074f7b1 HG |
54 | #define MAX_DIGEST_SIZE 64 |
55 | ||
263a8df0 LC |
56 | /* |
57 | * return a string with the driver name | |
58 | */ | |
59 | #define get_driver_name(tfm_type, tfm) crypto_tfm_alg_driver_name(tfm_type ## _tfm(tfm)) | |
60 | ||
ebfd9bcf HW |
61 | /* |
62 | * Used by test_cipher_speed() | |
63 | */ | |
6a17944c | 64 | static unsigned int sec; |
ebfd9bcf | 65 | |
a873a5f1 SK |
66 | static char *alg = NULL; |
67 | static u32 type; | |
7be380f7 | 68 | static u32 mask; |
1da177e4 | 69 | static int mode; |
f139cfa7 | 70 | static char *tvmem[TVMEMSIZE]; |
1da177e4 LT |
71 | |
72 | static char *check[] = { | |
b7e27530 | 73 | "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", "sm3", |
cd12fb90 JL |
74 | "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes", |
75 | "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", | |
90831639 | 76 | "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", |
2998db37 | 77 | "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320", |
79cc6ab8 | 78 | "lzo", "cts", "zlib", "sha3-224", "sha3-256", "sha3-384", "sha3-512", |
79 | NULL | |
1da177e4 LT |
80 | }; |
81 | ||
1425d2d1 VL |
82 | struct tcrypt_result { |
83 | struct completion completion; | |
84 | int err; | |
85 | }; | |
86 | ||
87 | static void tcrypt_complete(struct crypto_async_request *req, int err) | |
88 | { | |
89 | struct tcrypt_result *res = req->data; | |
90 | ||
91 | if (err == -EINPROGRESS) | |
92 | return; | |
93 | ||
94 | res->err = err; | |
95 | complete(&res->completion); | |
96 | } | |
97 | ||
1425d2d1 VL |
98 | static inline int do_one_aead_op(struct aead_request *req, int ret) |
99 | { | |
100 | if (ret == -EINPROGRESS || ret == -EBUSY) { | |
101 | struct tcrypt_result *tr = req->base.data; | |
102 | ||
103 | ret = wait_for_completion_interruptible(&tr->completion); | |
104 | if (!ret) | |
105 | ret = tr->err; | |
106 | reinit_completion(&tr->completion); | |
107 | } | |
108 | ||
109 | return ret; | |
110 | } | |
111 | ||
53f52d7a | 112 | static int test_aead_jiffies(struct aead_request *req, int enc, |
3e3dc25f | 113 | int blen, int secs) |
53f52d7a TC |
114 | { |
115 | unsigned long start, end; | |
116 | int bcount; | |
117 | int ret; | |
118 | ||
3e3dc25f | 119 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
53f52d7a TC |
120 | time_before(jiffies, end); bcount++) { |
121 | if (enc) | |
1425d2d1 | 122 | ret = do_one_aead_op(req, crypto_aead_encrypt(req)); |
53f52d7a | 123 | else |
1425d2d1 | 124 | ret = do_one_aead_op(req, crypto_aead_decrypt(req)); |
53f52d7a TC |
125 | |
126 | if (ret) | |
127 | return ret; | |
128 | } | |
129 | ||
130 | printk("%d operations in %d seconds (%ld bytes)\n", | |
3e3dc25f | 131 | bcount, secs, (long)bcount * blen); |
53f52d7a TC |
132 | return 0; |
133 | } | |
134 | ||
135 | static int test_aead_cycles(struct aead_request *req, int enc, int blen) | |
136 | { | |
137 | unsigned long cycles = 0; | |
138 | int ret = 0; | |
139 | int i; | |
140 | ||
53f52d7a TC |
141 | /* Warm-up run. */ |
142 | for (i = 0; i < 4; i++) { | |
143 | if (enc) | |
1425d2d1 | 144 | ret = do_one_aead_op(req, crypto_aead_encrypt(req)); |
53f52d7a | 145 | else |
1425d2d1 | 146 | ret = do_one_aead_op(req, crypto_aead_decrypt(req)); |
53f52d7a TC |
147 | |
148 | if (ret) | |
149 | goto out; | |
150 | } | |
151 | ||
152 | /* The real thing. */ | |
153 | for (i = 0; i < 8; i++) { | |
154 | cycles_t start, end; | |
155 | ||
156 | start = get_cycles(); | |
157 | if (enc) | |
1425d2d1 | 158 | ret = do_one_aead_op(req, crypto_aead_encrypt(req)); |
53f52d7a | 159 | else |
1425d2d1 | 160 | ret = do_one_aead_op(req, crypto_aead_decrypt(req)); |
53f52d7a TC |
161 | end = get_cycles(); |
162 | ||
163 | if (ret) | |
164 | goto out; | |
165 | ||
166 | cycles += end - start; | |
167 | } | |
168 | ||
169 | out: | |
53f52d7a TC |
170 | if (ret == 0) |
171 | printk("1 operation in %lu cycles (%d bytes)\n", | |
172 | (cycles + 4) / 8, blen); | |
173 | ||
174 | return ret; | |
175 | } | |
176 | ||
d5dc3927 | 177 | static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 }; |
53f52d7a TC |
178 | static u32 aead_sizes[] = { 16, 64, 256, 512, 1024, 2048, 4096, 8192, 0 }; |
179 | ||
180 | #define XBUFSIZE 8 | |
181 | #define MAX_IVLEN 32 | |
182 | ||
183 | static int testmgr_alloc_buf(char *buf[XBUFSIZE]) | |
184 | { | |
185 | int i; | |
186 | ||
187 | for (i = 0; i < XBUFSIZE; i++) { | |
188 | buf[i] = (void *)__get_free_page(GFP_KERNEL); | |
189 | if (!buf[i]) | |
190 | goto err_free_buf; | |
191 | } | |
192 | ||
193 | return 0; | |
194 | ||
195 | err_free_buf: | |
196 | while (i-- > 0) | |
197 | free_page((unsigned long)buf[i]); | |
198 | ||
199 | return -ENOMEM; | |
200 | } | |
201 | ||
202 | static void testmgr_free_buf(char *buf[XBUFSIZE]) | |
203 | { | |
204 | int i; | |
205 | ||
206 | for (i = 0; i < XBUFSIZE; i++) | |
207 | free_page((unsigned long)buf[i]); | |
208 | } | |
209 | ||
210 | static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE], | |
211 | unsigned int buflen) | |
212 | { | |
213 | int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE; | |
214 | int k, rem; | |
215 | ||
53f52d7a TC |
216 | if (np > XBUFSIZE) { |
217 | rem = PAGE_SIZE; | |
218 | np = XBUFSIZE; | |
c4768993 CS |
219 | } else { |
220 | rem = buflen % PAGE_SIZE; | |
53f52d7a | 221 | } |
c4768993 | 222 | |
31267270 | 223 | sg_init_table(sg, np + 1); |
c4768993 CS |
224 | np--; |
225 | for (k = 0; k < np; k++) | |
31267270 | 226 | sg_set_buf(&sg[k + 1], xbuf[k], PAGE_SIZE); |
c4768993 | 227 | |
31267270 | 228 | sg_set_buf(&sg[k + 1], xbuf[k], rem); |
53f52d7a TC |
229 | } |
230 | ||
3e3dc25f | 231 | static void test_aead_speed(const char *algo, int enc, unsigned int secs, |
53f52d7a TC |
232 | struct aead_speed_template *template, |
233 | unsigned int tcount, u8 authsize, | |
234 | unsigned int aad_size, u8 *keysize) | |
235 | { | |
236 | unsigned int i, j; | |
237 | struct crypto_aead *tfm; | |
238 | int ret = -ENOMEM; | |
239 | const char *key; | |
240 | struct aead_request *req; | |
241 | struct scatterlist *sg; | |
53f52d7a TC |
242 | struct scatterlist *sgout; |
243 | const char *e; | |
244 | void *assoc; | |
96692a73 | 245 | char *iv; |
53f52d7a TC |
246 | char *xbuf[XBUFSIZE]; |
247 | char *xoutbuf[XBUFSIZE]; | |
248 | char *axbuf[XBUFSIZE]; | |
249 | unsigned int *b_size; | |
250 | unsigned int iv_len; | |
1425d2d1 | 251 | struct tcrypt_result result; |
53f52d7a | 252 | |
96692a73 CS |
253 | iv = kzalloc(MAX_IVLEN, GFP_KERNEL); |
254 | if (!iv) | |
255 | return; | |
256 | ||
ac5f863f CE |
257 | if (aad_size >= PAGE_SIZE) { |
258 | pr_err("associate data length (%u) too big\n", aad_size); | |
96692a73 | 259 | goto out_noxbuf; |
ac5f863f CE |
260 | } |
261 | ||
53f52d7a TC |
262 | if (enc == ENCRYPT) |
263 | e = "encryption"; | |
264 | else | |
265 | e = "decryption"; | |
266 | ||
267 | if (testmgr_alloc_buf(xbuf)) | |
268 | goto out_noxbuf; | |
269 | if (testmgr_alloc_buf(axbuf)) | |
270 | goto out_noaxbuf; | |
271 | if (testmgr_alloc_buf(xoutbuf)) | |
272 | goto out_nooutbuf; | |
273 | ||
a3f2185a | 274 | sg = kmalloc(sizeof(*sg) * 9 * 2, GFP_KERNEL); |
53f52d7a TC |
275 | if (!sg) |
276 | goto out_nosg; | |
a3f2185a | 277 | sgout = &sg[9]; |
53f52d7a | 278 | |
5e4b8c1f | 279 | tfm = crypto_alloc_aead(algo, 0, 0); |
53f52d7a TC |
280 | |
281 | if (IS_ERR(tfm)) { | |
282 | pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo, | |
283 | PTR_ERR(tfm)); | |
a2ea6ed6 | 284 | goto out_notfm; |
53f52d7a TC |
285 | } |
286 | ||
1425d2d1 | 287 | init_completion(&result.completion); |
263a8df0 LC |
288 | printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo, |
289 | get_driver_name(crypto_aead, tfm), e); | |
290 | ||
53f52d7a TC |
291 | req = aead_request_alloc(tfm, GFP_KERNEL); |
292 | if (!req) { | |
293 | pr_err("alg: aead: Failed to allocate request for %s\n", | |
294 | algo); | |
6af1f93e | 295 | goto out_noreq; |
53f52d7a TC |
296 | } |
297 | ||
1425d2d1 VL |
298 | aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
299 | tcrypt_complete, &result); | |
300 | ||
53f52d7a TC |
301 | i = 0; |
302 | do { | |
303 | b_size = aead_sizes; | |
304 | do { | |
305 | assoc = axbuf[0]; | |
ac5f863f | 306 | memset(assoc, 0xff, aad_size); |
53f52d7a TC |
307 | |
308 | if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { | |
309 | pr_err("template (%u) too big for tvmem (%lu)\n", | |
310 | *keysize + *b_size, | |
311 | TVMEMSIZE * PAGE_SIZE); | |
312 | goto out; | |
313 | } | |
314 | ||
315 | key = tvmem[0]; | |
316 | for (j = 0; j < tcount; j++) { | |
317 | if (template[j].klen == *keysize) { | |
318 | key = template[j].key; | |
319 | break; | |
320 | } | |
321 | } | |
322 | ret = crypto_aead_setkey(tfm, key, *keysize); | |
323 | ret = crypto_aead_setauthsize(tfm, authsize); | |
324 | ||
325 | iv_len = crypto_aead_ivsize(tfm); | |
326 | if (iv_len) | |
96692a73 | 327 | memset(iv, 0xff, iv_len); |
53f52d7a TC |
328 | |
329 | crypto_aead_clear_flags(tfm, ~0); | |
330 | printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ", | |
331 | i, *keysize * 8, *b_size); | |
332 | ||
333 | ||
334 | memset(tvmem[0], 0xff, PAGE_SIZE); | |
335 | ||
336 | if (ret) { | |
337 | pr_err("setkey() failed flags=%x\n", | |
338 | crypto_aead_get_flags(tfm)); | |
339 | goto out; | |
340 | } | |
341 | ||
31267270 | 342 | sg_init_aead(sg, xbuf, |
53f52d7a TC |
343 | *b_size + (enc ? authsize : 0)); |
344 | ||
31267270 | 345 | sg_init_aead(sgout, xoutbuf, |
53f52d7a TC |
346 | *b_size + (enc ? authsize : 0)); |
347 | ||
31267270 HX |
348 | sg_set_buf(&sg[0], assoc, aad_size); |
349 | sg_set_buf(&sgout[0], assoc, aad_size); | |
350 | ||
53f52d7a | 351 | aead_request_set_crypt(req, sg, sgout, *b_size, iv); |
a3f2185a | 352 | aead_request_set_ad(req, aad_size); |
53f52d7a | 353 | |
3e3dc25f MR |
354 | if (secs) |
355 | ret = test_aead_jiffies(req, enc, *b_size, | |
356 | secs); | |
53f52d7a TC |
357 | else |
358 | ret = test_aead_cycles(req, enc, *b_size); | |
359 | ||
360 | if (ret) { | |
361 | pr_err("%s() failed return code=%d\n", e, ret); | |
362 | break; | |
363 | } | |
364 | b_size++; | |
365 | i++; | |
366 | } while (*b_size); | |
367 | keysize++; | |
368 | } while (*keysize); | |
369 | ||
370 | out: | |
6af1f93e CE |
371 | aead_request_free(req); |
372 | out_noreq: | |
53f52d7a | 373 | crypto_free_aead(tfm); |
a2ea6ed6 | 374 | out_notfm: |
53f52d7a TC |
375 | kfree(sg); |
376 | out_nosg: | |
377 | testmgr_free_buf(xoutbuf); | |
378 | out_nooutbuf: | |
379 | testmgr_free_buf(axbuf); | |
380 | out_noaxbuf: | |
381 | testmgr_free_buf(xbuf); | |
382 | out_noxbuf: | |
96692a73 | 383 | kfree(iv); |
53f52d7a | 384 | } |
d5dc3927 | 385 | |
beb63da7 DM |
386 | static void test_hash_sg_init(struct scatterlist *sg) |
387 | { | |
388 | int i; | |
389 | ||
390 | sg_init_table(sg, TVMEMSIZE); | |
391 | for (i = 0; i < TVMEMSIZE; i++) { | |
392 | sg_set_buf(sg + i, tvmem[i], PAGE_SIZE); | |
393 | memset(tvmem[i], 0xff, PAGE_SIZE); | |
394 | } | |
395 | } | |
396 | ||
beb63da7 DM |
397 | static inline int do_one_ahash_op(struct ahash_request *req, int ret) |
398 | { | |
399 | if (ret == -EINPROGRESS || ret == -EBUSY) { | |
400 | struct tcrypt_result *tr = req->base.data; | |
401 | ||
8a45ac12 | 402 | wait_for_completion(&tr->completion); |
16735d02 | 403 | reinit_completion(&tr->completion); |
8a45ac12 | 404 | ret = tr->err; |
beb63da7 DM |
405 | } |
406 | return ret; | |
407 | } | |
408 | ||
72259deb HX |
409 | struct test_mb_ahash_data { |
410 | struct scatterlist sg[TVMEMSIZE]; | |
411 | char result[64]; | |
412 | struct ahash_request *req; | |
413 | struct tcrypt_result tresult; | |
414 | char *xbuf[XBUFSIZE]; | |
415 | }; | |
087bcd22 MD |
416 | |
417 | static void test_mb_ahash_speed(const char *algo, unsigned int sec, | |
72259deb | 418 | struct hash_speed *speed) |
087bcd22 | 419 | { |
72259deb | 420 | struct test_mb_ahash_data *data; |
087bcd22 | 421 | struct crypto_ahash *tfm; |
72259deb | 422 | unsigned long start, end; |
f8de55b6 | 423 | unsigned long cycles; |
72259deb HX |
424 | unsigned int i, j, k; |
425 | int ret; | |
426 | ||
427 | data = kzalloc(sizeof(*data) * 8, GFP_KERNEL); | |
428 | if (!data) | |
429 | return; | |
087bcd22 MD |
430 | |
431 | tfm = crypto_alloc_ahash(algo, 0, 0); | |
432 | if (IS_ERR(tfm)) { | |
433 | pr_err("failed to load transform for %s: %ld\n", | |
434 | algo, PTR_ERR(tfm)); | |
72259deb | 435 | goto free_data; |
087bcd22 | 436 | } |
72259deb | 437 | |
087bcd22 | 438 | for (i = 0; i < 8; ++i) { |
72259deb HX |
439 | if (testmgr_alloc_buf(data[i].xbuf)) |
440 | goto out; | |
087bcd22 | 441 | |
72259deb | 442 | init_completion(&data[i].tresult.completion); |
087bcd22 | 443 | |
72259deb HX |
444 | data[i].req = ahash_request_alloc(tfm, GFP_KERNEL); |
445 | if (!data[i].req) { | |
f83f5b12 KK |
446 | pr_err("alg: hash: Failed to allocate request for %s\n", |
447 | algo); | |
72259deb | 448 | goto out; |
087bcd22 | 449 | } |
087bcd22 | 450 | |
72259deb HX |
451 | ahash_request_set_callback(data[i].req, 0, |
452 | tcrypt_complete, &data[i].tresult); | |
453 | test_hash_sg_init(data[i].sg); | |
087bcd22 MD |
454 | } |
455 | ||
72259deb HX |
456 | pr_info("\ntesting speed of multibuffer %s (%s)\n", algo, |
457 | get_driver_name(crypto_ahash, tfm)); | |
087bcd22 MD |
458 | |
459 | for (i = 0; speed[i].blen != 0; i++) { | |
72259deb HX |
460 | /* For some reason this only tests digests. */ |
461 | if (speed[i].blen != speed[i].plen) | |
462 | continue; | |
463 | ||
087bcd22 | 464 | if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) { |
f83f5b12 KK |
465 | pr_err("template (%u) too big for tvmem (%lu)\n", |
466 | speed[i].blen, TVMEMSIZE * PAGE_SIZE); | |
467 | goto out; | |
087bcd22 MD |
468 | } |
469 | ||
470 | if (speed[i].klen) | |
471 | crypto_ahash_setkey(tfm, tvmem[0], speed[i].klen); | |
472 | ||
72259deb HX |
473 | for (k = 0; k < 8; k++) |
474 | ahash_request_set_crypt(data[k].req, data[k].sg, | |
475 | data[k].result, speed[i].blen); | |
087bcd22 | 476 | |
72259deb HX |
477 | pr_info("test%3u " |
478 | "(%5u byte blocks,%5u bytes per update,%4u updates): ", | |
087bcd22 MD |
479 | i, speed[i].blen, speed[i].plen, |
480 | speed[i].blen / speed[i].plen); | |
481 | ||
72259deb HX |
482 | start = get_cycles(); |
483 | ||
484 | for (k = 0; k < 8; k++) { | |
485 | ret = crypto_ahash_digest(data[k].req); | |
d13cd11f HX |
486 | if (ret == -EINPROGRESS) { |
487 | ret = 0; | |
087bcd22 | 488 | continue; |
d13cd11f | 489 | } |
72259deb HX |
490 | |
491 | if (ret) | |
492 | break; | |
493 | ||
494 | complete(&data[k].tresult.completion); | |
495 | data[k].tresult.err = 0; | |
087bcd22 | 496 | } |
087bcd22 | 497 | |
72259deb HX |
498 | for (j = 0; j < k; j++) { |
499 | struct tcrypt_result *tr = &data[j].tresult; | |
087bcd22 | 500 | |
72259deb HX |
501 | wait_for_completion(&tr->completion); |
502 | if (tr->err) | |
503 | ret = tr->err; | |
087bcd22 MD |
504 | } |
505 | ||
72259deb HX |
506 | end = get_cycles(); |
507 | cycles = end - start; | |
508 | pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", | |
509 | cycles, cycles / (8 * speed[i].blen)); | |
510 | ||
511 | if (ret) { | |
512 | pr_err("At least one hashing failed ret=%d\n", ret); | |
513 | break; | |
514 | } | |
087bcd22 | 515 | } |
087bcd22 MD |
516 | |
517 | out: | |
518 | for (k = 0; k < 8; ++k) | |
72259deb HX |
519 | ahash_request_free(data[k].req); |
520 | ||
087bcd22 | 521 | for (k = 0; k < 8; ++k) |
72259deb HX |
522 | testmgr_free_buf(data[k].xbuf); |
523 | ||
524 | crypto_free_ahash(tfm); | |
525 | ||
526 | free_data: | |
527 | kfree(data); | |
087bcd22 MD |
528 | } |
529 | ||
beb63da7 | 530 | static int test_ahash_jiffies_digest(struct ahash_request *req, int blen, |
3e3dc25f | 531 | char *out, int secs) |
beb63da7 DM |
532 | { |
533 | unsigned long start, end; | |
534 | int bcount; | |
535 | int ret; | |
536 | ||
3e3dc25f | 537 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
beb63da7 DM |
538 | time_before(jiffies, end); bcount++) { |
539 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); | |
540 | if (ret) | |
541 | return ret; | |
542 | } | |
543 | ||
544 | printk("%6u opers/sec, %9lu bytes/sec\n", | |
3e3dc25f | 545 | bcount / secs, ((long)bcount * blen) / secs); |
beb63da7 DM |
546 | |
547 | return 0; | |
548 | } | |
549 | ||
550 | static int test_ahash_jiffies(struct ahash_request *req, int blen, | |
3e3dc25f | 551 | int plen, char *out, int secs) |
beb63da7 DM |
552 | { |
553 | unsigned long start, end; | |
554 | int bcount, pcount; | |
555 | int ret; | |
556 | ||
557 | if (plen == blen) | |
3e3dc25f | 558 | return test_ahash_jiffies_digest(req, blen, out, secs); |
beb63da7 | 559 | |
3e3dc25f | 560 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
beb63da7 | 561 | time_before(jiffies, end); bcount++) { |
43a9607d | 562 | ret = do_one_ahash_op(req, crypto_ahash_init(req)); |
beb63da7 DM |
563 | if (ret) |
564 | return ret; | |
565 | for (pcount = 0; pcount < blen; pcount += plen) { | |
566 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); | |
567 | if (ret) | |
568 | return ret; | |
569 | } | |
570 | /* we assume there is enough space in 'out' for the result */ | |
571 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); | |
572 | if (ret) | |
573 | return ret; | |
574 | } | |
575 | ||
576 | pr_cont("%6u opers/sec, %9lu bytes/sec\n", | |
3e3dc25f | 577 | bcount / secs, ((long)bcount * blen) / secs); |
beb63da7 DM |
578 | |
579 | return 0; | |
580 | } | |
581 | ||
582 | static int test_ahash_cycles_digest(struct ahash_request *req, int blen, | |
583 | char *out) | |
584 | { | |
585 | unsigned long cycles = 0; | |
586 | int ret, i; | |
587 | ||
588 | /* Warm-up run. */ | |
589 | for (i = 0; i < 4; i++) { | |
590 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); | |
591 | if (ret) | |
592 | goto out; | |
593 | } | |
594 | ||
595 | /* The real thing. */ | |
596 | for (i = 0; i < 8; i++) { | |
597 | cycles_t start, end; | |
598 | ||
599 | start = get_cycles(); | |
600 | ||
601 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); | |
602 | if (ret) | |
603 | goto out; | |
604 | ||
605 | end = get_cycles(); | |
606 | ||
607 | cycles += end - start; | |
608 | } | |
609 | ||
610 | out: | |
611 | if (ret) | |
612 | return ret; | |
613 | ||
614 | pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", | |
615 | cycles / 8, cycles / (8 * blen)); | |
616 | ||
617 | return 0; | |
618 | } | |
619 | ||
620 | static int test_ahash_cycles(struct ahash_request *req, int blen, | |
621 | int plen, char *out) | |
622 | { | |
623 | unsigned long cycles = 0; | |
624 | int i, pcount, ret; | |
625 | ||
626 | if (plen == blen) | |
627 | return test_ahash_cycles_digest(req, blen, out); | |
628 | ||
629 | /* Warm-up run. */ | |
630 | for (i = 0; i < 4; i++) { | |
43a9607d | 631 | ret = do_one_ahash_op(req, crypto_ahash_init(req)); |
beb63da7 DM |
632 | if (ret) |
633 | goto out; | |
634 | for (pcount = 0; pcount < blen; pcount += plen) { | |
635 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); | |
636 | if (ret) | |
637 | goto out; | |
638 | } | |
639 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); | |
640 | if (ret) | |
641 | goto out; | |
642 | } | |
643 | ||
644 | /* The real thing. */ | |
645 | for (i = 0; i < 8; i++) { | |
646 | cycles_t start, end; | |
647 | ||
648 | start = get_cycles(); | |
649 | ||
43a9607d | 650 | ret = do_one_ahash_op(req, crypto_ahash_init(req)); |
beb63da7 DM |
651 | if (ret) |
652 | goto out; | |
653 | for (pcount = 0; pcount < blen; pcount += plen) { | |
654 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); | |
655 | if (ret) | |
656 | goto out; | |
657 | } | |
658 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); | |
659 | if (ret) | |
660 | goto out; | |
661 | ||
662 | end = get_cycles(); | |
663 | ||
664 | cycles += end - start; | |
665 | } | |
666 | ||
667 | out: | |
668 | if (ret) | |
669 | return ret; | |
670 | ||
671 | pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", | |
672 | cycles / 8, cycles / (8 * blen)); | |
673 | ||
674 | return 0; | |
675 | } | |
676 | ||
0660511c HX |
677 | static void test_ahash_speed_common(const char *algo, unsigned int secs, |
678 | struct hash_speed *speed, unsigned mask) | |
beb63da7 DM |
679 | { |
680 | struct scatterlist sg[TVMEMSIZE]; | |
681 | struct tcrypt_result tresult; | |
682 | struct ahash_request *req; | |
683 | struct crypto_ahash *tfm; | |
f074f7b1 | 684 | char *output; |
beb63da7 DM |
685 | int i, ret; |
686 | ||
0660511c | 687 | tfm = crypto_alloc_ahash(algo, 0, mask); |
beb63da7 DM |
688 | if (IS_ERR(tfm)) { |
689 | pr_err("failed to load transform for %s: %ld\n", | |
690 | algo, PTR_ERR(tfm)); | |
691 | return; | |
692 | } | |
693 | ||
263a8df0 LC |
694 | printk(KERN_INFO "\ntesting speed of async %s (%s)\n", algo, |
695 | get_driver_name(crypto_ahash, tfm)); | |
696 | ||
f074f7b1 HG |
697 | if (crypto_ahash_digestsize(tfm) > MAX_DIGEST_SIZE) { |
698 | pr_err("digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm), | |
699 | MAX_DIGEST_SIZE); | |
beb63da7 DM |
700 | goto out; |
701 | } | |
702 | ||
703 | test_hash_sg_init(sg); | |
704 | req = ahash_request_alloc(tfm, GFP_KERNEL); | |
705 | if (!req) { | |
706 | pr_err("ahash request allocation failure\n"); | |
707 | goto out; | |
708 | } | |
709 | ||
710 | init_completion(&tresult.completion); | |
711 | ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, | |
712 | tcrypt_complete, &tresult); | |
713 | ||
f074f7b1 HG |
714 | output = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL); |
715 | if (!output) | |
716 | goto out_nomem; | |
717 | ||
beb63da7 DM |
718 | for (i = 0; speed[i].blen != 0; i++) { |
719 | if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) { | |
720 | pr_err("template (%u) too big for tvmem (%lu)\n", | |
721 | speed[i].blen, TVMEMSIZE * PAGE_SIZE); | |
722 | break; | |
723 | } | |
724 | ||
725 | pr_info("test%3u " | |
726 | "(%5u byte blocks,%5u bytes per update,%4u updates): ", | |
727 | i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen); | |
728 | ||
729 | ahash_request_set_crypt(req, sg, output, speed[i].plen); | |
730 | ||
3e3dc25f | 731 | if (secs) |
beb63da7 | 732 | ret = test_ahash_jiffies(req, speed[i].blen, |
3e3dc25f | 733 | speed[i].plen, output, secs); |
beb63da7 DM |
734 | else |
735 | ret = test_ahash_cycles(req, speed[i].blen, | |
736 | speed[i].plen, output); | |
737 | ||
738 | if (ret) { | |
739 | pr_err("hashing failed ret=%d\n", ret); | |
740 | break; | |
741 | } | |
742 | } | |
743 | ||
f074f7b1 HG |
744 | kfree(output); |
745 | ||
746 | out_nomem: | |
beb63da7 DM |
747 | ahash_request_free(req); |
748 | ||
749 | out: | |
750 | crypto_free_ahash(tfm); | |
751 | } | |
752 | ||
0660511c HX |
753 | static void test_ahash_speed(const char *algo, unsigned int secs, |
754 | struct hash_speed *speed) | |
755 | { | |
756 | return test_ahash_speed_common(algo, secs, speed, 0); | |
757 | } | |
758 | ||
759 | static void test_hash_speed(const char *algo, unsigned int secs, | |
760 | struct hash_speed *speed) | |
761 | { | |
762 | return test_ahash_speed_common(algo, secs, speed, CRYPTO_ALG_ASYNC); | |
763 | } | |
764 | ||
7166e589 | 765 | static inline int do_one_acipher_op(struct skcipher_request *req, int ret) |
3f3baf35 JK |
766 | { |
767 | if (ret == -EINPROGRESS || ret == -EBUSY) { | |
768 | struct tcrypt_result *tr = req->base.data; | |
769 | ||
8a45ac12 | 770 | wait_for_completion(&tr->completion); |
16735d02 | 771 | reinit_completion(&tr->completion); |
8a45ac12 | 772 | ret = tr->err; |
3f3baf35 JK |
773 | } |
774 | ||
775 | return ret; | |
776 | } | |
777 | ||
7166e589 | 778 | static int test_acipher_jiffies(struct skcipher_request *req, int enc, |
3e3dc25f | 779 | int blen, int secs) |
3f3baf35 JK |
780 | { |
781 | unsigned long start, end; | |
782 | int bcount; | |
783 | int ret; | |
784 | ||
3e3dc25f | 785 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
3f3baf35 JK |
786 | time_before(jiffies, end); bcount++) { |
787 | if (enc) | |
788 | ret = do_one_acipher_op(req, | |
7166e589 | 789 | crypto_skcipher_encrypt(req)); |
3f3baf35 JK |
790 | else |
791 | ret = do_one_acipher_op(req, | |
7166e589 | 792 | crypto_skcipher_decrypt(req)); |
3f3baf35 JK |
793 | |
794 | if (ret) | |
795 | return ret; | |
796 | } | |
797 | ||
798 | pr_cont("%d operations in %d seconds (%ld bytes)\n", | |
3e3dc25f | 799 | bcount, secs, (long)bcount * blen); |
3f3baf35 JK |
800 | return 0; |
801 | } | |
802 | ||
7166e589 | 803 | static int test_acipher_cycles(struct skcipher_request *req, int enc, |
3f3baf35 JK |
804 | int blen) |
805 | { | |
806 | unsigned long cycles = 0; | |
807 | int ret = 0; | |
808 | int i; | |
809 | ||
810 | /* Warm-up run. */ | |
811 | for (i = 0; i < 4; i++) { | |
812 | if (enc) | |
813 | ret = do_one_acipher_op(req, | |
7166e589 | 814 | crypto_skcipher_encrypt(req)); |
3f3baf35 JK |
815 | else |
816 | ret = do_one_acipher_op(req, | |
7166e589 | 817 | crypto_skcipher_decrypt(req)); |
3f3baf35 JK |
818 | |
819 | if (ret) | |
820 | goto out; | |
821 | } | |
822 | ||
823 | /* The real thing. */ | |
824 | for (i = 0; i < 8; i++) { | |
825 | cycles_t start, end; | |
826 | ||
827 | start = get_cycles(); | |
828 | if (enc) | |
829 | ret = do_one_acipher_op(req, | |
7166e589 | 830 | crypto_skcipher_encrypt(req)); |
3f3baf35 JK |
831 | else |
832 | ret = do_one_acipher_op(req, | |
7166e589 | 833 | crypto_skcipher_decrypt(req)); |
3f3baf35 JK |
834 | end = get_cycles(); |
835 | ||
836 | if (ret) | |
837 | goto out; | |
838 | ||
839 | cycles += end - start; | |
840 | } | |
841 | ||
842 | out: | |
843 | if (ret == 0) | |
844 | pr_cont("1 operation in %lu cycles (%d bytes)\n", | |
845 | (cycles + 4) / 8, blen); | |
846 | ||
847 | return ret; | |
848 | } | |
849 | ||
7166e589 HX |
850 | static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, |
851 | struct cipher_speed_template *template, | |
852 | unsigned int tcount, u8 *keysize, bool async) | |
3f3baf35 | 853 | { |
de197533 | 854 | unsigned int ret, i, j, k, iv_len; |
3f3baf35 JK |
855 | struct tcrypt_result tresult; |
856 | const char *key; | |
857 | char iv[128]; | |
7166e589 HX |
858 | struct skcipher_request *req; |
859 | struct crypto_skcipher *tfm; | |
3f3baf35 JK |
860 | const char *e; |
861 | u32 *b_size; | |
862 | ||
863 | if (enc == ENCRYPT) | |
864 | e = "encryption"; | |
865 | else | |
866 | e = "decryption"; | |
867 | ||
3f3baf35 JK |
868 | init_completion(&tresult.completion); |
869 | ||
7166e589 | 870 | tfm = crypto_alloc_skcipher(algo, 0, async ? 0 : CRYPTO_ALG_ASYNC); |
3f3baf35 JK |
871 | |
872 | if (IS_ERR(tfm)) { | |
873 | pr_err("failed to load transform for %s: %ld\n", algo, | |
874 | PTR_ERR(tfm)); | |
875 | return; | |
876 | } | |
877 | ||
263a8df0 | 878 | pr_info("\ntesting speed of async %s (%s) %s\n", algo, |
7166e589 | 879 | get_driver_name(crypto_skcipher, tfm), e); |
263a8df0 | 880 | |
7166e589 | 881 | req = skcipher_request_alloc(tfm, GFP_KERNEL); |
3f3baf35 JK |
882 | if (!req) { |
883 | pr_err("tcrypt: skcipher: Failed to allocate request for %s\n", | |
884 | algo); | |
885 | goto out; | |
886 | } | |
887 | ||
7166e589 HX |
888 | skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
889 | tcrypt_complete, &tresult); | |
3f3baf35 JK |
890 | |
891 | i = 0; | |
892 | do { | |
893 | b_size = block_sizes; | |
894 | ||
895 | do { | |
896 | struct scatterlist sg[TVMEMSIZE]; | |
897 | ||
898 | if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { | |
899 | pr_err("template (%u) too big for " | |
900 | "tvmem (%lu)\n", *keysize + *b_size, | |
901 | TVMEMSIZE * PAGE_SIZE); | |
902 | goto out_free_req; | |
903 | } | |
904 | ||
905 | pr_info("test %u (%d bit key, %d byte blocks): ", i, | |
906 | *keysize * 8, *b_size); | |
907 | ||
908 | memset(tvmem[0], 0xff, PAGE_SIZE); | |
909 | ||
910 | /* set key, plain text and IV */ | |
911 | key = tvmem[0]; | |
912 | for (j = 0; j < tcount; j++) { | |
913 | if (template[j].klen == *keysize) { | |
914 | key = template[j].key; | |
915 | break; | |
916 | } | |
917 | } | |
918 | ||
7166e589 | 919 | crypto_skcipher_clear_flags(tfm, ~0); |
3f3baf35 | 920 | |
7166e589 | 921 | ret = crypto_skcipher_setkey(tfm, key, *keysize); |
3f3baf35 JK |
922 | if (ret) { |
923 | pr_err("setkey() failed flags=%x\n", | |
7166e589 | 924 | crypto_skcipher_get_flags(tfm)); |
3f3baf35 JK |
925 | goto out_free_req; |
926 | } | |
927 | ||
de197533 | 928 | k = *keysize + *b_size; |
007ee8de HG |
929 | sg_init_table(sg, DIV_ROUND_UP(k, PAGE_SIZE)); |
930 | ||
de197533 NR |
931 | if (k > PAGE_SIZE) { |
932 | sg_set_buf(sg, tvmem[0] + *keysize, | |
3f3baf35 | 933 | PAGE_SIZE - *keysize); |
de197533 NR |
934 | k -= PAGE_SIZE; |
935 | j = 1; | |
936 | while (k > PAGE_SIZE) { | |
937 | sg_set_buf(sg + j, tvmem[j], PAGE_SIZE); | |
938 | memset(tvmem[j], 0xff, PAGE_SIZE); | |
939 | j++; | |
940 | k -= PAGE_SIZE; | |
941 | } | |
942 | sg_set_buf(sg + j, tvmem[j], k); | |
943 | memset(tvmem[j], 0xff, k); | |
944 | } else { | |
945 | sg_set_buf(sg, tvmem[0] + *keysize, *b_size); | |
3f3baf35 JK |
946 | } |
947 | ||
7166e589 | 948 | iv_len = crypto_skcipher_ivsize(tfm); |
3f3baf35 JK |
949 | if (iv_len) |
950 | memset(&iv, 0xff, iv_len); | |
951 | ||
7166e589 | 952 | skcipher_request_set_crypt(req, sg, sg, *b_size, iv); |
3f3baf35 | 953 | |
3e3dc25f | 954 | if (secs) |
3f3baf35 | 955 | ret = test_acipher_jiffies(req, enc, |
3e3dc25f | 956 | *b_size, secs); |
3f3baf35 JK |
957 | else |
958 | ret = test_acipher_cycles(req, enc, | |
959 | *b_size); | |
960 | ||
961 | if (ret) { | |
962 | pr_err("%s() failed flags=%x\n", e, | |
7166e589 | 963 | crypto_skcipher_get_flags(tfm)); |
3f3baf35 JK |
964 | break; |
965 | } | |
966 | b_size++; | |
967 | i++; | |
968 | } while (*b_size); | |
969 | keysize++; | |
970 | } while (*keysize); | |
971 | ||
972 | out_free_req: | |
7166e589 | 973 | skcipher_request_free(req); |
3f3baf35 | 974 | out: |
7166e589 HX |
975 | crypto_free_skcipher(tfm); |
976 | } | |
977 | ||
978 | static void test_acipher_speed(const char *algo, int enc, unsigned int secs, | |
979 | struct cipher_speed_template *template, | |
980 | unsigned int tcount, u8 *keysize) | |
981 | { | |
982 | return test_skcipher_speed(algo, enc, secs, template, tcount, keysize, | |
983 | true); | |
984 | } | |
985 | ||
986 | static void test_cipher_speed(const char *algo, int enc, unsigned int secs, | |
987 | struct cipher_speed_template *template, | |
988 | unsigned int tcount, u8 *keysize) | |
989 | { | |
990 | return test_skcipher_speed(algo, enc, secs, template, tcount, keysize, | |
991 | false); | |
3f3baf35 JK |
992 | } |
993 | ||
ef2736fc | 994 | static void test_available(void) |
1da177e4 LT |
995 | { |
996 | char **name = check; | |
ef2736fc | 997 | |
1da177e4 LT |
998 | while (*name) { |
999 | printk("alg %s ", *name); | |
6158efc0 | 1000 | printk(crypto_has_alg(*name, 0, 0) ? |
e4d5b79c | 1001 | "found\n" : "not found\n"); |
1da177e4 | 1002 | name++; |
ef2736fc | 1003 | } |
1da177e4 LT |
1004 | } |
1005 | ||
01b32324 HX |
1006 | static inline int tcrypt_test(const char *alg) |
1007 | { | |
4e033a6b JW |
1008 | int ret; |
1009 | ||
76512f2d RV |
1010 | pr_debug("testing %s\n", alg); |
1011 | ||
4e033a6b JW |
1012 | ret = alg_test(alg, alg, 0, 0); |
1013 | /* non-fips algs return -EINVAL in fips mode */ | |
1014 | if (fips_enabled && ret == -EINVAL) | |
1015 | ret = 0; | |
1016 | return ret; | |
01b32324 HX |
1017 | } |
1018 | ||
8606813a | 1019 | static int do_test(const char *alg, u32 type, u32 mask, int m) |
01b32324 HX |
1020 | { |
1021 | int i; | |
4e033a6b | 1022 | int ret = 0; |
01b32324 HX |
1023 | |
1024 | switch (m) { | |
1da177e4 | 1025 | case 0: |
8606813a HX |
1026 | if (alg) { |
1027 | if (!crypto_has_alg(alg, type, | |
1028 | mask ?: CRYPTO_ALG_TYPE_MASK)) | |
1029 | ret = -ENOENT; | |
1030 | break; | |
1031 | } | |
1032 | ||
01b32324 | 1033 | for (i = 1; i < 200; i++) |
8606813a | 1034 | ret += do_test(NULL, 0, 0, i); |
1da177e4 LT |
1035 | break; |
1036 | ||
1037 | case 1: | |
4e033a6b | 1038 | ret += tcrypt_test("md5"); |
1da177e4 LT |
1039 | break; |
1040 | ||
1041 | case 2: | |
4e033a6b | 1042 | ret += tcrypt_test("sha1"); |
1da177e4 LT |
1043 | break; |
1044 | ||
1045 | case 3: | |
4e033a6b JW |
1046 | ret += tcrypt_test("ecb(des)"); |
1047 | ret += tcrypt_test("cbc(des)"); | |
8163fc30 | 1048 | ret += tcrypt_test("ctr(des)"); |
1da177e4 LT |
1049 | break; |
1050 | ||
1051 | case 4: | |
4e033a6b JW |
1052 | ret += tcrypt_test("ecb(des3_ede)"); |
1053 | ret += tcrypt_test("cbc(des3_ede)"); | |
e080b17a | 1054 | ret += tcrypt_test("ctr(des3_ede)"); |
1da177e4 LT |
1055 | break; |
1056 | ||
1057 | case 5: | |
4e033a6b | 1058 | ret += tcrypt_test("md4"); |
1da177e4 | 1059 | break; |
ef2736fc | 1060 | |
1da177e4 | 1061 | case 6: |
4e033a6b | 1062 | ret += tcrypt_test("sha256"); |
1da177e4 | 1063 | break; |
ef2736fc | 1064 | |
1da177e4 | 1065 | case 7: |
4e033a6b JW |
1066 | ret += tcrypt_test("ecb(blowfish)"); |
1067 | ret += tcrypt_test("cbc(blowfish)"); | |
85b63e34 | 1068 | ret += tcrypt_test("ctr(blowfish)"); |
1da177e4 LT |
1069 | break; |
1070 | ||
1071 | case 8: | |
4e033a6b JW |
1072 | ret += tcrypt_test("ecb(twofish)"); |
1073 | ret += tcrypt_test("cbc(twofish)"); | |
573da620 | 1074 | ret += tcrypt_test("ctr(twofish)"); |
bee3a90e | 1075 | ret += tcrypt_test("lrw(twofish)"); |
131f7541 | 1076 | ret += tcrypt_test("xts(twofish)"); |
1da177e4 | 1077 | break; |
ef2736fc | 1078 | |
1da177e4 | 1079 | case 9: |
4e033a6b | 1080 | ret += tcrypt_test("ecb(serpent)"); |
9d25917d JK |
1081 | ret += tcrypt_test("cbc(serpent)"); |
1082 | ret += tcrypt_test("ctr(serpent)"); | |
87aae4bf | 1083 | ret += tcrypt_test("lrw(serpent)"); |
5209c07a | 1084 | ret += tcrypt_test("xts(serpent)"); |
1da177e4 LT |
1085 | break; |
1086 | ||
1087 | case 10: | |
4e033a6b JW |
1088 | ret += tcrypt_test("ecb(aes)"); |
1089 | ret += tcrypt_test("cbc(aes)"); | |
1090 | ret += tcrypt_test("lrw(aes)"); | |
1091 | ret += tcrypt_test("xts(aes)"); | |
1092 | ret += tcrypt_test("ctr(aes)"); | |
1093 | ret += tcrypt_test("rfc3686(ctr(aes))"); | |
1da177e4 LT |
1094 | break; |
1095 | ||
1096 | case 11: | |
4e033a6b | 1097 | ret += tcrypt_test("sha384"); |
1da177e4 | 1098 | break; |
ef2736fc | 1099 | |
1da177e4 | 1100 | case 12: |
4e033a6b | 1101 | ret += tcrypt_test("sha512"); |
1da177e4 LT |
1102 | break; |
1103 | ||
1104 | case 13: | |
4e033a6b | 1105 | ret += tcrypt_test("deflate"); |
1da177e4 LT |
1106 | break; |
1107 | ||
1108 | case 14: | |
4e033a6b | 1109 | ret += tcrypt_test("ecb(cast5)"); |
a2c58260 JG |
1110 | ret += tcrypt_test("cbc(cast5)"); |
1111 | ret += tcrypt_test("ctr(cast5)"); | |
1da177e4 LT |
1112 | break; |
1113 | ||
1114 | case 15: | |
4e033a6b | 1115 | ret += tcrypt_test("ecb(cast6)"); |
9b8b0405 JG |
1116 | ret += tcrypt_test("cbc(cast6)"); |
1117 | ret += tcrypt_test("ctr(cast6)"); | |
1118 | ret += tcrypt_test("lrw(cast6)"); | |
1119 | ret += tcrypt_test("xts(cast6)"); | |
1da177e4 LT |
1120 | break; |
1121 | ||
1122 | case 16: | |
4e033a6b | 1123 | ret += tcrypt_test("ecb(arc4)"); |
1da177e4 LT |
1124 | break; |
1125 | ||
1126 | case 17: | |
4e033a6b | 1127 | ret += tcrypt_test("michael_mic"); |
1da177e4 LT |
1128 | break; |
1129 | ||
1130 | case 18: | |
4e033a6b | 1131 | ret += tcrypt_test("crc32c"); |
1da177e4 LT |
1132 | break; |
1133 | ||
1134 | case 19: | |
4e033a6b | 1135 | ret += tcrypt_test("ecb(tea)"); |
1da177e4 LT |
1136 | break; |
1137 | ||
1138 | case 20: | |
4e033a6b | 1139 | ret += tcrypt_test("ecb(xtea)"); |
1da177e4 LT |
1140 | break; |
1141 | ||
1142 | case 21: | |
4e033a6b | 1143 | ret += tcrypt_test("ecb(khazad)"); |
1da177e4 LT |
1144 | break; |
1145 | ||
1146 | case 22: | |
4e033a6b | 1147 | ret += tcrypt_test("wp512"); |
1da177e4 LT |
1148 | break; |
1149 | ||
1150 | case 23: | |
4e033a6b | 1151 | ret += tcrypt_test("wp384"); |
1da177e4 LT |
1152 | break; |
1153 | ||
1154 | case 24: | |
4e033a6b | 1155 | ret += tcrypt_test("wp256"); |
1da177e4 LT |
1156 | break; |
1157 | ||
1158 | case 25: | |
4e033a6b | 1159 | ret += tcrypt_test("ecb(tnepres)"); |
1da177e4 LT |
1160 | break; |
1161 | ||
1162 | case 26: | |
4e033a6b JW |
1163 | ret += tcrypt_test("ecb(anubis)"); |
1164 | ret += tcrypt_test("cbc(anubis)"); | |
1da177e4 LT |
1165 | break; |
1166 | ||
1167 | case 27: | |
4e033a6b | 1168 | ret += tcrypt_test("tgr192"); |
1da177e4 LT |
1169 | break; |
1170 | ||
1171 | case 28: | |
4e033a6b | 1172 | ret += tcrypt_test("tgr160"); |
1da177e4 LT |
1173 | break; |
1174 | ||
1175 | case 29: | |
4e033a6b | 1176 | ret += tcrypt_test("tgr128"); |
1da177e4 | 1177 | break; |
2998db37 | 1178 | |
fb4f10ed | 1179 | case 30: |
4e033a6b | 1180 | ret += tcrypt_test("ecb(xeta)"); |
fb4f10ed | 1181 | break; |
1da177e4 | 1182 | |
90831639 | 1183 | case 31: |
4e033a6b | 1184 | ret += tcrypt_test("pcbc(fcrypt)"); |
90831639 DH |
1185 | break; |
1186 | ||
02ab5a70 | 1187 | case 32: |
4e033a6b JW |
1188 | ret += tcrypt_test("ecb(camellia)"); |
1189 | ret += tcrypt_test("cbc(camellia)"); | |
54216bbd JK |
1190 | ret += tcrypt_test("ctr(camellia)"); |
1191 | ret += tcrypt_test("lrw(camellia)"); | |
1192 | ret += tcrypt_test("xts(camellia)"); | |
02ab5a70 | 1193 | break; |
93b5e86a | 1194 | |
cd12fb90 | 1195 | case 33: |
4e033a6b | 1196 | ret += tcrypt_test("sha224"); |
cd12fb90 | 1197 | break; |
02ab5a70 | 1198 | |
2407d608 | 1199 | case 34: |
4e033a6b | 1200 | ret += tcrypt_test("salsa20"); |
2407d608 TSH |
1201 | break; |
1202 | ||
8df213d9 | 1203 | case 35: |
4e033a6b | 1204 | ret += tcrypt_test("gcm(aes)"); |
8df213d9 HX |
1205 | break; |
1206 | ||
0b77abb3 | 1207 | case 36: |
4e033a6b | 1208 | ret += tcrypt_test("lzo"); |
0b77abb3 ZS |
1209 | break; |
1210 | ||
93cc74e0 | 1211 | case 37: |
4e033a6b | 1212 | ret += tcrypt_test("ccm(aes)"); |
93cc74e0 JL |
1213 | break; |
1214 | ||
76cb9521 | 1215 | case 38: |
4e033a6b | 1216 | ret += tcrypt_test("cts(cbc(aes))"); |
76cb9521 KC |
1217 | break; |
1218 | ||
fd4adf1a | 1219 | case 39: |
4e033a6b | 1220 | ret += tcrypt_test("rmd128"); |
fd4adf1a AKR |
1221 | break; |
1222 | ||
1223 | case 40: | |
4e033a6b | 1224 | ret += tcrypt_test("rmd160"); |
fd4adf1a AKR |
1225 | break; |
1226 | ||
2998db37 | 1227 | case 41: |
4e033a6b | 1228 | ret += tcrypt_test("rmd256"); |
2998db37 AKR |
1229 | break; |
1230 | ||
1231 | case 42: | |
4e033a6b | 1232 | ret += tcrypt_test("rmd320"); |
01b32324 HX |
1233 | break; |
1234 | ||
1235 | case 43: | |
4e033a6b | 1236 | ret += tcrypt_test("ecb(seed)"); |
2998db37 AKR |
1237 | break; |
1238 | ||
0c01aed5 | 1239 | case 44: |
4e033a6b | 1240 | ret += tcrypt_test("zlib"); |
0c01aed5 GU |
1241 | break; |
1242 | ||
5d667322 | 1243 | case 45: |
4e033a6b | 1244 | ret += tcrypt_test("rfc4309(ccm(aes))"); |
5d667322 JW |
1245 | break; |
1246 | ||
54216bbd JK |
1247 | case 46: |
1248 | ret += tcrypt_test("ghash"); | |
1249 | break; | |
1250 | ||
68411521 HX |
1251 | case 47: |
1252 | ret += tcrypt_test("crct10dif"); | |
1253 | break; | |
1254 | ||
79cc6ab8 | 1255 | case 48: |
1256 | ret += tcrypt_test("sha3-224"); | |
1257 | break; | |
1258 | ||
1259 | case 49: | |
1260 | ret += tcrypt_test("sha3-256"); | |
1261 | break; | |
1262 | ||
1263 | case 50: | |
1264 | ret += tcrypt_test("sha3-384"); | |
1265 | break; | |
1266 | ||
1267 | case 51: | |
1268 | ret += tcrypt_test("sha3-512"); | |
1269 | break; | |
1270 | ||
b7e27530 GBY |
1271 | case 52: |
1272 | ret += tcrypt_test("sm3"); | |
1273 | break; | |
1274 | ||
1da177e4 | 1275 | case 100: |
4e033a6b | 1276 | ret += tcrypt_test("hmac(md5)"); |
1da177e4 | 1277 | break; |
ef2736fc | 1278 | |
1da177e4 | 1279 | case 101: |
4e033a6b | 1280 | ret += tcrypt_test("hmac(sha1)"); |
1da177e4 | 1281 | break; |
ef2736fc | 1282 | |
1da177e4 | 1283 | case 102: |
4e033a6b | 1284 | ret += tcrypt_test("hmac(sha256)"); |
1da177e4 LT |
1285 | break; |
1286 | ||
a28091ae | 1287 | case 103: |
4e033a6b | 1288 | ret += tcrypt_test("hmac(sha384)"); |
a28091ae AD |
1289 | break; |
1290 | ||
1291 | case 104: | |
4e033a6b | 1292 | ret += tcrypt_test("hmac(sha512)"); |
a28091ae | 1293 | break; |
38ed9ab2 | 1294 | |
cd12fb90 | 1295 | case 105: |
4e033a6b | 1296 | ret += tcrypt_test("hmac(sha224)"); |
cd12fb90 | 1297 | break; |
1da177e4 | 1298 | |
38ed9ab2 | 1299 | case 106: |
4e033a6b | 1300 | ret += tcrypt_test("xcbc(aes)"); |
38ed9ab2 HX |
1301 | break; |
1302 | ||
fd4adf1a | 1303 | case 107: |
4e033a6b | 1304 | ret += tcrypt_test("hmac(rmd128)"); |
fd4adf1a AKR |
1305 | break; |
1306 | ||
1307 | case 108: | |
4e033a6b | 1308 | ret += tcrypt_test("hmac(rmd160)"); |
fd4adf1a AKR |
1309 | break; |
1310 | ||
f1939f7c SW |
1311 | case 109: |
1312 | ret += tcrypt_test("vmac(aes)"); | |
1313 | break; | |
93b5e86a | 1314 | |
a482b081 SZ |
1315 | case 110: |
1316 | ret += tcrypt_test("hmac(crc32)"); | |
1317 | break; | |
f1939f7c | 1318 | |
98eca72f | 1319 | case 111: |
1320 | ret += tcrypt_test("hmac(sha3-224)"); | |
1321 | break; | |
1322 | ||
1323 | case 112: | |
1324 | ret += tcrypt_test("hmac(sha3-256)"); | |
1325 | break; | |
1326 | ||
1327 | case 113: | |
1328 | ret += tcrypt_test("hmac(sha3-384)"); | |
1329 | break; | |
1330 | ||
1331 | case 114: | |
1332 | ret += tcrypt_test("hmac(sha3-512)"); | |
1333 | break; | |
1334 | ||
e08ca2da | 1335 | case 150: |
4e033a6b | 1336 | ret += tcrypt_test("ansi_cprng"); |
e08ca2da JW |
1337 | break; |
1338 | ||
69435b94 AH |
1339 | case 151: |
1340 | ret += tcrypt_test("rfc4106(gcm(aes))"); | |
1341 | break; | |
1342 | ||
e9b7441a JK |
1343 | case 152: |
1344 | ret += tcrypt_test("rfc4543(gcm(aes))"); | |
1345 | break; | |
1346 | ||
93b5e86a JK |
1347 | case 153: |
1348 | ret += tcrypt_test("cmac(aes)"); | |
1349 | break; | |
1350 | ||
1351 | case 154: | |
1352 | ret += tcrypt_test("cmac(des3_ede)"); | |
1353 | break; | |
1354 | ||
bbf9c893 HG |
1355 | case 155: |
1356 | ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))"); | |
1357 | break; | |
1358 | ||
bca4feb0 HG |
1359 | case 156: |
1360 | ret += tcrypt_test("authenc(hmac(md5),ecb(cipher_null))"); | |
1361 | break; | |
1362 | ||
1363 | case 157: | |
1364 | ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))"); | |
1365 | break; | |
5208ed2c NL |
1366 | case 181: |
1367 | ret += tcrypt_test("authenc(hmac(sha1),cbc(des))"); | |
1368 | break; | |
1369 | case 182: | |
1370 | ret += tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))"); | |
1371 | break; | |
1372 | case 183: | |
1373 | ret += tcrypt_test("authenc(hmac(sha224),cbc(des))"); | |
1374 | break; | |
1375 | case 184: | |
1376 | ret += tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))"); | |
1377 | break; | |
1378 | case 185: | |
1379 | ret += tcrypt_test("authenc(hmac(sha256),cbc(des))"); | |
1380 | break; | |
1381 | case 186: | |
1382 | ret += tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))"); | |
1383 | break; | |
1384 | case 187: | |
1385 | ret += tcrypt_test("authenc(hmac(sha384),cbc(des))"); | |
1386 | break; | |
1387 | case 188: | |
1388 | ret += tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))"); | |
1389 | break; | |
1390 | case 189: | |
1391 | ret += tcrypt_test("authenc(hmac(sha512),cbc(des))"); | |
1392 | break; | |
1393 | case 190: | |
1394 | ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))"); | |
1395 | break; | |
ebfd9bcf | 1396 | case 200: |
cba83564 | 1397 | test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, |
477035c2 | 1398 | speed_template_16_24_32); |
cba83564 | 1399 | test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, |
477035c2 | 1400 | speed_template_16_24_32); |
cba83564 | 1401 | test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, |
477035c2 | 1402 | speed_template_16_24_32); |
cba83564 | 1403 | test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, |
477035c2 | 1404 | speed_template_16_24_32); |
f3d1044c | 1405 | test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, |
477035c2 | 1406 | speed_template_32_40_48); |
f3d1044c | 1407 | test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, |
477035c2 | 1408 | speed_template_32_40_48); |
f19f5111 | 1409 | test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, |
b66ad0b7 | 1410 | speed_template_32_64); |
f19f5111 | 1411 | test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, |
b66ad0b7 | 1412 | speed_template_32_64); |
1503a24f HX |
1413 | test_cipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0, |
1414 | speed_template_16_24_32); | |
1415 | test_cipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0, | |
1416 | speed_template_16_24_32); | |
9996e342 JG |
1417 | test_cipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0, |
1418 | speed_template_16_24_32); | |
1419 | test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, | |
1420 | speed_template_16_24_32); | |
ebfd9bcf HW |
1421 | break; |
1422 | ||
1423 | case 201: | |
cba83564 | 1424 | test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec, |
da7f033d | 1425 | des3_speed_template, DES3_SPEED_VECTORS, |
477035c2 | 1426 | speed_template_24); |
cba83564 | 1427 | test_cipher_speed("ecb(des3_ede)", DECRYPT, sec, |
da7f033d | 1428 | des3_speed_template, DES3_SPEED_VECTORS, |
477035c2 | 1429 | speed_template_24); |
cba83564 | 1430 | test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec, |
da7f033d | 1431 | des3_speed_template, DES3_SPEED_VECTORS, |
477035c2 | 1432 | speed_template_24); |
cba83564 | 1433 | test_cipher_speed("cbc(des3_ede)", DECRYPT, sec, |
da7f033d | 1434 | des3_speed_template, DES3_SPEED_VECTORS, |
477035c2 | 1435 | speed_template_24); |
87131507 JK |
1436 | test_cipher_speed("ctr(des3_ede)", ENCRYPT, sec, |
1437 | des3_speed_template, DES3_SPEED_VECTORS, | |
1438 | speed_template_24); | |
1439 | test_cipher_speed("ctr(des3_ede)", DECRYPT, sec, | |
1440 | des3_speed_template, DES3_SPEED_VECTORS, | |
1441 | speed_template_24); | |
ebfd9bcf HW |
1442 | break; |
1443 | ||
1444 | case 202: | |
cba83564 | 1445 | test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, |
477035c2 | 1446 | speed_template_16_24_32); |
cba83564 | 1447 | test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, |
477035c2 | 1448 | speed_template_16_24_32); |
cba83564 | 1449 | test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, |
477035c2 | 1450 | speed_template_16_24_32); |
cba83564 | 1451 | test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, |
477035c2 | 1452 | speed_template_16_24_32); |
ee5002a5 JK |
1453 | test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, |
1454 | speed_template_16_24_32); | |
1455 | test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, | |
1456 | speed_template_16_24_32); | |
bee3a90e JK |
1457 | test_cipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0, |
1458 | speed_template_32_40_48); | |
1459 | test_cipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0, | |
1460 | speed_template_32_40_48); | |
131f7541 JK |
1461 | test_cipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0, |
1462 | speed_template_32_48_64); | |
1463 | test_cipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0, | |
1464 | speed_template_32_48_64); | |
ebfd9bcf HW |
1465 | break; |
1466 | ||
1467 | case 203: | |
cba83564 | 1468 | test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, |
477035c2 | 1469 | speed_template_8_32); |
cba83564 | 1470 | test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, |
477035c2 | 1471 | speed_template_8_32); |
cba83564 | 1472 | test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, |
477035c2 | 1473 | speed_template_8_32); |
cba83564 | 1474 | test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, |
477035c2 | 1475 | speed_template_8_32); |
7d47b86c JK |
1476 | test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0, |
1477 | speed_template_8_32); | |
1478 | test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0, | |
1479 | speed_template_8_32); | |
ebfd9bcf HW |
1480 | break; |
1481 | ||
1482 | case 204: | |
cba83564 | 1483 | test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, |
477035c2 | 1484 | speed_template_8); |
cba83564 | 1485 | test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, |
477035c2 | 1486 | speed_template_8); |
cba83564 | 1487 | test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, |
477035c2 | 1488 | speed_template_8); |
cba83564 | 1489 | test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, |
477035c2 | 1490 | speed_template_8); |
ebfd9bcf HW |
1491 | break; |
1492 | ||
02ab5a70 NT |
1493 | case 205: |
1494 | test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, | |
477035c2 | 1495 | speed_template_16_24_32); |
02ab5a70 | 1496 | test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, |
477035c2 | 1497 | speed_template_16_24_32); |
02ab5a70 | 1498 | test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, |
477035c2 | 1499 | speed_template_16_24_32); |
02ab5a70 | 1500 | test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, |
477035c2 | 1501 | speed_template_16_24_32); |
4de59337 JK |
1502 | test_cipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0, |
1503 | speed_template_16_24_32); | |
1504 | test_cipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0, | |
1505 | speed_template_16_24_32); | |
1506 | test_cipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0, | |
1507 | speed_template_32_40_48); | |
1508 | test_cipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0, | |
1509 | speed_template_32_40_48); | |
1510 | test_cipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0, | |
1511 | speed_template_32_48_64); | |
1512 | test_cipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0, | |
1513 | speed_template_32_48_64); | |
02ab5a70 NT |
1514 | break; |
1515 | ||
5de8f1b5 TSH |
1516 | case 206: |
1517 | test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0, | |
477035c2 | 1518 | speed_template_16_32); |
5de8f1b5 TSH |
1519 | break; |
1520 | ||
7fb7fe44 JK |
1521 | case 207: |
1522 | test_cipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0, | |
1523 | speed_template_16_32); | |
1524 | test_cipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0, | |
1525 | speed_template_16_32); | |
1526 | test_cipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0, | |
1527 | speed_template_16_32); | |
1528 | test_cipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0, | |
1529 | speed_template_16_32); | |
1530 | test_cipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0, | |
1531 | speed_template_16_32); | |
1532 | test_cipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0, | |
1533 | speed_template_16_32); | |
87aae4bf JK |
1534 | test_cipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0, |
1535 | speed_template_32_48); | |
1536 | test_cipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0, | |
1537 | speed_template_32_48); | |
5209c07a JK |
1538 | test_cipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0, |
1539 | speed_template_32_64); | |
1540 | test_cipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0, | |
1541 | speed_template_32_64); | |
7fb7fe44 JK |
1542 | break; |
1543 | ||
31b4cd29 JK |
1544 | case 208: |
1545 | test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0, | |
1546 | speed_template_8); | |
1547 | break; | |
1548 | ||
a2c58260 JG |
1549 | case 209: |
1550 | test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, | |
1551 | speed_template_8_16); | |
1552 | test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, | |
1553 | speed_template_8_16); | |
1554 | test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, | |
1555 | speed_template_8_16); | |
1556 | test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, | |
1557 | speed_template_8_16); | |
1558 | test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, | |
1559 | speed_template_8_16); | |
1560 | test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, | |
1561 | speed_template_8_16); | |
1562 | break; | |
1563 | ||
9b8b0405 JG |
1564 | case 210: |
1565 | test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, | |
1566 | speed_template_16_32); | |
1567 | test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, | |
1568 | speed_template_16_32); | |
1569 | test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, | |
1570 | speed_template_16_32); | |
1571 | test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, | |
1572 | speed_template_16_32); | |
1573 | test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, | |
1574 | speed_template_16_32); | |
1575 | test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, | |
1576 | speed_template_16_32); | |
1577 | test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, | |
1578 | speed_template_32_48); | |
1579 | test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, | |
1580 | speed_template_32_48); | |
1581 | test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, | |
1582 | speed_template_32_64); | |
1583 | test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, | |
1584 | speed_template_32_64); | |
1585 | break; | |
1586 | ||
53f52d7a TC |
1587 | case 211: |
1588 | test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec, | |
34a1c740 | 1589 | NULL, 0, 16, 16, aead_speed_template_20); |
1425d2d1 | 1590 | test_aead_speed("gcm(aes)", ENCRYPT, sec, |
f18611da | 1591 | NULL, 0, 16, 8, speed_template_16_24_32); |
53f52d7a TC |
1592 | break; |
1593 | ||
4e4aab63 HX |
1594 | case 212: |
1595 | test_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec, | |
34a1c740 | 1596 | NULL, 0, 16, 16, aead_speed_template_19); |
4e4aab63 HX |
1597 | break; |
1598 | ||
2dce063a MW |
1599 | case 213: |
1600 | test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, sec, | |
1601 | NULL, 0, 16, 8, aead_speed_template_36); | |
1602 | break; | |
1603 | ||
1604 | case 214: | |
1605 | test_cipher_speed("chacha20", ENCRYPT, sec, NULL, 0, | |
1606 | speed_template_32); | |
1607 | break; | |
1608 | ||
e8057928 | 1609 | case 300: |
8606813a HX |
1610 | if (alg) { |
1611 | test_hash_speed(alg, sec, generic_hash_speed_template); | |
1612 | break; | |
1613 | } | |
e8057928 | 1614 | /* fall through */ |
e8057928 | 1615 | case 301: |
e9d41164 | 1616 | test_hash_speed("md4", sec, generic_hash_speed_template); |
e8057928 | 1617 | if (mode > 300 && mode < 400) break; |
59517226 | 1618 | /* fall through */ |
e8057928 | 1619 | case 302: |
e9d41164 | 1620 | test_hash_speed("md5", sec, generic_hash_speed_template); |
e8057928 | 1621 | if (mode > 300 && mode < 400) break; |
59517226 | 1622 | /* fall through */ |
e8057928 | 1623 | case 303: |
e9d41164 | 1624 | test_hash_speed("sha1", sec, generic_hash_speed_template); |
e8057928 | 1625 | if (mode > 300 && mode < 400) break; |
59517226 | 1626 | /* fall through */ |
e8057928 | 1627 | case 304: |
e9d41164 | 1628 | test_hash_speed("sha256", sec, generic_hash_speed_template); |
e8057928 | 1629 | if (mode > 300 && mode < 400) break; |
59517226 | 1630 | /* fall through */ |
e8057928 | 1631 | case 305: |
e9d41164 | 1632 | test_hash_speed("sha384", sec, generic_hash_speed_template); |
e8057928 | 1633 | if (mode > 300 && mode < 400) break; |
59517226 | 1634 | /* fall through */ |
e8057928 | 1635 | case 306: |
e9d41164 | 1636 | test_hash_speed("sha512", sec, generic_hash_speed_template); |
e8057928 | 1637 | if (mode > 300 && mode < 400) break; |
59517226 | 1638 | /* fall through */ |
e8057928 | 1639 | case 307: |
e9d41164 | 1640 | test_hash_speed("wp256", sec, generic_hash_speed_template); |
e8057928 | 1641 | if (mode > 300 && mode < 400) break; |
59517226 | 1642 | /* fall through */ |
e8057928 | 1643 | case 308: |
e9d41164 | 1644 | test_hash_speed("wp384", sec, generic_hash_speed_template); |
e8057928 | 1645 | if (mode > 300 && mode < 400) break; |
59517226 | 1646 | /* fall through */ |
e8057928 | 1647 | case 309: |
e9d41164 | 1648 | test_hash_speed("wp512", sec, generic_hash_speed_template); |
e8057928 | 1649 | if (mode > 300 && mode < 400) break; |
59517226 | 1650 | /* fall through */ |
e8057928 | 1651 | case 310: |
e9d41164 | 1652 | test_hash_speed("tgr128", sec, generic_hash_speed_template); |
e8057928 | 1653 | if (mode > 300 && mode < 400) break; |
59517226 | 1654 | /* fall through */ |
e8057928 | 1655 | case 311: |
e9d41164 | 1656 | test_hash_speed("tgr160", sec, generic_hash_speed_template); |
e8057928 | 1657 | if (mode > 300 && mode < 400) break; |
59517226 | 1658 | /* fall through */ |
e8057928 | 1659 | case 312: |
e9d41164 | 1660 | test_hash_speed("tgr192", sec, generic_hash_speed_template); |
e8057928 | 1661 | if (mode > 300 && mode < 400) break; |
59517226 | 1662 | /* fall through */ |
cd12fb90 JL |
1663 | case 313: |
1664 | test_hash_speed("sha224", sec, generic_hash_speed_template); | |
1665 | if (mode > 300 && mode < 400) break; | |
59517226 | 1666 | /* fall through */ |
fd4adf1a AKR |
1667 | case 314: |
1668 | test_hash_speed("rmd128", sec, generic_hash_speed_template); | |
1669 | if (mode > 300 && mode < 400) break; | |
59517226 | 1670 | /* fall through */ |
fd4adf1a AKR |
1671 | case 315: |
1672 | test_hash_speed("rmd160", sec, generic_hash_speed_template); | |
1673 | if (mode > 300 && mode < 400) break; | |
59517226 | 1674 | /* fall through */ |
2998db37 AKR |
1675 | case 316: |
1676 | test_hash_speed("rmd256", sec, generic_hash_speed_template); | |
1677 | if (mode > 300 && mode < 400) break; | |
59517226 | 1678 | /* fall through */ |
2998db37 AKR |
1679 | case 317: |
1680 | test_hash_speed("rmd320", sec, generic_hash_speed_template); | |
1681 | if (mode > 300 && mode < 400) break; | |
59517226 | 1682 | /* fall through */ |
18bcc919 HY |
1683 | case 318: |
1684 | test_hash_speed("ghash-generic", sec, hash_speed_template_16); | |
1685 | if (mode > 300 && mode < 400) break; | |
59517226 | 1686 | /* fall through */ |
e3899e4d TC |
1687 | case 319: |
1688 | test_hash_speed("crc32c", sec, generic_hash_speed_template); | |
1689 | if (mode > 300 && mode < 400) break; | |
59517226 | 1690 | /* fall through */ |
68411521 HX |
1691 | case 320: |
1692 | test_hash_speed("crct10dif", sec, generic_hash_speed_template); | |
1693 | if (mode > 300 && mode < 400) break; | |
59517226 | 1694 | /* fall through */ |
2dce063a MW |
1695 | case 321: |
1696 | test_hash_speed("poly1305", sec, poly1305_speed_template); | |
1697 | if (mode > 300 && mode < 400) break; | |
59517226 | 1698 | /* fall through */ |
79cc6ab8 | 1699 | case 322: |
1700 | test_hash_speed("sha3-224", sec, generic_hash_speed_template); | |
1701 | if (mode > 300 && mode < 400) break; | |
59517226 | 1702 | /* fall through */ |
79cc6ab8 | 1703 | case 323: |
1704 | test_hash_speed("sha3-256", sec, generic_hash_speed_template); | |
1705 | if (mode > 300 && mode < 400) break; | |
59517226 | 1706 | /* fall through */ |
79cc6ab8 | 1707 | case 324: |
1708 | test_hash_speed("sha3-384", sec, generic_hash_speed_template); | |
1709 | if (mode > 300 && mode < 400) break; | |
59517226 | 1710 | /* fall through */ |
79cc6ab8 | 1711 | case 325: |
1712 | test_hash_speed("sha3-512", sec, generic_hash_speed_template); | |
1713 | if (mode > 300 && mode < 400) break; | |
59517226 | 1714 | /* fall through */ |
b7e27530 GBY |
1715 | case 326: |
1716 | test_hash_speed("sm3", sec, generic_hash_speed_template); | |
1717 | if (mode > 300 && mode < 400) break; | |
59517226 | 1718 | /* fall through */ |
e8057928 ML |
1719 | case 399: |
1720 | break; | |
1721 | ||
beb63da7 | 1722 | case 400: |
8606813a HX |
1723 | if (alg) { |
1724 | test_ahash_speed(alg, sec, generic_hash_speed_template); | |
1725 | break; | |
1726 | } | |
beb63da7 | 1727 | /* fall through */ |
beb63da7 DM |
1728 | case 401: |
1729 | test_ahash_speed("md4", sec, generic_hash_speed_template); | |
1730 | if (mode > 400 && mode < 500) break; | |
59517226 | 1731 | /* fall through */ |
beb63da7 DM |
1732 | case 402: |
1733 | test_ahash_speed("md5", sec, generic_hash_speed_template); | |
1734 | if (mode > 400 && mode < 500) break; | |
59517226 | 1735 | /* fall through */ |
beb63da7 DM |
1736 | case 403: |
1737 | test_ahash_speed("sha1", sec, generic_hash_speed_template); | |
1738 | if (mode > 400 && mode < 500) break; | |
59517226 | 1739 | /* fall through */ |
beb63da7 DM |
1740 | case 404: |
1741 | test_ahash_speed("sha256", sec, generic_hash_speed_template); | |
1742 | if (mode > 400 && mode < 500) break; | |
59517226 | 1743 | /* fall through */ |
beb63da7 DM |
1744 | case 405: |
1745 | test_ahash_speed("sha384", sec, generic_hash_speed_template); | |
1746 | if (mode > 400 && mode < 500) break; | |
59517226 | 1747 | /* fall through */ |
beb63da7 DM |
1748 | case 406: |
1749 | test_ahash_speed("sha512", sec, generic_hash_speed_template); | |
1750 | if (mode > 400 && mode < 500) break; | |
59517226 | 1751 | /* fall through */ |
beb63da7 DM |
1752 | case 407: |
1753 | test_ahash_speed("wp256", sec, generic_hash_speed_template); | |
1754 | if (mode > 400 && mode < 500) break; | |
59517226 | 1755 | /* fall through */ |
beb63da7 DM |
1756 | case 408: |
1757 | test_ahash_speed("wp384", sec, generic_hash_speed_template); | |
1758 | if (mode > 400 && mode < 500) break; | |
59517226 | 1759 | /* fall through */ |
beb63da7 DM |
1760 | case 409: |
1761 | test_ahash_speed("wp512", sec, generic_hash_speed_template); | |
1762 | if (mode > 400 && mode < 500) break; | |
59517226 | 1763 | /* fall through */ |
beb63da7 DM |
1764 | case 410: |
1765 | test_ahash_speed("tgr128", sec, generic_hash_speed_template); | |
1766 | if (mode > 400 && mode < 500) break; | |
59517226 | 1767 | /* fall through */ |
beb63da7 DM |
1768 | case 411: |
1769 | test_ahash_speed("tgr160", sec, generic_hash_speed_template); | |
1770 | if (mode > 400 && mode < 500) break; | |
59517226 | 1771 | /* fall through */ |
beb63da7 DM |
1772 | case 412: |
1773 | test_ahash_speed("tgr192", sec, generic_hash_speed_template); | |
1774 | if (mode > 400 && mode < 500) break; | |
59517226 | 1775 | /* fall through */ |
beb63da7 DM |
1776 | case 413: |
1777 | test_ahash_speed("sha224", sec, generic_hash_speed_template); | |
1778 | if (mode > 400 && mode < 500) break; | |
59517226 | 1779 | /* fall through */ |
beb63da7 DM |
1780 | case 414: |
1781 | test_ahash_speed("rmd128", sec, generic_hash_speed_template); | |
1782 | if (mode > 400 && mode < 500) break; | |
59517226 | 1783 | /* fall through */ |
beb63da7 DM |
1784 | case 415: |
1785 | test_ahash_speed("rmd160", sec, generic_hash_speed_template); | |
1786 | if (mode > 400 && mode < 500) break; | |
59517226 | 1787 | /* fall through */ |
beb63da7 DM |
1788 | case 416: |
1789 | test_ahash_speed("rmd256", sec, generic_hash_speed_template); | |
1790 | if (mode > 400 && mode < 500) break; | |
59517226 | 1791 | /* fall through */ |
beb63da7 DM |
1792 | case 417: |
1793 | test_ahash_speed("rmd320", sec, generic_hash_speed_template); | |
1794 | if (mode > 400 && mode < 500) break; | |
59517226 | 1795 | /* fall through */ |
79cc6ab8 | 1796 | case 418: |
1797 | test_ahash_speed("sha3-224", sec, generic_hash_speed_template); | |
1798 | if (mode > 400 && mode < 500) break; | |
59517226 | 1799 | /* fall through */ |
79cc6ab8 | 1800 | case 419: |
1801 | test_ahash_speed("sha3-256", sec, generic_hash_speed_template); | |
1802 | if (mode > 400 && mode < 500) break; | |
59517226 | 1803 | /* fall through */ |
79cc6ab8 | 1804 | case 420: |
1805 | test_ahash_speed("sha3-384", sec, generic_hash_speed_template); | |
1806 | if (mode > 400 && mode < 500) break; | |
59517226 | 1807 | /* fall through */ |
79cc6ab8 | 1808 | case 421: |
1809 | test_ahash_speed("sha3-512", sec, generic_hash_speed_template); | |
1810 | if (mode > 400 && mode < 500) break; | |
59517226 | 1811 | /* fall through */ |
087bcd22 MD |
1812 | case 422: |
1813 | test_mb_ahash_speed("sha1", sec, generic_hash_speed_template); | |
1814 | if (mode > 400 && mode < 500) break; | |
59517226 | 1815 | /* fall through */ |
087bcd22 MD |
1816 | case 423: |
1817 | test_mb_ahash_speed("sha256", sec, generic_hash_speed_template); | |
1818 | if (mode > 400 && mode < 500) break; | |
59517226 | 1819 | /* fall through */ |
14009c4b MD |
1820 | case 424: |
1821 | test_mb_ahash_speed("sha512", sec, generic_hash_speed_template); | |
1822 | if (mode > 400 && mode < 500) break; | |
59517226 | 1823 | /* fall through */ |
b7e27530 GBY |
1824 | case 425: |
1825 | test_mb_ahash_speed("sm3", sec, generic_hash_speed_template); | |
1826 | if (mode > 400 && mode < 500) break; | |
59517226 | 1827 | /* fall through */ |
beb63da7 DM |
1828 | case 499: |
1829 | break; | |
1830 | ||
3f3baf35 JK |
1831 | case 500: |
1832 | test_acipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, | |
1833 | speed_template_16_24_32); | |
1834 | test_acipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, | |
1835 | speed_template_16_24_32); | |
1836 | test_acipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, | |
1837 | speed_template_16_24_32); | |
1838 | test_acipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, | |
1839 | speed_template_16_24_32); | |
1840 | test_acipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, | |
1841 | speed_template_32_40_48); | |
1842 | test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, | |
1843 | speed_template_32_40_48); | |
1844 | test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, | |
b66ad0b7 | 1845 | speed_template_32_64); |
3f3baf35 | 1846 | test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, |
b66ad0b7 | 1847 | speed_template_32_64); |
1503a24f HX |
1848 | test_acipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0, |
1849 | speed_template_16_24_32); | |
1850 | test_acipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0, | |
1851 | speed_template_16_24_32); | |
3f3baf35 JK |
1852 | test_acipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0, |
1853 | speed_template_16_24_32); | |
1854 | test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, | |
1855 | speed_template_16_24_32); | |
de197533 NR |
1856 | test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0, |
1857 | speed_template_16_24_32); | |
1858 | test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0, | |
1859 | speed_template_16_24_32); | |
1860 | test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0, | |
1861 | speed_template_16_24_32); | |
1862 | test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0, | |
1863 | speed_template_16_24_32); | |
69d3150c JK |
1864 | test_acipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL, 0, |
1865 | speed_template_20_28_36); | |
1866 | test_acipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL, 0, | |
1867 | speed_template_20_28_36); | |
3f3baf35 JK |
1868 | break; |
1869 | ||
1870 | case 501: | |
1871 | test_acipher_speed("ecb(des3_ede)", ENCRYPT, sec, | |
1872 | des3_speed_template, DES3_SPEED_VECTORS, | |
1873 | speed_template_24); | |
1874 | test_acipher_speed("ecb(des3_ede)", DECRYPT, sec, | |
1875 | des3_speed_template, DES3_SPEED_VECTORS, | |
1876 | speed_template_24); | |
1877 | test_acipher_speed("cbc(des3_ede)", ENCRYPT, sec, | |
1878 | des3_speed_template, DES3_SPEED_VECTORS, | |
1879 | speed_template_24); | |
1880 | test_acipher_speed("cbc(des3_ede)", DECRYPT, sec, | |
1881 | des3_speed_template, DES3_SPEED_VECTORS, | |
1882 | speed_template_24); | |
de197533 NR |
1883 | test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec, |
1884 | des3_speed_template, DES3_SPEED_VECTORS, | |
1885 | speed_template_24); | |
1886 | test_acipher_speed("cfb(des3_ede)", DECRYPT, sec, | |
1887 | des3_speed_template, DES3_SPEED_VECTORS, | |
1888 | speed_template_24); | |
1889 | test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec, | |
1890 | des3_speed_template, DES3_SPEED_VECTORS, | |
1891 | speed_template_24); | |
1892 | test_acipher_speed("ofb(des3_ede)", DECRYPT, sec, | |
1893 | des3_speed_template, DES3_SPEED_VECTORS, | |
1894 | speed_template_24); | |
3f3baf35 JK |
1895 | break; |
1896 | ||
1897 | case 502: | |
1898 | test_acipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, | |
1899 | speed_template_8); | |
1900 | test_acipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, | |
1901 | speed_template_8); | |
1902 | test_acipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, | |
1903 | speed_template_8); | |
1904 | test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, | |
1905 | speed_template_8); | |
de197533 NR |
1906 | test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0, |
1907 | speed_template_8); | |
1908 | test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0, | |
1909 | speed_template_8); | |
1910 | test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0, | |
1911 | speed_template_8); | |
1912 | test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0, | |
1913 | speed_template_8); | |
3f3baf35 JK |
1914 | break; |
1915 | ||
7fb7fe44 JK |
1916 | case 503: |
1917 | test_acipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0, | |
1918 | speed_template_16_32); | |
1919 | test_acipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0, | |
1920 | speed_template_16_32); | |
1921 | test_acipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0, | |
1922 | speed_template_16_32); | |
1923 | test_acipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0, | |
1924 | speed_template_16_32); | |
1925 | test_acipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0, | |
1926 | speed_template_16_32); | |
1927 | test_acipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0, | |
1928 | speed_template_16_32); | |
87aae4bf JK |
1929 | test_acipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0, |
1930 | speed_template_32_48); | |
1931 | test_acipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0, | |
1932 | speed_template_32_48); | |
5209c07a JK |
1933 | test_acipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0, |
1934 | speed_template_32_64); | |
1935 | test_acipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0, | |
1936 | speed_template_32_64); | |
7fb7fe44 JK |
1937 | break; |
1938 | ||
107778b5 JG |
1939 | case 504: |
1940 | test_acipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, | |
1941 | speed_template_16_24_32); | |
1942 | test_acipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, | |
1943 | speed_template_16_24_32); | |
1944 | test_acipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, | |
1945 | speed_template_16_24_32); | |
1946 | test_acipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, | |
1947 | speed_template_16_24_32); | |
1948 | test_acipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, | |
1949 | speed_template_16_24_32); | |
1950 | test_acipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, | |
1951 | speed_template_16_24_32); | |
1952 | test_acipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0, | |
1953 | speed_template_32_40_48); | |
1954 | test_acipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0, | |
1955 | speed_template_32_40_48); | |
1956 | test_acipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0, | |
1957 | speed_template_32_48_64); | |
1958 | test_acipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0, | |
1959 | speed_template_32_48_64); | |
1960 | break; | |
1961 | ||
31b4cd29 JK |
1962 | case 505: |
1963 | test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0, | |
1964 | speed_template_8); | |
1965 | break; | |
1966 | ||
a2c58260 JG |
1967 | case 506: |
1968 | test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, | |
1969 | speed_template_8_16); | |
1970 | test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, | |
1971 | speed_template_8_16); | |
1972 | test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, | |
1973 | speed_template_8_16); | |
1974 | test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, | |
1975 | speed_template_8_16); | |
1976 | test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, | |
1977 | speed_template_8_16); | |
1978 | test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, | |
1979 | speed_template_8_16); | |
1980 | break; | |
1981 | ||
9b8b0405 JG |
1982 | case 507: |
1983 | test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, | |
1984 | speed_template_16_32); | |
1985 | test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, | |
1986 | speed_template_16_32); | |
1987 | test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, | |
1988 | speed_template_16_32); | |
1989 | test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, | |
1990 | speed_template_16_32); | |
1991 | test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, | |
1992 | speed_template_16_32); | |
1993 | test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, | |
1994 | speed_template_16_32); | |
1995 | test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, | |
1996 | speed_template_32_48); | |
1997 | test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, | |
1998 | speed_template_32_48); | |
1999 | test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, | |
2000 | speed_template_32_64); | |
2001 | test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, | |
2002 | speed_template_32_64); | |
2003 | break; | |
2004 | ||
bf9c5181 JK |
2005 | case 508: |
2006 | test_acipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, | |
2007 | speed_template_16_32); | |
2008 | test_acipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, | |
2009 | speed_template_16_32); | |
2010 | test_acipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, | |
2011 | speed_template_16_32); | |
2012 | test_acipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, | |
2013 | speed_template_16_32); | |
2014 | test_acipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0, | |
2015 | speed_template_16_32); | |
2016 | test_acipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0, | |
2017 | speed_template_16_32); | |
2018 | test_acipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0, | |
2019 | speed_template_32_48); | |
2020 | test_acipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0, | |
2021 | speed_template_32_48); | |
2022 | test_acipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0, | |
2023 | speed_template_32_64); | |
2024 | test_acipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0, | |
2025 | speed_template_32_64); | |
2026 | break; | |
2027 | ||
ad8b7c3e JK |
2028 | case 509: |
2029 | test_acipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, | |
2030 | speed_template_8_32); | |
2031 | test_acipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, | |
2032 | speed_template_8_32); | |
2033 | test_acipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, | |
2034 | speed_template_8_32); | |
2035 | test_acipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, | |
2036 | speed_template_8_32); | |
2037 | test_acipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0, | |
2038 | speed_template_8_32); | |
2039 | test_acipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0, | |
2040 | speed_template_8_32); | |
2041 | break; | |
2042 | ||
1da177e4 LT |
2043 | case 1000: |
2044 | test_available(); | |
2045 | break; | |
1da177e4 | 2046 | } |
4e033a6b JW |
2047 | |
2048 | return ret; | |
1da177e4 LT |
2049 | } |
2050 | ||
3af5b90b | 2051 | static int __init tcrypt_mod_init(void) |
1da177e4 | 2052 | { |
e3a4ea4f | 2053 | int err = -ENOMEM; |
f139cfa7 | 2054 | int i; |
e3a4ea4f | 2055 | |
f139cfa7 HX |
2056 | for (i = 0; i < TVMEMSIZE; i++) { |
2057 | tvmem[i] = (void *)__get_free_page(GFP_KERNEL); | |
2058 | if (!tvmem[i]) | |
2059 | goto err_free_tv; | |
2060 | } | |
1da177e4 | 2061 | |
8606813a | 2062 | err = do_test(alg, type, mask, mode); |
a873a5f1 | 2063 | |
4e033a6b JW |
2064 | if (err) { |
2065 | printk(KERN_ERR "tcrypt: one or more tests failed!\n"); | |
2066 | goto err_free_tv; | |
76512f2d RV |
2067 | } else { |
2068 | pr_debug("all tests passed\n"); | |
4e033a6b | 2069 | } |
14fdf477 | 2070 | |
4e033a6b JW |
2071 | /* We intentionaly return -EAGAIN to prevent keeping the module, |
2072 | * unless we're running in fips mode. It does all its work from | |
2073 | * init() and doesn't offer any runtime functionality, but in | |
2074 | * the fips case, checking for a successful load is helpful. | |
14fdf477 ML |
2075 | * => we don't need it in the memory, do we? |
2076 | * -- mludvig | |
2077 | */ | |
4e033a6b JW |
2078 | if (!fips_enabled) |
2079 | err = -EAGAIN; | |
e3a4ea4f | 2080 | |
f139cfa7 HX |
2081 | err_free_tv: |
2082 | for (i = 0; i < TVMEMSIZE && tvmem[i]; i++) | |
2083 | free_page((unsigned long)tvmem[i]); | |
e3a4ea4f MH |
2084 | |
2085 | return err; | |
1da177e4 LT |
2086 | } |
2087 | ||
2088 | /* | |
2089 | * If an init function is provided, an exit function must also be provided | |
2090 | * to allow module unload. | |
2091 | */ | |
3af5b90b | 2092 | static void __exit tcrypt_mod_fini(void) { } |
1da177e4 | 2093 | |
3af5b90b KB |
2094 | module_init(tcrypt_mod_init); |
2095 | module_exit(tcrypt_mod_fini); | |
1da177e4 | 2096 | |
a873a5f1 SK |
2097 | module_param(alg, charp, 0); |
2098 | module_param(type, uint, 0); | |
7be380f7 | 2099 | module_param(mask, uint, 0); |
1da177e4 | 2100 | module_param(mode, int, 0); |
ebfd9bcf | 2101 | module_param(sec, uint, 0); |
6a17944c HX |
2102 | MODULE_PARM_DESC(sec, "Length in seconds of speed tests " |
2103 | "(defaults to zero which uses CPU cycles instead)"); | |
1da177e4 LT |
2104 | |
2105 | MODULE_LICENSE("GPL"); | |
2106 | MODULE_DESCRIPTION("Quick & dirty crypto testing module"); | |
2107 | MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>"); |