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