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