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