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