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