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 | |
Rabin Vincent | 76512f2 | 2017-01-18 14:54:05 +0100 | [diff] [blame] | 25 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 26 | |
Herbert Xu | 1ce5a04 | 2015-04-22 15:06:30 +0800 | [diff] [blame] | 27 | #include <crypto/aead.h> |
Herbert Xu | 18e33e6 | 2008-07-10 16:01:22 +0800 | [diff] [blame] | 28 | #include <crypto/hash.h> |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 29 | #include <crypto/skcipher.h> |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 30 | #include <linux/err.h> |
Herbert Xu | daf0944 | 2015-04-22 13:25:57 +0800 | [diff] [blame] | 31 | #include <linux/fips.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <linux/init.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 33 | #include <linux/gfp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <linux/module.h> |
David Hardeman | 378f058 | 2005-09-17 17:55:31 +1000 | [diff] [blame] | 35 | #include <linux/scatterlist.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <linux/string.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #include <linux/moduleparam.h> |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 38 | #include <linux/jiffies.h> |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 39 | #include <linux/timex.h> |
| 40 | #include <linux/interrupt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #include "tcrypt.h" |
| 42 | |
| 43 | /* |
Herbert Xu | f139cfa | 2008-07-31 12:23:53 +0800 | [diff] [blame] | 44 | * Need slab memory for testing (size in number of pages). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | */ |
Herbert Xu | f139cfa | 2008-07-31 12:23:53 +0800 | [diff] [blame] | 46 | #define TVMEMSIZE 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 48 | /* |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 49 | * Used by test_cipher_speed() |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | */ |
| 51 | #define ENCRYPT 1 |
| 52 | #define DECRYPT 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Horia Geant? | f074f7b | 2015-08-27 18:38:36 +0300 | [diff] [blame] | 54 | #define MAX_DIGEST_SIZE 64 |
| 55 | |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 56 | /* |
Luca Clementi | 263a8df | 2014-06-25 22:57:42 -0700 | [diff] [blame] | 57 | * return a string with the driver name |
| 58 | */ |
| 59 | #define get_driver_name(tfm_type, tfm) crypto_tfm_alg_driver_name(tfm_type ## _tfm(tfm)) |
| 60 | |
| 61 | /* |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 62 | * Used by test_cipher_speed() |
| 63 | */ |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 64 | static unsigned int sec; |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 65 | |
Steffen Klassert | a873a5f | 2009-06-19 19:46:53 +0800 | [diff] [blame] | 66 | static char *alg = NULL; |
| 67 | static u32 type; |
Herbert Xu | 7be380f | 2009-07-14 16:06:54 +0800 | [diff] [blame] | 68 | static u32 mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | static int mode; |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 70 | static u32 num_mb = 8; |
Herbert Xu | f139cfa | 2008-07-31 12:23:53 +0800 | [diff] [blame] | 71 | static char *tvmem[TVMEMSIZE]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
| 73 | static char *check[] = { |
Gilad Ben-Yossef | b7e2753 | 2017-08-21 13:51:29 +0300 | [diff] [blame] | 74 | "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", "sm3", |
Jonathan Lynch | cd12fb9 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 75 | "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes", |
| 76 | "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", |
David Howells | 9083163 | 2006-12-16 12:13:14 +1100 | [diff] [blame] | 77 | "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 78 | "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320", |
Horia Geantă | 4d407b0 | 2018-09-19 17:54:21 +0300 | [diff] [blame] | 79 | "lzo", "cts", "sha3-224", "sha3-256", "sha3-384", "sha3-512", NULL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 82 | static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 }; |
| 83 | static u32 aead_sizes[] = { 16, 64, 256, 512, 1024, 2048, 4096, 8192, 0 }; |
| 84 | |
| 85 | #define XBUFSIZE 8 |
| 86 | #define MAX_IVLEN 32 |
| 87 | |
| 88 | static int testmgr_alloc_buf(char *buf[XBUFSIZE]) |
| 89 | { |
| 90 | int i; |
| 91 | |
| 92 | for (i = 0; i < XBUFSIZE; i++) { |
| 93 | buf[i] = (void *)__get_free_page(GFP_KERNEL); |
| 94 | if (!buf[i]) |
| 95 | goto err_free_buf; |
| 96 | } |
| 97 | |
| 98 | return 0; |
| 99 | |
| 100 | err_free_buf: |
| 101 | while (i-- > 0) |
| 102 | free_page((unsigned long)buf[i]); |
| 103 | |
| 104 | return -ENOMEM; |
| 105 | } |
| 106 | |
| 107 | static void testmgr_free_buf(char *buf[XBUFSIZE]) |
| 108 | { |
| 109 | int i; |
| 110 | |
| 111 | for (i = 0; i < XBUFSIZE; i++) |
| 112 | free_page((unsigned long)buf[i]); |
| 113 | } |
| 114 | |
| 115 | static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE], |
| 116 | unsigned int buflen, const void *assoc, |
| 117 | unsigned int aad_size) |
| 118 | { |
| 119 | int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE; |
| 120 | int k, rem; |
| 121 | |
| 122 | if (np > XBUFSIZE) { |
| 123 | rem = PAGE_SIZE; |
| 124 | np = XBUFSIZE; |
| 125 | } else { |
| 126 | rem = buflen % PAGE_SIZE; |
| 127 | } |
| 128 | |
| 129 | sg_init_table(sg, np + 1); |
| 130 | |
| 131 | sg_set_buf(&sg[0], assoc, aad_size); |
| 132 | |
| 133 | if (rem) |
| 134 | np--; |
| 135 | for (k = 0; k < np; k++) |
| 136 | sg_set_buf(&sg[k + 1], xbuf[k], PAGE_SIZE); |
| 137 | |
| 138 | if (rem) |
| 139 | sg_set_buf(&sg[k + 1], xbuf[k], rem); |
| 140 | } |
| 141 | |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 142 | static inline int do_one_aead_op(struct aead_request *req, int ret) |
| 143 | { |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 144 | struct crypto_wait *wait = req->base.data; |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 145 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 146 | return crypto_wait_req(ret, wait); |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 147 | } |
| 148 | |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 149 | struct test_mb_aead_data { |
| 150 | struct scatterlist sg[XBUFSIZE]; |
| 151 | struct scatterlist sgout[XBUFSIZE]; |
| 152 | struct aead_request *req; |
| 153 | struct crypto_wait wait; |
| 154 | char *xbuf[XBUFSIZE]; |
| 155 | char *xoutbuf[XBUFSIZE]; |
| 156 | char *axbuf[XBUFSIZE]; |
| 157 | }; |
| 158 | |
| 159 | static int do_mult_aead_op(struct test_mb_aead_data *data, int enc, |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 160 | u32 num_mb, int *rc) |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 161 | { |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 162 | int i, err = 0; |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 163 | |
| 164 | /* Fire up a bunch of concurrent requests */ |
| 165 | for (i = 0; i < num_mb; i++) { |
| 166 | if (enc == ENCRYPT) |
| 167 | rc[i] = crypto_aead_encrypt(data[i].req); |
| 168 | else |
| 169 | rc[i] = crypto_aead_decrypt(data[i].req); |
| 170 | } |
| 171 | |
| 172 | /* Wait for all requests to finish */ |
| 173 | for (i = 0; i < num_mb; i++) { |
| 174 | rc[i] = crypto_wait_req(rc[i], &data[i].wait); |
| 175 | |
| 176 | if (rc[i]) { |
| 177 | pr_info("concurrent request %d error %d\n", i, rc[i]); |
| 178 | err = rc[i]; |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | return err; |
| 183 | } |
| 184 | |
| 185 | static int test_mb_aead_jiffies(struct test_mb_aead_data *data, int enc, |
| 186 | int blen, int secs, u32 num_mb) |
| 187 | { |
| 188 | unsigned long start, end; |
| 189 | int bcount; |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 190 | int ret = 0; |
| 191 | int *rc; |
| 192 | |
| 193 | rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL); |
| 194 | if (!rc) |
| 195 | return -ENOMEM; |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 196 | |
| 197 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
| 198 | time_before(jiffies, end); bcount++) { |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 199 | ret = do_mult_aead_op(data, enc, num_mb, rc); |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 200 | if (ret) |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 201 | goto out; |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | pr_cont("%d operations in %d seconds (%ld bytes)\n", |
| 205 | bcount * num_mb, secs, (long)bcount * blen * num_mb); |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 206 | |
| 207 | out: |
| 208 | kfree(rc); |
| 209 | return ret; |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | static int test_mb_aead_cycles(struct test_mb_aead_data *data, int enc, |
| 213 | int blen, u32 num_mb) |
| 214 | { |
| 215 | unsigned long cycles = 0; |
| 216 | int ret = 0; |
| 217 | int i; |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 218 | int *rc; |
| 219 | |
| 220 | rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL); |
| 221 | if (!rc) |
| 222 | return -ENOMEM; |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 223 | |
| 224 | /* Warm-up run. */ |
| 225 | for (i = 0; i < 4; i++) { |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 226 | ret = do_mult_aead_op(data, enc, num_mb, rc); |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 227 | if (ret) |
| 228 | goto out; |
| 229 | } |
| 230 | |
| 231 | /* The real thing. */ |
| 232 | for (i = 0; i < 8; i++) { |
| 233 | cycles_t start, end; |
| 234 | |
| 235 | start = get_cycles(); |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 236 | ret = do_mult_aead_op(data, enc, num_mb, rc); |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 237 | end = get_cycles(); |
| 238 | |
| 239 | if (ret) |
| 240 | goto out; |
| 241 | |
| 242 | cycles += end - start; |
| 243 | } |
| 244 | |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 245 | pr_cont("1 operation in %lu cycles (%d bytes)\n", |
| 246 | (cycles + 4) / (8 * num_mb), blen); |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 247 | |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 248 | out: |
| 249 | kfree(rc); |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 250 | return ret; |
| 251 | } |
| 252 | |
| 253 | static void test_mb_aead_speed(const char *algo, int enc, int secs, |
| 254 | struct aead_speed_template *template, |
| 255 | unsigned int tcount, u8 authsize, |
| 256 | unsigned int aad_size, u8 *keysize, u32 num_mb) |
| 257 | { |
| 258 | struct test_mb_aead_data *data; |
| 259 | struct crypto_aead *tfm; |
| 260 | unsigned int i, j, iv_len; |
| 261 | const char *key; |
| 262 | const char *e; |
| 263 | void *assoc; |
| 264 | u32 *b_size; |
| 265 | char *iv; |
| 266 | int ret; |
| 267 | |
| 268 | |
| 269 | if (aad_size >= PAGE_SIZE) { |
| 270 | pr_err("associate data length (%u) too big\n", aad_size); |
| 271 | return; |
| 272 | } |
| 273 | |
| 274 | iv = kzalloc(MAX_IVLEN, GFP_KERNEL); |
| 275 | if (!iv) |
| 276 | return; |
| 277 | |
| 278 | if (enc == ENCRYPT) |
| 279 | e = "encryption"; |
| 280 | else |
| 281 | e = "decryption"; |
| 282 | |
| 283 | data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL); |
| 284 | if (!data) |
| 285 | goto out_free_iv; |
| 286 | |
| 287 | tfm = crypto_alloc_aead(algo, 0, 0); |
| 288 | if (IS_ERR(tfm)) { |
| 289 | pr_err("failed to load transform for %s: %ld\n", |
| 290 | algo, PTR_ERR(tfm)); |
| 291 | goto out_free_data; |
| 292 | } |
| 293 | |
| 294 | ret = crypto_aead_setauthsize(tfm, authsize); |
| 295 | |
| 296 | for (i = 0; i < num_mb; ++i) |
| 297 | if (testmgr_alloc_buf(data[i].xbuf)) { |
| 298 | while (i--) |
| 299 | testmgr_free_buf(data[i].xbuf); |
| 300 | goto out_free_tfm; |
| 301 | } |
| 302 | |
| 303 | for (i = 0; i < num_mb; ++i) |
| 304 | if (testmgr_alloc_buf(data[i].axbuf)) { |
| 305 | while (i--) |
| 306 | testmgr_free_buf(data[i].axbuf); |
| 307 | goto out_free_xbuf; |
| 308 | } |
| 309 | |
| 310 | for (i = 0; i < num_mb; ++i) |
| 311 | if (testmgr_alloc_buf(data[i].xoutbuf)) { |
| 312 | while (i--) |
Colin Ian King | c6ba4f3 | 2018-01-02 15:43:04 +0000 | [diff] [blame] | 313 | testmgr_free_buf(data[i].xoutbuf); |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 314 | goto out_free_axbuf; |
| 315 | } |
| 316 | |
| 317 | for (i = 0; i < num_mb; ++i) { |
| 318 | data[i].req = aead_request_alloc(tfm, GFP_KERNEL); |
| 319 | if (!data[i].req) { |
| 320 | pr_err("alg: skcipher: Failed to allocate request for %s\n", |
| 321 | algo); |
| 322 | while (i--) |
| 323 | aead_request_free(data[i].req); |
| 324 | goto out_free_xoutbuf; |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | for (i = 0; i < num_mb; ++i) { |
| 329 | crypto_init_wait(&data[i].wait); |
| 330 | aead_request_set_callback(data[i].req, |
| 331 | CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 332 | crypto_req_done, &data[i].wait); |
| 333 | } |
| 334 | |
| 335 | pr_info("\ntesting speed of multibuffer %s (%s) %s\n", algo, |
| 336 | get_driver_name(crypto_aead, tfm), e); |
| 337 | |
| 338 | i = 0; |
| 339 | do { |
| 340 | b_size = aead_sizes; |
| 341 | do { |
| 342 | if (*b_size + authsize > XBUFSIZE * PAGE_SIZE) { |
Colin Ian King | 38dbe2d | 2018-01-02 09:21:06 +0000 | [diff] [blame] | 343 | pr_err("template (%u) too big for buffer (%lu)\n", |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 344 | authsize + *b_size, |
| 345 | XBUFSIZE * PAGE_SIZE); |
| 346 | goto out; |
| 347 | } |
| 348 | |
| 349 | pr_info("test %u (%d bit key, %d byte blocks): ", i, |
| 350 | *keysize * 8, *b_size); |
| 351 | |
| 352 | /* Set up tfm global state, i.e. the key */ |
| 353 | |
| 354 | memset(tvmem[0], 0xff, PAGE_SIZE); |
| 355 | key = tvmem[0]; |
| 356 | for (j = 0; j < tcount; j++) { |
| 357 | if (template[j].klen == *keysize) { |
| 358 | key = template[j].key; |
| 359 | break; |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | crypto_aead_clear_flags(tfm, ~0); |
| 364 | |
| 365 | ret = crypto_aead_setkey(tfm, key, *keysize); |
| 366 | if (ret) { |
| 367 | pr_err("setkey() failed flags=%x\n", |
| 368 | crypto_aead_get_flags(tfm)); |
| 369 | goto out; |
| 370 | } |
| 371 | |
| 372 | iv_len = crypto_aead_ivsize(tfm); |
| 373 | if (iv_len) |
| 374 | memset(iv, 0xff, iv_len); |
| 375 | |
| 376 | /* Now setup per request stuff, i.e. buffers */ |
| 377 | |
| 378 | for (j = 0; j < num_mb; ++j) { |
| 379 | struct test_mb_aead_data *cur = &data[j]; |
| 380 | |
| 381 | assoc = cur->axbuf[0]; |
| 382 | memset(assoc, 0xff, aad_size); |
| 383 | |
| 384 | sg_init_aead(cur->sg, cur->xbuf, |
| 385 | *b_size + (enc ? 0 : authsize), |
| 386 | assoc, aad_size); |
| 387 | |
| 388 | sg_init_aead(cur->sgout, cur->xoutbuf, |
| 389 | *b_size + (enc ? authsize : 0), |
| 390 | assoc, aad_size); |
| 391 | |
| 392 | aead_request_set_ad(cur->req, aad_size); |
| 393 | |
| 394 | if (!enc) { |
| 395 | |
| 396 | aead_request_set_crypt(cur->req, |
| 397 | cur->sgout, |
| 398 | cur->sg, |
| 399 | *b_size, iv); |
| 400 | ret = crypto_aead_encrypt(cur->req); |
| 401 | ret = do_one_aead_op(cur->req, ret); |
| 402 | |
| 403 | if (ret) { |
| 404 | pr_err("calculating auth failed failed (%d)\n", |
| 405 | ret); |
| 406 | break; |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | aead_request_set_crypt(cur->req, cur->sg, |
| 411 | cur->sgout, *b_size + |
| 412 | (enc ? 0 : authsize), |
| 413 | iv); |
| 414 | |
| 415 | } |
| 416 | |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 417 | if (secs) { |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 418 | ret = test_mb_aead_jiffies(data, enc, *b_size, |
| 419 | secs, num_mb); |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 420 | cond_resched(); |
| 421 | } else { |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 422 | ret = test_mb_aead_cycles(data, enc, *b_size, |
| 423 | num_mb); |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 424 | } |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 425 | |
| 426 | if (ret) { |
| 427 | pr_err("%s() failed return code=%d\n", e, ret); |
| 428 | break; |
| 429 | } |
| 430 | b_size++; |
| 431 | i++; |
| 432 | } while (*b_size); |
| 433 | keysize++; |
| 434 | } while (*keysize); |
| 435 | |
| 436 | out: |
| 437 | for (i = 0; i < num_mb; ++i) |
| 438 | aead_request_free(data[i].req); |
| 439 | out_free_xoutbuf: |
| 440 | for (i = 0; i < num_mb; ++i) |
| 441 | testmgr_free_buf(data[i].xoutbuf); |
| 442 | out_free_axbuf: |
| 443 | for (i = 0; i < num_mb; ++i) |
| 444 | testmgr_free_buf(data[i].axbuf); |
| 445 | out_free_xbuf: |
| 446 | for (i = 0; i < num_mb; ++i) |
| 447 | testmgr_free_buf(data[i].xbuf); |
| 448 | out_free_tfm: |
| 449 | crypto_free_aead(tfm); |
| 450 | out_free_data: |
| 451 | kfree(data); |
| 452 | out_free_iv: |
| 453 | kfree(iv); |
| 454 | } |
| 455 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 456 | static int test_aead_jiffies(struct aead_request *req, int enc, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 457 | int blen, int secs) |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 458 | { |
| 459 | unsigned long start, end; |
| 460 | int bcount; |
| 461 | int ret; |
| 462 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 463 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 464 | time_before(jiffies, end); bcount++) { |
| 465 | if (enc) |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 466 | ret = do_one_aead_op(req, crypto_aead_encrypt(req)); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 467 | else |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 468 | ret = do_one_aead_op(req, crypto_aead_decrypt(req)); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 469 | |
| 470 | if (ret) |
| 471 | return ret; |
| 472 | } |
| 473 | |
| 474 | printk("%d operations in %d seconds (%ld bytes)\n", |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 475 | bcount, secs, (long)bcount * blen); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 476 | return 0; |
| 477 | } |
| 478 | |
| 479 | static int test_aead_cycles(struct aead_request *req, int enc, int blen) |
| 480 | { |
| 481 | unsigned long cycles = 0; |
| 482 | int ret = 0; |
| 483 | int i; |
| 484 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 485 | /* Warm-up run. */ |
| 486 | for (i = 0; i < 4; i++) { |
| 487 | if (enc) |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 488 | ret = do_one_aead_op(req, crypto_aead_encrypt(req)); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 489 | else |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 490 | ret = do_one_aead_op(req, crypto_aead_decrypt(req)); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 491 | |
| 492 | if (ret) |
| 493 | goto out; |
| 494 | } |
| 495 | |
| 496 | /* The real thing. */ |
| 497 | for (i = 0; i < 8; i++) { |
| 498 | cycles_t start, end; |
| 499 | |
| 500 | start = get_cycles(); |
| 501 | if (enc) |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 502 | ret = do_one_aead_op(req, crypto_aead_encrypt(req)); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 503 | else |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 504 | ret = do_one_aead_op(req, crypto_aead_decrypt(req)); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 505 | end = get_cycles(); |
| 506 | |
| 507 | if (ret) |
| 508 | goto out; |
| 509 | |
| 510 | cycles += end - start; |
| 511 | } |
| 512 | |
| 513 | out: |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 514 | if (ret == 0) |
| 515 | printk("1 operation in %lu cycles (%d bytes)\n", |
| 516 | (cycles + 4) / 8, blen); |
| 517 | |
| 518 | return ret; |
| 519 | } |
| 520 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 521 | 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] | 522 | struct aead_speed_template *template, |
| 523 | unsigned int tcount, u8 authsize, |
| 524 | unsigned int aad_size, u8 *keysize) |
| 525 | { |
| 526 | unsigned int i, j; |
| 527 | struct crypto_aead *tfm; |
| 528 | int ret = -ENOMEM; |
| 529 | const char *key; |
| 530 | struct aead_request *req; |
| 531 | struct scatterlist *sg; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 532 | struct scatterlist *sgout; |
| 533 | const char *e; |
| 534 | void *assoc; |
Cristian Stoica | 96692a73 | 2015-01-28 13:07:32 +0200 | [diff] [blame] | 535 | char *iv; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 536 | char *xbuf[XBUFSIZE]; |
| 537 | char *xoutbuf[XBUFSIZE]; |
| 538 | char *axbuf[XBUFSIZE]; |
| 539 | unsigned int *b_size; |
| 540 | unsigned int iv_len; |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 541 | struct crypto_wait wait; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 542 | |
Cristian Stoica | 96692a73 | 2015-01-28 13:07:32 +0200 | [diff] [blame] | 543 | iv = kzalloc(MAX_IVLEN, GFP_KERNEL); |
| 544 | if (!iv) |
| 545 | return; |
| 546 | |
Christian Engelmayer | ac5f863 | 2014-04-21 20:45:59 +0200 | [diff] [blame] | 547 | if (aad_size >= PAGE_SIZE) { |
| 548 | pr_err("associate data length (%u) too big\n", aad_size); |
Cristian Stoica | 96692a73 | 2015-01-28 13:07:32 +0200 | [diff] [blame] | 549 | goto out_noxbuf; |
Christian Engelmayer | ac5f863 | 2014-04-21 20:45:59 +0200 | [diff] [blame] | 550 | } |
| 551 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 552 | if (enc == ENCRYPT) |
| 553 | e = "encryption"; |
| 554 | else |
| 555 | e = "decryption"; |
| 556 | |
| 557 | if (testmgr_alloc_buf(xbuf)) |
| 558 | goto out_noxbuf; |
| 559 | if (testmgr_alloc_buf(axbuf)) |
| 560 | goto out_noaxbuf; |
| 561 | if (testmgr_alloc_buf(xoutbuf)) |
| 562 | goto out_nooutbuf; |
| 563 | |
Herbert Xu | a3f2185 | 2015-05-27 16:03:51 +0800 | [diff] [blame] | 564 | sg = kmalloc(sizeof(*sg) * 9 * 2, GFP_KERNEL); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 565 | if (!sg) |
| 566 | goto out_nosg; |
Herbert Xu | a3f2185 | 2015-05-27 16:03:51 +0800 | [diff] [blame] | 567 | sgout = &sg[9]; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 568 | |
Herbert Xu | 5e4b8c1 | 2015-08-13 17:29:06 +0800 | [diff] [blame] | 569 | tfm = crypto_alloc_aead(algo, 0, 0); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 570 | |
| 571 | if (IS_ERR(tfm)) { |
| 572 | pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo, |
| 573 | PTR_ERR(tfm)); |
Christian Engelmayer | a2ea6ed | 2014-04-21 20:46:40 +0200 | [diff] [blame] | 574 | goto out_notfm; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 575 | } |
| 576 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 577 | crypto_init_wait(&wait); |
Luca Clementi | 263a8df | 2014-06-25 22:57:42 -0700 | [diff] [blame] | 578 | printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo, |
| 579 | get_driver_name(crypto_aead, tfm), e); |
| 580 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 581 | req = aead_request_alloc(tfm, GFP_KERNEL); |
| 582 | if (!req) { |
| 583 | pr_err("alg: aead: Failed to allocate request for %s\n", |
| 584 | algo); |
Christian Engelmayer | 6af1f93 | 2014-04-21 20:47:05 +0200 | [diff] [blame] | 585 | goto out_noreq; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 586 | } |
| 587 | |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 588 | aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 589 | crypto_req_done, &wait); |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 590 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 591 | i = 0; |
| 592 | do { |
| 593 | b_size = aead_sizes; |
| 594 | do { |
| 595 | assoc = axbuf[0]; |
Christian Engelmayer | ac5f863 | 2014-04-21 20:45:59 +0200 | [diff] [blame] | 596 | memset(assoc, 0xff, aad_size); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 597 | |
| 598 | if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { |
| 599 | pr_err("template (%u) too big for tvmem (%lu)\n", |
| 600 | *keysize + *b_size, |
| 601 | TVMEMSIZE * PAGE_SIZE); |
| 602 | goto out; |
| 603 | } |
| 604 | |
| 605 | key = tvmem[0]; |
| 606 | for (j = 0; j < tcount; j++) { |
| 607 | if (template[j].klen == *keysize) { |
| 608 | key = template[j].key; |
| 609 | break; |
| 610 | } |
| 611 | } |
| 612 | ret = crypto_aead_setkey(tfm, key, *keysize); |
| 613 | ret = crypto_aead_setauthsize(tfm, authsize); |
| 614 | |
| 615 | iv_len = crypto_aead_ivsize(tfm); |
| 616 | if (iv_len) |
Cristian Stoica | 96692a73 | 2015-01-28 13:07:32 +0200 | [diff] [blame] | 617 | memset(iv, 0xff, iv_len); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 618 | |
| 619 | crypto_aead_clear_flags(tfm, ~0); |
| 620 | printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ", |
| 621 | i, *keysize * 8, *b_size); |
| 622 | |
| 623 | |
| 624 | memset(tvmem[0], 0xff, PAGE_SIZE); |
| 625 | |
| 626 | if (ret) { |
| 627 | pr_err("setkey() failed flags=%x\n", |
| 628 | crypto_aead_get_flags(tfm)); |
| 629 | goto out; |
| 630 | } |
| 631 | |
Tudor-Dan Ambarus | 5601e01 | 2017-11-14 16:59:15 +0200 | [diff] [blame] | 632 | sg_init_aead(sg, xbuf, *b_size + (enc ? 0 : authsize), |
| 633 | assoc, aad_size); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 634 | |
Herbert Xu | 3126727 | 2015-06-17 14:05:26 +0800 | [diff] [blame] | 635 | sg_init_aead(sgout, xoutbuf, |
Tudor-Dan Ambarus | 5601e01 | 2017-11-14 16:59:15 +0200 | [diff] [blame] | 636 | *b_size + (enc ? authsize : 0), assoc, |
| 637 | aad_size); |
Herbert Xu | 3126727 | 2015-06-17 14:05:26 +0800 | [diff] [blame] | 638 | |
Gilad Ben-Yossef | 4431bd4 | 2017-12-17 08:29:01 +0000 | [diff] [blame] | 639 | aead_request_set_ad(req, aad_size); |
| 640 | |
| 641 | if (!enc) { |
| 642 | |
| 643 | /* |
| 644 | * For decryption we need a proper auth so |
| 645 | * we do the encryption path once with buffers |
| 646 | * reversed (input <-> output) to calculate it |
| 647 | */ |
| 648 | aead_request_set_crypt(req, sgout, sg, |
| 649 | *b_size, iv); |
| 650 | ret = do_one_aead_op(req, |
| 651 | crypto_aead_encrypt(req)); |
| 652 | |
| 653 | if (ret) { |
| 654 | pr_err("calculating auth failed failed (%d)\n", |
| 655 | ret); |
| 656 | break; |
| 657 | } |
| 658 | } |
| 659 | |
Robert Baronescu | 7aacbfc | 2017-10-10 13:22:00 +0300 | [diff] [blame] | 660 | aead_request_set_crypt(req, sg, sgout, |
| 661 | *b_size + (enc ? 0 : authsize), |
| 662 | iv); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 663 | |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 664 | if (secs) { |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 665 | ret = test_aead_jiffies(req, enc, *b_size, |
| 666 | secs); |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 667 | cond_resched(); |
| 668 | } else { |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 669 | ret = test_aead_cycles(req, enc, *b_size); |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 670 | } |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 671 | |
| 672 | if (ret) { |
| 673 | pr_err("%s() failed return code=%d\n", e, ret); |
| 674 | break; |
| 675 | } |
| 676 | b_size++; |
| 677 | i++; |
| 678 | } while (*b_size); |
| 679 | keysize++; |
| 680 | } while (*keysize); |
| 681 | |
| 682 | out: |
Christian Engelmayer | 6af1f93 | 2014-04-21 20:47:05 +0200 | [diff] [blame] | 683 | aead_request_free(req); |
| 684 | out_noreq: |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 685 | crypto_free_aead(tfm); |
Christian Engelmayer | a2ea6ed | 2014-04-21 20:46:40 +0200 | [diff] [blame] | 686 | out_notfm: |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 687 | kfree(sg); |
| 688 | out_nosg: |
| 689 | testmgr_free_buf(xoutbuf); |
| 690 | out_nooutbuf: |
| 691 | testmgr_free_buf(axbuf); |
| 692 | out_noaxbuf: |
| 693 | testmgr_free_buf(xbuf); |
| 694 | out_noxbuf: |
Cristian Stoica | 96692a73 | 2015-01-28 13:07:32 +0200 | [diff] [blame] | 695 | kfree(iv); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 696 | } |
Sebastian Siewior | d5dc392 | 2008-03-11 21:27:11 +0800 | [diff] [blame] | 697 | |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 698 | static void test_hash_sg_init(struct scatterlist *sg) |
| 699 | { |
| 700 | int i; |
| 701 | |
| 702 | sg_init_table(sg, TVMEMSIZE); |
| 703 | for (i = 0; i < TVMEMSIZE; i++) { |
| 704 | sg_set_buf(sg + i, tvmem[i], PAGE_SIZE); |
| 705 | memset(tvmem[i], 0xff, PAGE_SIZE); |
| 706 | } |
| 707 | } |
| 708 | |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 709 | static inline int do_one_ahash_op(struct ahash_request *req, int ret) |
| 710 | { |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 711 | struct crypto_wait *wait = req->base.data; |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 712 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 713 | return crypto_wait_req(ret, wait); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 714 | } |
| 715 | |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 716 | struct test_mb_ahash_data { |
Gilad Ben-Yossef | 7c3f132 | 2017-12-17 08:29:00 +0000 | [diff] [blame] | 717 | struct scatterlist sg[XBUFSIZE]; |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 718 | char result[64]; |
| 719 | struct ahash_request *req; |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 720 | struct crypto_wait wait; |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 721 | char *xbuf[XBUFSIZE]; |
| 722 | }; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 723 | |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 724 | static inline int do_mult_ahash_op(struct test_mb_ahash_data *data, u32 num_mb, |
| 725 | int *rc) |
Gilad Ben-Yossef | b34a0f67 | 2017-12-17 08:29:03 +0000 | [diff] [blame] | 726 | { |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 727 | int i, err = 0; |
Gilad Ben-Yossef | b34a0f67 | 2017-12-17 08:29:03 +0000 | [diff] [blame] | 728 | |
| 729 | /* Fire up a bunch of concurrent requests */ |
| 730 | for (i = 0; i < num_mb; i++) |
| 731 | rc[i] = crypto_ahash_digest(data[i].req); |
| 732 | |
| 733 | /* Wait for all requests to finish */ |
| 734 | for (i = 0; i < num_mb; i++) { |
| 735 | rc[i] = crypto_wait_req(rc[i], &data[i].wait); |
| 736 | |
| 737 | if (rc[i]) { |
| 738 | pr_info("concurrent request %d error %d\n", i, rc[i]); |
| 739 | err = rc[i]; |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | return err; |
| 744 | } |
| 745 | |
| 746 | static int test_mb_ahash_jiffies(struct test_mb_ahash_data *data, int blen, |
| 747 | int secs, u32 num_mb) |
| 748 | { |
| 749 | unsigned long start, end; |
| 750 | int bcount; |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 751 | int ret = 0; |
| 752 | int *rc; |
| 753 | |
| 754 | rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL); |
| 755 | if (!rc) |
| 756 | return -ENOMEM; |
Gilad Ben-Yossef | b34a0f67 | 2017-12-17 08:29:03 +0000 | [diff] [blame] | 757 | |
| 758 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
| 759 | time_before(jiffies, end); bcount++) { |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 760 | ret = do_mult_ahash_op(data, num_mb, rc); |
Gilad Ben-Yossef | b34a0f67 | 2017-12-17 08:29:03 +0000 | [diff] [blame] | 761 | if (ret) |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 762 | goto out; |
Gilad Ben-Yossef | b34a0f67 | 2017-12-17 08:29:03 +0000 | [diff] [blame] | 763 | } |
| 764 | |
| 765 | pr_cont("%d operations in %d seconds (%ld bytes)\n", |
| 766 | bcount * num_mb, secs, (long)bcount * blen * num_mb); |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 767 | |
| 768 | out: |
| 769 | kfree(rc); |
| 770 | return ret; |
Gilad Ben-Yossef | b34a0f67 | 2017-12-17 08:29:03 +0000 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | static int test_mb_ahash_cycles(struct test_mb_ahash_data *data, int blen, |
| 774 | u32 num_mb) |
| 775 | { |
| 776 | unsigned long cycles = 0; |
| 777 | int ret = 0; |
| 778 | int i; |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 779 | int *rc; |
| 780 | |
| 781 | rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL); |
| 782 | if (!rc) |
| 783 | return -ENOMEM; |
Gilad Ben-Yossef | b34a0f67 | 2017-12-17 08:29:03 +0000 | [diff] [blame] | 784 | |
| 785 | /* Warm-up run. */ |
| 786 | for (i = 0; i < 4; i++) { |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 787 | ret = do_mult_ahash_op(data, num_mb, rc); |
Gilad Ben-Yossef | b34a0f67 | 2017-12-17 08:29:03 +0000 | [diff] [blame] | 788 | if (ret) |
| 789 | goto out; |
| 790 | } |
| 791 | |
| 792 | /* The real thing. */ |
| 793 | for (i = 0; i < 8; i++) { |
| 794 | cycles_t start, end; |
| 795 | |
| 796 | start = get_cycles(); |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 797 | ret = do_mult_ahash_op(data, num_mb, rc); |
Gilad Ben-Yossef | b34a0f67 | 2017-12-17 08:29:03 +0000 | [diff] [blame] | 798 | end = get_cycles(); |
| 799 | |
| 800 | if (ret) |
| 801 | goto out; |
| 802 | |
| 803 | cycles += end - start; |
| 804 | } |
| 805 | |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 806 | pr_cont("1 operation in %lu cycles (%d bytes)\n", |
| 807 | (cycles + 4) / (8 * num_mb), blen); |
Gilad Ben-Yossef | b34a0f67 | 2017-12-17 08:29:03 +0000 | [diff] [blame] | 808 | |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 809 | out: |
| 810 | kfree(rc); |
Gilad Ben-Yossef | b34a0f67 | 2017-12-17 08:29:03 +0000 | [diff] [blame] | 811 | return ret; |
| 812 | } |
| 813 | |
| 814 | static void test_mb_ahash_speed(const char *algo, unsigned int secs, |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 815 | struct hash_speed *speed, u32 num_mb) |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 816 | { |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 817 | struct test_mb_ahash_data *data; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 818 | struct crypto_ahash *tfm; |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 819 | unsigned int i, j, k; |
| 820 | int ret; |
| 821 | |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 822 | data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL); |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 823 | if (!data) |
| 824 | return; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 825 | |
| 826 | tfm = crypto_alloc_ahash(algo, 0, 0); |
| 827 | if (IS_ERR(tfm)) { |
| 828 | pr_err("failed to load transform for %s: %ld\n", |
| 829 | algo, PTR_ERR(tfm)); |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 830 | goto free_data; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 831 | } |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 832 | |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 833 | for (i = 0; i < num_mb; ++i) { |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 834 | if (testmgr_alloc_buf(data[i].xbuf)) |
| 835 | goto out; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 836 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 837 | crypto_init_wait(&data[i].wait); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 838 | |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 839 | data[i].req = ahash_request_alloc(tfm, GFP_KERNEL); |
| 840 | if (!data[i].req) { |
Krzysztof Kozlowski | f83f5b1 | 2016-06-28 09:23:06 +0200 | [diff] [blame] | 841 | pr_err("alg: hash: Failed to allocate request for %s\n", |
| 842 | algo); |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 843 | goto out; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 844 | } |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 845 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 846 | ahash_request_set_callback(data[i].req, 0, crypto_req_done, |
| 847 | &data[i].wait); |
Gilad Ben-Yossef | 7c3f132 | 2017-12-17 08:29:00 +0000 | [diff] [blame] | 848 | |
| 849 | sg_init_table(data[i].sg, XBUFSIZE); |
| 850 | for (j = 0; j < XBUFSIZE; j++) { |
| 851 | sg_set_buf(data[i].sg + j, data[i].xbuf[j], PAGE_SIZE); |
| 852 | memset(data[i].xbuf[j], 0xff, PAGE_SIZE); |
| 853 | } |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 854 | } |
| 855 | |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 856 | pr_info("\ntesting speed of multibuffer %s (%s)\n", algo, |
| 857 | get_driver_name(crypto_ahash, tfm)); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 858 | |
| 859 | for (i = 0; speed[i].blen != 0; i++) { |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 860 | /* For some reason this only tests digests. */ |
| 861 | if (speed[i].blen != speed[i].plen) |
| 862 | continue; |
| 863 | |
Gilad Ben-Yossef | 7c3f132 | 2017-12-17 08:29:00 +0000 | [diff] [blame] | 864 | if (speed[i].blen > XBUFSIZE * PAGE_SIZE) { |
Krzysztof Kozlowski | f83f5b1 | 2016-06-28 09:23:06 +0200 | [diff] [blame] | 865 | pr_err("template (%u) too big for tvmem (%lu)\n", |
Gilad Ben-Yossef | 7c3f132 | 2017-12-17 08:29:00 +0000 | [diff] [blame] | 866 | speed[i].blen, XBUFSIZE * PAGE_SIZE); |
Krzysztof Kozlowski | f83f5b1 | 2016-06-28 09:23:06 +0200 | [diff] [blame] | 867 | goto out; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 868 | } |
| 869 | |
| 870 | if (speed[i].klen) |
| 871 | crypto_ahash_setkey(tfm, tvmem[0], speed[i].klen); |
| 872 | |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 873 | for (k = 0; k < num_mb; k++) |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 874 | ahash_request_set_crypt(data[k].req, data[k].sg, |
| 875 | data[k].result, speed[i].blen); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 876 | |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 877 | pr_info("test%3u " |
| 878 | "(%5u byte blocks,%5u bytes per update,%4u updates): ", |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 879 | i, speed[i].blen, speed[i].plen, |
| 880 | speed[i].blen / speed[i].plen); |
| 881 | |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 882 | if (secs) { |
Gilad Ben-Yossef | b34a0f67 | 2017-12-17 08:29:03 +0000 | [diff] [blame] | 883 | ret = test_mb_ahash_jiffies(data, speed[i].blen, secs, |
| 884 | num_mb); |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 885 | cond_resched(); |
| 886 | } else { |
Gilad Ben-Yossef | b34a0f67 | 2017-12-17 08:29:03 +0000 | [diff] [blame] | 887 | ret = test_mb_ahash_cycles(data, speed[i].blen, num_mb); |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 888 | } |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 889 | |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 890 | |
| 891 | if (ret) { |
| 892 | pr_err("At least one hashing failed ret=%d\n", ret); |
| 893 | break; |
| 894 | } |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 895 | } |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 896 | |
| 897 | out: |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 898 | for (k = 0; k < num_mb; ++k) |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 899 | ahash_request_free(data[k].req); |
| 900 | |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 901 | for (k = 0; k < num_mb; ++k) |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 902 | testmgr_free_buf(data[k].xbuf); |
| 903 | |
| 904 | crypto_free_ahash(tfm); |
| 905 | |
| 906 | free_data: |
| 907 | kfree(data); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 908 | } |
| 909 | |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 910 | static int test_ahash_jiffies_digest(struct ahash_request *req, int blen, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 911 | char *out, int secs) |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 912 | { |
| 913 | unsigned long start, end; |
| 914 | int bcount; |
| 915 | int ret; |
| 916 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 917 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 918 | time_before(jiffies, end); bcount++) { |
| 919 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); |
| 920 | if (ret) |
| 921 | return ret; |
| 922 | } |
| 923 | |
| 924 | printk("%6u opers/sec, %9lu bytes/sec\n", |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 925 | bcount / secs, ((long)bcount * blen) / secs); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 926 | |
| 927 | return 0; |
| 928 | } |
| 929 | |
| 930 | static int test_ahash_jiffies(struct ahash_request *req, int blen, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 931 | int plen, char *out, int secs) |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 932 | { |
| 933 | unsigned long start, end; |
| 934 | int bcount, pcount; |
| 935 | int ret; |
| 936 | |
| 937 | if (plen == blen) |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 938 | return test_ahash_jiffies_digest(req, blen, out, secs); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 939 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 940 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 941 | time_before(jiffies, end); bcount++) { |
Herbert Xu | 43a9607 | 2015-04-22 11:02:27 +0800 | [diff] [blame] | 942 | ret = do_one_ahash_op(req, crypto_ahash_init(req)); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 943 | if (ret) |
| 944 | return ret; |
| 945 | for (pcount = 0; pcount < blen; pcount += plen) { |
| 946 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); |
| 947 | if (ret) |
| 948 | return ret; |
| 949 | } |
| 950 | /* we assume there is enough space in 'out' for the result */ |
| 951 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); |
| 952 | if (ret) |
| 953 | return ret; |
| 954 | } |
| 955 | |
| 956 | pr_cont("%6u opers/sec, %9lu bytes/sec\n", |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 957 | bcount / secs, ((long)bcount * blen) / secs); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 958 | |
| 959 | return 0; |
| 960 | } |
| 961 | |
| 962 | static int test_ahash_cycles_digest(struct ahash_request *req, int blen, |
| 963 | char *out) |
| 964 | { |
| 965 | unsigned long cycles = 0; |
| 966 | int ret, i; |
| 967 | |
| 968 | /* Warm-up run. */ |
| 969 | for (i = 0; i < 4; i++) { |
| 970 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); |
| 971 | if (ret) |
| 972 | goto out; |
| 973 | } |
| 974 | |
| 975 | /* The real thing. */ |
| 976 | for (i = 0; i < 8; i++) { |
| 977 | cycles_t start, end; |
| 978 | |
| 979 | start = get_cycles(); |
| 980 | |
| 981 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); |
| 982 | if (ret) |
| 983 | goto out; |
| 984 | |
| 985 | end = get_cycles(); |
| 986 | |
| 987 | cycles += end - start; |
| 988 | } |
| 989 | |
| 990 | out: |
| 991 | if (ret) |
| 992 | return ret; |
| 993 | |
| 994 | pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", |
| 995 | cycles / 8, cycles / (8 * blen)); |
| 996 | |
| 997 | return 0; |
| 998 | } |
| 999 | |
| 1000 | static int test_ahash_cycles(struct ahash_request *req, int blen, |
| 1001 | int plen, char *out) |
| 1002 | { |
| 1003 | unsigned long cycles = 0; |
| 1004 | int i, pcount, ret; |
| 1005 | |
| 1006 | if (plen == blen) |
| 1007 | return test_ahash_cycles_digest(req, blen, out); |
| 1008 | |
| 1009 | /* Warm-up run. */ |
| 1010 | for (i = 0; i < 4; i++) { |
Herbert Xu | 43a9607 | 2015-04-22 11:02:27 +0800 | [diff] [blame] | 1011 | ret = do_one_ahash_op(req, crypto_ahash_init(req)); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1012 | if (ret) |
| 1013 | goto out; |
| 1014 | for (pcount = 0; pcount < blen; pcount += plen) { |
| 1015 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); |
| 1016 | if (ret) |
| 1017 | goto out; |
| 1018 | } |
| 1019 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); |
| 1020 | if (ret) |
| 1021 | goto out; |
| 1022 | } |
| 1023 | |
| 1024 | /* The real thing. */ |
| 1025 | for (i = 0; i < 8; i++) { |
| 1026 | cycles_t start, end; |
| 1027 | |
| 1028 | start = get_cycles(); |
| 1029 | |
Herbert Xu | 43a9607 | 2015-04-22 11:02:27 +0800 | [diff] [blame] | 1030 | ret = do_one_ahash_op(req, crypto_ahash_init(req)); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1031 | if (ret) |
| 1032 | goto out; |
| 1033 | for (pcount = 0; pcount < blen; pcount += plen) { |
| 1034 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); |
| 1035 | if (ret) |
| 1036 | goto out; |
| 1037 | } |
| 1038 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); |
| 1039 | if (ret) |
| 1040 | goto out; |
| 1041 | |
| 1042 | end = get_cycles(); |
| 1043 | |
| 1044 | cycles += end - start; |
| 1045 | } |
| 1046 | |
| 1047 | out: |
| 1048 | if (ret) |
| 1049 | return ret; |
| 1050 | |
| 1051 | pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", |
| 1052 | cycles / 8, cycles / (8 * blen)); |
| 1053 | |
| 1054 | return 0; |
| 1055 | } |
| 1056 | |
Herbert Xu | 0660511 | 2016-02-01 21:36:49 +0800 | [diff] [blame] | 1057 | static void test_ahash_speed_common(const char *algo, unsigned int secs, |
| 1058 | struct hash_speed *speed, unsigned mask) |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1059 | { |
| 1060 | struct scatterlist sg[TVMEMSIZE]; |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 1061 | struct crypto_wait wait; |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1062 | struct ahash_request *req; |
| 1063 | struct crypto_ahash *tfm; |
Horia Geant? | f074f7b | 2015-08-27 18:38:36 +0300 | [diff] [blame] | 1064 | char *output; |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1065 | int i, ret; |
| 1066 | |
Herbert Xu | 0660511 | 2016-02-01 21:36:49 +0800 | [diff] [blame] | 1067 | tfm = crypto_alloc_ahash(algo, 0, mask); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1068 | if (IS_ERR(tfm)) { |
| 1069 | pr_err("failed to load transform for %s: %ld\n", |
| 1070 | algo, PTR_ERR(tfm)); |
| 1071 | return; |
| 1072 | } |
| 1073 | |
Luca Clementi | 263a8df | 2014-06-25 22:57:42 -0700 | [diff] [blame] | 1074 | printk(KERN_INFO "\ntesting speed of async %s (%s)\n", algo, |
| 1075 | get_driver_name(crypto_ahash, tfm)); |
| 1076 | |
Horia Geant? | f074f7b | 2015-08-27 18:38:36 +0300 | [diff] [blame] | 1077 | if (crypto_ahash_digestsize(tfm) > MAX_DIGEST_SIZE) { |
| 1078 | pr_err("digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm), |
| 1079 | MAX_DIGEST_SIZE); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1080 | goto out; |
| 1081 | } |
| 1082 | |
| 1083 | test_hash_sg_init(sg); |
| 1084 | req = ahash_request_alloc(tfm, GFP_KERNEL); |
| 1085 | if (!req) { |
| 1086 | pr_err("ahash request allocation failure\n"); |
| 1087 | goto out; |
| 1088 | } |
| 1089 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 1090 | crypto_init_wait(&wait); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1091 | ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 1092 | crypto_req_done, &wait); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1093 | |
Horia Geant? | f074f7b | 2015-08-27 18:38:36 +0300 | [diff] [blame] | 1094 | output = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL); |
| 1095 | if (!output) |
| 1096 | goto out_nomem; |
| 1097 | |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1098 | for (i = 0; speed[i].blen != 0; i++) { |
| 1099 | if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) { |
| 1100 | pr_err("template (%u) too big for tvmem (%lu)\n", |
| 1101 | speed[i].blen, TVMEMSIZE * PAGE_SIZE); |
| 1102 | break; |
| 1103 | } |
| 1104 | |
Horia Geantă | 331351f | 2018-09-12 16:20:48 +0300 | [diff] [blame] | 1105 | if (speed[i].klen) |
| 1106 | crypto_ahash_setkey(tfm, tvmem[0], speed[i].klen); |
| 1107 | |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1108 | pr_info("test%3u " |
| 1109 | "(%5u byte blocks,%5u bytes per update,%4u updates): ", |
| 1110 | i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen); |
| 1111 | |
| 1112 | ahash_request_set_crypt(req, sg, output, speed[i].plen); |
| 1113 | |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 1114 | if (secs) { |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1115 | ret = test_ahash_jiffies(req, speed[i].blen, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 1116 | speed[i].plen, output, secs); |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 1117 | cond_resched(); |
| 1118 | } else { |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1119 | ret = test_ahash_cycles(req, speed[i].blen, |
| 1120 | speed[i].plen, output); |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 1121 | } |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1122 | |
| 1123 | if (ret) { |
| 1124 | pr_err("hashing failed ret=%d\n", ret); |
| 1125 | break; |
| 1126 | } |
| 1127 | } |
| 1128 | |
Horia Geant? | f074f7b | 2015-08-27 18:38:36 +0300 | [diff] [blame] | 1129 | kfree(output); |
| 1130 | |
| 1131 | out_nomem: |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1132 | ahash_request_free(req); |
| 1133 | |
| 1134 | out: |
| 1135 | crypto_free_ahash(tfm); |
| 1136 | } |
| 1137 | |
Herbert Xu | 0660511 | 2016-02-01 21:36:49 +0800 | [diff] [blame] | 1138 | static void test_ahash_speed(const char *algo, unsigned int secs, |
| 1139 | struct hash_speed *speed) |
| 1140 | { |
| 1141 | return test_ahash_speed_common(algo, secs, speed, 0); |
| 1142 | } |
| 1143 | |
| 1144 | static void test_hash_speed(const char *algo, unsigned int secs, |
| 1145 | struct hash_speed *speed) |
| 1146 | { |
| 1147 | return test_ahash_speed_common(algo, secs, speed, CRYPTO_ALG_ASYNC); |
| 1148 | } |
| 1149 | |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1150 | struct test_mb_skcipher_data { |
| 1151 | struct scatterlist sg[XBUFSIZE]; |
| 1152 | struct skcipher_request *req; |
| 1153 | struct crypto_wait wait; |
| 1154 | char *xbuf[XBUFSIZE]; |
| 1155 | }; |
| 1156 | |
| 1157 | static int do_mult_acipher_op(struct test_mb_skcipher_data *data, int enc, |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 1158 | u32 num_mb, int *rc) |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1159 | { |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 1160 | int i, err = 0; |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1161 | |
| 1162 | /* Fire up a bunch of concurrent requests */ |
| 1163 | for (i = 0; i < num_mb; i++) { |
| 1164 | if (enc == ENCRYPT) |
| 1165 | rc[i] = crypto_skcipher_encrypt(data[i].req); |
| 1166 | else |
| 1167 | rc[i] = crypto_skcipher_decrypt(data[i].req); |
| 1168 | } |
| 1169 | |
| 1170 | /* Wait for all requests to finish */ |
| 1171 | for (i = 0; i < num_mb; i++) { |
| 1172 | rc[i] = crypto_wait_req(rc[i], &data[i].wait); |
| 1173 | |
| 1174 | if (rc[i]) { |
| 1175 | pr_info("concurrent request %d error %d\n", i, rc[i]); |
| 1176 | err = rc[i]; |
| 1177 | } |
| 1178 | } |
| 1179 | |
| 1180 | return err; |
| 1181 | } |
| 1182 | |
| 1183 | static int test_mb_acipher_jiffies(struct test_mb_skcipher_data *data, int enc, |
| 1184 | int blen, int secs, u32 num_mb) |
| 1185 | { |
| 1186 | unsigned long start, end; |
| 1187 | int bcount; |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 1188 | int ret = 0; |
| 1189 | int *rc; |
| 1190 | |
| 1191 | rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL); |
| 1192 | if (!rc) |
| 1193 | return -ENOMEM; |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1194 | |
| 1195 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
| 1196 | time_before(jiffies, end); bcount++) { |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 1197 | ret = do_mult_acipher_op(data, enc, num_mb, rc); |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1198 | if (ret) |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 1199 | goto out; |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1200 | } |
| 1201 | |
| 1202 | pr_cont("%d operations in %d seconds (%ld bytes)\n", |
| 1203 | bcount * num_mb, secs, (long)bcount * blen * num_mb); |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 1204 | |
| 1205 | out: |
| 1206 | kfree(rc); |
| 1207 | return ret; |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1208 | } |
| 1209 | |
| 1210 | static int test_mb_acipher_cycles(struct test_mb_skcipher_data *data, int enc, |
| 1211 | int blen, u32 num_mb) |
| 1212 | { |
| 1213 | unsigned long cycles = 0; |
| 1214 | int ret = 0; |
| 1215 | int i; |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 1216 | int *rc; |
| 1217 | |
| 1218 | rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL); |
| 1219 | if (!rc) |
| 1220 | return -ENOMEM; |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1221 | |
| 1222 | /* Warm-up run. */ |
| 1223 | for (i = 0; i < 4; i++) { |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 1224 | ret = do_mult_acipher_op(data, enc, num_mb, rc); |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1225 | if (ret) |
| 1226 | goto out; |
| 1227 | } |
| 1228 | |
| 1229 | /* The real thing. */ |
| 1230 | for (i = 0; i < 8; i++) { |
| 1231 | cycles_t start, end; |
| 1232 | |
| 1233 | start = get_cycles(); |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 1234 | ret = do_mult_acipher_op(data, enc, num_mb, rc); |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1235 | end = get_cycles(); |
| 1236 | |
| 1237 | if (ret) |
| 1238 | goto out; |
| 1239 | |
| 1240 | cycles += end - start; |
| 1241 | } |
| 1242 | |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 1243 | pr_cont("1 operation in %lu cycles (%d bytes)\n", |
| 1244 | (cycles + 4) / (8 * num_mb), blen); |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1245 | |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 1246 | out: |
| 1247 | kfree(rc); |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1248 | return ret; |
| 1249 | } |
| 1250 | |
| 1251 | static void test_mb_skcipher_speed(const char *algo, int enc, int secs, |
| 1252 | struct cipher_speed_template *template, |
| 1253 | unsigned int tcount, u8 *keysize, u32 num_mb) |
| 1254 | { |
| 1255 | struct test_mb_skcipher_data *data; |
| 1256 | struct crypto_skcipher *tfm; |
| 1257 | unsigned int i, j, iv_len; |
| 1258 | const char *key; |
| 1259 | const char *e; |
| 1260 | u32 *b_size; |
| 1261 | char iv[128]; |
| 1262 | int ret; |
| 1263 | |
| 1264 | if (enc == ENCRYPT) |
| 1265 | e = "encryption"; |
| 1266 | else |
| 1267 | e = "decryption"; |
| 1268 | |
| 1269 | data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL); |
| 1270 | if (!data) |
| 1271 | return; |
| 1272 | |
| 1273 | tfm = crypto_alloc_skcipher(algo, 0, 0); |
| 1274 | if (IS_ERR(tfm)) { |
| 1275 | pr_err("failed to load transform for %s: %ld\n", |
| 1276 | algo, PTR_ERR(tfm)); |
| 1277 | goto out_free_data; |
| 1278 | } |
| 1279 | |
| 1280 | for (i = 0; i < num_mb; ++i) |
| 1281 | if (testmgr_alloc_buf(data[i].xbuf)) { |
| 1282 | while (i--) |
| 1283 | testmgr_free_buf(data[i].xbuf); |
| 1284 | goto out_free_tfm; |
| 1285 | } |
| 1286 | |
| 1287 | |
| 1288 | for (i = 0; i < num_mb; ++i) |
| 1289 | if (testmgr_alloc_buf(data[i].xbuf)) { |
| 1290 | while (i--) |
| 1291 | testmgr_free_buf(data[i].xbuf); |
| 1292 | goto out_free_tfm; |
| 1293 | } |
| 1294 | |
| 1295 | |
| 1296 | for (i = 0; i < num_mb; ++i) { |
| 1297 | data[i].req = skcipher_request_alloc(tfm, GFP_KERNEL); |
| 1298 | if (!data[i].req) { |
| 1299 | pr_err("alg: skcipher: Failed to allocate request for %s\n", |
| 1300 | algo); |
| 1301 | while (i--) |
| 1302 | skcipher_request_free(data[i].req); |
| 1303 | goto out_free_xbuf; |
| 1304 | } |
| 1305 | } |
| 1306 | |
| 1307 | for (i = 0; i < num_mb; ++i) { |
| 1308 | skcipher_request_set_callback(data[i].req, |
| 1309 | CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 1310 | crypto_req_done, &data[i].wait); |
| 1311 | crypto_init_wait(&data[i].wait); |
| 1312 | } |
| 1313 | |
| 1314 | pr_info("\ntesting speed of multibuffer %s (%s) %s\n", algo, |
| 1315 | get_driver_name(crypto_skcipher, tfm), e); |
| 1316 | |
| 1317 | i = 0; |
| 1318 | do { |
| 1319 | b_size = block_sizes; |
| 1320 | do { |
| 1321 | if (*b_size > XBUFSIZE * PAGE_SIZE) { |
Colin Ian King | 38dbe2d | 2018-01-02 09:21:06 +0000 | [diff] [blame] | 1322 | pr_err("template (%u) too big for buffer (%lu)\n", |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1323 | *b_size, XBUFSIZE * PAGE_SIZE); |
| 1324 | goto out; |
| 1325 | } |
| 1326 | |
| 1327 | pr_info("test %u (%d bit key, %d byte blocks): ", i, |
| 1328 | *keysize * 8, *b_size); |
| 1329 | |
| 1330 | /* Set up tfm global state, i.e. the key */ |
| 1331 | |
| 1332 | memset(tvmem[0], 0xff, PAGE_SIZE); |
| 1333 | key = tvmem[0]; |
| 1334 | for (j = 0; j < tcount; j++) { |
| 1335 | if (template[j].klen == *keysize) { |
| 1336 | key = template[j].key; |
| 1337 | break; |
| 1338 | } |
| 1339 | } |
| 1340 | |
| 1341 | crypto_skcipher_clear_flags(tfm, ~0); |
| 1342 | |
| 1343 | ret = crypto_skcipher_setkey(tfm, key, *keysize); |
| 1344 | if (ret) { |
| 1345 | pr_err("setkey() failed flags=%x\n", |
| 1346 | crypto_skcipher_get_flags(tfm)); |
| 1347 | goto out; |
| 1348 | } |
| 1349 | |
| 1350 | iv_len = crypto_skcipher_ivsize(tfm); |
| 1351 | if (iv_len) |
| 1352 | memset(&iv, 0xff, iv_len); |
| 1353 | |
| 1354 | /* Now setup per request stuff, i.e. buffers */ |
| 1355 | |
| 1356 | for (j = 0; j < num_mb; ++j) { |
| 1357 | struct test_mb_skcipher_data *cur = &data[j]; |
| 1358 | unsigned int k = *b_size; |
| 1359 | unsigned int pages = DIV_ROUND_UP(k, PAGE_SIZE); |
| 1360 | unsigned int p = 0; |
| 1361 | |
| 1362 | sg_init_table(cur->sg, pages); |
| 1363 | |
| 1364 | while (k > PAGE_SIZE) { |
| 1365 | sg_set_buf(cur->sg + p, cur->xbuf[p], |
| 1366 | PAGE_SIZE); |
| 1367 | memset(cur->xbuf[p], 0xff, PAGE_SIZE); |
| 1368 | p++; |
| 1369 | k -= PAGE_SIZE; |
| 1370 | } |
| 1371 | |
| 1372 | sg_set_buf(cur->sg + p, cur->xbuf[p], k); |
| 1373 | memset(cur->xbuf[p], 0xff, k); |
| 1374 | |
| 1375 | skcipher_request_set_crypt(cur->req, cur->sg, |
| 1376 | cur->sg, *b_size, |
| 1377 | iv); |
| 1378 | } |
| 1379 | |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 1380 | if (secs) { |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1381 | ret = test_mb_acipher_jiffies(data, enc, |
| 1382 | *b_size, secs, |
| 1383 | num_mb); |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 1384 | cond_resched(); |
| 1385 | } else { |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1386 | ret = test_mb_acipher_cycles(data, enc, |
| 1387 | *b_size, num_mb); |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 1388 | } |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 1389 | |
| 1390 | if (ret) { |
| 1391 | pr_err("%s() failed flags=%x\n", e, |
| 1392 | crypto_skcipher_get_flags(tfm)); |
| 1393 | break; |
| 1394 | } |
| 1395 | b_size++; |
| 1396 | i++; |
| 1397 | } while (*b_size); |
| 1398 | keysize++; |
| 1399 | } while (*keysize); |
| 1400 | |
| 1401 | out: |
| 1402 | for (i = 0; i < num_mb; ++i) |
| 1403 | skcipher_request_free(data[i].req); |
| 1404 | out_free_xbuf: |
| 1405 | for (i = 0; i < num_mb; ++i) |
| 1406 | testmgr_free_buf(data[i].xbuf); |
| 1407 | out_free_tfm: |
| 1408 | crypto_free_skcipher(tfm); |
| 1409 | out_free_data: |
| 1410 | kfree(data); |
| 1411 | } |
| 1412 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1413 | static inline int do_one_acipher_op(struct skcipher_request *req, int ret) |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1414 | { |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 1415 | struct crypto_wait *wait = req->base.data; |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1416 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 1417 | return crypto_wait_req(ret, wait); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1418 | } |
| 1419 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1420 | static int test_acipher_jiffies(struct skcipher_request *req, int enc, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 1421 | int blen, int secs) |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1422 | { |
| 1423 | unsigned long start, end; |
| 1424 | int bcount; |
| 1425 | int ret; |
| 1426 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 1427 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1428 | time_before(jiffies, end); bcount++) { |
| 1429 | if (enc) |
| 1430 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1431 | crypto_skcipher_encrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1432 | else |
| 1433 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1434 | crypto_skcipher_decrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1435 | |
| 1436 | if (ret) |
| 1437 | return ret; |
| 1438 | } |
| 1439 | |
| 1440 | pr_cont("%d operations in %d seconds (%ld bytes)\n", |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 1441 | bcount, secs, (long)bcount * blen); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1442 | return 0; |
| 1443 | } |
| 1444 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1445 | static int test_acipher_cycles(struct skcipher_request *req, int enc, |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1446 | int blen) |
| 1447 | { |
| 1448 | unsigned long cycles = 0; |
| 1449 | int ret = 0; |
| 1450 | int i; |
| 1451 | |
| 1452 | /* Warm-up run. */ |
| 1453 | for (i = 0; i < 4; i++) { |
| 1454 | if (enc) |
| 1455 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1456 | crypto_skcipher_encrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1457 | else |
| 1458 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1459 | crypto_skcipher_decrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1460 | |
| 1461 | if (ret) |
| 1462 | goto out; |
| 1463 | } |
| 1464 | |
| 1465 | /* The real thing. */ |
| 1466 | for (i = 0; i < 8; i++) { |
| 1467 | cycles_t start, end; |
| 1468 | |
| 1469 | start = get_cycles(); |
| 1470 | if (enc) |
| 1471 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1472 | crypto_skcipher_encrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1473 | else |
| 1474 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1475 | crypto_skcipher_decrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1476 | end = get_cycles(); |
| 1477 | |
| 1478 | if (ret) |
| 1479 | goto out; |
| 1480 | |
| 1481 | cycles += end - start; |
| 1482 | } |
| 1483 | |
| 1484 | out: |
| 1485 | if (ret == 0) |
| 1486 | pr_cont("1 operation in %lu cycles (%d bytes)\n", |
| 1487 | (cycles + 4) / 8, blen); |
| 1488 | |
| 1489 | return ret; |
| 1490 | } |
| 1491 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1492 | static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, |
| 1493 | struct cipher_speed_template *template, |
| 1494 | unsigned int tcount, u8 *keysize, bool async) |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1495 | { |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 1496 | unsigned int ret, i, j, k, iv_len; |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 1497 | struct crypto_wait wait; |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1498 | const char *key; |
| 1499 | char iv[128]; |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1500 | struct skcipher_request *req; |
| 1501 | struct crypto_skcipher *tfm; |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1502 | const char *e; |
| 1503 | u32 *b_size; |
| 1504 | |
| 1505 | if (enc == ENCRYPT) |
| 1506 | e = "encryption"; |
| 1507 | else |
| 1508 | e = "decryption"; |
| 1509 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 1510 | crypto_init_wait(&wait); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1511 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1512 | tfm = crypto_alloc_skcipher(algo, 0, async ? 0 : CRYPTO_ALG_ASYNC); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1513 | |
| 1514 | if (IS_ERR(tfm)) { |
| 1515 | pr_err("failed to load transform for %s: %ld\n", algo, |
| 1516 | PTR_ERR(tfm)); |
| 1517 | return; |
| 1518 | } |
| 1519 | |
Luca Clementi | 263a8df | 2014-06-25 22:57:42 -0700 | [diff] [blame] | 1520 | pr_info("\ntesting speed of async %s (%s) %s\n", algo, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1521 | get_driver_name(crypto_skcipher, tfm), e); |
Luca Clementi | 263a8df | 2014-06-25 22:57:42 -0700 | [diff] [blame] | 1522 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1523 | req = skcipher_request_alloc(tfm, GFP_KERNEL); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1524 | if (!req) { |
| 1525 | pr_err("tcrypt: skcipher: Failed to allocate request for %s\n", |
| 1526 | algo); |
| 1527 | goto out; |
| 1528 | } |
| 1529 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1530 | skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 1531 | crypto_req_done, &wait); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1532 | |
| 1533 | i = 0; |
| 1534 | do { |
| 1535 | b_size = block_sizes; |
| 1536 | |
| 1537 | do { |
| 1538 | struct scatterlist sg[TVMEMSIZE]; |
| 1539 | |
| 1540 | if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { |
| 1541 | pr_err("template (%u) too big for " |
| 1542 | "tvmem (%lu)\n", *keysize + *b_size, |
| 1543 | TVMEMSIZE * PAGE_SIZE); |
| 1544 | goto out_free_req; |
| 1545 | } |
| 1546 | |
| 1547 | pr_info("test %u (%d bit key, %d byte blocks): ", i, |
| 1548 | *keysize * 8, *b_size); |
| 1549 | |
| 1550 | memset(tvmem[0], 0xff, PAGE_SIZE); |
| 1551 | |
| 1552 | /* set key, plain text and IV */ |
| 1553 | key = tvmem[0]; |
| 1554 | for (j = 0; j < tcount; j++) { |
| 1555 | if (template[j].klen == *keysize) { |
| 1556 | key = template[j].key; |
| 1557 | break; |
| 1558 | } |
| 1559 | } |
| 1560 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1561 | crypto_skcipher_clear_flags(tfm, ~0); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1562 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1563 | ret = crypto_skcipher_setkey(tfm, key, *keysize); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1564 | if (ret) { |
| 1565 | pr_err("setkey() failed flags=%x\n", |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1566 | crypto_skcipher_get_flags(tfm)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1567 | goto out_free_req; |
| 1568 | } |
| 1569 | |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 1570 | k = *keysize + *b_size; |
Horia Geant? | 007ee8d | 2015-03-09 16:14:58 +0200 | [diff] [blame] | 1571 | sg_init_table(sg, DIV_ROUND_UP(k, PAGE_SIZE)); |
| 1572 | |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 1573 | if (k > PAGE_SIZE) { |
| 1574 | sg_set_buf(sg, tvmem[0] + *keysize, |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1575 | PAGE_SIZE - *keysize); |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 1576 | k -= PAGE_SIZE; |
| 1577 | j = 1; |
| 1578 | while (k > PAGE_SIZE) { |
| 1579 | sg_set_buf(sg + j, tvmem[j], PAGE_SIZE); |
| 1580 | memset(tvmem[j], 0xff, PAGE_SIZE); |
| 1581 | j++; |
| 1582 | k -= PAGE_SIZE; |
| 1583 | } |
| 1584 | sg_set_buf(sg + j, tvmem[j], k); |
| 1585 | memset(tvmem[j], 0xff, k); |
| 1586 | } else { |
| 1587 | sg_set_buf(sg, tvmem[0] + *keysize, *b_size); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1588 | } |
| 1589 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1590 | iv_len = crypto_skcipher_ivsize(tfm); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1591 | if (iv_len) |
| 1592 | memset(&iv, 0xff, iv_len); |
| 1593 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1594 | skcipher_request_set_crypt(req, sg, sg, *b_size, iv); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1595 | |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 1596 | if (secs) { |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1597 | ret = test_acipher_jiffies(req, enc, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 1598 | *b_size, secs); |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 1599 | cond_resched(); |
| 1600 | } else { |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1601 | ret = test_acipher_cycles(req, enc, |
| 1602 | *b_size); |
Horia Geantă | 2af6329 | 2018-07-23 17:18:48 +0300 | [diff] [blame] | 1603 | } |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1604 | |
| 1605 | if (ret) { |
| 1606 | pr_err("%s() failed flags=%x\n", e, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1607 | crypto_skcipher_get_flags(tfm)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1608 | break; |
| 1609 | } |
| 1610 | b_size++; |
| 1611 | i++; |
| 1612 | } while (*b_size); |
| 1613 | keysize++; |
| 1614 | } while (*keysize); |
| 1615 | |
| 1616 | out_free_req: |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1617 | skcipher_request_free(req); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1618 | out: |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1619 | crypto_free_skcipher(tfm); |
| 1620 | } |
| 1621 | |
| 1622 | static void test_acipher_speed(const char *algo, int enc, unsigned int secs, |
| 1623 | struct cipher_speed_template *template, |
| 1624 | unsigned int tcount, u8 *keysize) |
| 1625 | { |
| 1626 | return test_skcipher_speed(algo, enc, secs, template, tcount, keysize, |
| 1627 | true); |
| 1628 | } |
| 1629 | |
| 1630 | static void test_cipher_speed(const char *algo, int enc, unsigned int secs, |
| 1631 | struct cipher_speed_template *template, |
| 1632 | unsigned int tcount, u8 *keysize) |
| 1633 | { |
| 1634 | return test_skcipher_speed(algo, enc, secs, template, tcount, keysize, |
| 1635 | false); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1636 | } |
| 1637 | |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1638 | static void test_available(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1639 | { |
| 1640 | char **name = check; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1641 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1642 | while (*name) { |
| 1643 | printk("alg %s ", *name); |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 1644 | printk(crypto_has_alg(*name, 0, 0) ? |
Herbert Xu | e4d5b79 | 2006-08-26 18:12:40 +1000 | [diff] [blame] | 1645 | "found\n" : "not found\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1646 | name++; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1647 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1648 | } |
| 1649 | |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 1650 | static inline int tcrypt_test(const char *alg) |
| 1651 | { |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1652 | int ret; |
| 1653 | |
Rabin Vincent | 76512f2 | 2017-01-18 14:54:05 +0100 | [diff] [blame] | 1654 | pr_debug("testing %s\n", alg); |
| 1655 | |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1656 | ret = alg_test(alg, alg, 0, 0); |
| 1657 | /* non-fips algs return -EINVAL in fips mode */ |
| 1658 | if (fips_enabled && ret == -EINVAL) |
| 1659 | ret = 0; |
| 1660 | return ret; |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 1661 | } |
| 1662 | |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 1663 | static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb) |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 1664 | { |
| 1665 | int i; |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1666 | int ret = 0; |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 1667 | |
| 1668 | switch (m) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1669 | case 0: |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 1670 | if (alg) { |
| 1671 | if (!crypto_has_alg(alg, type, |
| 1672 | mask ?: CRYPTO_ALG_TYPE_MASK)) |
| 1673 | ret = -ENOENT; |
| 1674 | break; |
| 1675 | } |
| 1676 | |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 1677 | for (i = 1; i < 200; i++) |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 1678 | ret += do_test(NULL, 0, 0, i, num_mb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1679 | break; |
| 1680 | |
| 1681 | case 1: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1682 | ret += tcrypt_test("md5"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1683 | break; |
| 1684 | |
| 1685 | case 2: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1686 | ret += tcrypt_test("sha1"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1687 | break; |
| 1688 | |
| 1689 | case 3: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1690 | ret += tcrypt_test("ecb(des)"); |
| 1691 | ret += tcrypt_test("cbc(des)"); |
Jussi Kivilinna | 8163fc3 | 2012-10-20 14:53:07 +0300 | [diff] [blame] | 1692 | ret += tcrypt_test("ctr(des)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | break; |
| 1694 | |
| 1695 | case 4: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1696 | ret += tcrypt_test("ecb(des3_ede)"); |
| 1697 | ret += tcrypt_test("cbc(des3_ede)"); |
Jussi Kivilinna | e080b17 | 2012-10-20 14:53:12 +0300 | [diff] [blame] | 1698 | ret += tcrypt_test("ctr(des3_ede)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1699 | break; |
| 1700 | |
| 1701 | case 5: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1702 | ret += tcrypt_test("md4"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1703 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1704 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1705 | case 6: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1706 | ret += tcrypt_test("sha256"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1707 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1708 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1709 | case 7: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1710 | ret += tcrypt_test("ecb(blowfish)"); |
| 1711 | ret += tcrypt_test("cbc(blowfish)"); |
Jussi Kivilinna | 85b63e3 | 2011-10-10 23:03:03 +0300 | [diff] [blame] | 1712 | ret += tcrypt_test("ctr(blowfish)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 | break; |
| 1714 | |
| 1715 | case 8: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1716 | ret += tcrypt_test("ecb(twofish)"); |
| 1717 | ret += tcrypt_test("cbc(twofish)"); |
Jussi Kivilinna | 573da62 | 2011-10-10 23:03:12 +0300 | [diff] [blame] | 1718 | ret += tcrypt_test("ctr(twofish)"); |
Jussi Kivilinna | bee3a90 | 2011-10-18 13:32:56 +0300 | [diff] [blame] | 1719 | ret += tcrypt_test("lrw(twofish)"); |
Jussi Kivilinna | 131f754 | 2011-10-18 13:33:38 +0300 | [diff] [blame] | 1720 | ret += tcrypt_test("xts(twofish)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1721 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1722 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1723 | case 9: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1724 | ret += tcrypt_test("ecb(serpent)"); |
Jussi Kivilinna | 9d25917 | 2011-10-18 00:02:53 +0300 | [diff] [blame] | 1725 | ret += tcrypt_test("cbc(serpent)"); |
| 1726 | ret += tcrypt_test("ctr(serpent)"); |
Jussi Kivilinna | 87aae4b | 2011-10-18 13:32:39 +0300 | [diff] [blame] | 1727 | ret += tcrypt_test("lrw(serpent)"); |
Jussi Kivilinna | 5209c07 | 2011-10-18 13:33:22 +0300 | [diff] [blame] | 1728 | ret += tcrypt_test("xts(serpent)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1729 | break; |
| 1730 | |
| 1731 | case 10: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1732 | ret += tcrypt_test("ecb(aes)"); |
| 1733 | ret += tcrypt_test("cbc(aes)"); |
| 1734 | ret += tcrypt_test("lrw(aes)"); |
| 1735 | ret += tcrypt_test("xts(aes)"); |
| 1736 | ret += tcrypt_test("ctr(aes)"); |
| 1737 | ret += tcrypt_test("rfc3686(ctr(aes))"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1738 | break; |
| 1739 | |
| 1740 | case 11: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1741 | ret += tcrypt_test("sha384"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1742 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1743 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1744 | case 12: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1745 | ret += tcrypt_test("sha512"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1746 | break; |
| 1747 | |
| 1748 | case 13: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1749 | ret += tcrypt_test("deflate"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1750 | break; |
| 1751 | |
| 1752 | case 14: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1753 | ret += tcrypt_test("ecb(cast5)"); |
Johannes Goetzfried | a2c5826 | 2012-07-11 19:37:21 +0200 | [diff] [blame] | 1754 | ret += tcrypt_test("cbc(cast5)"); |
| 1755 | ret += tcrypt_test("ctr(cast5)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1756 | break; |
| 1757 | |
| 1758 | case 15: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1759 | ret += tcrypt_test("ecb(cast6)"); |
Johannes Goetzfried | 9b8b040 | 2012-07-11 19:38:29 +0200 | [diff] [blame] | 1760 | ret += tcrypt_test("cbc(cast6)"); |
| 1761 | ret += tcrypt_test("ctr(cast6)"); |
| 1762 | ret += tcrypt_test("lrw(cast6)"); |
| 1763 | ret += tcrypt_test("xts(cast6)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1764 | break; |
| 1765 | |
| 1766 | case 16: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1767 | ret += tcrypt_test("ecb(arc4)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1768 | break; |
| 1769 | |
| 1770 | case 17: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1771 | ret += tcrypt_test("michael_mic"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1772 | break; |
| 1773 | |
| 1774 | case 18: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1775 | ret += tcrypt_test("crc32c"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1776 | break; |
| 1777 | |
| 1778 | case 19: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1779 | ret += tcrypt_test("ecb(tea)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1780 | break; |
| 1781 | |
| 1782 | case 20: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1783 | ret += tcrypt_test("ecb(xtea)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1784 | break; |
| 1785 | |
| 1786 | case 21: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1787 | ret += tcrypt_test("ecb(khazad)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1788 | break; |
| 1789 | |
| 1790 | case 22: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1791 | ret += tcrypt_test("wp512"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1792 | break; |
| 1793 | |
| 1794 | case 23: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1795 | ret += tcrypt_test("wp384"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1796 | break; |
| 1797 | |
| 1798 | case 24: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1799 | ret += tcrypt_test("wp256"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1800 | break; |
| 1801 | |
| 1802 | case 25: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1803 | ret += tcrypt_test("ecb(tnepres)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1804 | break; |
| 1805 | |
| 1806 | case 26: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1807 | ret += tcrypt_test("ecb(anubis)"); |
| 1808 | ret += tcrypt_test("cbc(anubis)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1809 | break; |
| 1810 | |
| 1811 | case 27: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1812 | ret += tcrypt_test("tgr192"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1813 | break; |
| 1814 | |
| 1815 | case 28: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1816 | ret += tcrypt_test("tgr160"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1817 | break; |
| 1818 | |
| 1819 | case 29: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1820 | ret += tcrypt_test("tgr128"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1821 | break; |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1822 | |
Aaron Grothe | fb4f10e | 2005-09-01 17:42:46 -0700 | [diff] [blame] | 1823 | case 30: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1824 | ret += tcrypt_test("ecb(xeta)"); |
Aaron Grothe | fb4f10e | 2005-09-01 17:42:46 -0700 | [diff] [blame] | 1825 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1826 | |
David Howells | 9083163 | 2006-12-16 12:13:14 +1100 | [diff] [blame] | 1827 | case 31: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1828 | ret += tcrypt_test("pcbc(fcrypt)"); |
David Howells | 9083163 | 2006-12-16 12:13:14 +1100 | [diff] [blame] | 1829 | break; |
| 1830 | |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1831 | case 32: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1832 | ret += tcrypt_test("ecb(camellia)"); |
| 1833 | ret += tcrypt_test("cbc(camellia)"); |
Jussi Kivilinna | 54216bb | 2012-09-21 10:27:10 +0300 | [diff] [blame] | 1834 | ret += tcrypt_test("ctr(camellia)"); |
| 1835 | ret += tcrypt_test("lrw(camellia)"); |
| 1836 | ret += tcrypt_test("xts(camellia)"); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1837 | break; |
Jussi Kivilinna | 93b5e86 | 2013-04-08 10:48:44 +0300 | [diff] [blame] | 1838 | |
Jonathan Lynch | cd12fb9 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1839 | case 33: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1840 | ret += tcrypt_test("sha224"); |
Jonathan Lynch | cd12fb9 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1841 | break; |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1842 | |
Tan Swee Heng | 2407d60 | 2007-11-23 19:45:00 +0800 | [diff] [blame] | 1843 | case 34: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1844 | ret += tcrypt_test("salsa20"); |
Tan Swee Heng | 2407d60 | 2007-11-23 19:45:00 +0800 | [diff] [blame] | 1845 | break; |
| 1846 | |
Herbert Xu | 8df213d | 2007-12-02 14:55:47 +1100 | [diff] [blame] | 1847 | case 35: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1848 | ret += tcrypt_test("gcm(aes)"); |
Herbert Xu | 8df213d | 2007-12-02 14:55:47 +1100 | [diff] [blame] | 1849 | break; |
| 1850 | |
Zoltan Sogor | 0b77abb | 2007-12-07 16:53:23 +0800 | [diff] [blame] | 1851 | case 36: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1852 | ret += tcrypt_test("lzo"); |
Zoltan Sogor | 0b77abb | 2007-12-07 16:53:23 +0800 | [diff] [blame] | 1853 | break; |
| 1854 | |
Joy Latten | 93cc74e | 2007-12-12 20:24:22 +0800 | [diff] [blame] | 1855 | case 37: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1856 | ret += tcrypt_test("ccm(aes)"); |
Joy Latten | 93cc74e | 2007-12-12 20:24:22 +0800 | [diff] [blame] | 1857 | break; |
| 1858 | |
Kevin Coffman | 76cb952 | 2008-03-24 21:26:16 +0800 | [diff] [blame] | 1859 | case 38: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1860 | ret += tcrypt_test("cts(cbc(aes))"); |
Kevin Coffman | 76cb952 | 2008-03-24 21:26:16 +0800 | [diff] [blame] | 1861 | break; |
| 1862 | |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1863 | case 39: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1864 | ret += tcrypt_test("rmd128"); |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1865 | break; |
| 1866 | |
| 1867 | case 40: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1868 | ret += tcrypt_test("rmd160"); |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1869 | break; |
| 1870 | |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1871 | case 41: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1872 | ret += tcrypt_test("rmd256"); |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1873 | break; |
| 1874 | |
| 1875 | case 42: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1876 | ret += tcrypt_test("rmd320"); |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 1877 | break; |
| 1878 | |
| 1879 | case 43: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1880 | ret += tcrypt_test("ecb(seed)"); |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1881 | break; |
| 1882 | |
Jarod Wilson | 5d66732 | 2009-05-04 19:23:40 +0800 | [diff] [blame] | 1883 | case 45: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1884 | ret += tcrypt_test("rfc4309(ccm(aes))"); |
Jarod Wilson | 5d66732 | 2009-05-04 19:23:40 +0800 | [diff] [blame] | 1885 | break; |
| 1886 | |
Jussi Kivilinna | 54216bb | 2012-09-21 10:27:10 +0300 | [diff] [blame] | 1887 | case 46: |
| 1888 | ret += tcrypt_test("ghash"); |
| 1889 | break; |
| 1890 | |
Herbert Xu | 68411521 | 2013-09-07 12:56:26 +1000 | [diff] [blame] | 1891 | case 47: |
| 1892 | ret += tcrypt_test("crct10dif"); |
| 1893 | break; |
| 1894 | |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1895 | case 48: |
| 1896 | ret += tcrypt_test("sha3-224"); |
| 1897 | break; |
| 1898 | |
| 1899 | case 49: |
| 1900 | ret += tcrypt_test("sha3-256"); |
| 1901 | break; |
| 1902 | |
| 1903 | case 50: |
| 1904 | ret += tcrypt_test("sha3-384"); |
| 1905 | break; |
| 1906 | |
| 1907 | case 51: |
| 1908 | ret += tcrypt_test("sha3-512"); |
| 1909 | break; |
| 1910 | |
Gilad Ben-Yossef | b7e2753 | 2017-08-21 13:51:29 +0300 | [diff] [blame] | 1911 | case 52: |
| 1912 | ret += tcrypt_test("sm3"); |
| 1913 | break; |
| 1914 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1915 | case 100: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1916 | ret += tcrypt_test("hmac(md5)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1917 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1918 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1919 | case 101: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1920 | ret += tcrypt_test("hmac(sha1)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1921 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1922 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1923 | case 102: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1924 | ret += tcrypt_test("hmac(sha256)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1925 | break; |
| 1926 | |
Andrew Donofrio | a28091a | 2006-12-10 12:10:20 +1100 | [diff] [blame] | 1927 | case 103: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1928 | ret += tcrypt_test("hmac(sha384)"); |
Andrew Donofrio | a28091a | 2006-12-10 12:10:20 +1100 | [diff] [blame] | 1929 | break; |
| 1930 | |
| 1931 | case 104: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1932 | ret += tcrypt_test("hmac(sha512)"); |
Andrew Donofrio | a28091a | 2006-12-10 12:10:20 +1100 | [diff] [blame] | 1933 | break; |
Herbert Xu | 38ed9ab | 2008-01-01 15:59:28 +1100 | [diff] [blame] | 1934 | |
Jonathan Lynch | cd12fb9 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1935 | case 105: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1936 | ret += tcrypt_test("hmac(sha224)"); |
Jonathan Lynch | cd12fb9 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1937 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1938 | |
Herbert Xu | 38ed9ab | 2008-01-01 15:59:28 +1100 | [diff] [blame] | 1939 | case 106: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1940 | ret += tcrypt_test("xcbc(aes)"); |
Herbert Xu | 38ed9ab | 2008-01-01 15:59:28 +1100 | [diff] [blame] | 1941 | break; |
| 1942 | |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1943 | case 107: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1944 | ret += tcrypt_test("hmac(rmd128)"); |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1945 | break; |
| 1946 | |
| 1947 | case 108: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1948 | ret += tcrypt_test("hmac(rmd160)"); |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1949 | break; |
| 1950 | |
Shane Wang | f1939f7 | 2009-09-02 20:05:22 +1000 | [diff] [blame] | 1951 | case 109: |
Eric Biggers | 0917b87 | 2018-06-18 10:22:40 -0700 | [diff] [blame] | 1952 | ret += tcrypt_test("vmac64(aes)"); |
Shane Wang | f1939f7 | 2009-09-02 20:05:22 +1000 | [diff] [blame] | 1953 | break; |
Jussi Kivilinna | 93b5e86 | 2013-04-08 10:48:44 +0300 | [diff] [blame] | 1954 | |
raveendra padasalagi | 98eca72 | 2016-07-01 11:16:54 +0530 | [diff] [blame] | 1955 | case 111: |
| 1956 | ret += tcrypt_test("hmac(sha3-224)"); |
| 1957 | break; |
| 1958 | |
| 1959 | case 112: |
| 1960 | ret += tcrypt_test("hmac(sha3-256)"); |
| 1961 | break; |
| 1962 | |
| 1963 | case 113: |
| 1964 | ret += tcrypt_test("hmac(sha3-384)"); |
| 1965 | break; |
| 1966 | |
| 1967 | case 114: |
| 1968 | ret += tcrypt_test("hmac(sha3-512)"); |
| 1969 | break; |
| 1970 | |
Jarod Wilson | e08ca2d | 2009-05-04 19:46:29 +0800 | [diff] [blame] | 1971 | case 150: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1972 | ret += tcrypt_test("ansi_cprng"); |
Jarod Wilson | e08ca2d | 2009-05-04 19:46:29 +0800 | [diff] [blame] | 1973 | break; |
| 1974 | |
Adrian Hoban | 69435b9 | 2010-11-04 15:02:04 -0400 | [diff] [blame] | 1975 | case 151: |
| 1976 | ret += tcrypt_test("rfc4106(gcm(aes))"); |
| 1977 | break; |
| 1978 | |
Jussi Kivilinna | e9b7441 | 2013-04-07 16:43:51 +0300 | [diff] [blame] | 1979 | case 152: |
| 1980 | ret += tcrypt_test("rfc4543(gcm(aes))"); |
| 1981 | break; |
| 1982 | |
Jussi Kivilinna | 93b5e86 | 2013-04-08 10:48:44 +0300 | [diff] [blame] | 1983 | case 153: |
| 1984 | ret += tcrypt_test("cmac(aes)"); |
| 1985 | break; |
| 1986 | |
| 1987 | case 154: |
| 1988 | ret += tcrypt_test("cmac(des3_ede)"); |
| 1989 | break; |
| 1990 | |
Horia Geanta | bbf9c89 | 2013-11-28 15:11:16 +0200 | [diff] [blame] | 1991 | case 155: |
| 1992 | ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))"); |
| 1993 | break; |
| 1994 | |
Horia Geanta | bca4feb | 2014-03-14 17:46:51 +0200 | [diff] [blame] | 1995 | case 156: |
| 1996 | ret += tcrypt_test("authenc(hmac(md5),ecb(cipher_null))"); |
| 1997 | break; |
| 1998 | |
| 1999 | case 157: |
| 2000 | ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))"); |
| 2001 | break; |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2002 | case 181: |
| 2003 | ret += tcrypt_test("authenc(hmac(sha1),cbc(des))"); |
| 2004 | break; |
| 2005 | case 182: |
| 2006 | ret += tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))"); |
| 2007 | break; |
| 2008 | case 183: |
| 2009 | ret += tcrypt_test("authenc(hmac(sha224),cbc(des))"); |
| 2010 | break; |
| 2011 | case 184: |
| 2012 | ret += tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))"); |
| 2013 | break; |
| 2014 | case 185: |
| 2015 | ret += tcrypt_test("authenc(hmac(sha256),cbc(des))"); |
| 2016 | break; |
| 2017 | case 186: |
| 2018 | ret += tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))"); |
| 2019 | break; |
| 2020 | case 187: |
| 2021 | ret += tcrypt_test("authenc(hmac(sha384),cbc(des))"); |
| 2022 | break; |
| 2023 | case 188: |
| 2024 | ret += tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))"); |
| 2025 | break; |
| 2026 | case 189: |
| 2027 | ret += tcrypt_test("authenc(hmac(sha512),cbc(des))"); |
| 2028 | break; |
| 2029 | case 190: |
| 2030 | ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))"); |
| 2031 | break; |
Gilad Ben-Yossef | cd83a8a | 2018-03-06 09:44:43 +0000 | [diff] [blame] | 2032 | case 191: |
| 2033 | ret += tcrypt_test("ecb(sm4)"); |
Gilad Ben-Yossef | 95ba597 | 2018-09-20 14:18:38 +0100 | [diff] [blame^] | 2034 | ret += tcrypt_test("cbc(sm4)"); |
| 2035 | ret += tcrypt_test("ctr(sm4)"); |
Gilad Ben-Yossef | cd83a8a | 2018-03-06 09:44:43 +0000 | [diff] [blame] | 2036 | break; |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 2037 | case 200: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2038 | test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2039 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2040 | test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2041 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2042 | test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2043 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2044 | test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2045 | speed_template_16_24_32); |
Rik Snel | f3d1044 | 2006-11-29 19:01:41 +1100 | [diff] [blame] | 2046 | test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2047 | speed_template_32_40_48); |
Rik Snel | f3d1044 | 2006-11-29 19:01:41 +1100 | [diff] [blame] | 2048 | test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2049 | speed_template_32_40_48); |
Rik Snel | f19f511 | 2007-09-19 20:23:13 +0800 | [diff] [blame] | 2050 | test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, |
Horia Geantă | b66ad0b | 2017-07-19 19:40:32 +0300 | [diff] [blame] | 2051 | speed_template_32_64); |
Rik Snel | f19f511 | 2007-09-19 20:23:13 +0800 | [diff] [blame] | 2052 | test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, |
Horia Geantă | b66ad0b | 2017-07-19 19:40:32 +0300 | [diff] [blame] | 2053 | speed_template_32_64); |
Herbert Xu | 1503a24 | 2016-06-29 18:04:14 +0800 | [diff] [blame] | 2054 | test_cipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0, |
| 2055 | speed_template_16_24_32); |
| 2056 | test_cipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0, |
| 2057 | speed_template_16_24_32); |
Jan Glauber | 9996e34 | 2011-04-26 16:34:01 +1000 | [diff] [blame] | 2058 | test_cipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0, |
| 2059 | speed_template_16_24_32); |
| 2060 | test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, |
| 2061 | speed_template_16_24_32); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 2062 | break; |
| 2063 | |
| 2064 | case 201: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2065 | test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2066 | des3_speed_template, DES3_SPEED_VECTORS, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2067 | speed_template_24); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2068 | test_cipher_speed("ecb(des3_ede)", DECRYPT, sec, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2069 | des3_speed_template, DES3_SPEED_VECTORS, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2070 | speed_template_24); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2071 | test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2072 | des3_speed_template, DES3_SPEED_VECTORS, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2073 | speed_template_24); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2074 | test_cipher_speed("cbc(des3_ede)", DECRYPT, sec, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2075 | des3_speed_template, DES3_SPEED_VECTORS, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2076 | speed_template_24); |
Jussi Kivilinna | 8713150 | 2014-06-09 20:59:49 +0300 | [diff] [blame] | 2077 | test_cipher_speed("ctr(des3_ede)", ENCRYPT, sec, |
| 2078 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2079 | speed_template_24); |
| 2080 | test_cipher_speed("ctr(des3_ede)", DECRYPT, sec, |
| 2081 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2082 | speed_template_24); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 2083 | break; |
| 2084 | |
| 2085 | case 202: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2086 | test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2087 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2088 | test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2089 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2090 | test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2091 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2092 | test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2093 | speed_template_16_24_32); |
Jussi Kivilinna | ee5002a | 2011-09-26 16:47:15 +0300 | [diff] [blame] | 2094 | test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, |
| 2095 | speed_template_16_24_32); |
| 2096 | test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, |
| 2097 | speed_template_16_24_32); |
Jussi Kivilinna | bee3a90 | 2011-10-18 13:32:56 +0300 | [diff] [blame] | 2098 | test_cipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0, |
| 2099 | speed_template_32_40_48); |
| 2100 | test_cipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0, |
| 2101 | speed_template_32_40_48); |
Jussi Kivilinna | 131f754 | 2011-10-18 13:33:38 +0300 | [diff] [blame] | 2102 | test_cipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0, |
| 2103 | speed_template_32_48_64); |
| 2104 | test_cipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0, |
| 2105 | speed_template_32_48_64); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 2106 | break; |
| 2107 | |
| 2108 | case 203: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2109 | test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2110 | speed_template_8_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2111 | test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2112 | speed_template_8_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2113 | test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2114 | speed_template_8_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2115 | test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2116 | speed_template_8_32); |
Jussi Kivilinna | 7d47b86 | 2011-09-02 01:45:17 +0300 | [diff] [blame] | 2117 | test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0, |
| 2118 | speed_template_8_32); |
| 2119 | test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0, |
| 2120 | speed_template_8_32); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 2121 | break; |
| 2122 | |
| 2123 | case 204: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2124 | test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2125 | speed_template_8); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2126 | test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2127 | speed_template_8); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2128 | test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2129 | speed_template_8); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 2130 | test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2131 | speed_template_8); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 2132 | break; |
| 2133 | |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 2134 | case 205: |
| 2135 | test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2136 | speed_template_16_24_32); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 2137 | test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2138 | speed_template_16_24_32); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 2139 | test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2140 | speed_template_16_24_32); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 2141 | test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2142 | speed_template_16_24_32); |
Jussi Kivilinna | 4de5933 | 2012-03-05 20:26:26 +0200 | [diff] [blame] | 2143 | test_cipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0, |
| 2144 | speed_template_16_24_32); |
| 2145 | test_cipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0, |
| 2146 | speed_template_16_24_32); |
| 2147 | test_cipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0, |
| 2148 | speed_template_32_40_48); |
| 2149 | test_cipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0, |
| 2150 | speed_template_32_40_48); |
| 2151 | test_cipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0, |
| 2152 | speed_template_32_48_64); |
| 2153 | test_cipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0, |
| 2154 | speed_template_32_48_64); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 2155 | break; |
| 2156 | |
Tan Swee Heng | 5de8f1b | 2007-12-07 17:17:43 +0800 | [diff] [blame] | 2157 | case 206: |
| 2158 | test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 2159 | speed_template_16_32); |
Tan Swee Heng | 5de8f1b | 2007-12-07 17:17:43 +0800 | [diff] [blame] | 2160 | break; |
| 2161 | |
Jussi Kivilinna | 7fb7fe4 | 2011-10-18 00:03:03 +0300 | [diff] [blame] | 2162 | case 207: |
| 2163 | test_cipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0, |
| 2164 | speed_template_16_32); |
| 2165 | test_cipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0, |
| 2166 | speed_template_16_32); |
| 2167 | test_cipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0, |
| 2168 | speed_template_16_32); |
| 2169 | test_cipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0, |
| 2170 | speed_template_16_32); |
| 2171 | test_cipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0, |
| 2172 | speed_template_16_32); |
| 2173 | test_cipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0, |
| 2174 | speed_template_16_32); |
Jussi Kivilinna | 87aae4b | 2011-10-18 13:32:39 +0300 | [diff] [blame] | 2175 | test_cipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0, |
| 2176 | speed_template_32_48); |
| 2177 | test_cipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0, |
| 2178 | speed_template_32_48); |
Jussi Kivilinna | 5209c07 | 2011-10-18 13:33:22 +0300 | [diff] [blame] | 2179 | test_cipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0, |
| 2180 | speed_template_32_64); |
| 2181 | test_cipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0, |
| 2182 | speed_template_32_64); |
Jussi Kivilinna | 7fb7fe4 | 2011-10-18 00:03:03 +0300 | [diff] [blame] | 2183 | break; |
| 2184 | |
Jussi Kivilinna | 31b4cd29 | 2012-06-12 16:52:04 +0800 | [diff] [blame] | 2185 | case 208: |
| 2186 | test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0, |
| 2187 | speed_template_8); |
| 2188 | break; |
| 2189 | |
Johannes Goetzfried | a2c5826 | 2012-07-11 19:37:21 +0200 | [diff] [blame] | 2190 | case 209: |
| 2191 | test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, |
| 2192 | speed_template_8_16); |
| 2193 | test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, |
| 2194 | speed_template_8_16); |
| 2195 | test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, |
| 2196 | speed_template_8_16); |
| 2197 | test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, |
| 2198 | speed_template_8_16); |
| 2199 | test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, |
| 2200 | speed_template_8_16); |
| 2201 | test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, |
| 2202 | speed_template_8_16); |
| 2203 | break; |
| 2204 | |
Johannes Goetzfried | 9b8b040 | 2012-07-11 19:38:29 +0200 | [diff] [blame] | 2205 | case 210: |
| 2206 | test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, |
| 2207 | speed_template_16_32); |
| 2208 | test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, |
| 2209 | speed_template_16_32); |
| 2210 | test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, |
| 2211 | speed_template_16_32); |
| 2212 | test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, |
| 2213 | speed_template_16_32); |
| 2214 | test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, |
| 2215 | speed_template_16_32); |
| 2216 | test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, |
| 2217 | speed_template_16_32); |
| 2218 | test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, |
| 2219 | speed_template_32_48); |
| 2220 | test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, |
| 2221 | speed_template_32_48); |
| 2222 | test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, |
| 2223 | speed_template_32_64); |
| 2224 | test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, |
| 2225 | speed_template_32_64); |
| 2226 | break; |
| 2227 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 2228 | case 211: |
| 2229 | test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec, |
Herbert Xu | 34a1c74 | 2015-07-09 07:17:26 +0800 | [diff] [blame] | 2230 | NULL, 0, 16, 16, aead_speed_template_20); |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 2231 | test_aead_speed("gcm(aes)", ENCRYPT, sec, |
Cyrille Pitchen | f18611d | 2015-11-17 13:37:10 +0100 | [diff] [blame] | 2232 | NULL, 0, 16, 8, speed_template_16_24_32); |
Gilad Ben-Yossef | 4431bd4 | 2017-12-17 08:29:01 +0000 | [diff] [blame] | 2233 | test_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec, |
| 2234 | NULL, 0, 16, 16, aead_speed_template_20); |
| 2235 | test_aead_speed("gcm(aes)", DECRYPT, sec, |
| 2236 | NULL, 0, 16, 8, speed_template_16_24_32); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 2237 | break; |
| 2238 | |
Herbert Xu | 4e4aab6 | 2015-06-17 14:04:21 +0800 | [diff] [blame] | 2239 | case 212: |
| 2240 | test_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec, |
Herbert Xu | 34a1c74 | 2015-07-09 07:17:26 +0800 | [diff] [blame] | 2241 | NULL, 0, 16, 16, aead_speed_template_19); |
Gilad Ben-Yossef | 4431bd4 | 2017-12-17 08:29:01 +0000 | [diff] [blame] | 2242 | test_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec, |
| 2243 | NULL, 0, 16, 16, aead_speed_template_19); |
Herbert Xu | 4e4aab6 | 2015-06-17 14:04:21 +0800 | [diff] [blame] | 2244 | break; |
| 2245 | |
Martin Willi | 2dce063 | 2015-07-16 19:13:59 +0200 | [diff] [blame] | 2246 | case 213: |
| 2247 | test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, sec, |
| 2248 | NULL, 0, 16, 8, aead_speed_template_36); |
Gilad Ben-Yossef | 4431bd4 | 2017-12-17 08:29:01 +0000 | [diff] [blame] | 2249 | test_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT, sec, |
| 2250 | NULL, 0, 16, 8, aead_speed_template_36); |
Martin Willi | 2dce063 | 2015-07-16 19:13:59 +0200 | [diff] [blame] | 2251 | break; |
| 2252 | |
| 2253 | case 214: |
| 2254 | test_cipher_speed("chacha20", ENCRYPT, sec, NULL, 0, |
| 2255 | speed_template_32); |
| 2256 | break; |
| 2257 | |
Gilad Ben-Yossef | 427988d | 2017-12-17 08:29:05 +0000 | [diff] [blame] | 2258 | case 215: |
| 2259 | test_mb_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec, NULL, |
| 2260 | 0, 16, 16, aead_speed_template_20, num_mb); |
| 2261 | test_mb_aead_speed("gcm(aes)", ENCRYPT, sec, NULL, 0, 16, 8, |
| 2262 | speed_template_16_24_32, num_mb); |
| 2263 | test_mb_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec, NULL, |
| 2264 | 0, 16, 16, aead_speed_template_20, num_mb); |
| 2265 | test_mb_aead_speed("gcm(aes)", DECRYPT, sec, NULL, 0, 16, 8, |
| 2266 | speed_template_16_24_32, num_mb); |
| 2267 | break; |
| 2268 | |
| 2269 | case 216: |
| 2270 | test_mb_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec, NULL, 0, |
| 2271 | 16, 16, aead_speed_template_19, num_mb); |
| 2272 | test_mb_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec, NULL, 0, |
| 2273 | 16, 16, aead_speed_template_19, num_mb); |
| 2274 | break; |
| 2275 | |
| 2276 | case 217: |
| 2277 | test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, |
| 2278 | sec, NULL, 0, 16, 8, aead_speed_template_36, |
| 2279 | num_mb); |
| 2280 | test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT, |
| 2281 | sec, NULL, 0, 16, 8, aead_speed_template_36, |
| 2282 | num_mb); |
| 2283 | break; |
| 2284 | |
Gilad Ben-Yossef | 95ba597 | 2018-09-20 14:18:38 +0100 | [diff] [blame^] | 2285 | case 218: |
| 2286 | test_cipher_speed("ecb(sm4)", ENCRYPT, sec, NULL, 0, |
| 2287 | speed_template_16); |
| 2288 | test_cipher_speed("ecb(sm4)", DECRYPT, sec, NULL, 0, |
| 2289 | speed_template_16); |
| 2290 | test_cipher_speed("cbc(sm4)", ENCRYPT, sec, NULL, 0, |
| 2291 | speed_template_16); |
| 2292 | test_cipher_speed("cbc(sm4)", DECRYPT, sec, NULL, 0, |
| 2293 | speed_template_16); |
| 2294 | test_cipher_speed("ctr(sm4)", ENCRYPT, sec, NULL, 0, |
| 2295 | speed_template_16); |
| 2296 | test_cipher_speed("ctr(sm4)", DECRYPT, sec, NULL, 0, |
| 2297 | speed_template_16); |
| 2298 | break; |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2299 | case 300: |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 2300 | if (alg) { |
| 2301 | test_hash_speed(alg, sec, generic_hash_speed_template); |
| 2302 | break; |
| 2303 | } |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2304 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2305 | case 301: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 2306 | test_hash_speed("md4", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2307 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2308 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2309 | case 302: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 2310 | test_hash_speed("md5", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2311 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2312 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2313 | case 303: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 2314 | test_hash_speed("sha1", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2315 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2316 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2317 | case 304: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 2318 | test_hash_speed("sha256", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2319 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2320 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2321 | case 305: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 2322 | test_hash_speed("sha384", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2323 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2324 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2325 | case 306: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 2326 | test_hash_speed("sha512", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2327 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2328 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2329 | case 307: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 2330 | test_hash_speed("wp256", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2331 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2332 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2333 | case 308: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 2334 | test_hash_speed("wp384", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2335 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2336 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2337 | case 309: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 2338 | test_hash_speed("wp512", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2339 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2340 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2341 | case 310: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 2342 | test_hash_speed("tgr128", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2343 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2344 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2345 | case 311: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 2346 | test_hash_speed("tgr160", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2347 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2348 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2349 | case 312: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 2350 | test_hash_speed("tgr192", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2351 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2352 | /* fall through */ |
Jonathan Lynch | cd12fb9 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 2353 | case 313: |
| 2354 | test_hash_speed("sha224", sec, generic_hash_speed_template); |
| 2355 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2356 | /* fall through */ |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 2357 | case 314: |
| 2358 | test_hash_speed("rmd128", sec, generic_hash_speed_template); |
| 2359 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2360 | /* fall through */ |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 2361 | case 315: |
| 2362 | test_hash_speed("rmd160", sec, generic_hash_speed_template); |
| 2363 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2364 | /* fall through */ |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 2365 | case 316: |
| 2366 | test_hash_speed("rmd256", sec, generic_hash_speed_template); |
| 2367 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2368 | /* fall through */ |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 2369 | case 317: |
| 2370 | test_hash_speed("rmd320", sec, generic_hash_speed_template); |
| 2371 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2372 | /* fall through */ |
Huang Ying | 18bcc91 | 2010-03-10 18:30:32 +0800 | [diff] [blame] | 2373 | case 318: |
| 2374 | test_hash_speed("ghash-generic", sec, hash_speed_template_16); |
| 2375 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2376 | /* fall through */ |
Tim Chen | e3899e4 | 2012-09-27 15:44:24 -0700 | [diff] [blame] | 2377 | case 319: |
| 2378 | test_hash_speed("crc32c", sec, generic_hash_speed_template); |
| 2379 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2380 | /* fall through */ |
Herbert Xu | 68411521 | 2013-09-07 12:56:26 +1000 | [diff] [blame] | 2381 | case 320: |
| 2382 | test_hash_speed("crct10dif", sec, generic_hash_speed_template); |
| 2383 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2384 | /* fall through */ |
Martin Willi | 2dce063 | 2015-07-16 19:13:59 +0200 | [diff] [blame] | 2385 | case 321: |
| 2386 | test_hash_speed("poly1305", sec, poly1305_speed_template); |
| 2387 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2388 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 2389 | case 322: |
| 2390 | test_hash_speed("sha3-224", sec, generic_hash_speed_template); |
| 2391 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2392 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 2393 | case 323: |
| 2394 | test_hash_speed("sha3-256", sec, generic_hash_speed_template); |
| 2395 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2396 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 2397 | case 324: |
| 2398 | test_hash_speed("sha3-384", sec, generic_hash_speed_template); |
| 2399 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2400 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 2401 | case 325: |
| 2402 | test_hash_speed("sha3-512", sec, generic_hash_speed_template); |
| 2403 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2404 | /* fall through */ |
Gilad Ben-Yossef | b7e2753 | 2017-08-21 13:51:29 +0300 | [diff] [blame] | 2405 | case 326: |
| 2406 | test_hash_speed("sm3", sec, generic_hash_speed_template); |
| 2407 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2408 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 2409 | case 399: |
| 2410 | break; |
| 2411 | |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2412 | case 400: |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 2413 | if (alg) { |
| 2414 | test_ahash_speed(alg, sec, generic_hash_speed_template); |
| 2415 | break; |
| 2416 | } |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2417 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2418 | case 401: |
| 2419 | test_ahash_speed("md4", sec, generic_hash_speed_template); |
| 2420 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2421 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2422 | case 402: |
| 2423 | test_ahash_speed("md5", sec, generic_hash_speed_template); |
| 2424 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2425 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2426 | case 403: |
| 2427 | test_ahash_speed("sha1", sec, generic_hash_speed_template); |
| 2428 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2429 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2430 | case 404: |
| 2431 | test_ahash_speed("sha256", sec, generic_hash_speed_template); |
| 2432 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2433 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2434 | case 405: |
| 2435 | test_ahash_speed("sha384", sec, generic_hash_speed_template); |
| 2436 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2437 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2438 | case 406: |
| 2439 | test_ahash_speed("sha512", sec, generic_hash_speed_template); |
| 2440 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2441 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2442 | case 407: |
| 2443 | test_ahash_speed("wp256", sec, generic_hash_speed_template); |
| 2444 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2445 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2446 | case 408: |
| 2447 | test_ahash_speed("wp384", sec, generic_hash_speed_template); |
| 2448 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2449 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2450 | case 409: |
| 2451 | test_ahash_speed("wp512", sec, generic_hash_speed_template); |
| 2452 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2453 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2454 | case 410: |
| 2455 | test_ahash_speed("tgr128", sec, generic_hash_speed_template); |
| 2456 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2457 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2458 | case 411: |
| 2459 | test_ahash_speed("tgr160", sec, generic_hash_speed_template); |
| 2460 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2461 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2462 | case 412: |
| 2463 | test_ahash_speed("tgr192", sec, generic_hash_speed_template); |
| 2464 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2465 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2466 | case 413: |
| 2467 | test_ahash_speed("sha224", sec, generic_hash_speed_template); |
| 2468 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2469 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2470 | case 414: |
| 2471 | test_ahash_speed("rmd128", sec, generic_hash_speed_template); |
| 2472 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2473 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2474 | case 415: |
| 2475 | test_ahash_speed("rmd160", sec, generic_hash_speed_template); |
| 2476 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2477 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2478 | case 416: |
| 2479 | test_ahash_speed("rmd256", sec, generic_hash_speed_template); |
| 2480 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2481 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2482 | case 417: |
| 2483 | test_ahash_speed("rmd320", sec, generic_hash_speed_template); |
| 2484 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2485 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 2486 | case 418: |
| 2487 | test_ahash_speed("sha3-224", sec, generic_hash_speed_template); |
| 2488 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2489 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 2490 | case 419: |
| 2491 | test_ahash_speed("sha3-256", sec, generic_hash_speed_template); |
| 2492 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2493 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 2494 | case 420: |
| 2495 | test_ahash_speed("sha3-384", sec, generic_hash_speed_template); |
| 2496 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2497 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 2498 | case 421: |
| 2499 | test_ahash_speed("sha3-512", sec, generic_hash_speed_template); |
| 2500 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2501 | /* fall through */ |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 2502 | case 422: |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 2503 | test_mb_ahash_speed("sha1", sec, generic_hash_speed_template, |
| 2504 | num_mb); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 2505 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2506 | /* fall through */ |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 2507 | case 423: |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 2508 | test_mb_ahash_speed("sha256", sec, generic_hash_speed_template, |
| 2509 | num_mb); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 2510 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2511 | /* fall through */ |
Megha Dey | 14009c4 | 2016-06-27 10:20:09 -0700 | [diff] [blame] | 2512 | case 424: |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 2513 | test_mb_ahash_speed("sha512", sec, generic_hash_speed_template, |
| 2514 | num_mb); |
Megha Dey | 14009c4 | 2016-06-27 10:20:09 -0700 | [diff] [blame] | 2515 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2516 | /* fall through */ |
Gilad Ben-Yossef | b7e2753 | 2017-08-21 13:51:29 +0300 | [diff] [blame] | 2517 | case 425: |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 2518 | test_mb_ahash_speed("sm3", sec, generic_hash_speed_template, |
| 2519 | num_mb); |
Gilad Ben-Yossef | b7e2753 | 2017-08-21 13:51:29 +0300 | [diff] [blame] | 2520 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 2521 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 2522 | case 499: |
| 2523 | break; |
| 2524 | |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 2525 | case 500: |
| 2526 | test_acipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, |
| 2527 | speed_template_16_24_32); |
| 2528 | test_acipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, |
| 2529 | speed_template_16_24_32); |
| 2530 | test_acipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, |
| 2531 | speed_template_16_24_32); |
| 2532 | test_acipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, |
| 2533 | speed_template_16_24_32); |
| 2534 | test_acipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, |
| 2535 | speed_template_32_40_48); |
| 2536 | test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, |
| 2537 | speed_template_32_40_48); |
| 2538 | test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, |
Horia Geantă | b66ad0b | 2017-07-19 19:40:32 +0300 | [diff] [blame] | 2539 | speed_template_32_64); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 2540 | test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, |
Horia Geantă | b66ad0b | 2017-07-19 19:40:32 +0300 | [diff] [blame] | 2541 | speed_template_32_64); |
Herbert Xu | 1503a24 | 2016-06-29 18:04:14 +0800 | [diff] [blame] | 2542 | test_acipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0, |
| 2543 | speed_template_16_24_32); |
| 2544 | test_acipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0, |
| 2545 | speed_template_16_24_32); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 2546 | test_acipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0, |
| 2547 | speed_template_16_24_32); |
| 2548 | test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, |
| 2549 | speed_template_16_24_32); |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 2550 | test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0, |
| 2551 | speed_template_16_24_32); |
| 2552 | test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0, |
| 2553 | speed_template_16_24_32); |
| 2554 | test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0, |
| 2555 | speed_template_16_24_32); |
| 2556 | test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0, |
| 2557 | speed_template_16_24_32); |
Jussi Kivilinna | 69d3150 | 2012-12-28 12:04:58 +0200 | [diff] [blame] | 2558 | test_acipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL, 0, |
| 2559 | speed_template_20_28_36); |
| 2560 | test_acipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL, 0, |
| 2561 | speed_template_20_28_36); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 2562 | break; |
| 2563 | |
| 2564 | case 501: |
| 2565 | test_acipher_speed("ecb(des3_ede)", ENCRYPT, sec, |
| 2566 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2567 | speed_template_24); |
| 2568 | test_acipher_speed("ecb(des3_ede)", DECRYPT, sec, |
| 2569 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2570 | speed_template_24); |
| 2571 | test_acipher_speed("cbc(des3_ede)", ENCRYPT, sec, |
| 2572 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2573 | speed_template_24); |
| 2574 | test_acipher_speed("cbc(des3_ede)", DECRYPT, sec, |
| 2575 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2576 | speed_template_24); |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 2577 | test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec, |
| 2578 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2579 | speed_template_24); |
| 2580 | test_acipher_speed("cfb(des3_ede)", DECRYPT, sec, |
| 2581 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2582 | speed_template_24); |
| 2583 | test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec, |
| 2584 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2585 | speed_template_24); |
| 2586 | test_acipher_speed("ofb(des3_ede)", DECRYPT, sec, |
| 2587 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2588 | speed_template_24); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 2589 | break; |
| 2590 | |
| 2591 | case 502: |
| 2592 | test_acipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, |
| 2593 | speed_template_8); |
| 2594 | test_acipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, |
| 2595 | speed_template_8); |
| 2596 | test_acipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, |
| 2597 | speed_template_8); |
| 2598 | test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, |
| 2599 | speed_template_8); |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 2600 | test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0, |
| 2601 | speed_template_8); |
| 2602 | test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0, |
| 2603 | speed_template_8); |
| 2604 | test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0, |
| 2605 | speed_template_8); |
| 2606 | test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0, |
| 2607 | speed_template_8); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 2608 | break; |
| 2609 | |
Jussi Kivilinna | 7fb7fe4 | 2011-10-18 00:03:03 +0300 | [diff] [blame] | 2610 | case 503: |
| 2611 | test_acipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0, |
| 2612 | speed_template_16_32); |
| 2613 | test_acipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0, |
| 2614 | speed_template_16_32); |
| 2615 | test_acipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0, |
| 2616 | speed_template_16_32); |
| 2617 | test_acipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0, |
| 2618 | speed_template_16_32); |
| 2619 | test_acipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0, |
| 2620 | speed_template_16_32); |
| 2621 | test_acipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0, |
| 2622 | speed_template_16_32); |
Jussi Kivilinna | 87aae4b | 2011-10-18 13:32:39 +0300 | [diff] [blame] | 2623 | test_acipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0, |
| 2624 | speed_template_32_48); |
| 2625 | test_acipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0, |
| 2626 | speed_template_32_48); |
Jussi Kivilinna | 5209c07 | 2011-10-18 13:33:22 +0300 | [diff] [blame] | 2627 | test_acipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0, |
| 2628 | speed_template_32_64); |
| 2629 | test_acipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0, |
| 2630 | speed_template_32_64); |
Jussi Kivilinna | 7fb7fe4 | 2011-10-18 00:03:03 +0300 | [diff] [blame] | 2631 | break; |
| 2632 | |
Johannes Goetzfried | 107778b5 | 2012-05-28 15:54:24 +0200 | [diff] [blame] | 2633 | case 504: |
| 2634 | test_acipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, |
| 2635 | speed_template_16_24_32); |
| 2636 | test_acipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, |
| 2637 | speed_template_16_24_32); |
| 2638 | test_acipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, |
| 2639 | speed_template_16_24_32); |
| 2640 | test_acipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, |
| 2641 | speed_template_16_24_32); |
| 2642 | test_acipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, |
| 2643 | speed_template_16_24_32); |
| 2644 | test_acipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, |
| 2645 | speed_template_16_24_32); |
| 2646 | test_acipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0, |
| 2647 | speed_template_32_40_48); |
| 2648 | test_acipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0, |
| 2649 | speed_template_32_40_48); |
| 2650 | test_acipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0, |
| 2651 | speed_template_32_48_64); |
| 2652 | test_acipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0, |
| 2653 | speed_template_32_48_64); |
| 2654 | break; |
| 2655 | |
Jussi Kivilinna | 31b4cd29 | 2012-06-12 16:52:04 +0800 | [diff] [blame] | 2656 | case 505: |
| 2657 | test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0, |
| 2658 | speed_template_8); |
| 2659 | break; |
| 2660 | |
Johannes Goetzfried | a2c5826 | 2012-07-11 19:37:21 +0200 | [diff] [blame] | 2661 | case 506: |
| 2662 | test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, |
| 2663 | speed_template_8_16); |
| 2664 | test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, |
| 2665 | speed_template_8_16); |
| 2666 | test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, |
| 2667 | speed_template_8_16); |
| 2668 | test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, |
| 2669 | speed_template_8_16); |
| 2670 | test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, |
| 2671 | speed_template_8_16); |
| 2672 | test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, |
| 2673 | speed_template_8_16); |
| 2674 | break; |
| 2675 | |
Johannes Goetzfried | 9b8b040 | 2012-07-11 19:38:29 +0200 | [diff] [blame] | 2676 | case 507: |
| 2677 | test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, |
| 2678 | speed_template_16_32); |
| 2679 | test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, |
| 2680 | speed_template_16_32); |
| 2681 | test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, |
| 2682 | speed_template_16_32); |
| 2683 | test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, |
| 2684 | speed_template_16_32); |
| 2685 | test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, |
| 2686 | speed_template_16_32); |
| 2687 | test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, |
| 2688 | speed_template_16_32); |
| 2689 | test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, |
| 2690 | speed_template_32_48); |
| 2691 | test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, |
| 2692 | speed_template_32_48); |
| 2693 | test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, |
| 2694 | speed_template_32_64); |
| 2695 | test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, |
| 2696 | speed_template_32_64); |
| 2697 | break; |
| 2698 | |
Jussi Kivilinna | bf9c518 | 2012-10-26 14:48:51 +0300 | [diff] [blame] | 2699 | case 508: |
| 2700 | test_acipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, |
| 2701 | speed_template_16_32); |
| 2702 | test_acipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, |
| 2703 | speed_template_16_32); |
| 2704 | test_acipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, |
| 2705 | speed_template_16_32); |
| 2706 | test_acipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, |
| 2707 | speed_template_16_32); |
| 2708 | test_acipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0, |
| 2709 | speed_template_16_32); |
| 2710 | test_acipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0, |
| 2711 | speed_template_16_32); |
| 2712 | test_acipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0, |
| 2713 | speed_template_32_48); |
| 2714 | test_acipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0, |
| 2715 | speed_template_32_48); |
| 2716 | test_acipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0, |
| 2717 | speed_template_32_64); |
| 2718 | test_acipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0, |
| 2719 | speed_template_32_64); |
| 2720 | break; |
| 2721 | |
Jussi Kivilinna | ad8b7c3 | 2013-04-13 13:46:40 +0300 | [diff] [blame] | 2722 | case 509: |
| 2723 | test_acipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, |
| 2724 | speed_template_8_32); |
| 2725 | test_acipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, |
| 2726 | speed_template_8_32); |
| 2727 | test_acipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, |
| 2728 | speed_template_8_32); |
| 2729 | test_acipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, |
| 2730 | speed_template_8_32); |
| 2731 | test_acipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0, |
| 2732 | speed_template_8_32); |
| 2733 | test_acipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0, |
| 2734 | speed_template_8_32); |
| 2735 | break; |
| 2736 | |
Gilad Ben-Yossef | e161c59 | 2017-12-17 08:29:04 +0000 | [diff] [blame] | 2737 | case 600: |
| 2738 | test_mb_skcipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, |
| 2739 | speed_template_16_24_32, num_mb); |
| 2740 | test_mb_skcipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, |
| 2741 | speed_template_16_24_32, num_mb); |
| 2742 | test_mb_skcipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, |
| 2743 | speed_template_16_24_32, num_mb); |
| 2744 | test_mb_skcipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, |
| 2745 | speed_template_16_24_32, num_mb); |
| 2746 | test_mb_skcipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, |
| 2747 | speed_template_32_40_48, num_mb); |
| 2748 | test_mb_skcipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, |
| 2749 | speed_template_32_40_48, num_mb); |
| 2750 | test_mb_skcipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, |
| 2751 | speed_template_32_64, num_mb); |
| 2752 | test_mb_skcipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, |
| 2753 | speed_template_32_64, num_mb); |
| 2754 | test_mb_skcipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0, |
| 2755 | speed_template_16_24_32, num_mb); |
| 2756 | test_mb_skcipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0, |
| 2757 | speed_template_16_24_32, num_mb); |
| 2758 | test_mb_skcipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0, |
| 2759 | speed_template_16_24_32, num_mb); |
| 2760 | test_mb_skcipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, |
| 2761 | speed_template_16_24_32, num_mb); |
| 2762 | test_mb_skcipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0, |
| 2763 | speed_template_16_24_32, num_mb); |
| 2764 | test_mb_skcipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0, |
| 2765 | speed_template_16_24_32, num_mb); |
| 2766 | test_mb_skcipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0, |
| 2767 | speed_template_16_24_32, num_mb); |
| 2768 | test_mb_skcipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0, |
| 2769 | speed_template_16_24_32, num_mb); |
| 2770 | test_mb_skcipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL, |
| 2771 | 0, speed_template_20_28_36, num_mb); |
| 2772 | test_mb_skcipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL, |
| 2773 | 0, speed_template_20_28_36, num_mb); |
| 2774 | break; |
| 2775 | |
| 2776 | case 601: |
| 2777 | test_mb_skcipher_speed("ecb(des3_ede)", ENCRYPT, sec, |
| 2778 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2779 | speed_template_24, num_mb); |
| 2780 | test_mb_skcipher_speed("ecb(des3_ede)", DECRYPT, sec, |
| 2781 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2782 | speed_template_24, num_mb); |
| 2783 | test_mb_skcipher_speed("cbc(des3_ede)", ENCRYPT, sec, |
| 2784 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2785 | speed_template_24, num_mb); |
| 2786 | test_mb_skcipher_speed("cbc(des3_ede)", DECRYPT, sec, |
| 2787 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2788 | speed_template_24, num_mb); |
| 2789 | test_mb_skcipher_speed("cfb(des3_ede)", ENCRYPT, sec, |
| 2790 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2791 | speed_template_24, num_mb); |
| 2792 | test_mb_skcipher_speed("cfb(des3_ede)", DECRYPT, sec, |
| 2793 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2794 | speed_template_24, num_mb); |
| 2795 | test_mb_skcipher_speed("ofb(des3_ede)", ENCRYPT, sec, |
| 2796 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2797 | speed_template_24, num_mb); |
| 2798 | test_mb_skcipher_speed("ofb(des3_ede)", DECRYPT, sec, |
| 2799 | des3_speed_template, DES3_SPEED_VECTORS, |
| 2800 | speed_template_24, num_mb); |
| 2801 | break; |
| 2802 | |
| 2803 | case 602: |
| 2804 | test_mb_skcipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, |
| 2805 | speed_template_8, num_mb); |
| 2806 | test_mb_skcipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, |
| 2807 | speed_template_8, num_mb); |
| 2808 | test_mb_skcipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, |
| 2809 | speed_template_8, num_mb); |
| 2810 | test_mb_skcipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, |
| 2811 | speed_template_8, num_mb); |
| 2812 | test_mb_skcipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0, |
| 2813 | speed_template_8, num_mb); |
| 2814 | test_mb_skcipher_speed("cfb(des)", DECRYPT, sec, NULL, 0, |
| 2815 | speed_template_8, num_mb); |
| 2816 | test_mb_skcipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0, |
| 2817 | speed_template_8, num_mb); |
| 2818 | test_mb_skcipher_speed("ofb(des)", DECRYPT, sec, NULL, 0, |
| 2819 | speed_template_8, num_mb); |
| 2820 | break; |
| 2821 | |
| 2822 | case 603: |
| 2823 | test_mb_skcipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0, |
| 2824 | speed_template_16_32, num_mb); |
| 2825 | test_mb_skcipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0, |
| 2826 | speed_template_16_32, num_mb); |
| 2827 | test_mb_skcipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0, |
| 2828 | speed_template_16_32, num_mb); |
| 2829 | test_mb_skcipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0, |
| 2830 | speed_template_16_32, num_mb); |
| 2831 | test_mb_skcipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0, |
| 2832 | speed_template_16_32, num_mb); |
| 2833 | test_mb_skcipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0, |
| 2834 | speed_template_16_32, num_mb); |
| 2835 | test_mb_skcipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0, |
| 2836 | speed_template_32_48, num_mb); |
| 2837 | test_mb_skcipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0, |
| 2838 | speed_template_32_48, num_mb); |
| 2839 | test_mb_skcipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0, |
| 2840 | speed_template_32_64, num_mb); |
| 2841 | test_mb_skcipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0, |
| 2842 | speed_template_32_64, num_mb); |
| 2843 | break; |
| 2844 | |
| 2845 | case 604: |
| 2846 | test_mb_skcipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, |
| 2847 | speed_template_16_24_32, num_mb); |
| 2848 | test_mb_skcipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, |
| 2849 | speed_template_16_24_32, num_mb); |
| 2850 | test_mb_skcipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, |
| 2851 | speed_template_16_24_32, num_mb); |
| 2852 | test_mb_skcipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, |
| 2853 | speed_template_16_24_32, num_mb); |
| 2854 | test_mb_skcipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, |
| 2855 | speed_template_16_24_32, num_mb); |
| 2856 | test_mb_skcipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, |
| 2857 | speed_template_16_24_32, num_mb); |
| 2858 | test_mb_skcipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0, |
| 2859 | speed_template_32_40_48, num_mb); |
| 2860 | test_mb_skcipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0, |
| 2861 | speed_template_32_40_48, num_mb); |
| 2862 | test_mb_skcipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0, |
| 2863 | speed_template_32_48_64, num_mb); |
| 2864 | test_mb_skcipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0, |
| 2865 | speed_template_32_48_64, num_mb); |
| 2866 | break; |
| 2867 | |
| 2868 | case 605: |
| 2869 | test_mb_skcipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0, |
| 2870 | speed_template_8, num_mb); |
| 2871 | break; |
| 2872 | |
| 2873 | case 606: |
| 2874 | test_mb_skcipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, |
| 2875 | speed_template_8_16, num_mb); |
| 2876 | test_mb_skcipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, |
| 2877 | speed_template_8_16, num_mb); |
| 2878 | test_mb_skcipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, |
| 2879 | speed_template_8_16, num_mb); |
| 2880 | test_mb_skcipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, |
| 2881 | speed_template_8_16, num_mb); |
| 2882 | test_mb_skcipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, |
| 2883 | speed_template_8_16, num_mb); |
| 2884 | test_mb_skcipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, |
| 2885 | speed_template_8_16, num_mb); |
| 2886 | break; |
| 2887 | |
| 2888 | case 607: |
| 2889 | test_mb_skcipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, |
| 2890 | speed_template_16_32, num_mb); |
| 2891 | test_mb_skcipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, |
| 2892 | speed_template_16_32, num_mb); |
| 2893 | test_mb_skcipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, |
| 2894 | speed_template_16_32, num_mb); |
| 2895 | test_mb_skcipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, |
| 2896 | speed_template_16_32, num_mb); |
| 2897 | test_mb_skcipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, |
| 2898 | speed_template_16_32, num_mb); |
| 2899 | test_mb_skcipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, |
| 2900 | speed_template_16_32, num_mb); |
| 2901 | test_mb_skcipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, |
| 2902 | speed_template_32_48, num_mb); |
| 2903 | test_mb_skcipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, |
| 2904 | speed_template_32_48, num_mb); |
| 2905 | test_mb_skcipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, |
| 2906 | speed_template_32_64, num_mb); |
| 2907 | test_mb_skcipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, |
| 2908 | speed_template_32_64, num_mb); |
| 2909 | break; |
| 2910 | |
| 2911 | case 608: |
| 2912 | test_mb_skcipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, |
| 2913 | speed_template_16_32, num_mb); |
| 2914 | test_mb_skcipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, |
| 2915 | speed_template_16_32, num_mb); |
| 2916 | test_mb_skcipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, |
| 2917 | speed_template_16_32, num_mb); |
| 2918 | test_mb_skcipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, |
| 2919 | speed_template_16_32, num_mb); |
| 2920 | test_mb_skcipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0, |
| 2921 | speed_template_16_32, num_mb); |
| 2922 | test_mb_skcipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0, |
| 2923 | speed_template_16_32, num_mb); |
| 2924 | test_mb_skcipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0, |
| 2925 | speed_template_32_48, num_mb); |
| 2926 | test_mb_skcipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0, |
| 2927 | speed_template_32_48, num_mb); |
| 2928 | test_mb_skcipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0, |
| 2929 | speed_template_32_64, num_mb); |
| 2930 | test_mb_skcipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0, |
| 2931 | speed_template_32_64, num_mb); |
| 2932 | break; |
| 2933 | |
| 2934 | case 609: |
| 2935 | test_mb_skcipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, |
| 2936 | speed_template_8_32, num_mb); |
| 2937 | test_mb_skcipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, |
| 2938 | speed_template_8_32, num_mb); |
| 2939 | test_mb_skcipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, |
| 2940 | speed_template_8_32, num_mb); |
| 2941 | test_mb_skcipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, |
| 2942 | speed_template_8_32, num_mb); |
| 2943 | test_mb_skcipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0, |
| 2944 | speed_template_8_32, num_mb); |
| 2945 | test_mb_skcipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0, |
| 2946 | speed_template_8_32, num_mb); |
| 2947 | break; |
| 2948 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2949 | case 1000: |
| 2950 | test_available(); |
| 2951 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2952 | } |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2953 | |
| 2954 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2955 | } |
| 2956 | |
Kamalesh Babulal | 3af5b90 | 2008-04-05 21:00:57 +0800 | [diff] [blame] | 2957 | static int __init tcrypt_mod_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2958 | { |
Mikko Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 2959 | int err = -ENOMEM; |
Herbert Xu | f139cfa | 2008-07-31 12:23:53 +0800 | [diff] [blame] | 2960 | int i; |
Mikko Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 2961 | |
Herbert Xu | f139cfa | 2008-07-31 12:23:53 +0800 | [diff] [blame] | 2962 | for (i = 0; i < TVMEMSIZE; i++) { |
| 2963 | tvmem[i] = (void *)__get_free_page(GFP_KERNEL); |
| 2964 | if (!tvmem[i]) |
| 2965 | goto err_free_tv; |
| 2966 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2967 | |
Kees Cook | 4e234ee | 2018-04-26 19:57:28 -0700 | [diff] [blame] | 2968 | err = do_test(alg, type, mask, mode, num_mb); |
Steffen Klassert | a873a5f | 2009-06-19 19:46:53 +0800 | [diff] [blame] | 2969 | |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2970 | if (err) { |
| 2971 | printk(KERN_ERR "tcrypt: one or more tests failed!\n"); |
| 2972 | goto err_free_tv; |
Rabin Vincent | 76512f2 | 2017-01-18 14:54:05 +0100 | [diff] [blame] | 2973 | } else { |
| 2974 | pr_debug("all tests passed\n"); |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2975 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2976 | |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2977 | /* We intentionaly return -EAGAIN to prevent keeping the module, |
| 2978 | * unless we're running in fips mode. It does all its work from |
| 2979 | * init() and doesn't offer any runtime functionality, but in |
| 2980 | * the fips case, checking for a successful load is helpful. |
Michal Ludvig | 14fdf47 | 2006-05-30 14:49:38 +1000 | [diff] [blame] | 2981 | * => we don't need it in the memory, do we? |
| 2982 | * -- mludvig |
| 2983 | */ |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2984 | if (!fips_enabled) |
| 2985 | err = -EAGAIN; |
Mikko Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 2986 | |
Herbert Xu | f139cfa | 2008-07-31 12:23:53 +0800 | [diff] [blame] | 2987 | err_free_tv: |
| 2988 | for (i = 0; i < TVMEMSIZE && tvmem[i]; i++) |
| 2989 | free_page((unsigned long)tvmem[i]); |
Mikko Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 2990 | |
| 2991 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2992 | } |
| 2993 | |
| 2994 | /* |
| 2995 | * If an init function is provided, an exit function must also be provided |
| 2996 | * to allow module unload. |
| 2997 | */ |
Kamalesh Babulal | 3af5b90 | 2008-04-05 21:00:57 +0800 | [diff] [blame] | 2998 | static void __exit tcrypt_mod_fini(void) { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2999 | |
Kamalesh Babulal | 3af5b90 | 2008-04-05 21:00:57 +0800 | [diff] [blame] | 3000 | module_init(tcrypt_mod_init); |
| 3001 | module_exit(tcrypt_mod_fini); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3002 | |
Steffen Klassert | a873a5f | 2009-06-19 19:46:53 +0800 | [diff] [blame] | 3003 | module_param(alg, charp, 0); |
| 3004 | module_param(type, uint, 0); |
Herbert Xu | 7be380f | 2009-07-14 16:06:54 +0800 | [diff] [blame] | 3005 | module_param(mask, uint, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3006 | module_param(mode, int, 0); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 3007 | module_param(sec, uint, 0); |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 3008 | MODULE_PARM_DESC(sec, "Length in seconds of speed tests " |
| 3009 | "(defaults to zero which uses CPU cycles instead)"); |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 3010 | module_param(num_mb, uint, 0000); |
| 3011 | MODULE_PARM_DESC(num_mb, "Number of concurrent requests to be used in mb speed tests (defaults to 8)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3012 | |
| 3013 | MODULE_LICENSE("GPL"); |
| 3014 | MODULE_DESCRIPTION("Quick & dirty crypto testing module"); |
| 3015 | MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>"); |