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