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