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