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