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