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