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