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 | cd12fb90 | 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 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 821 | 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] | 822 | { |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 823 | struct crypto_wait *wait = req->base.data; |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 824 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 825 | return crypto_wait_req(ret, wait); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 826 | } |
| 827 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 828 | static int test_acipher_jiffies(struct skcipher_request *req, int enc, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 829 | int blen, int secs) |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 830 | { |
| 831 | unsigned long start, end; |
| 832 | int bcount; |
| 833 | int ret; |
| 834 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 835 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 836 | time_before(jiffies, end); bcount++) { |
| 837 | if (enc) |
| 838 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 839 | crypto_skcipher_encrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 840 | else |
| 841 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 842 | crypto_skcipher_decrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 843 | |
| 844 | if (ret) |
| 845 | return ret; |
| 846 | } |
| 847 | |
| 848 | pr_cont("%d operations in %d seconds (%ld bytes)\n", |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 849 | bcount, secs, (long)bcount * blen); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 850 | return 0; |
| 851 | } |
| 852 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 853 | static int test_acipher_cycles(struct skcipher_request *req, int enc, |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 854 | int blen) |
| 855 | { |
| 856 | unsigned long cycles = 0; |
| 857 | int ret = 0; |
| 858 | int i; |
| 859 | |
| 860 | /* Warm-up run. */ |
| 861 | for (i = 0; i < 4; i++) { |
| 862 | if (enc) |
| 863 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 864 | crypto_skcipher_encrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 865 | else |
| 866 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 867 | crypto_skcipher_decrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 868 | |
| 869 | if (ret) |
| 870 | goto out; |
| 871 | } |
| 872 | |
| 873 | /* The real thing. */ |
| 874 | for (i = 0; i < 8; i++) { |
| 875 | cycles_t start, end; |
| 876 | |
| 877 | start = get_cycles(); |
| 878 | if (enc) |
| 879 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 880 | crypto_skcipher_encrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 881 | else |
| 882 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 883 | crypto_skcipher_decrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 884 | end = get_cycles(); |
| 885 | |
| 886 | if (ret) |
| 887 | goto out; |
| 888 | |
| 889 | cycles += end - start; |
| 890 | } |
| 891 | |
| 892 | out: |
| 893 | if (ret == 0) |
| 894 | pr_cont("1 operation in %lu cycles (%d bytes)\n", |
| 895 | (cycles + 4) / 8, blen); |
| 896 | |
| 897 | return ret; |
| 898 | } |
| 899 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 900 | static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, |
| 901 | struct cipher_speed_template *template, |
| 902 | unsigned int tcount, u8 *keysize, bool async) |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 903 | { |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 904 | unsigned int ret, i, j, k, iv_len; |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 905 | struct crypto_wait wait; |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 906 | const char *key; |
| 907 | char iv[128]; |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 908 | struct skcipher_request *req; |
| 909 | struct crypto_skcipher *tfm; |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 910 | const char *e; |
| 911 | u32 *b_size; |
| 912 | |
| 913 | if (enc == ENCRYPT) |
| 914 | e = "encryption"; |
| 915 | else |
| 916 | e = "decryption"; |
| 917 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 918 | crypto_init_wait(&wait); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 919 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 920 | tfm = crypto_alloc_skcipher(algo, 0, async ? 0 : CRYPTO_ALG_ASYNC); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 921 | |
| 922 | if (IS_ERR(tfm)) { |
| 923 | pr_err("failed to load transform for %s: %ld\n", algo, |
| 924 | PTR_ERR(tfm)); |
| 925 | return; |
| 926 | } |
| 927 | |
Luca Clementi | 263a8df | 2014-06-25 22:57:42 -0700 | [diff] [blame] | 928 | pr_info("\ntesting speed of async %s (%s) %s\n", algo, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 929 | get_driver_name(crypto_skcipher, tfm), e); |
Luca Clementi | 263a8df | 2014-06-25 22:57:42 -0700 | [diff] [blame] | 930 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 931 | req = skcipher_request_alloc(tfm, GFP_KERNEL); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 932 | if (!req) { |
| 933 | pr_err("tcrypt: skcipher: Failed to allocate request for %s\n", |
| 934 | algo); |
| 935 | goto out; |
| 936 | } |
| 937 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 938 | skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 939 | crypto_req_done, &wait); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 940 | |
| 941 | i = 0; |
| 942 | do { |
| 943 | b_size = block_sizes; |
| 944 | |
| 945 | do { |
| 946 | struct scatterlist sg[TVMEMSIZE]; |
| 947 | |
| 948 | if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { |
| 949 | pr_err("template (%u) too big for " |
| 950 | "tvmem (%lu)\n", *keysize + *b_size, |
| 951 | TVMEMSIZE * PAGE_SIZE); |
| 952 | goto out_free_req; |
| 953 | } |
| 954 | |
| 955 | pr_info("test %u (%d bit key, %d byte blocks): ", i, |
| 956 | *keysize * 8, *b_size); |
| 957 | |
| 958 | memset(tvmem[0], 0xff, PAGE_SIZE); |
| 959 | |
| 960 | /* set key, plain text and IV */ |
| 961 | key = tvmem[0]; |
| 962 | for (j = 0; j < tcount; j++) { |
| 963 | if (template[j].klen == *keysize) { |
| 964 | key = template[j].key; |
| 965 | break; |
| 966 | } |
| 967 | } |
| 968 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 969 | crypto_skcipher_clear_flags(tfm, ~0); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 970 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 971 | ret = crypto_skcipher_setkey(tfm, key, *keysize); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 972 | if (ret) { |
| 973 | pr_err("setkey() failed flags=%x\n", |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 974 | crypto_skcipher_get_flags(tfm)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 975 | goto out_free_req; |
| 976 | } |
| 977 | |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 978 | k = *keysize + *b_size; |
Horia Geant? | 007ee8d | 2015-03-09 16:14:58 +0200 | [diff] [blame] | 979 | sg_init_table(sg, DIV_ROUND_UP(k, PAGE_SIZE)); |
| 980 | |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 981 | if (k > PAGE_SIZE) { |
| 982 | sg_set_buf(sg, tvmem[0] + *keysize, |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 983 | PAGE_SIZE - *keysize); |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 984 | k -= PAGE_SIZE; |
| 985 | j = 1; |
| 986 | while (k > PAGE_SIZE) { |
| 987 | sg_set_buf(sg + j, tvmem[j], PAGE_SIZE); |
| 988 | memset(tvmem[j], 0xff, PAGE_SIZE); |
| 989 | j++; |
| 990 | k -= PAGE_SIZE; |
| 991 | } |
| 992 | sg_set_buf(sg + j, tvmem[j], k); |
| 993 | memset(tvmem[j], 0xff, k); |
| 994 | } else { |
| 995 | sg_set_buf(sg, tvmem[0] + *keysize, *b_size); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 996 | } |
| 997 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 998 | iv_len = crypto_skcipher_ivsize(tfm); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 999 | if (iv_len) |
| 1000 | memset(&iv, 0xff, iv_len); |
| 1001 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1002 | skcipher_request_set_crypt(req, sg, sg, *b_size, iv); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1003 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 1004 | if (secs) |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1005 | ret = test_acipher_jiffies(req, enc, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 1006 | *b_size, secs); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1007 | else |
| 1008 | ret = test_acipher_cycles(req, enc, |
| 1009 | *b_size); |
| 1010 | |
| 1011 | if (ret) { |
| 1012 | pr_err("%s() failed flags=%x\n", e, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1013 | crypto_skcipher_get_flags(tfm)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1014 | break; |
| 1015 | } |
| 1016 | b_size++; |
| 1017 | i++; |
| 1018 | } while (*b_size); |
| 1019 | keysize++; |
| 1020 | } while (*keysize); |
| 1021 | |
| 1022 | out_free_req: |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1023 | skcipher_request_free(req); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1024 | out: |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 1025 | crypto_free_skcipher(tfm); |
| 1026 | } |
| 1027 | |
| 1028 | static void test_acipher_speed(const char *algo, int enc, unsigned int secs, |
| 1029 | struct cipher_speed_template *template, |
| 1030 | unsigned int tcount, u8 *keysize) |
| 1031 | { |
| 1032 | return test_skcipher_speed(algo, enc, secs, template, tcount, keysize, |
| 1033 | true); |
| 1034 | } |
| 1035 | |
| 1036 | static void test_cipher_speed(const char *algo, int enc, unsigned int secs, |
| 1037 | struct cipher_speed_template *template, |
| 1038 | unsigned int tcount, u8 *keysize) |
| 1039 | { |
| 1040 | return test_skcipher_speed(algo, enc, secs, template, tcount, keysize, |
| 1041 | false); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1042 | } |
| 1043 | |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1044 | static void test_available(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1045 | { |
| 1046 | char **name = check; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1047 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | while (*name) { |
| 1049 | printk("alg %s ", *name); |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 1050 | printk(crypto_has_alg(*name, 0, 0) ? |
Herbert Xu | e4d5b79 | 2006-08-26 18:12:40 +1000 | [diff] [blame] | 1051 | "found\n" : "not found\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | name++; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1053 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | } |
| 1055 | |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 1056 | static inline int tcrypt_test(const char *alg) |
| 1057 | { |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1058 | int ret; |
| 1059 | |
Rabin Vincent | 76512f2 | 2017-01-18 14:54:05 +0100 | [diff] [blame] | 1060 | pr_debug("testing %s\n", alg); |
| 1061 | |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1062 | ret = alg_test(alg, alg, 0, 0); |
| 1063 | /* non-fips algs return -EINVAL in fips mode */ |
| 1064 | if (fips_enabled && ret == -EINVAL) |
| 1065 | ret = 0; |
| 1066 | return ret; |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 1067 | } |
| 1068 | |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 1069 | 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] | 1070 | { |
| 1071 | int i; |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1072 | int ret = 0; |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 1073 | |
| 1074 | switch (m) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1075 | case 0: |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 1076 | if (alg) { |
| 1077 | if (!crypto_has_alg(alg, type, |
| 1078 | mask ?: CRYPTO_ALG_TYPE_MASK)) |
| 1079 | ret = -ENOENT; |
| 1080 | break; |
| 1081 | } |
| 1082 | |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 1083 | for (i = 1; i < 200; i++) |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 1084 | ret += do_test(NULL, 0, 0, i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1085 | break; |
| 1086 | |
| 1087 | case 1: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1088 | ret += tcrypt_test("md5"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1089 | break; |
| 1090 | |
| 1091 | case 2: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1092 | ret += tcrypt_test("sha1"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | break; |
| 1094 | |
| 1095 | case 3: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1096 | ret += tcrypt_test("ecb(des)"); |
| 1097 | ret += tcrypt_test("cbc(des)"); |
Jussi Kivilinna | 8163fc3 | 2012-10-20 14:53:07 +0300 | [diff] [blame] | 1098 | ret += tcrypt_test("ctr(des)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1099 | break; |
| 1100 | |
| 1101 | case 4: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1102 | ret += tcrypt_test("ecb(des3_ede)"); |
| 1103 | ret += tcrypt_test("cbc(des3_ede)"); |
Jussi Kivilinna | e080b17 | 2012-10-20 14:53:12 +0300 | [diff] [blame] | 1104 | ret += tcrypt_test("ctr(des3_ede)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | break; |
| 1106 | |
| 1107 | case 5: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1108 | ret += tcrypt_test("md4"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1110 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1111 | case 6: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1112 | ret += tcrypt_test("sha256"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1113 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1115 | case 7: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1116 | ret += tcrypt_test("ecb(blowfish)"); |
| 1117 | ret += tcrypt_test("cbc(blowfish)"); |
Jussi Kivilinna | 85b63e3 | 2011-10-10 23:03:03 +0300 | [diff] [blame] | 1118 | ret += tcrypt_test("ctr(blowfish)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1119 | break; |
| 1120 | |
| 1121 | case 8: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1122 | ret += tcrypt_test("ecb(twofish)"); |
| 1123 | ret += tcrypt_test("cbc(twofish)"); |
Jussi Kivilinna | 573da62 | 2011-10-10 23:03:12 +0300 | [diff] [blame] | 1124 | ret += tcrypt_test("ctr(twofish)"); |
Jussi Kivilinna | bee3a90 | 2011-10-18 13:32:56 +0300 | [diff] [blame] | 1125 | ret += tcrypt_test("lrw(twofish)"); |
Jussi Kivilinna | 131f754 | 2011-10-18 13:33:38 +0300 | [diff] [blame] | 1126 | ret += tcrypt_test("xts(twofish)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1128 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1129 | case 9: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1130 | ret += tcrypt_test("ecb(serpent)"); |
Jussi Kivilinna | 9d25917 | 2011-10-18 00:02:53 +0300 | [diff] [blame] | 1131 | ret += tcrypt_test("cbc(serpent)"); |
| 1132 | ret += tcrypt_test("ctr(serpent)"); |
Jussi Kivilinna | 87aae4b | 2011-10-18 13:32:39 +0300 | [diff] [blame] | 1133 | ret += tcrypt_test("lrw(serpent)"); |
Jussi Kivilinna | 5209c07 | 2011-10-18 13:33:22 +0300 | [diff] [blame] | 1134 | ret += tcrypt_test("xts(serpent)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | break; |
| 1136 | |
| 1137 | case 10: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1138 | ret += tcrypt_test("ecb(aes)"); |
| 1139 | ret += tcrypt_test("cbc(aes)"); |
| 1140 | ret += tcrypt_test("lrw(aes)"); |
| 1141 | ret += tcrypt_test("xts(aes)"); |
| 1142 | ret += tcrypt_test("ctr(aes)"); |
| 1143 | ret += tcrypt_test("rfc3686(ctr(aes))"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1144 | break; |
| 1145 | |
| 1146 | case 11: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1147 | ret += tcrypt_test("sha384"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1149 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | case 12: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1151 | ret += tcrypt_test("sha512"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1152 | break; |
| 1153 | |
| 1154 | case 13: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1155 | ret += tcrypt_test("deflate"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | break; |
| 1157 | |
| 1158 | case 14: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1159 | ret += tcrypt_test("ecb(cast5)"); |
Johannes Goetzfried | a2c5826 | 2012-07-11 19:37:21 +0200 | [diff] [blame] | 1160 | ret += tcrypt_test("cbc(cast5)"); |
| 1161 | ret += tcrypt_test("ctr(cast5)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | break; |
| 1163 | |
| 1164 | case 15: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1165 | ret += tcrypt_test("ecb(cast6)"); |
Johannes Goetzfried | 9b8b040 | 2012-07-11 19:38:29 +0200 | [diff] [blame] | 1166 | ret += tcrypt_test("cbc(cast6)"); |
| 1167 | ret += tcrypt_test("ctr(cast6)"); |
| 1168 | ret += tcrypt_test("lrw(cast6)"); |
| 1169 | ret += tcrypt_test("xts(cast6)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | break; |
| 1171 | |
| 1172 | case 16: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1173 | ret += tcrypt_test("ecb(arc4)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1174 | break; |
| 1175 | |
| 1176 | case 17: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1177 | ret += tcrypt_test("michael_mic"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1178 | break; |
| 1179 | |
| 1180 | case 18: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1181 | ret += tcrypt_test("crc32c"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1182 | break; |
| 1183 | |
| 1184 | case 19: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1185 | ret += tcrypt_test("ecb(tea)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1186 | break; |
| 1187 | |
| 1188 | case 20: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1189 | ret += tcrypt_test("ecb(xtea)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 | break; |
| 1191 | |
| 1192 | case 21: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1193 | ret += tcrypt_test("ecb(khazad)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | break; |
| 1195 | |
| 1196 | case 22: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1197 | ret += tcrypt_test("wp512"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | break; |
| 1199 | |
| 1200 | case 23: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1201 | ret += tcrypt_test("wp384"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | break; |
| 1203 | |
| 1204 | case 24: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1205 | ret += tcrypt_test("wp256"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1206 | break; |
| 1207 | |
| 1208 | case 25: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1209 | ret += tcrypt_test("ecb(tnepres)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | break; |
| 1211 | |
| 1212 | case 26: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1213 | ret += tcrypt_test("ecb(anubis)"); |
| 1214 | ret += tcrypt_test("cbc(anubis)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | break; |
| 1216 | |
| 1217 | case 27: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1218 | ret += tcrypt_test("tgr192"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1219 | break; |
| 1220 | |
| 1221 | case 28: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1222 | ret += tcrypt_test("tgr160"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1223 | break; |
| 1224 | |
| 1225 | case 29: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1226 | ret += tcrypt_test("tgr128"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | break; |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1228 | |
Aaron Grothe | fb4f10e | 2005-09-01 17:42:46 -0700 | [diff] [blame] | 1229 | case 30: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1230 | ret += tcrypt_test("ecb(xeta)"); |
Aaron Grothe | fb4f10e | 2005-09-01 17:42:46 -0700 | [diff] [blame] | 1231 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | |
David Howells | 9083163 | 2006-12-16 12:13:14 +1100 | [diff] [blame] | 1233 | case 31: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1234 | ret += tcrypt_test("pcbc(fcrypt)"); |
David Howells | 9083163 | 2006-12-16 12:13:14 +1100 | [diff] [blame] | 1235 | break; |
| 1236 | |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1237 | case 32: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1238 | ret += tcrypt_test("ecb(camellia)"); |
| 1239 | ret += tcrypt_test("cbc(camellia)"); |
Jussi Kivilinna | 54216bb | 2012-09-21 10:27:10 +0300 | [diff] [blame] | 1240 | ret += tcrypt_test("ctr(camellia)"); |
| 1241 | ret += tcrypt_test("lrw(camellia)"); |
| 1242 | ret += tcrypt_test("xts(camellia)"); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1243 | break; |
Jussi Kivilinna | 93b5e86 | 2013-04-08 10:48:44 +0300 | [diff] [blame] | 1244 | |
Jonathan Lynch | cd12fb90 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1245 | case 33: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1246 | ret += tcrypt_test("sha224"); |
Jonathan Lynch | cd12fb90 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1247 | break; |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1248 | |
Tan Swee Heng | 2407d60 | 2007-11-23 19:45:00 +0800 | [diff] [blame] | 1249 | case 34: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1250 | ret += tcrypt_test("salsa20"); |
Tan Swee Heng | 2407d60 | 2007-11-23 19:45:00 +0800 | [diff] [blame] | 1251 | break; |
| 1252 | |
Herbert Xu | 8df213d | 2007-12-02 14:55:47 +1100 | [diff] [blame] | 1253 | case 35: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1254 | ret += tcrypt_test("gcm(aes)"); |
Herbert Xu | 8df213d | 2007-12-02 14:55:47 +1100 | [diff] [blame] | 1255 | break; |
| 1256 | |
Zoltan Sogor | 0b77abb | 2007-12-07 16:53:23 +0800 | [diff] [blame] | 1257 | case 36: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1258 | ret += tcrypt_test("lzo"); |
Zoltan Sogor | 0b77abb | 2007-12-07 16:53:23 +0800 | [diff] [blame] | 1259 | break; |
| 1260 | |
Joy Latten | 93cc74e | 2007-12-12 20:24:22 +0800 | [diff] [blame] | 1261 | case 37: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1262 | ret += tcrypt_test("ccm(aes)"); |
Joy Latten | 93cc74e | 2007-12-12 20:24:22 +0800 | [diff] [blame] | 1263 | break; |
| 1264 | |
Kevin Coffman | 76cb952 | 2008-03-24 21:26:16 +0800 | [diff] [blame] | 1265 | case 38: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1266 | ret += tcrypt_test("cts(cbc(aes))"); |
Kevin Coffman | 76cb952 | 2008-03-24 21:26:16 +0800 | [diff] [blame] | 1267 | break; |
| 1268 | |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1269 | case 39: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1270 | ret += tcrypt_test("rmd128"); |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1271 | break; |
| 1272 | |
| 1273 | case 40: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1274 | ret += tcrypt_test("rmd160"); |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1275 | break; |
| 1276 | |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1277 | case 41: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1278 | ret += tcrypt_test("rmd256"); |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1279 | break; |
| 1280 | |
| 1281 | case 42: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1282 | ret += tcrypt_test("rmd320"); |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 1283 | break; |
| 1284 | |
| 1285 | case 43: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1286 | ret += tcrypt_test("ecb(seed)"); |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1287 | break; |
| 1288 | |
Geert Uytterhoeven | 0c01aed | 2009-03-04 15:42:15 +0800 | [diff] [blame] | 1289 | case 44: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1290 | ret += tcrypt_test("zlib"); |
Geert Uytterhoeven | 0c01aed | 2009-03-04 15:42:15 +0800 | [diff] [blame] | 1291 | break; |
| 1292 | |
Jarod Wilson | 5d66732 | 2009-05-04 19:23:40 +0800 | [diff] [blame] | 1293 | case 45: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1294 | ret += tcrypt_test("rfc4309(ccm(aes))"); |
Jarod Wilson | 5d66732 | 2009-05-04 19:23:40 +0800 | [diff] [blame] | 1295 | break; |
| 1296 | |
Jussi Kivilinna | 54216bb | 2012-09-21 10:27:10 +0300 | [diff] [blame] | 1297 | case 46: |
| 1298 | ret += tcrypt_test("ghash"); |
| 1299 | break; |
| 1300 | |
Herbert Xu | 68411521 | 2013-09-07 12:56:26 +1000 | [diff] [blame] | 1301 | case 47: |
| 1302 | ret += tcrypt_test("crct10dif"); |
| 1303 | break; |
| 1304 | |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1305 | case 48: |
| 1306 | ret += tcrypt_test("sha3-224"); |
| 1307 | break; |
| 1308 | |
| 1309 | case 49: |
| 1310 | ret += tcrypt_test("sha3-256"); |
| 1311 | break; |
| 1312 | |
| 1313 | case 50: |
| 1314 | ret += tcrypt_test("sha3-384"); |
| 1315 | break; |
| 1316 | |
| 1317 | case 51: |
| 1318 | ret += tcrypt_test("sha3-512"); |
| 1319 | break; |
| 1320 | |
Gilad Ben-Yossef | b7e2753 | 2017-08-21 13:51:29 +0300 | [diff] [blame] | 1321 | case 52: |
| 1322 | ret += tcrypt_test("sm3"); |
| 1323 | break; |
| 1324 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1325 | case 100: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1326 | ret += tcrypt_test("hmac(md5)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1327 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1328 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1329 | case 101: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1330 | ret += tcrypt_test("hmac(sha1)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1331 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1332 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1333 | case 102: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1334 | ret += tcrypt_test("hmac(sha256)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1335 | break; |
| 1336 | |
Andrew Donofrio | a28091a | 2006-12-10 12:10:20 +1100 | [diff] [blame] | 1337 | case 103: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1338 | ret += tcrypt_test("hmac(sha384)"); |
Andrew Donofrio | a28091a | 2006-12-10 12:10:20 +1100 | [diff] [blame] | 1339 | break; |
| 1340 | |
| 1341 | case 104: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1342 | ret += tcrypt_test("hmac(sha512)"); |
Andrew Donofrio | a28091a | 2006-12-10 12:10:20 +1100 | [diff] [blame] | 1343 | break; |
Herbert Xu | 38ed9ab | 2008-01-01 15:59:28 +1100 | [diff] [blame] | 1344 | |
Jonathan Lynch | cd12fb90 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1345 | case 105: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1346 | ret += tcrypt_test("hmac(sha224)"); |
Jonathan Lynch | cd12fb90 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1347 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1348 | |
Herbert Xu | 38ed9ab | 2008-01-01 15:59:28 +1100 | [diff] [blame] | 1349 | case 106: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1350 | ret += tcrypt_test("xcbc(aes)"); |
Herbert Xu | 38ed9ab | 2008-01-01 15:59:28 +1100 | [diff] [blame] | 1351 | break; |
| 1352 | |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1353 | case 107: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1354 | ret += tcrypt_test("hmac(rmd128)"); |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1355 | break; |
| 1356 | |
| 1357 | case 108: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1358 | ret += tcrypt_test("hmac(rmd160)"); |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1359 | break; |
| 1360 | |
Shane Wang | f1939f7 | 2009-09-02 20:05:22 +1000 | [diff] [blame] | 1361 | case 109: |
| 1362 | ret += tcrypt_test("vmac(aes)"); |
| 1363 | break; |
Jussi Kivilinna | 93b5e86 | 2013-04-08 10:48:44 +0300 | [diff] [blame] | 1364 | |
Sonic Zhang | a482b08 | 2012-05-25 17:54:13 +0800 | [diff] [blame] | 1365 | case 110: |
| 1366 | ret += tcrypt_test("hmac(crc32)"); |
| 1367 | break; |
Shane Wang | f1939f7 | 2009-09-02 20:05:22 +1000 | [diff] [blame] | 1368 | |
raveendra padasalagi | 98eca72 | 2016-07-01 11:16:54 +0530 | [diff] [blame] | 1369 | case 111: |
| 1370 | ret += tcrypt_test("hmac(sha3-224)"); |
| 1371 | break; |
| 1372 | |
| 1373 | case 112: |
| 1374 | ret += tcrypt_test("hmac(sha3-256)"); |
| 1375 | break; |
| 1376 | |
| 1377 | case 113: |
| 1378 | ret += tcrypt_test("hmac(sha3-384)"); |
| 1379 | break; |
| 1380 | |
| 1381 | case 114: |
| 1382 | ret += tcrypt_test("hmac(sha3-512)"); |
| 1383 | break; |
| 1384 | |
Jarod Wilson | e08ca2d | 2009-05-04 19:46:29 +0800 | [diff] [blame] | 1385 | case 150: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1386 | ret += tcrypt_test("ansi_cprng"); |
Jarod Wilson | e08ca2d | 2009-05-04 19:46:29 +0800 | [diff] [blame] | 1387 | break; |
| 1388 | |
Adrian Hoban | 69435b9 | 2010-11-04 15:02:04 -0400 | [diff] [blame] | 1389 | case 151: |
| 1390 | ret += tcrypt_test("rfc4106(gcm(aes))"); |
| 1391 | break; |
| 1392 | |
Jussi Kivilinna | e9b7441 | 2013-04-07 16:43:51 +0300 | [diff] [blame] | 1393 | case 152: |
| 1394 | ret += tcrypt_test("rfc4543(gcm(aes))"); |
| 1395 | break; |
| 1396 | |
Jussi Kivilinna | 93b5e86 | 2013-04-08 10:48:44 +0300 | [diff] [blame] | 1397 | case 153: |
| 1398 | ret += tcrypt_test("cmac(aes)"); |
| 1399 | break; |
| 1400 | |
| 1401 | case 154: |
| 1402 | ret += tcrypt_test("cmac(des3_ede)"); |
| 1403 | break; |
| 1404 | |
Horia Geanta | bbf9c89 | 2013-11-28 15:11:16 +0200 | [diff] [blame] | 1405 | case 155: |
| 1406 | ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))"); |
| 1407 | break; |
| 1408 | |
Horia Geanta | bca4feb | 2014-03-14 17:46:51 +0200 | [diff] [blame] | 1409 | case 156: |
| 1410 | ret += tcrypt_test("authenc(hmac(md5),ecb(cipher_null))"); |
| 1411 | break; |
| 1412 | |
| 1413 | case 157: |
| 1414 | ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))"); |
| 1415 | break; |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 1416 | case 181: |
| 1417 | ret += tcrypt_test("authenc(hmac(sha1),cbc(des))"); |
| 1418 | break; |
| 1419 | case 182: |
| 1420 | ret += tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))"); |
| 1421 | break; |
| 1422 | case 183: |
| 1423 | ret += tcrypt_test("authenc(hmac(sha224),cbc(des))"); |
| 1424 | break; |
| 1425 | case 184: |
| 1426 | ret += tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))"); |
| 1427 | break; |
| 1428 | case 185: |
| 1429 | ret += tcrypt_test("authenc(hmac(sha256),cbc(des))"); |
| 1430 | break; |
| 1431 | case 186: |
| 1432 | ret += tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))"); |
| 1433 | break; |
| 1434 | case 187: |
| 1435 | ret += tcrypt_test("authenc(hmac(sha384),cbc(des))"); |
| 1436 | break; |
| 1437 | case 188: |
| 1438 | ret += tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))"); |
| 1439 | break; |
| 1440 | case 189: |
| 1441 | ret += tcrypt_test("authenc(hmac(sha512),cbc(des))"); |
| 1442 | break; |
| 1443 | case 190: |
| 1444 | ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))"); |
| 1445 | break; |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1446 | case 200: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1447 | test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1448 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1449 | test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1450 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1451 | test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1452 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1453 | test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1454 | speed_template_16_24_32); |
Rik Snel | f3d1044 | 2006-11-29 19:01:41 +1100 | [diff] [blame] | 1455 | test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1456 | speed_template_32_40_48); |
Rik Snel | f3d1044 | 2006-11-29 19:01:41 +1100 | [diff] [blame] | 1457 | test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1458 | speed_template_32_40_48); |
Rik Snel | f19f511 | 2007-09-19 20:23:13 +0800 | [diff] [blame] | 1459 | test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, |
Horia Geantă | b66ad0b | 2017-07-19 19:40:32 +0300 | [diff] [blame] | 1460 | speed_template_32_64); |
Rik Snel | f19f511 | 2007-09-19 20:23:13 +0800 | [diff] [blame] | 1461 | test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, |
Horia Geantă | b66ad0b | 2017-07-19 19:40:32 +0300 | [diff] [blame] | 1462 | speed_template_32_64); |
Herbert Xu | 1503a24 | 2016-06-29 18:04:14 +0800 | [diff] [blame] | 1463 | test_cipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0, |
| 1464 | speed_template_16_24_32); |
| 1465 | test_cipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0, |
| 1466 | speed_template_16_24_32); |
Jan Glauber | 9996e34 | 2011-04-26 16:34:01 +1000 | [diff] [blame] | 1467 | test_cipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0, |
| 1468 | speed_template_16_24_32); |
| 1469 | test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, |
| 1470 | speed_template_16_24_32); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1471 | break; |
| 1472 | |
| 1473 | case 201: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1474 | test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1475 | des3_speed_template, DES3_SPEED_VECTORS, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1476 | speed_template_24); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1477 | test_cipher_speed("ecb(des3_ede)", DECRYPT, sec, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1478 | des3_speed_template, DES3_SPEED_VECTORS, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1479 | speed_template_24); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1480 | test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1481 | des3_speed_template, DES3_SPEED_VECTORS, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1482 | speed_template_24); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1483 | test_cipher_speed("cbc(des3_ede)", DECRYPT, sec, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1484 | des3_speed_template, DES3_SPEED_VECTORS, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1485 | speed_template_24); |
Jussi Kivilinna | 8713150 | 2014-06-09 20:59:49 +0300 | [diff] [blame] | 1486 | test_cipher_speed("ctr(des3_ede)", ENCRYPT, sec, |
| 1487 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1488 | speed_template_24); |
| 1489 | test_cipher_speed("ctr(des3_ede)", DECRYPT, sec, |
| 1490 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1491 | speed_template_24); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1492 | break; |
| 1493 | |
| 1494 | case 202: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1495 | test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1496 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1497 | test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1498 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1499 | test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1500 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1501 | test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1502 | speed_template_16_24_32); |
Jussi Kivilinna | ee5002a | 2011-09-26 16:47:15 +0300 | [diff] [blame] | 1503 | test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, |
| 1504 | speed_template_16_24_32); |
| 1505 | test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, |
| 1506 | speed_template_16_24_32); |
Jussi Kivilinna | bee3a90 | 2011-10-18 13:32:56 +0300 | [diff] [blame] | 1507 | test_cipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0, |
| 1508 | speed_template_32_40_48); |
| 1509 | test_cipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0, |
| 1510 | speed_template_32_40_48); |
Jussi Kivilinna | 131f754 | 2011-10-18 13:33:38 +0300 | [diff] [blame] | 1511 | test_cipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0, |
| 1512 | speed_template_32_48_64); |
| 1513 | test_cipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0, |
| 1514 | speed_template_32_48_64); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1515 | break; |
| 1516 | |
| 1517 | case 203: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1518 | test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1519 | speed_template_8_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1520 | test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1521 | speed_template_8_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1522 | test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1523 | speed_template_8_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1524 | test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1525 | speed_template_8_32); |
Jussi Kivilinna | 7d47b86 | 2011-09-02 01:45:17 +0300 | [diff] [blame] | 1526 | test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0, |
| 1527 | speed_template_8_32); |
| 1528 | test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0, |
| 1529 | speed_template_8_32); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1530 | break; |
| 1531 | |
| 1532 | case 204: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1533 | test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1534 | speed_template_8); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1535 | test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1536 | speed_template_8); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1537 | test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1538 | speed_template_8); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1539 | test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1540 | speed_template_8); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1541 | break; |
| 1542 | |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1543 | case 205: |
| 1544 | test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1545 | speed_template_16_24_32); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1546 | test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1547 | speed_template_16_24_32); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1548 | test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1549 | speed_template_16_24_32); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1550 | test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1551 | speed_template_16_24_32); |
Jussi Kivilinna | 4de5933 | 2012-03-05 20:26:26 +0200 | [diff] [blame] | 1552 | test_cipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0, |
| 1553 | speed_template_16_24_32); |
| 1554 | test_cipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0, |
| 1555 | speed_template_16_24_32); |
| 1556 | test_cipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0, |
| 1557 | speed_template_32_40_48); |
| 1558 | test_cipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0, |
| 1559 | speed_template_32_40_48); |
| 1560 | test_cipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0, |
| 1561 | speed_template_32_48_64); |
| 1562 | test_cipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0, |
| 1563 | speed_template_32_48_64); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1564 | break; |
| 1565 | |
Tan Swee Heng | 5de8f1b | 2007-12-07 17:17:43 +0800 | [diff] [blame] | 1566 | case 206: |
| 1567 | test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1568 | speed_template_16_32); |
Tan Swee Heng | 5de8f1b | 2007-12-07 17:17:43 +0800 | [diff] [blame] | 1569 | break; |
| 1570 | |
Jussi Kivilinna | 7fb7fe4 | 2011-10-18 00:03:03 +0300 | [diff] [blame] | 1571 | case 207: |
| 1572 | test_cipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0, |
| 1573 | speed_template_16_32); |
| 1574 | test_cipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0, |
| 1575 | speed_template_16_32); |
| 1576 | test_cipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0, |
| 1577 | speed_template_16_32); |
| 1578 | test_cipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0, |
| 1579 | speed_template_16_32); |
| 1580 | test_cipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0, |
| 1581 | speed_template_16_32); |
| 1582 | test_cipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0, |
| 1583 | speed_template_16_32); |
Jussi Kivilinna | 87aae4b | 2011-10-18 13:32:39 +0300 | [diff] [blame] | 1584 | test_cipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0, |
| 1585 | speed_template_32_48); |
| 1586 | test_cipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0, |
| 1587 | speed_template_32_48); |
Jussi Kivilinna | 5209c07 | 2011-10-18 13:33:22 +0300 | [diff] [blame] | 1588 | test_cipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0, |
| 1589 | speed_template_32_64); |
| 1590 | test_cipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0, |
| 1591 | speed_template_32_64); |
Jussi Kivilinna | 7fb7fe4 | 2011-10-18 00:03:03 +0300 | [diff] [blame] | 1592 | break; |
| 1593 | |
Jussi Kivilinna | 31b4cd29 | 2012-06-12 16:52:04 +0800 | [diff] [blame] | 1594 | case 208: |
| 1595 | test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0, |
| 1596 | speed_template_8); |
| 1597 | break; |
| 1598 | |
Johannes Goetzfried | a2c5826 | 2012-07-11 19:37:21 +0200 | [diff] [blame] | 1599 | case 209: |
| 1600 | test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, |
| 1601 | speed_template_8_16); |
| 1602 | test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, |
| 1603 | speed_template_8_16); |
| 1604 | test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, |
| 1605 | speed_template_8_16); |
| 1606 | test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, |
| 1607 | speed_template_8_16); |
| 1608 | test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, |
| 1609 | speed_template_8_16); |
| 1610 | test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, |
| 1611 | speed_template_8_16); |
| 1612 | break; |
| 1613 | |
Johannes Goetzfried | 9b8b040 | 2012-07-11 19:38:29 +0200 | [diff] [blame] | 1614 | case 210: |
| 1615 | test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, |
| 1616 | speed_template_16_32); |
| 1617 | test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, |
| 1618 | speed_template_16_32); |
| 1619 | test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, |
| 1620 | speed_template_16_32); |
| 1621 | test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, |
| 1622 | speed_template_16_32); |
| 1623 | test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, |
| 1624 | speed_template_16_32); |
| 1625 | test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, |
| 1626 | speed_template_16_32); |
| 1627 | test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, |
| 1628 | speed_template_32_48); |
| 1629 | test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, |
| 1630 | speed_template_32_48); |
| 1631 | test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, |
| 1632 | speed_template_32_64); |
| 1633 | test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, |
| 1634 | speed_template_32_64); |
| 1635 | break; |
| 1636 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 1637 | case 211: |
| 1638 | test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec, |
Herbert Xu | 34a1c74 | 2015-07-09 07:17:26 +0800 | [diff] [blame] | 1639 | NULL, 0, 16, 16, aead_speed_template_20); |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 1640 | test_aead_speed("gcm(aes)", ENCRYPT, sec, |
Cyrille Pitchen | f18611d | 2015-11-17 13:37:10 +0100 | [diff] [blame] | 1641 | NULL, 0, 16, 8, speed_template_16_24_32); |
Gilad Ben-Yossef | 4431bd4 | 2017-12-17 08:29:01 +0000 | [diff] [blame] | 1642 | test_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec, |
| 1643 | NULL, 0, 16, 16, aead_speed_template_20); |
| 1644 | test_aead_speed("gcm(aes)", DECRYPT, sec, |
| 1645 | NULL, 0, 16, 8, speed_template_16_24_32); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 1646 | break; |
| 1647 | |
Herbert Xu | 4e4aab6 | 2015-06-17 14:04:21 +0800 | [diff] [blame] | 1648 | case 212: |
| 1649 | test_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec, |
Herbert Xu | 34a1c74 | 2015-07-09 07:17:26 +0800 | [diff] [blame] | 1650 | NULL, 0, 16, 16, aead_speed_template_19); |
Gilad Ben-Yossef | 4431bd4 | 2017-12-17 08:29:01 +0000 | [diff] [blame] | 1651 | test_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec, |
| 1652 | NULL, 0, 16, 16, aead_speed_template_19); |
Herbert Xu | 4e4aab6 | 2015-06-17 14:04:21 +0800 | [diff] [blame] | 1653 | break; |
| 1654 | |
Martin Willi | 2dce063 | 2015-07-16 19:13:59 +0200 | [diff] [blame] | 1655 | case 213: |
| 1656 | test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, sec, |
| 1657 | NULL, 0, 16, 8, aead_speed_template_36); |
Gilad Ben-Yossef | 4431bd4 | 2017-12-17 08:29:01 +0000 | [diff] [blame] | 1658 | test_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT, sec, |
| 1659 | NULL, 0, 16, 8, aead_speed_template_36); |
Martin Willi | 2dce063 | 2015-07-16 19:13:59 +0200 | [diff] [blame] | 1660 | break; |
| 1661 | |
| 1662 | case 214: |
| 1663 | test_cipher_speed("chacha20", ENCRYPT, sec, NULL, 0, |
| 1664 | speed_template_32); |
| 1665 | break; |
| 1666 | |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1667 | case 300: |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 1668 | if (alg) { |
| 1669 | test_hash_speed(alg, sec, generic_hash_speed_template); |
| 1670 | break; |
| 1671 | } |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1672 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1673 | case 301: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1674 | test_hash_speed("md4", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1675 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1676 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1677 | case 302: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1678 | test_hash_speed("md5", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1679 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1680 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1681 | case 303: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1682 | test_hash_speed("sha1", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1683 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1684 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1685 | case 304: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1686 | test_hash_speed("sha256", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1687 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1688 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1689 | case 305: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1690 | test_hash_speed("sha384", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1691 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1692 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1693 | case 306: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1694 | test_hash_speed("sha512", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1695 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1696 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1697 | case 307: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1698 | test_hash_speed("wp256", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1699 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1700 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1701 | case 308: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1702 | test_hash_speed("wp384", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1703 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1704 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1705 | case 309: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1706 | test_hash_speed("wp512", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1707 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1708 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1709 | case 310: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1710 | test_hash_speed("tgr128", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1711 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1712 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1713 | case 311: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1714 | test_hash_speed("tgr160", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1715 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1716 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1717 | case 312: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1718 | test_hash_speed("tgr192", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1719 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1720 | /* fall through */ |
Jonathan Lynch | cd12fb90 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1721 | case 313: |
| 1722 | test_hash_speed("sha224", sec, generic_hash_speed_template); |
| 1723 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1724 | /* fall through */ |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1725 | case 314: |
| 1726 | test_hash_speed("rmd128", sec, generic_hash_speed_template); |
| 1727 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1728 | /* fall through */ |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1729 | case 315: |
| 1730 | test_hash_speed("rmd160", sec, generic_hash_speed_template); |
| 1731 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1732 | /* fall through */ |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1733 | case 316: |
| 1734 | test_hash_speed("rmd256", sec, generic_hash_speed_template); |
| 1735 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1736 | /* fall through */ |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1737 | case 317: |
| 1738 | test_hash_speed("rmd320", sec, generic_hash_speed_template); |
| 1739 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1740 | /* fall through */ |
Huang Ying | 18bcc91 | 2010-03-10 18:30:32 +0800 | [diff] [blame] | 1741 | case 318: |
| 1742 | test_hash_speed("ghash-generic", sec, hash_speed_template_16); |
| 1743 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1744 | /* fall through */ |
Tim Chen | e3899e4 | 2012-09-27 15:44:24 -0700 | [diff] [blame] | 1745 | case 319: |
| 1746 | test_hash_speed("crc32c", sec, generic_hash_speed_template); |
| 1747 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1748 | /* fall through */ |
Herbert Xu | 68411521 | 2013-09-07 12:56:26 +1000 | [diff] [blame] | 1749 | case 320: |
| 1750 | test_hash_speed("crct10dif", sec, generic_hash_speed_template); |
| 1751 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1752 | /* fall through */ |
Martin Willi | 2dce063 | 2015-07-16 19:13:59 +0200 | [diff] [blame] | 1753 | case 321: |
| 1754 | test_hash_speed("poly1305", sec, poly1305_speed_template); |
| 1755 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1756 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1757 | case 322: |
| 1758 | test_hash_speed("sha3-224", sec, generic_hash_speed_template); |
| 1759 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1760 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1761 | case 323: |
| 1762 | test_hash_speed("sha3-256", sec, generic_hash_speed_template); |
| 1763 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1764 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1765 | case 324: |
| 1766 | test_hash_speed("sha3-384", sec, generic_hash_speed_template); |
| 1767 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1768 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1769 | case 325: |
| 1770 | test_hash_speed("sha3-512", sec, generic_hash_speed_template); |
| 1771 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1772 | /* fall through */ |
Gilad Ben-Yossef | b7e2753 | 2017-08-21 13:51:29 +0300 | [diff] [blame] | 1773 | case 326: |
| 1774 | test_hash_speed("sm3", sec, generic_hash_speed_template); |
| 1775 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1776 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1777 | case 399: |
| 1778 | break; |
| 1779 | |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1780 | case 400: |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 1781 | if (alg) { |
| 1782 | test_ahash_speed(alg, sec, generic_hash_speed_template); |
| 1783 | break; |
| 1784 | } |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1785 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1786 | case 401: |
| 1787 | test_ahash_speed("md4", sec, generic_hash_speed_template); |
| 1788 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1789 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1790 | case 402: |
| 1791 | test_ahash_speed("md5", sec, generic_hash_speed_template); |
| 1792 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1793 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1794 | case 403: |
| 1795 | test_ahash_speed("sha1", sec, generic_hash_speed_template); |
| 1796 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1797 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1798 | case 404: |
| 1799 | test_ahash_speed("sha256", sec, generic_hash_speed_template); |
| 1800 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1801 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1802 | case 405: |
| 1803 | test_ahash_speed("sha384", sec, generic_hash_speed_template); |
| 1804 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1805 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1806 | case 406: |
| 1807 | test_ahash_speed("sha512", sec, generic_hash_speed_template); |
| 1808 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1809 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1810 | case 407: |
| 1811 | test_ahash_speed("wp256", sec, generic_hash_speed_template); |
| 1812 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1813 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1814 | case 408: |
| 1815 | test_ahash_speed("wp384", sec, generic_hash_speed_template); |
| 1816 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1817 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1818 | case 409: |
| 1819 | test_ahash_speed("wp512", sec, generic_hash_speed_template); |
| 1820 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1821 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1822 | case 410: |
| 1823 | test_ahash_speed("tgr128", sec, generic_hash_speed_template); |
| 1824 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1825 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1826 | case 411: |
| 1827 | test_ahash_speed("tgr160", sec, generic_hash_speed_template); |
| 1828 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1829 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1830 | case 412: |
| 1831 | test_ahash_speed("tgr192", sec, generic_hash_speed_template); |
| 1832 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1833 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1834 | case 413: |
| 1835 | test_ahash_speed("sha224", sec, generic_hash_speed_template); |
| 1836 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1837 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1838 | case 414: |
| 1839 | test_ahash_speed("rmd128", sec, generic_hash_speed_template); |
| 1840 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1841 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1842 | case 415: |
| 1843 | test_ahash_speed("rmd160", sec, generic_hash_speed_template); |
| 1844 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1845 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1846 | case 416: |
| 1847 | test_ahash_speed("rmd256", sec, generic_hash_speed_template); |
| 1848 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1849 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1850 | case 417: |
| 1851 | test_ahash_speed("rmd320", sec, generic_hash_speed_template); |
| 1852 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1853 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1854 | case 418: |
| 1855 | test_ahash_speed("sha3-224", sec, generic_hash_speed_template); |
| 1856 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1857 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1858 | case 419: |
| 1859 | test_ahash_speed("sha3-256", sec, generic_hash_speed_template); |
| 1860 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1861 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1862 | case 420: |
| 1863 | test_ahash_speed("sha3-384", sec, generic_hash_speed_template); |
| 1864 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1865 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1866 | case 421: |
| 1867 | test_ahash_speed("sha3-512", sec, generic_hash_speed_template); |
| 1868 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1869 | /* fall through */ |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 1870 | case 422: |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 1871 | test_mb_ahash_speed("sha1", sec, generic_hash_speed_template, |
| 1872 | num_mb); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 1873 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1874 | /* fall through */ |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 1875 | case 423: |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 1876 | test_mb_ahash_speed("sha256", sec, generic_hash_speed_template, |
| 1877 | num_mb); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 1878 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1879 | /* fall through */ |
Megha Dey | 14009c4 | 2016-06-27 10:20:09 -0700 | [diff] [blame] | 1880 | case 424: |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 1881 | test_mb_ahash_speed("sha512", sec, generic_hash_speed_template, |
| 1882 | num_mb); |
Megha Dey | 14009c4 | 2016-06-27 10:20:09 -0700 | [diff] [blame] | 1883 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1884 | /* fall through */ |
Gilad Ben-Yossef | b7e2753 | 2017-08-21 13:51:29 +0300 | [diff] [blame] | 1885 | case 425: |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 1886 | test_mb_ahash_speed("sm3", sec, generic_hash_speed_template, |
| 1887 | num_mb); |
Gilad Ben-Yossef | b7e2753 | 2017-08-21 13:51:29 +0300 | [diff] [blame] | 1888 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1889 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1890 | case 499: |
| 1891 | break; |
| 1892 | |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1893 | case 500: |
| 1894 | test_acipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, |
| 1895 | speed_template_16_24_32); |
| 1896 | test_acipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, |
| 1897 | speed_template_16_24_32); |
| 1898 | test_acipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, |
| 1899 | speed_template_16_24_32); |
| 1900 | test_acipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, |
| 1901 | speed_template_16_24_32); |
| 1902 | test_acipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, |
| 1903 | speed_template_32_40_48); |
| 1904 | test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, |
| 1905 | speed_template_32_40_48); |
| 1906 | test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, |
Horia Geantă | b66ad0b | 2017-07-19 19:40:32 +0300 | [diff] [blame] | 1907 | speed_template_32_64); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1908 | test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, |
Horia Geantă | b66ad0b | 2017-07-19 19:40:32 +0300 | [diff] [blame] | 1909 | speed_template_32_64); |
Herbert Xu | 1503a24 | 2016-06-29 18:04:14 +0800 | [diff] [blame] | 1910 | test_acipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0, |
| 1911 | speed_template_16_24_32); |
| 1912 | test_acipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0, |
| 1913 | speed_template_16_24_32); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1914 | test_acipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0, |
| 1915 | speed_template_16_24_32); |
| 1916 | test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, |
| 1917 | speed_template_16_24_32); |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 1918 | test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0, |
| 1919 | speed_template_16_24_32); |
| 1920 | test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0, |
| 1921 | speed_template_16_24_32); |
| 1922 | test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0, |
| 1923 | speed_template_16_24_32); |
| 1924 | test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0, |
| 1925 | speed_template_16_24_32); |
Jussi Kivilinna | 69d3150 | 2012-12-28 12:04:58 +0200 | [diff] [blame] | 1926 | test_acipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL, 0, |
| 1927 | speed_template_20_28_36); |
| 1928 | test_acipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL, 0, |
| 1929 | speed_template_20_28_36); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1930 | break; |
| 1931 | |
| 1932 | case 501: |
| 1933 | test_acipher_speed("ecb(des3_ede)", ENCRYPT, sec, |
| 1934 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1935 | speed_template_24); |
| 1936 | test_acipher_speed("ecb(des3_ede)", DECRYPT, sec, |
| 1937 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1938 | speed_template_24); |
| 1939 | test_acipher_speed("cbc(des3_ede)", ENCRYPT, sec, |
| 1940 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1941 | speed_template_24); |
| 1942 | test_acipher_speed("cbc(des3_ede)", DECRYPT, sec, |
| 1943 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1944 | speed_template_24); |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 1945 | test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec, |
| 1946 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1947 | speed_template_24); |
| 1948 | test_acipher_speed("cfb(des3_ede)", DECRYPT, sec, |
| 1949 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1950 | speed_template_24); |
| 1951 | test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec, |
| 1952 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1953 | speed_template_24); |
| 1954 | test_acipher_speed("ofb(des3_ede)", DECRYPT, sec, |
| 1955 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1956 | speed_template_24); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1957 | break; |
| 1958 | |
| 1959 | case 502: |
| 1960 | test_acipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, |
| 1961 | speed_template_8); |
| 1962 | test_acipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, |
| 1963 | speed_template_8); |
| 1964 | test_acipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, |
| 1965 | speed_template_8); |
| 1966 | test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, |
| 1967 | speed_template_8); |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 1968 | test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0, |
| 1969 | speed_template_8); |
| 1970 | test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0, |
| 1971 | speed_template_8); |
| 1972 | test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0, |
| 1973 | speed_template_8); |
| 1974 | test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0, |
| 1975 | speed_template_8); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1976 | break; |
| 1977 | |
Jussi Kivilinna | 7fb7fe4 | 2011-10-18 00:03:03 +0300 | [diff] [blame] | 1978 | case 503: |
| 1979 | test_acipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0, |
| 1980 | speed_template_16_32); |
| 1981 | test_acipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0, |
| 1982 | speed_template_16_32); |
| 1983 | test_acipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0, |
| 1984 | speed_template_16_32); |
| 1985 | test_acipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0, |
| 1986 | speed_template_16_32); |
| 1987 | test_acipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0, |
| 1988 | speed_template_16_32); |
| 1989 | test_acipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0, |
| 1990 | speed_template_16_32); |
Jussi Kivilinna | 87aae4b | 2011-10-18 13:32:39 +0300 | [diff] [blame] | 1991 | test_acipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0, |
| 1992 | speed_template_32_48); |
| 1993 | test_acipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0, |
| 1994 | speed_template_32_48); |
Jussi Kivilinna | 5209c07 | 2011-10-18 13:33:22 +0300 | [diff] [blame] | 1995 | test_acipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0, |
| 1996 | speed_template_32_64); |
| 1997 | test_acipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0, |
| 1998 | speed_template_32_64); |
Jussi Kivilinna | 7fb7fe4 | 2011-10-18 00:03:03 +0300 | [diff] [blame] | 1999 | break; |
| 2000 | |
Johannes Goetzfried | 107778b5 | 2012-05-28 15:54:24 +0200 | [diff] [blame] | 2001 | case 504: |
| 2002 | test_acipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, |
| 2003 | speed_template_16_24_32); |
| 2004 | test_acipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, |
| 2005 | speed_template_16_24_32); |
| 2006 | test_acipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, |
| 2007 | speed_template_16_24_32); |
| 2008 | test_acipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, |
| 2009 | speed_template_16_24_32); |
| 2010 | test_acipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, |
| 2011 | speed_template_16_24_32); |
| 2012 | test_acipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, |
| 2013 | speed_template_16_24_32); |
| 2014 | test_acipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0, |
| 2015 | speed_template_32_40_48); |
| 2016 | test_acipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0, |
| 2017 | speed_template_32_40_48); |
| 2018 | test_acipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0, |
| 2019 | speed_template_32_48_64); |
| 2020 | test_acipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0, |
| 2021 | speed_template_32_48_64); |
| 2022 | break; |
| 2023 | |
Jussi Kivilinna | 31b4cd29 | 2012-06-12 16:52:04 +0800 | [diff] [blame] | 2024 | case 505: |
| 2025 | test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0, |
| 2026 | speed_template_8); |
| 2027 | break; |
| 2028 | |
Johannes Goetzfried | a2c5826 | 2012-07-11 19:37:21 +0200 | [diff] [blame] | 2029 | case 506: |
| 2030 | test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, |
| 2031 | speed_template_8_16); |
| 2032 | test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, |
| 2033 | speed_template_8_16); |
| 2034 | test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, |
| 2035 | speed_template_8_16); |
| 2036 | test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, |
| 2037 | speed_template_8_16); |
| 2038 | test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, |
| 2039 | speed_template_8_16); |
| 2040 | test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, |
| 2041 | speed_template_8_16); |
| 2042 | break; |
| 2043 | |
Johannes Goetzfried | 9b8b040 | 2012-07-11 19:38:29 +0200 | [diff] [blame] | 2044 | case 507: |
| 2045 | test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, |
| 2046 | speed_template_16_32); |
| 2047 | test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, |
| 2048 | speed_template_16_32); |
| 2049 | test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, |
| 2050 | speed_template_16_32); |
| 2051 | test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, |
| 2052 | speed_template_16_32); |
| 2053 | test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, |
| 2054 | speed_template_16_32); |
| 2055 | test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, |
| 2056 | speed_template_16_32); |
| 2057 | test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, |
| 2058 | speed_template_32_48); |
| 2059 | test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, |
| 2060 | speed_template_32_48); |
| 2061 | test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, |
| 2062 | speed_template_32_64); |
| 2063 | test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, |
| 2064 | speed_template_32_64); |
| 2065 | break; |
| 2066 | |
Jussi Kivilinna | bf9c518 | 2012-10-26 14:48:51 +0300 | [diff] [blame] | 2067 | case 508: |
| 2068 | test_acipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, |
| 2069 | speed_template_16_32); |
| 2070 | test_acipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, |
| 2071 | speed_template_16_32); |
| 2072 | test_acipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, |
| 2073 | speed_template_16_32); |
| 2074 | test_acipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, |
| 2075 | speed_template_16_32); |
| 2076 | test_acipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0, |
| 2077 | speed_template_16_32); |
| 2078 | test_acipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0, |
| 2079 | speed_template_16_32); |
| 2080 | test_acipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0, |
| 2081 | speed_template_32_48); |
| 2082 | test_acipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0, |
| 2083 | speed_template_32_48); |
| 2084 | test_acipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0, |
| 2085 | speed_template_32_64); |
| 2086 | test_acipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0, |
| 2087 | speed_template_32_64); |
| 2088 | break; |
| 2089 | |
Jussi Kivilinna | ad8b7c3 | 2013-04-13 13:46:40 +0300 | [diff] [blame] | 2090 | case 509: |
| 2091 | test_acipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, |
| 2092 | speed_template_8_32); |
| 2093 | test_acipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, |
| 2094 | speed_template_8_32); |
| 2095 | test_acipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, |
| 2096 | speed_template_8_32); |
| 2097 | test_acipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, |
| 2098 | speed_template_8_32); |
| 2099 | test_acipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0, |
| 2100 | speed_template_8_32); |
| 2101 | test_acipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0, |
| 2102 | speed_template_8_32); |
| 2103 | break; |
| 2104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2105 | case 1000: |
| 2106 | test_available(); |
| 2107 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2108 | } |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2109 | |
| 2110 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2111 | } |
| 2112 | |
Kamalesh Babulal | 3af5b90 | 2008-04-05 21:00:57 +0800 | [diff] [blame] | 2113 | static int __init tcrypt_mod_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | { |
Mikko Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 2115 | int err = -ENOMEM; |
Herbert Xu | f139cfa | 2008-07-31 12:23:53 +0800 | [diff] [blame] | 2116 | int i; |
Mikko Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 2117 | |
Herbert Xu | f139cfa | 2008-07-31 12:23:53 +0800 | [diff] [blame] | 2118 | for (i = 0; i < TVMEMSIZE; i++) { |
| 2119 | tvmem[i] = (void *)__get_free_page(GFP_KERNEL); |
| 2120 | if (!tvmem[i]) |
| 2121 | goto err_free_tv; |
| 2122 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 2124 | err = do_test(alg, type, mask, mode); |
Steffen Klassert | a873a5f | 2009-06-19 19:46:53 +0800 | [diff] [blame] | 2125 | |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2126 | if (err) { |
| 2127 | printk(KERN_ERR "tcrypt: one or more tests failed!\n"); |
| 2128 | goto err_free_tv; |
Rabin Vincent | 76512f2 | 2017-01-18 14:54:05 +0100 | [diff] [blame] | 2129 | } else { |
| 2130 | pr_debug("all tests passed\n"); |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2131 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2132 | |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2133 | /* We intentionaly return -EAGAIN to prevent keeping the module, |
| 2134 | * unless we're running in fips mode. It does all its work from |
| 2135 | * init() and doesn't offer any runtime functionality, but in |
| 2136 | * the fips case, checking for a successful load is helpful. |
Michal Ludvig | 14fdf47 | 2006-05-30 14:49:38 +1000 | [diff] [blame] | 2137 | * => we don't need it in the memory, do we? |
| 2138 | * -- mludvig |
| 2139 | */ |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2140 | if (!fips_enabled) |
| 2141 | err = -EAGAIN; |
Mikko Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 2142 | |
Herbert Xu | f139cfa | 2008-07-31 12:23:53 +0800 | [diff] [blame] | 2143 | err_free_tv: |
| 2144 | for (i = 0; i < TVMEMSIZE && tvmem[i]; i++) |
| 2145 | free_page((unsigned long)tvmem[i]); |
Mikko Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 2146 | |
| 2147 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2148 | } |
| 2149 | |
| 2150 | /* |
| 2151 | * If an init function is provided, an exit function must also be provided |
| 2152 | * to allow module unload. |
| 2153 | */ |
Kamalesh Babulal | 3af5b90 | 2008-04-05 21:00:57 +0800 | [diff] [blame] | 2154 | static void __exit tcrypt_mod_fini(void) { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2155 | |
Kamalesh Babulal | 3af5b90 | 2008-04-05 21:00:57 +0800 | [diff] [blame] | 2156 | module_init(tcrypt_mod_init); |
| 2157 | module_exit(tcrypt_mod_fini); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2158 | |
Steffen Klassert | a873a5f | 2009-06-19 19:46:53 +0800 | [diff] [blame] | 2159 | module_param(alg, charp, 0); |
| 2160 | module_param(type, uint, 0); |
Herbert Xu | 7be380f | 2009-07-14 16:06:54 +0800 | [diff] [blame] | 2161 | module_param(mask, uint, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2162 | module_param(mode, int, 0); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 2163 | module_param(sec, uint, 0); |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 2164 | MODULE_PARM_DESC(sec, "Length in seconds of speed tests " |
| 2165 | "(defaults to zero which uses CPU cycles instead)"); |
Gilad Ben-Yossef | 8fcdc86 | 2017-12-17 08:29:02 +0000 | [diff] [blame] | 2166 | module_param(num_mb, uint, 0000); |
| 2167 | 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] | 2168 | |
| 2169 | MODULE_LICENSE("GPL"); |
| 2170 | MODULE_DESCRIPTION("Quick & dirty crypto testing module"); |
| 2171 | MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>"); |