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; |
Herbert Xu | f139cfa | 2008-07-31 12:23:53 +0800 | [diff] [blame] | 70 | static char *tvmem[TVMEMSIZE]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
| 72 | static char *check[] = { |
Gilad Ben-Yossef | b7e2753 | 2017-08-21 13:51:29 +0300 | [diff] [blame] | 73 | "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", "sm3", |
Jonathan Lynch | cd12fb9 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 74 | "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes", |
| 75 | "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", |
David Howells | 9083163 | 2006-12-16 12:13:14 +1100 | [diff] [blame] | 76 | "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 77 | "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320", |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 78 | "lzo", "cts", "zlib", "sha3-224", "sha3-256", "sha3-384", "sha3-512", |
| 79 | NULL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 82 | static inline int do_one_aead_op(struct aead_request *req, int ret) |
| 83 | { |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 84 | struct crypto_wait *wait = req->base.data; |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 85 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 86 | return crypto_wait_req(ret, wait); |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 87 | } |
| 88 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 89 | static int test_aead_jiffies(struct aead_request *req, int enc, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 90 | int blen, int secs) |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 91 | { |
| 92 | unsigned long start, end; |
| 93 | int bcount; |
| 94 | int ret; |
| 95 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 96 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 97 | time_before(jiffies, end); bcount++) { |
| 98 | if (enc) |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 99 | ret = do_one_aead_op(req, crypto_aead_encrypt(req)); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 100 | else |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 101 | ret = do_one_aead_op(req, crypto_aead_decrypt(req)); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 102 | |
| 103 | if (ret) |
| 104 | return ret; |
| 105 | } |
| 106 | |
| 107 | printk("%d operations in %d seconds (%ld bytes)\n", |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 108 | bcount, secs, (long)bcount * blen); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | static int test_aead_cycles(struct aead_request *req, int enc, int blen) |
| 113 | { |
| 114 | unsigned long cycles = 0; |
| 115 | int ret = 0; |
| 116 | int i; |
| 117 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 118 | /* Warm-up run. */ |
| 119 | for (i = 0; i < 4; i++) { |
| 120 | if (enc) |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 121 | ret = do_one_aead_op(req, crypto_aead_encrypt(req)); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 122 | else |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 123 | ret = do_one_aead_op(req, crypto_aead_decrypt(req)); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 124 | |
| 125 | if (ret) |
| 126 | goto out; |
| 127 | } |
| 128 | |
| 129 | /* The real thing. */ |
| 130 | for (i = 0; i < 8; i++) { |
| 131 | cycles_t start, end; |
| 132 | |
| 133 | start = get_cycles(); |
| 134 | if (enc) |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 135 | ret = do_one_aead_op(req, crypto_aead_encrypt(req)); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 136 | else |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 137 | ret = do_one_aead_op(req, crypto_aead_decrypt(req)); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 138 | end = get_cycles(); |
| 139 | |
| 140 | if (ret) |
| 141 | goto out; |
| 142 | |
| 143 | cycles += end - start; |
| 144 | } |
| 145 | |
| 146 | out: |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 147 | if (ret == 0) |
| 148 | printk("1 operation in %lu cycles (%d bytes)\n", |
| 149 | (cycles + 4) / 8, blen); |
| 150 | |
| 151 | return ret; |
| 152 | } |
| 153 | |
Sebastian Siewior | d5dc392 | 2008-03-11 21:27:11 +0800 | [diff] [blame] | 154 | static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 }; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 155 | static u32 aead_sizes[] = { 16, 64, 256, 512, 1024, 2048, 4096, 8192, 0 }; |
| 156 | |
| 157 | #define XBUFSIZE 8 |
| 158 | #define MAX_IVLEN 32 |
| 159 | |
| 160 | static int testmgr_alloc_buf(char *buf[XBUFSIZE]) |
| 161 | { |
| 162 | int i; |
| 163 | |
| 164 | for (i = 0; i < XBUFSIZE; i++) { |
| 165 | buf[i] = (void *)__get_free_page(GFP_KERNEL); |
| 166 | if (!buf[i]) |
| 167 | goto err_free_buf; |
| 168 | } |
| 169 | |
| 170 | return 0; |
| 171 | |
| 172 | err_free_buf: |
| 173 | while (i-- > 0) |
| 174 | free_page((unsigned long)buf[i]); |
| 175 | |
| 176 | return -ENOMEM; |
| 177 | } |
| 178 | |
| 179 | static void testmgr_free_buf(char *buf[XBUFSIZE]) |
| 180 | { |
| 181 | int i; |
| 182 | |
| 183 | for (i = 0; i < XBUFSIZE; i++) |
| 184 | free_page((unsigned long)buf[i]); |
| 185 | } |
| 186 | |
| 187 | static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE], |
Tudor-Dan Ambarus | 5601e01 | 2017-11-14 16:59:15 +0200 | [diff] [blame^] | 188 | unsigned int buflen, const void *assoc, |
| 189 | unsigned int aad_size) |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 190 | { |
| 191 | int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE; |
| 192 | int k, rem; |
| 193 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 194 | if (np > XBUFSIZE) { |
| 195 | rem = PAGE_SIZE; |
| 196 | np = XBUFSIZE; |
Cristian Stoica | c476899 | 2015-01-27 11:54:27 +0200 | [diff] [blame] | 197 | } else { |
| 198 | rem = buflen % PAGE_SIZE; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 199 | } |
Cristian Stoica | c476899 | 2015-01-27 11:54:27 +0200 | [diff] [blame] | 200 | |
Herbert Xu | 3126727 | 2015-06-17 14:05:26 +0800 | [diff] [blame] | 201 | sg_init_table(sg, np + 1); |
Tudor-Dan Ambarus | 5601e01 | 2017-11-14 16:59:15 +0200 | [diff] [blame^] | 202 | |
| 203 | sg_set_buf(&sg[0], assoc, aad_size); |
| 204 | |
Robert Baronescu | 5c6ac1d | 2017-10-10 13:21:59 +0300 | [diff] [blame] | 205 | if (rem) |
| 206 | np--; |
Cristian Stoica | c476899 | 2015-01-27 11:54:27 +0200 | [diff] [blame] | 207 | for (k = 0; k < np; k++) |
Herbert Xu | 3126727 | 2015-06-17 14:05:26 +0800 | [diff] [blame] | 208 | sg_set_buf(&sg[k + 1], xbuf[k], PAGE_SIZE); |
Cristian Stoica | c476899 | 2015-01-27 11:54:27 +0200 | [diff] [blame] | 209 | |
Robert Baronescu | 5c6ac1d | 2017-10-10 13:21:59 +0300 | [diff] [blame] | 210 | if (rem) |
| 211 | sg_set_buf(&sg[k + 1], xbuf[k], rem); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 212 | } |
| 213 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 214 | 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] | 215 | struct aead_speed_template *template, |
| 216 | unsigned int tcount, u8 authsize, |
| 217 | unsigned int aad_size, u8 *keysize) |
| 218 | { |
| 219 | unsigned int i, j; |
| 220 | struct crypto_aead *tfm; |
| 221 | int ret = -ENOMEM; |
| 222 | const char *key; |
| 223 | struct aead_request *req; |
| 224 | struct scatterlist *sg; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 225 | struct scatterlist *sgout; |
| 226 | const char *e; |
| 227 | void *assoc; |
Cristian Stoica | 96692a73 | 2015-01-28 13:07:32 +0200 | [diff] [blame] | 228 | char *iv; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 229 | char *xbuf[XBUFSIZE]; |
| 230 | char *xoutbuf[XBUFSIZE]; |
| 231 | char *axbuf[XBUFSIZE]; |
| 232 | unsigned int *b_size; |
| 233 | unsigned int iv_len; |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 234 | struct crypto_wait wait; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 235 | |
Cristian Stoica | 96692a73 | 2015-01-28 13:07:32 +0200 | [diff] [blame] | 236 | iv = kzalloc(MAX_IVLEN, GFP_KERNEL); |
| 237 | if (!iv) |
| 238 | return; |
| 239 | |
Christian Engelmayer | ac5f863 | 2014-04-21 20:45:59 +0200 | [diff] [blame] | 240 | if (aad_size >= PAGE_SIZE) { |
| 241 | pr_err("associate data length (%u) too big\n", aad_size); |
Cristian Stoica | 96692a73 | 2015-01-28 13:07:32 +0200 | [diff] [blame] | 242 | goto out_noxbuf; |
Christian Engelmayer | ac5f863 | 2014-04-21 20:45:59 +0200 | [diff] [blame] | 243 | } |
| 244 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 245 | if (enc == ENCRYPT) |
| 246 | e = "encryption"; |
| 247 | else |
| 248 | e = "decryption"; |
| 249 | |
| 250 | if (testmgr_alloc_buf(xbuf)) |
| 251 | goto out_noxbuf; |
| 252 | if (testmgr_alloc_buf(axbuf)) |
| 253 | goto out_noaxbuf; |
| 254 | if (testmgr_alloc_buf(xoutbuf)) |
| 255 | goto out_nooutbuf; |
| 256 | |
Herbert Xu | a3f2185 | 2015-05-27 16:03:51 +0800 | [diff] [blame] | 257 | sg = kmalloc(sizeof(*sg) * 9 * 2, GFP_KERNEL); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 258 | if (!sg) |
| 259 | goto out_nosg; |
Herbert Xu | a3f2185 | 2015-05-27 16:03:51 +0800 | [diff] [blame] | 260 | sgout = &sg[9]; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 261 | |
Herbert Xu | 5e4b8c1 | 2015-08-13 17:29:06 +0800 | [diff] [blame] | 262 | tfm = crypto_alloc_aead(algo, 0, 0); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 263 | |
| 264 | if (IS_ERR(tfm)) { |
| 265 | pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo, |
| 266 | PTR_ERR(tfm)); |
Christian Engelmayer | a2ea6ed | 2014-04-21 20:46:40 +0200 | [diff] [blame] | 267 | goto out_notfm; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 268 | } |
| 269 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 270 | crypto_init_wait(&wait); |
Luca Clementi | 263a8df | 2014-06-25 22:57:42 -0700 | [diff] [blame] | 271 | printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo, |
| 272 | get_driver_name(crypto_aead, tfm), e); |
| 273 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 274 | req = aead_request_alloc(tfm, GFP_KERNEL); |
| 275 | if (!req) { |
| 276 | pr_err("alg: aead: Failed to allocate request for %s\n", |
| 277 | algo); |
Christian Engelmayer | 6af1f93 | 2014-04-21 20:47:05 +0200 | [diff] [blame] | 278 | goto out_noreq; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 279 | } |
| 280 | |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 281 | aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 282 | crypto_req_done, &wait); |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 283 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 284 | i = 0; |
| 285 | do { |
| 286 | b_size = aead_sizes; |
| 287 | do { |
| 288 | assoc = axbuf[0]; |
Christian Engelmayer | ac5f863 | 2014-04-21 20:45:59 +0200 | [diff] [blame] | 289 | memset(assoc, 0xff, aad_size); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 290 | |
| 291 | if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { |
| 292 | pr_err("template (%u) too big for tvmem (%lu)\n", |
| 293 | *keysize + *b_size, |
| 294 | TVMEMSIZE * PAGE_SIZE); |
| 295 | goto out; |
| 296 | } |
| 297 | |
| 298 | key = tvmem[0]; |
| 299 | for (j = 0; j < tcount; j++) { |
| 300 | if (template[j].klen == *keysize) { |
| 301 | key = template[j].key; |
| 302 | break; |
| 303 | } |
| 304 | } |
| 305 | ret = crypto_aead_setkey(tfm, key, *keysize); |
| 306 | ret = crypto_aead_setauthsize(tfm, authsize); |
| 307 | |
| 308 | iv_len = crypto_aead_ivsize(tfm); |
| 309 | if (iv_len) |
Cristian Stoica | 96692a73 | 2015-01-28 13:07:32 +0200 | [diff] [blame] | 310 | memset(iv, 0xff, iv_len); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 311 | |
| 312 | crypto_aead_clear_flags(tfm, ~0); |
| 313 | printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ", |
| 314 | i, *keysize * 8, *b_size); |
| 315 | |
| 316 | |
| 317 | memset(tvmem[0], 0xff, PAGE_SIZE); |
| 318 | |
| 319 | if (ret) { |
| 320 | pr_err("setkey() failed flags=%x\n", |
| 321 | crypto_aead_get_flags(tfm)); |
| 322 | goto out; |
| 323 | } |
| 324 | |
Tudor-Dan Ambarus | 5601e01 | 2017-11-14 16:59:15 +0200 | [diff] [blame^] | 325 | sg_init_aead(sg, xbuf, *b_size + (enc ? 0 : authsize), |
| 326 | assoc, aad_size); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 327 | |
Herbert Xu | 3126727 | 2015-06-17 14:05:26 +0800 | [diff] [blame] | 328 | sg_init_aead(sgout, xoutbuf, |
Tudor-Dan Ambarus | 5601e01 | 2017-11-14 16:59:15 +0200 | [diff] [blame^] | 329 | *b_size + (enc ? authsize : 0), assoc, |
| 330 | aad_size); |
Herbert Xu | 3126727 | 2015-06-17 14:05:26 +0800 | [diff] [blame] | 331 | |
Robert Baronescu | 7aacbfc | 2017-10-10 13:22:00 +0300 | [diff] [blame] | 332 | aead_request_set_crypt(req, sg, sgout, |
| 333 | *b_size + (enc ? 0 : authsize), |
| 334 | iv); |
Herbert Xu | a3f2185 | 2015-05-27 16:03:51 +0800 | [diff] [blame] | 335 | aead_request_set_ad(req, aad_size); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 336 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 337 | if (secs) |
| 338 | ret = test_aead_jiffies(req, enc, *b_size, |
| 339 | secs); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 340 | else |
| 341 | ret = test_aead_cycles(req, enc, *b_size); |
| 342 | |
| 343 | if (ret) { |
| 344 | pr_err("%s() failed return code=%d\n", e, ret); |
| 345 | break; |
| 346 | } |
| 347 | b_size++; |
| 348 | i++; |
| 349 | } while (*b_size); |
| 350 | keysize++; |
| 351 | } while (*keysize); |
| 352 | |
| 353 | out: |
Christian Engelmayer | 6af1f93 | 2014-04-21 20:47:05 +0200 | [diff] [blame] | 354 | aead_request_free(req); |
| 355 | out_noreq: |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 356 | crypto_free_aead(tfm); |
Christian Engelmayer | a2ea6ed | 2014-04-21 20:46:40 +0200 | [diff] [blame] | 357 | out_notfm: |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 358 | kfree(sg); |
| 359 | out_nosg: |
| 360 | testmgr_free_buf(xoutbuf); |
| 361 | out_nooutbuf: |
| 362 | testmgr_free_buf(axbuf); |
| 363 | out_noaxbuf: |
| 364 | testmgr_free_buf(xbuf); |
| 365 | out_noxbuf: |
Cristian Stoica | 96692a73 | 2015-01-28 13:07:32 +0200 | [diff] [blame] | 366 | kfree(iv); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 367 | } |
Sebastian Siewior | d5dc392 | 2008-03-11 21:27:11 +0800 | [diff] [blame] | 368 | |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 369 | static void test_hash_sg_init(struct scatterlist *sg) |
| 370 | { |
| 371 | int i; |
| 372 | |
| 373 | sg_init_table(sg, TVMEMSIZE); |
| 374 | for (i = 0; i < TVMEMSIZE; i++) { |
| 375 | sg_set_buf(sg + i, tvmem[i], PAGE_SIZE); |
| 376 | memset(tvmem[i], 0xff, PAGE_SIZE); |
| 377 | } |
| 378 | } |
| 379 | |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 380 | static inline int do_one_ahash_op(struct ahash_request *req, int ret) |
| 381 | { |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 382 | struct crypto_wait *wait = req->base.data; |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 383 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 384 | return crypto_wait_req(ret, wait); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 385 | } |
| 386 | |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 387 | struct test_mb_ahash_data { |
| 388 | struct scatterlist sg[TVMEMSIZE]; |
| 389 | char result[64]; |
| 390 | struct ahash_request *req; |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 391 | struct crypto_wait wait; |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 392 | char *xbuf[XBUFSIZE]; |
| 393 | }; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 394 | |
| 395 | static void test_mb_ahash_speed(const char *algo, unsigned int sec, |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 396 | struct hash_speed *speed) |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 397 | { |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 398 | struct test_mb_ahash_data *data; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 399 | struct crypto_ahash *tfm; |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 400 | unsigned long start, end; |
Herbert Xu | f8de55b | 2016-06-28 16:41:38 +0800 | [diff] [blame] | 401 | unsigned long cycles; |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 402 | unsigned int i, j, k; |
| 403 | int ret; |
| 404 | |
| 405 | data = kzalloc(sizeof(*data) * 8, GFP_KERNEL); |
| 406 | if (!data) |
| 407 | return; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 408 | |
| 409 | tfm = crypto_alloc_ahash(algo, 0, 0); |
| 410 | if (IS_ERR(tfm)) { |
| 411 | pr_err("failed to load transform for %s: %ld\n", |
| 412 | algo, PTR_ERR(tfm)); |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 413 | goto free_data; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 414 | } |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 415 | |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 416 | for (i = 0; i < 8; ++i) { |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 417 | if (testmgr_alloc_buf(data[i].xbuf)) |
| 418 | goto out; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 419 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 420 | crypto_init_wait(&data[i].wait); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 421 | |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 422 | data[i].req = ahash_request_alloc(tfm, GFP_KERNEL); |
| 423 | if (!data[i].req) { |
Krzysztof Kozlowski | f83f5b1 | 2016-06-28 09:23:06 +0200 | [diff] [blame] | 424 | pr_err("alg: hash: Failed to allocate request for %s\n", |
| 425 | algo); |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 426 | goto out; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 427 | } |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 428 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 429 | ahash_request_set_callback(data[i].req, 0, crypto_req_done, |
| 430 | &data[i].wait); |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 431 | test_hash_sg_init(data[i].sg); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 432 | } |
| 433 | |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 434 | pr_info("\ntesting speed of multibuffer %s (%s)\n", algo, |
| 435 | get_driver_name(crypto_ahash, tfm)); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 436 | |
| 437 | for (i = 0; speed[i].blen != 0; i++) { |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 438 | /* For some reason this only tests digests. */ |
| 439 | if (speed[i].blen != speed[i].plen) |
| 440 | continue; |
| 441 | |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 442 | if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) { |
Krzysztof Kozlowski | f83f5b1 | 2016-06-28 09:23:06 +0200 | [diff] [blame] | 443 | pr_err("template (%u) too big for tvmem (%lu)\n", |
| 444 | speed[i].blen, TVMEMSIZE * PAGE_SIZE); |
| 445 | goto out; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | if (speed[i].klen) |
| 449 | crypto_ahash_setkey(tfm, tvmem[0], speed[i].klen); |
| 450 | |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 451 | for (k = 0; k < 8; k++) |
| 452 | ahash_request_set_crypt(data[k].req, data[k].sg, |
| 453 | data[k].result, speed[i].blen); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 454 | |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 455 | pr_info("test%3u " |
| 456 | "(%5u byte blocks,%5u bytes per update,%4u updates): ", |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 457 | i, speed[i].blen, speed[i].plen, |
| 458 | speed[i].blen / speed[i].plen); |
| 459 | |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 460 | start = get_cycles(); |
| 461 | |
| 462 | for (k = 0; k < 8; k++) { |
| 463 | ret = crypto_ahash_digest(data[k].req); |
Herbert Xu | d13cd11 | 2016-06-30 11:00:13 +0800 | [diff] [blame] | 464 | if (ret == -EINPROGRESS) { |
| 465 | ret = 0; |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 466 | continue; |
Herbert Xu | d13cd11 | 2016-06-30 11:00:13 +0800 | [diff] [blame] | 467 | } |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 468 | |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 469 | if (ret) |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 470 | break; |
| 471 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 472 | crypto_req_done(&data[k].req->base, 0); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 473 | } |
| 474 | |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 475 | for (j = 0; j < k; j++) { |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 476 | struct crypto_wait *wait = &data[j].wait; |
| 477 | int wait_ret; |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 478 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 479 | wait_ret = crypto_wait_req(-EINPROGRESS, wait); |
| 480 | if (wait_ret) |
| 481 | ret = wait_ret; |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | end = get_cycles(); |
| 485 | cycles = end - start; |
| 486 | pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", |
| 487 | cycles, cycles / (8 * speed[i].blen)); |
| 488 | |
| 489 | if (ret) { |
| 490 | pr_err("At least one hashing failed ret=%d\n", ret); |
| 491 | break; |
| 492 | } |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 493 | } |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 494 | |
| 495 | out: |
| 496 | for (k = 0; k < 8; ++k) |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 497 | ahash_request_free(data[k].req); |
| 498 | |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 499 | for (k = 0; k < 8; ++k) |
Herbert Xu | 72259de | 2016-06-28 20:33:52 +0800 | [diff] [blame] | 500 | testmgr_free_buf(data[k].xbuf); |
| 501 | |
| 502 | crypto_free_ahash(tfm); |
| 503 | |
| 504 | free_data: |
| 505 | kfree(data); |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 506 | } |
| 507 | |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 508 | static int test_ahash_jiffies_digest(struct ahash_request *req, int blen, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 509 | char *out, int secs) |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 510 | { |
| 511 | unsigned long start, end; |
| 512 | int bcount; |
| 513 | int ret; |
| 514 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 515 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 516 | time_before(jiffies, end); bcount++) { |
| 517 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); |
| 518 | if (ret) |
| 519 | return ret; |
| 520 | } |
| 521 | |
| 522 | printk("%6u opers/sec, %9lu bytes/sec\n", |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 523 | bcount / secs, ((long)bcount * blen) / secs); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 524 | |
| 525 | return 0; |
| 526 | } |
| 527 | |
| 528 | static int test_ahash_jiffies(struct ahash_request *req, int blen, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 529 | int plen, char *out, int secs) |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 530 | { |
| 531 | unsigned long start, end; |
| 532 | int bcount, pcount; |
| 533 | int ret; |
| 534 | |
| 535 | if (plen == blen) |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 536 | return test_ahash_jiffies_digest(req, blen, out, secs); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 537 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 538 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 539 | time_before(jiffies, end); bcount++) { |
Herbert Xu | 43a9607 | 2015-04-22 11:02:27 +0800 | [diff] [blame] | 540 | ret = do_one_ahash_op(req, crypto_ahash_init(req)); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 541 | if (ret) |
| 542 | return ret; |
| 543 | for (pcount = 0; pcount < blen; pcount += plen) { |
| 544 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); |
| 545 | if (ret) |
| 546 | return ret; |
| 547 | } |
| 548 | /* we assume there is enough space in 'out' for the result */ |
| 549 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); |
| 550 | if (ret) |
| 551 | return ret; |
| 552 | } |
| 553 | |
| 554 | pr_cont("%6u opers/sec, %9lu bytes/sec\n", |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 555 | bcount / secs, ((long)bcount * blen) / secs); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 556 | |
| 557 | return 0; |
| 558 | } |
| 559 | |
| 560 | static int test_ahash_cycles_digest(struct ahash_request *req, int blen, |
| 561 | char *out) |
| 562 | { |
| 563 | unsigned long cycles = 0; |
| 564 | int ret, i; |
| 565 | |
| 566 | /* Warm-up run. */ |
| 567 | for (i = 0; i < 4; i++) { |
| 568 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); |
| 569 | if (ret) |
| 570 | goto out; |
| 571 | } |
| 572 | |
| 573 | /* The real thing. */ |
| 574 | for (i = 0; i < 8; i++) { |
| 575 | cycles_t start, end; |
| 576 | |
| 577 | start = get_cycles(); |
| 578 | |
| 579 | ret = do_one_ahash_op(req, crypto_ahash_digest(req)); |
| 580 | if (ret) |
| 581 | goto out; |
| 582 | |
| 583 | end = get_cycles(); |
| 584 | |
| 585 | cycles += end - start; |
| 586 | } |
| 587 | |
| 588 | out: |
| 589 | if (ret) |
| 590 | return ret; |
| 591 | |
| 592 | pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", |
| 593 | cycles / 8, cycles / (8 * blen)); |
| 594 | |
| 595 | return 0; |
| 596 | } |
| 597 | |
| 598 | static int test_ahash_cycles(struct ahash_request *req, int blen, |
| 599 | int plen, char *out) |
| 600 | { |
| 601 | unsigned long cycles = 0; |
| 602 | int i, pcount, ret; |
| 603 | |
| 604 | if (plen == blen) |
| 605 | return test_ahash_cycles_digest(req, blen, out); |
| 606 | |
| 607 | /* Warm-up run. */ |
| 608 | for (i = 0; i < 4; i++) { |
Herbert Xu | 43a9607 | 2015-04-22 11:02:27 +0800 | [diff] [blame] | 609 | ret = do_one_ahash_op(req, crypto_ahash_init(req)); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 610 | if (ret) |
| 611 | goto out; |
| 612 | for (pcount = 0; pcount < blen; pcount += plen) { |
| 613 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); |
| 614 | if (ret) |
| 615 | goto out; |
| 616 | } |
| 617 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); |
| 618 | if (ret) |
| 619 | goto out; |
| 620 | } |
| 621 | |
| 622 | /* The real thing. */ |
| 623 | for (i = 0; i < 8; i++) { |
| 624 | cycles_t start, end; |
| 625 | |
| 626 | start = get_cycles(); |
| 627 | |
Herbert Xu | 43a9607 | 2015-04-22 11:02:27 +0800 | [diff] [blame] | 628 | ret = do_one_ahash_op(req, crypto_ahash_init(req)); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 629 | if (ret) |
| 630 | goto out; |
| 631 | for (pcount = 0; pcount < blen; pcount += plen) { |
| 632 | ret = do_one_ahash_op(req, crypto_ahash_update(req)); |
| 633 | if (ret) |
| 634 | goto out; |
| 635 | } |
| 636 | ret = do_one_ahash_op(req, crypto_ahash_final(req)); |
| 637 | if (ret) |
| 638 | goto out; |
| 639 | |
| 640 | end = get_cycles(); |
| 641 | |
| 642 | cycles += end - start; |
| 643 | } |
| 644 | |
| 645 | out: |
| 646 | if (ret) |
| 647 | return ret; |
| 648 | |
| 649 | pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", |
| 650 | cycles / 8, cycles / (8 * blen)); |
| 651 | |
| 652 | return 0; |
| 653 | } |
| 654 | |
Herbert Xu | 0660511 | 2016-02-01 21:36:49 +0800 | [diff] [blame] | 655 | static void test_ahash_speed_common(const char *algo, unsigned int secs, |
| 656 | struct hash_speed *speed, unsigned mask) |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 657 | { |
| 658 | struct scatterlist sg[TVMEMSIZE]; |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 659 | struct crypto_wait wait; |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 660 | struct ahash_request *req; |
| 661 | struct crypto_ahash *tfm; |
Horia Geant? | f074f7b | 2015-08-27 18:38:36 +0300 | [diff] [blame] | 662 | char *output; |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 663 | int i, ret; |
| 664 | |
Herbert Xu | 0660511 | 2016-02-01 21:36:49 +0800 | [diff] [blame] | 665 | tfm = crypto_alloc_ahash(algo, 0, mask); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 666 | if (IS_ERR(tfm)) { |
| 667 | pr_err("failed to load transform for %s: %ld\n", |
| 668 | algo, PTR_ERR(tfm)); |
| 669 | return; |
| 670 | } |
| 671 | |
Luca Clementi | 263a8df | 2014-06-25 22:57:42 -0700 | [diff] [blame] | 672 | printk(KERN_INFO "\ntesting speed of async %s (%s)\n", algo, |
| 673 | get_driver_name(crypto_ahash, tfm)); |
| 674 | |
Horia Geant? | f074f7b | 2015-08-27 18:38:36 +0300 | [diff] [blame] | 675 | if (crypto_ahash_digestsize(tfm) > MAX_DIGEST_SIZE) { |
| 676 | pr_err("digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm), |
| 677 | MAX_DIGEST_SIZE); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 678 | goto out; |
| 679 | } |
| 680 | |
| 681 | test_hash_sg_init(sg); |
| 682 | req = ahash_request_alloc(tfm, GFP_KERNEL); |
| 683 | if (!req) { |
| 684 | pr_err("ahash request allocation failure\n"); |
| 685 | goto out; |
| 686 | } |
| 687 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 688 | crypto_init_wait(&wait); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 689 | ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 690 | crypto_req_done, &wait); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 691 | |
Horia Geant? | f074f7b | 2015-08-27 18:38:36 +0300 | [diff] [blame] | 692 | output = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL); |
| 693 | if (!output) |
| 694 | goto out_nomem; |
| 695 | |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 696 | for (i = 0; speed[i].blen != 0; i++) { |
| 697 | if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) { |
| 698 | pr_err("template (%u) too big for tvmem (%lu)\n", |
| 699 | speed[i].blen, TVMEMSIZE * PAGE_SIZE); |
| 700 | break; |
| 701 | } |
| 702 | |
| 703 | pr_info("test%3u " |
| 704 | "(%5u byte blocks,%5u bytes per update,%4u updates): ", |
| 705 | i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen); |
| 706 | |
| 707 | ahash_request_set_crypt(req, sg, output, speed[i].plen); |
| 708 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 709 | if (secs) |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 710 | ret = test_ahash_jiffies(req, speed[i].blen, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 711 | speed[i].plen, output, secs); |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 712 | else |
| 713 | ret = test_ahash_cycles(req, speed[i].blen, |
| 714 | speed[i].plen, output); |
| 715 | |
| 716 | if (ret) { |
| 717 | pr_err("hashing failed ret=%d\n", ret); |
| 718 | break; |
| 719 | } |
| 720 | } |
| 721 | |
Horia Geant? | f074f7b | 2015-08-27 18:38:36 +0300 | [diff] [blame] | 722 | kfree(output); |
| 723 | |
| 724 | out_nomem: |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 725 | ahash_request_free(req); |
| 726 | |
| 727 | out: |
| 728 | crypto_free_ahash(tfm); |
| 729 | } |
| 730 | |
Herbert Xu | 0660511 | 2016-02-01 21:36:49 +0800 | [diff] [blame] | 731 | static void test_ahash_speed(const char *algo, unsigned int secs, |
| 732 | struct hash_speed *speed) |
| 733 | { |
| 734 | return test_ahash_speed_common(algo, secs, speed, 0); |
| 735 | } |
| 736 | |
| 737 | static void test_hash_speed(const char *algo, unsigned int secs, |
| 738 | struct hash_speed *speed) |
| 739 | { |
| 740 | return test_ahash_speed_common(algo, secs, speed, CRYPTO_ALG_ASYNC); |
| 741 | } |
| 742 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 743 | 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] | 744 | { |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 745 | struct crypto_wait *wait = req->base.data; |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 746 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 747 | return crypto_wait_req(ret, wait); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 748 | } |
| 749 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 750 | static int test_acipher_jiffies(struct skcipher_request *req, int enc, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 751 | int blen, int secs) |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 752 | { |
| 753 | unsigned long start, end; |
| 754 | int bcount; |
| 755 | int ret; |
| 756 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 757 | for (start = jiffies, end = start + secs * HZ, bcount = 0; |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 758 | time_before(jiffies, end); bcount++) { |
| 759 | if (enc) |
| 760 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 761 | crypto_skcipher_encrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 762 | else |
| 763 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 764 | crypto_skcipher_decrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 765 | |
| 766 | if (ret) |
| 767 | return ret; |
| 768 | } |
| 769 | |
| 770 | pr_cont("%d operations in %d seconds (%ld bytes)\n", |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 771 | bcount, secs, (long)bcount * blen); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 772 | return 0; |
| 773 | } |
| 774 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 775 | static int test_acipher_cycles(struct skcipher_request *req, int enc, |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 776 | int blen) |
| 777 | { |
| 778 | unsigned long cycles = 0; |
| 779 | int ret = 0; |
| 780 | int i; |
| 781 | |
| 782 | /* Warm-up run. */ |
| 783 | for (i = 0; i < 4; i++) { |
| 784 | if (enc) |
| 785 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 786 | crypto_skcipher_encrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 787 | else |
| 788 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 789 | crypto_skcipher_decrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 790 | |
| 791 | if (ret) |
| 792 | goto out; |
| 793 | } |
| 794 | |
| 795 | /* The real thing. */ |
| 796 | for (i = 0; i < 8; i++) { |
| 797 | cycles_t start, end; |
| 798 | |
| 799 | start = get_cycles(); |
| 800 | if (enc) |
| 801 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 802 | crypto_skcipher_encrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 803 | else |
| 804 | ret = do_one_acipher_op(req, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 805 | crypto_skcipher_decrypt(req)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 806 | end = get_cycles(); |
| 807 | |
| 808 | if (ret) |
| 809 | goto out; |
| 810 | |
| 811 | cycles += end - start; |
| 812 | } |
| 813 | |
| 814 | out: |
| 815 | if (ret == 0) |
| 816 | pr_cont("1 operation in %lu cycles (%d bytes)\n", |
| 817 | (cycles + 4) / 8, blen); |
| 818 | |
| 819 | return ret; |
| 820 | } |
| 821 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 822 | static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, |
| 823 | struct cipher_speed_template *template, |
| 824 | unsigned int tcount, u8 *keysize, bool async) |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 825 | { |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 826 | unsigned int ret, i, j, k, iv_len; |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 827 | struct crypto_wait wait; |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 828 | const char *key; |
| 829 | char iv[128]; |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 830 | struct skcipher_request *req; |
| 831 | struct crypto_skcipher *tfm; |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 832 | const char *e; |
| 833 | u32 *b_size; |
| 834 | |
| 835 | if (enc == ENCRYPT) |
| 836 | e = "encryption"; |
| 837 | else |
| 838 | e = "decryption"; |
| 839 | |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 840 | crypto_init_wait(&wait); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 841 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 842 | tfm = crypto_alloc_skcipher(algo, 0, async ? 0 : CRYPTO_ALG_ASYNC); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 843 | |
| 844 | if (IS_ERR(tfm)) { |
| 845 | pr_err("failed to load transform for %s: %ld\n", algo, |
| 846 | PTR_ERR(tfm)); |
| 847 | return; |
| 848 | } |
| 849 | |
Luca Clementi | 263a8df | 2014-06-25 22:57:42 -0700 | [diff] [blame] | 850 | pr_info("\ntesting speed of async %s (%s) %s\n", algo, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 851 | get_driver_name(crypto_skcipher, tfm), e); |
Luca Clementi | 263a8df | 2014-06-25 22:57:42 -0700 | [diff] [blame] | 852 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 853 | req = skcipher_request_alloc(tfm, GFP_KERNEL); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 854 | if (!req) { |
| 855 | pr_err("tcrypt: skcipher: Failed to allocate request for %s\n", |
| 856 | algo); |
| 857 | goto out; |
| 858 | } |
| 859 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 860 | skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
Gilad Ben-Yossef | 6467104 | 2017-10-18 08:00:48 +0100 | [diff] [blame] | 861 | crypto_req_done, &wait); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 862 | |
| 863 | i = 0; |
| 864 | do { |
| 865 | b_size = block_sizes; |
| 866 | |
| 867 | do { |
| 868 | struct scatterlist sg[TVMEMSIZE]; |
| 869 | |
| 870 | if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { |
| 871 | pr_err("template (%u) too big for " |
| 872 | "tvmem (%lu)\n", *keysize + *b_size, |
| 873 | TVMEMSIZE * PAGE_SIZE); |
| 874 | goto out_free_req; |
| 875 | } |
| 876 | |
| 877 | pr_info("test %u (%d bit key, %d byte blocks): ", i, |
| 878 | *keysize * 8, *b_size); |
| 879 | |
| 880 | memset(tvmem[0], 0xff, PAGE_SIZE); |
| 881 | |
| 882 | /* set key, plain text and IV */ |
| 883 | key = tvmem[0]; |
| 884 | for (j = 0; j < tcount; j++) { |
| 885 | if (template[j].klen == *keysize) { |
| 886 | key = template[j].key; |
| 887 | break; |
| 888 | } |
| 889 | } |
| 890 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 891 | crypto_skcipher_clear_flags(tfm, ~0); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 892 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 893 | ret = crypto_skcipher_setkey(tfm, key, *keysize); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 894 | if (ret) { |
| 895 | pr_err("setkey() failed flags=%x\n", |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 896 | crypto_skcipher_get_flags(tfm)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 897 | goto out_free_req; |
| 898 | } |
| 899 | |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 900 | k = *keysize + *b_size; |
Horia Geant? | 007ee8d | 2015-03-09 16:14:58 +0200 | [diff] [blame] | 901 | sg_init_table(sg, DIV_ROUND_UP(k, PAGE_SIZE)); |
| 902 | |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 903 | if (k > PAGE_SIZE) { |
| 904 | sg_set_buf(sg, tvmem[0] + *keysize, |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 905 | PAGE_SIZE - *keysize); |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 906 | k -= PAGE_SIZE; |
| 907 | j = 1; |
| 908 | while (k > PAGE_SIZE) { |
| 909 | sg_set_buf(sg + j, tvmem[j], PAGE_SIZE); |
| 910 | memset(tvmem[j], 0xff, PAGE_SIZE); |
| 911 | j++; |
| 912 | k -= PAGE_SIZE; |
| 913 | } |
| 914 | sg_set_buf(sg + j, tvmem[j], k); |
| 915 | memset(tvmem[j], 0xff, k); |
| 916 | } else { |
| 917 | sg_set_buf(sg, tvmem[0] + *keysize, *b_size); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 918 | } |
| 919 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 920 | iv_len = crypto_skcipher_ivsize(tfm); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 921 | if (iv_len) |
| 922 | memset(&iv, 0xff, iv_len); |
| 923 | |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 924 | skcipher_request_set_crypt(req, sg, sg, *b_size, iv); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 925 | |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 926 | if (secs) |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 927 | ret = test_acipher_jiffies(req, enc, |
Mark Rustad | 3e3dc25 | 2014-07-25 02:53:38 -0700 | [diff] [blame] | 928 | *b_size, secs); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 929 | else |
| 930 | ret = test_acipher_cycles(req, enc, |
| 931 | *b_size); |
| 932 | |
| 933 | if (ret) { |
| 934 | pr_err("%s() failed flags=%x\n", e, |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 935 | crypto_skcipher_get_flags(tfm)); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 936 | break; |
| 937 | } |
| 938 | b_size++; |
| 939 | i++; |
| 940 | } while (*b_size); |
| 941 | keysize++; |
| 942 | } while (*keysize); |
| 943 | |
| 944 | out_free_req: |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 945 | skcipher_request_free(req); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 946 | out: |
Herbert Xu | 7166e58 | 2016-06-29 18:03:50 +0800 | [diff] [blame] | 947 | crypto_free_skcipher(tfm); |
| 948 | } |
| 949 | |
| 950 | static void test_acipher_speed(const char *algo, int enc, unsigned int secs, |
| 951 | struct cipher_speed_template *template, |
| 952 | unsigned int tcount, u8 *keysize) |
| 953 | { |
| 954 | return test_skcipher_speed(algo, enc, secs, template, tcount, keysize, |
| 955 | true); |
| 956 | } |
| 957 | |
| 958 | static void test_cipher_speed(const char *algo, int enc, unsigned int secs, |
| 959 | struct cipher_speed_template *template, |
| 960 | unsigned int tcount, u8 *keysize) |
| 961 | { |
| 962 | return test_skcipher_speed(algo, enc, secs, template, tcount, keysize, |
| 963 | false); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 964 | } |
| 965 | |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 966 | static void test_available(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | { |
| 968 | char **name = check; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 969 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 970 | while (*name) { |
| 971 | printk("alg %s ", *name); |
Herbert Xu | 6158efc | 2007-04-04 17:41:07 +1000 | [diff] [blame] | 972 | printk(crypto_has_alg(*name, 0, 0) ? |
Herbert Xu | e4d5b79 | 2006-08-26 18:12:40 +1000 | [diff] [blame] | 973 | "found\n" : "not found\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 974 | name++; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 975 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | } |
| 977 | |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 978 | static inline int tcrypt_test(const char *alg) |
| 979 | { |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 980 | int ret; |
| 981 | |
Rabin Vincent | 76512f2 | 2017-01-18 14:54:05 +0100 | [diff] [blame] | 982 | pr_debug("testing %s\n", alg); |
| 983 | |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 984 | ret = alg_test(alg, alg, 0, 0); |
| 985 | /* non-fips algs return -EINVAL in fips mode */ |
| 986 | if (fips_enabled && ret == -EINVAL) |
| 987 | ret = 0; |
| 988 | return ret; |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 989 | } |
| 990 | |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 991 | 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] | 992 | { |
| 993 | int i; |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 994 | int ret = 0; |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 995 | |
| 996 | switch (m) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | case 0: |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 998 | if (alg) { |
| 999 | if (!crypto_has_alg(alg, type, |
| 1000 | mask ?: CRYPTO_ALG_TYPE_MASK)) |
| 1001 | ret = -ENOENT; |
| 1002 | break; |
| 1003 | } |
| 1004 | |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 1005 | for (i = 1; i < 200; i++) |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 1006 | ret += do_test(NULL, 0, 0, i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | break; |
| 1008 | |
| 1009 | case 1: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1010 | ret += tcrypt_test("md5"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | break; |
| 1012 | |
| 1013 | case 2: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1014 | ret += tcrypt_test("sha1"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | break; |
| 1016 | |
| 1017 | case 3: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1018 | ret += tcrypt_test("ecb(des)"); |
| 1019 | ret += tcrypt_test("cbc(des)"); |
Jussi Kivilinna | 8163fc3 | 2012-10-20 14:53:07 +0300 | [diff] [blame] | 1020 | ret += tcrypt_test("ctr(des)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1021 | break; |
| 1022 | |
| 1023 | case 4: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1024 | ret += tcrypt_test("ecb(des3_ede)"); |
| 1025 | ret += tcrypt_test("cbc(des3_ede)"); |
Jussi Kivilinna | e080b17 | 2012-10-20 14:53:12 +0300 | [diff] [blame] | 1026 | ret += tcrypt_test("ctr(des3_ede)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | break; |
| 1028 | |
| 1029 | case 5: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1030 | ret += tcrypt_test("md4"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1032 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | case 6: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1034 | ret += tcrypt_test("sha256"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1035 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1036 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1037 | case 7: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1038 | ret += tcrypt_test("ecb(blowfish)"); |
| 1039 | ret += tcrypt_test("cbc(blowfish)"); |
Jussi Kivilinna | 85b63e3 | 2011-10-10 23:03:03 +0300 | [diff] [blame] | 1040 | ret += tcrypt_test("ctr(blowfish)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | break; |
| 1042 | |
| 1043 | case 8: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1044 | ret += tcrypt_test("ecb(twofish)"); |
| 1045 | ret += tcrypt_test("cbc(twofish)"); |
Jussi Kivilinna | 573da62 | 2011-10-10 23:03:12 +0300 | [diff] [blame] | 1046 | ret += tcrypt_test("ctr(twofish)"); |
Jussi Kivilinna | bee3a90 | 2011-10-18 13:32:56 +0300 | [diff] [blame] | 1047 | ret += tcrypt_test("lrw(twofish)"); |
Jussi Kivilinna | 131f754 | 2011-10-18 13:33:38 +0300 | [diff] [blame] | 1048 | ret += tcrypt_test("xts(twofish)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1050 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | case 9: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1052 | ret += tcrypt_test("ecb(serpent)"); |
Jussi Kivilinna | 9d25917 | 2011-10-18 00:02:53 +0300 | [diff] [blame] | 1053 | ret += tcrypt_test("cbc(serpent)"); |
| 1054 | ret += tcrypt_test("ctr(serpent)"); |
Jussi Kivilinna | 87aae4b | 2011-10-18 13:32:39 +0300 | [diff] [blame] | 1055 | ret += tcrypt_test("lrw(serpent)"); |
Jussi Kivilinna | 5209c07 | 2011-10-18 13:33:22 +0300 | [diff] [blame] | 1056 | ret += tcrypt_test("xts(serpent)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1057 | break; |
| 1058 | |
| 1059 | case 10: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1060 | ret += tcrypt_test("ecb(aes)"); |
| 1061 | ret += tcrypt_test("cbc(aes)"); |
| 1062 | ret += tcrypt_test("lrw(aes)"); |
| 1063 | ret += tcrypt_test("xts(aes)"); |
| 1064 | ret += tcrypt_test("ctr(aes)"); |
| 1065 | ret += tcrypt_test("rfc3686(ctr(aes))"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | break; |
| 1067 | |
| 1068 | case 11: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1069 | ret += tcrypt_test("sha384"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1070 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1071 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1072 | case 12: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1073 | ret += tcrypt_test("sha512"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | break; |
| 1075 | |
| 1076 | case 13: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1077 | ret += tcrypt_test("deflate"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1078 | break; |
| 1079 | |
| 1080 | case 14: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1081 | ret += tcrypt_test("ecb(cast5)"); |
Johannes Goetzfried | a2c5826 | 2012-07-11 19:37:21 +0200 | [diff] [blame] | 1082 | ret += tcrypt_test("cbc(cast5)"); |
| 1083 | ret += tcrypt_test("ctr(cast5)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1084 | break; |
| 1085 | |
| 1086 | case 15: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1087 | ret += tcrypt_test("ecb(cast6)"); |
Johannes Goetzfried | 9b8b040 | 2012-07-11 19:38:29 +0200 | [diff] [blame] | 1088 | ret += tcrypt_test("cbc(cast6)"); |
| 1089 | ret += tcrypt_test("ctr(cast6)"); |
| 1090 | ret += tcrypt_test("lrw(cast6)"); |
| 1091 | ret += tcrypt_test("xts(cast6)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1092 | break; |
| 1093 | |
| 1094 | case 16: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1095 | ret += tcrypt_test("ecb(arc4)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1096 | break; |
| 1097 | |
| 1098 | case 17: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1099 | ret += tcrypt_test("michael_mic"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | break; |
| 1101 | |
| 1102 | case 18: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1103 | ret += tcrypt_test("crc32c"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1104 | break; |
| 1105 | |
| 1106 | case 19: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1107 | ret += tcrypt_test("ecb(tea)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1108 | break; |
| 1109 | |
| 1110 | case 20: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1111 | ret += tcrypt_test("ecb(xtea)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | break; |
| 1113 | |
| 1114 | case 21: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1115 | ret += tcrypt_test("ecb(khazad)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1116 | break; |
| 1117 | |
| 1118 | case 22: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1119 | ret += tcrypt_test("wp512"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | break; |
| 1121 | |
| 1122 | case 23: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1123 | ret += tcrypt_test("wp384"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | break; |
| 1125 | |
| 1126 | case 24: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1127 | ret += tcrypt_test("wp256"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1128 | break; |
| 1129 | |
| 1130 | case 25: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1131 | ret += tcrypt_test("ecb(tnepres)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | break; |
| 1133 | |
| 1134 | case 26: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1135 | ret += tcrypt_test("ecb(anubis)"); |
| 1136 | ret += tcrypt_test("cbc(anubis)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | break; |
| 1138 | |
| 1139 | case 27: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1140 | ret += tcrypt_test("tgr192"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | break; |
| 1142 | |
| 1143 | case 28: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1144 | ret += tcrypt_test("tgr160"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | break; |
| 1146 | |
| 1147 | case 29: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1148 | ret += tcrypt_test("tgr128"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1149 | break; |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1150 | |
Aaron Grothe | fb4f10e | 2005-09-01 17:42:46 -0700 | [diff] [blame] | 1151 | case 30: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1152 | ret += tcrypt_test("ecb(xeta)"); |
Aaron Grothe | fb4f10e | 2005-09-01 17:42:46 -0700 | [diff] [blame] | 1153 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1154 | |
David Howells | 9083163 | 2006-12-16 12:13:14 +1100 | [diff] [blame] | 1155 | case 31: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1156 | ret += tcrypt_test("pcbc(fcrypt)"); |
David Howells | 9083163 | 2006-12-16 12:13:14 +1100 | [diff] [blame] | 1157 | break; |
| 1158 | |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1159 | case 32: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1160 | ret += tcrypt_test("ecb(camellia)"); |
| 1161 | ret += tcrypt_test("cbc(camellia)"); |
Jussi Kivilinna | 54216bb | 2012-09-21 10:27:10 +0300 | [diff] [blame] | 1162 | ret += tcrypt_test("ctr(camellia)"); |
| 1163 | ret += tcrypt_test("lrw(camellia)"); |
| 1164 | ret += tcrypt_test("xts(camellia)"); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1165 | break; |
Jussi Kivilinna | 93b5e86 | 2013-04-08 10:48:44 +0300 | [diff] [blame] | 1166 | |
Jonathan Lynch | cd12fb9 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1167 | case 33: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1168 | ret += tcrypt_test("sha224"); |
Jonathan Lynch | cd12fb9 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1169 | break; |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1170 | |
Tan Swee Heng | 2407d60 | 2007-11-23 19:45:00 +0800 | [diff] [blame] | 1171 | case 34: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1172 | ret += tcrypt_test("salsa20"); |
Tan Swee Heng | 2407d60 | 2007-11-23 19:45:00 +0800 | [diff] [blame] | 1173 | break; |
| 1174 | |
Herbert Xu | 8df213d | 2007-12-02 14:55:47 +1100 | [diff] [blame] | 1175 | case 35: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1176 | ret += tcrypt_test("gcm(aes)"); |
Herbert Xu | 8df213d | 2007-12-02 14:55:47 +1100 | [diff] [blame] | 1177 | break; |
| 1178 | |
Zoltan Sogor | 0b77abb | 2007-12-07 16:53:23 +0800 | [diff] [blame] | 1179 | case 36: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1180 | ret += tcrypt_test("lzo"); |
Zoltan Sogor | 0b77abb | 2007-12-07 16:53:23 +0800 | [diff] [blame] | 1181 | break; |
| 1182 | |
Joy Latten | 93cc74e | 2007-12-12 20:24:22 +0800 | [diff] [blame] | 1183 | case 37: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1184 | ret += tcrypt_test("ccm(aes)"); |
Joy Latten | 93cc74e | 2007-12-12 20:24:22 +0800 | [diff] [blame] | 1185 | break; |
| 1186 | |
Kevin Coffman | 76cb952 | 2008-03-24 21:26:16 +0800 | [diff] [blame] | 1187 | case 38: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1188 | ret += tcrypt_test("cts(cbc(aes))"); |
Kevin Coffman | 76cb952 | 2008-03-24 21:26:16 +0800 | [diff] [blame] | 1189 | break; |
| 1190 | |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1191 | case 39: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1192 | ret += tcrypt_test("rmd128"); |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1193 | break; |
| 1194 | |
| 1195 | case 40: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1196 | ret += tcrypt_test("rmd160"); |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1197 | break; |
| 1198 | |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1199 | case 41: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1200 | ret += tcrypt_test("rmd256"); |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1201 | break; |
| 1202 | |
| 1203 | case 42: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1204 | ret += tcrypt_test("rmd320"); |
Herbert Xu | 01b3232 | 2008-07-31 15:41:55 +0800 | [diff] [blame] | 1205 | break; |
| 1206 | |
| 1207 | case 43: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1208 | ret += tcrypt_test("ecb(seed)"); |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1209 | break; |
| 1210 | |
Geert Uytterhoeven | 0c01aed | 2009-03-04 15:42:15 +0800 | [diff] [blame] | 1211 | case 44: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1212 | ret += tcrypt_test("zlib"); |
Geert Uytterhoeven | 0c01aed | 2009-03-04 15:42:15 +0800 | [diff] [blame] | 1213 | break; |
| 1214 | |
Jarod Wilson | 5d66732 | 2009-05-04 19:23:40 +0800 | [diff] [blame] | 1215 | case 45: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1216 | ret += tcrypt_test("rfc4309(ccm(aes))"); |
Jarod Wilson | 5d66732 | 2009-05-04 19:23:40 +0800 | [diff] [blame] | 1217 | break; |
| 1218 | |
Jussi Kivilinna | 54216bb | 2012-09-21 10:27:10 +0300 | [diff] [blame] | 1219 | case 46: |
| 1220 | ret += tcrypt_test("ghash"); |
| 1221 | break; |
| 1222 | |
Herbert Xu | 68411521 | 2013-09-07 12:56:26 +1000 | [diff] [blame] | 1223 | case 47: |
| 1224 | ret += tcrypt_test("crct10dif"); |
| 1225 | break; |
| 1226 | |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1227 | case 48: |
| 1228 | ret += tcrypt_test("sha3-224"); |
| 1229 | break; |
| 1230 | |
| 1231 | case 49: |
| 1232 | ret += tcrypt_test("sha3-256"); |
| 1233 | break; |
| 1234 | |
| 1235 | case 50: |
| 1236 | ret += tcrypt_test("sha3-384"); |
| 1237 | break; |
| 1238 | |
| 1239 | case 51: |
| 1240 | ret += tcrypt_test("sha3-512"); |
| 1241 | break; |
| 1242 | |
Gilad Ben-Yossef | b7e2753 | 2017-08-21 13:51:29 +0300 | [diff] [blame] | 1243 | case 52: |
| 1244 | ret += tcrypt_test("sm3"); |
| 1245 | break; |
| 1246 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1247 | case 100: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1248 | ret += tcrypt_test("hmac(md5)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1250 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | case 101: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1252 | ret += tcrypt_test("hmac(sha1)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1253 | break; |
Herbert Xu | ef2736f | 2005-06-22 13:26:03 -0700 | [diff] [blame] | 1254 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1255 | case 102: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1256 | ret += tcrypt_test("hmac(sha256)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1257 | break; |
| 1258 | |
Andrew Donofrio | a28091a | 2006-12-10 12:10:20 +1100 | [diff] [blame] | 1259 | case 103: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1260 | ret += tcrypt_test("hmac(sha384)"); |
Andrew Donofrio | a28091a | 2006-12-10 12:10:20 +1100 | [diff] [blame] | 1261 | break; |
| 1262 | |
| 1263 | case 104: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1264 | ret += tcrypt_test("hmac(sha512)"); |
Andrew Donofrio | a28091a | 2006-12-10 12:10:20 +1100 | [diff] [blame] | 1265 | break; |
Herbert Xu | 38ed9ab | 2008-01-01 15:59:28 +1100 | [diff] [blame] | 1266 | |
Jonathan Lynch | cd12fb9 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1267 | case 105: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1268 | ret += tcrypt_test("hmac(sha224)"); |
Jonathan Lynch | cd12fb9 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1269 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1270 | |
Herbert Xu | 38ed9ab | 2008-01-01 15:59:28 +1100 | [diff] [blame] | 1271 | case 106: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1272 | ret += tcrypt_test("xcbc(aes)"); |
Herbert Xu | 38ed9ab | 2008-01-01 15:59:28 +1100 | [diff] [blame] | 1273 | break; |
| 1274 | |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1275 | case 107: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1276 | ret += tcrypt_test("hmac(rmd128)"); |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1277 | break; |
| 1278 | |
| 1279 | case 108: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1280 | ret += tcrypt_test("hmac(rmd160)"); |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1281 | break; |
| 1282 | |
Shane Wang | f1939f7 | 2009-09-02 20:05:22 +1000 | [diff] [blame] | 1283 | case 109: |
| 1284 | ret += tcrypt_test("vmac(aes)"); |
| 1285 | break; |
Jussi Kivilinna | 93b5e86 | 2013-04-08 10:48:44 +0300 | [diff] [blame] | 1286 | |
Sonic Zhang | a482b08 | 2012-05-25 17:54:13 +0800 | [diff] [blame] | 1287 | case 110: |
| 1288 | ret += tcrypt_test("hmac(crc32)"); |
| 1289 | break; |
Shane Wang | f1939f7 | 2009-09-02 20:05:22 +1000 | [diff] [blame] | 1290 | |
raveendra padasalagi | 98eca72 | 2016-07-01 11:16:54 +0530 | [diff] [blame] | 1291 | case 111: |
| 1292 | ret += tcrypt_test("hmac(sha3-224)"); |
| 1293 | break; |
| 1294 | |
| 1295 | case 112: |
| 1296 | ret += tcrypt_test("hmac(sha3-256)"); |
| 1297 | break; |
| 1298 | |
| 1299 | case 113: |
| 1300 | ret += tcrypt_test("hmac(sha3-384)"); |
| 1301 | break; |
| 1302 | |
| 1303 | case 114: |
| 1304 | ret += tcrypt_test("hmac(sha3-512)"); |
| 1305 | break; |
| 1306 | |
Jarod Wilson | e08ca2d | 2009-05-04 19:46:29 +0800 | [diff] [blame] | 1307 | case 150: |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 1308 | ret += tcrypt_test("ansi_cprng"); |
Jarod Wilson | e08ca2d | 2009-05-04 19:46:29 +0800 | [diff] [blame] | 1309 | break; |
| 1310 | |
Adrian Hoban | 69435b9 | 2010-11-04 15:02:04 -0400 | [diff] [blame] | 1311 | case 151: |
| 1312 | ret += tcrypt_test("rfc4106(gcm(aes))"); |
| 1313 | break; |
| 1314 | |
Jussi Kivilinna | e9b7441 | 2013-04-07 16:43:51 +0300 | [diff] [blame] | 1315 | case 152: |
| 1316 | ret += tcrypt_test("rfc4543(gcm(aes))"); |
| 1317 | break; |
| 1318 | |
Jussi Kivilinna | 93b5e86 | 2013-04-08 10:48:44 +0300 | [diff] [blame] | 1319 | case 153: |
| 1320 | ret += tcrypt_test("cmac(aes)"); |
| 1321 | break; |
| 1322 | |
| 1323 | case 154: |
| 1324 | ret += tcrypt_test("cmac(des3_ede)"); |
| 1325 | break; |
| 1326 | |
Horia Geanta | bbf9c89 | 2013-11-28 15:11:16 +0200 | [diff] [blame] | 1327 | case 155: |
| 1328 | ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))"); |
| 1329 | break; |
| 1330 | |
Horia Geanta | bca4feb | 2014-03-14 17:46:51 +0200 | [diff] [blame] | 1331 | case 156: |
| 1332 | ret += tcrypt_test("authenc(hmac(md5),ecb(cipher_null))"); |
| 1333 | break; |
| 1334 | |
| 1335 | case 157: |
| 1336 | ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))"); |
| 1337 | break; |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 1338 | case 181: |
| 1339 | ret += tcrypt_test("authenc(hmac(sha1),cbc(des))"); |
| 1340 | break; |
| 1341 | case 182: |
| 1342 | ret += tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))"); |
| 1343 | break; |
| 1344 | case 183: |
| 1345 | ret += tcrypt_test("authenc(hmac(sha224),cbc(des))"); |
| 1346 | break; |
| 1347 | case 184: |
| 1348 | ret += tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))"); |
| 1349 | break; |
| 1350 | case 185: |
| 1351 | ret += tcrypt_test("authenc(hmac(sha256),cbc(des))"); |
| 1352 | break; |
| 1353 | case 186: |
| 1354 | ret += tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))"); |
| 1355 | break; |
| 1356 | case 187: |
| 1357 | ret += tcrypt_test("authenc(hmac(sha384),cbc(des))"); |
| 1358 | break; |
| 1359 | case 188: |
| 1360 | ret += tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))"); |
| 1361 | break; |
| 1362 | case 189: |
| 1363 | ret += tcrypt_test("authenc(hmac(sha512),cbc(des))"); |
| 1364 | break; |
| 1365 | case 190: |
| 1366 | ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))"); |
| 1367 | break; |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1368 | case 200: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1369 | test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1370 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1371 | test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1372 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1373 | test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1374 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1375 | test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1376 | speed_template_16_24_32); |
Rik Snel | f3d1044 | 2006-11-29 19:01:41 +1100 | [diff] [blame] | 1377 | test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1378 | speed_template_32_40_48); |
Rik Snel | f3d1044 | 2006-11-29 19:01:41 +1100 | [diff] [blame] | 1379 | test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1380 | speed_template_32_40_48); |
Rik Snel | f19f511 | 2007-09-19 20:23:13 +0800 | [diff] [blame] | 1381 | test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, |
Horia Geantă | b66ad0b | 2017-07-19 19:40:32 +0300 | [diff] [blame] | 1382 | speed_template_32_64); |
Rik Snel | f19f511 | 2007-09-19 20:23:13 +0800 | [diff] [blame] | 1383 | test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, |
Horia Geantă | b66ad0b | 2017-07-19 19:40:32 +0300 | [diff] [blame] | 1384 | speed_template_32_64); |
Herbert Xu | 1503a24 | 2016-06-29 18:04:14 +0800 | [diff] [blame] | 1385 | test_cipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0, |
| 1386 | speed_template_16_24_32); |
| 1387 | test_cipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0, |
| 1388 | speed_template_16_24_32); |
Jan Glauber | 9996e34 | 2011-04-26 16:34:01 +1000 | [diff] [blame] | 1389 | test_cipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0, |
| 1390 | speed_template_16_24_32); |
| 1391 | test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, |
| 1392 | speed_template_16_24_32); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1393 | break; |
| 1394 | |
| 1395 | case 201: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1396 | test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1397 | des3_speed_template, DES3_SPEED_VECTORS, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1398 | speed_template_24); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1399 | test_cipher_speed("ecb(des3_ede)", DECRYPT, sec, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1400 | des3_speed_template, DES3_SPEED_VECTORS, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1401 | speed_template_24); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1402 | test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1403 | des3_speed_template, DES3_SPEED_VECTORS, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1404 | speed_template_24); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1405 | test_cipher_speed("cbc(des3_ede)", DECRYPT, sec, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1406 | des3_speed_template, DES3_SPEED_VECTORS, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1407 | speed_template_24); |
Jussi Kivilinna | 8713150 | 2014-06-09 20:59:49 +0300 | [diff] [blame] | 1408 | test_cipher_speed("ctr(des3_ede)", ENCRYPT, sec, |
| 1409 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1410 | speed_template_24); |
| 1411 | test_cipher_speed("ctr(des3_ede)", DECRYPT, sec, |
| 1412 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1413 | speed_template_24); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1414 | break; |
| 1415 | |
| 1416 | case 202: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1417 | test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1418 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1419 | test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1420 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1421 | test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1422 | speed_template_16_24_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1423 | test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1424 | speed_template_16_24_32); |
Jussi Kivilinna | ee5002a | 2011-09-26 16:47:15 +0300 | [diff] [blame] | 1425 | test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, |
| 1426 | speed_template_16_24_32); |
| 1427 | test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, |
| 1428 | speed_template_16_24_32); |
Jussi Kivilinna | bee3a90 | 2011-10-18 13:32:56 +0300 | [diff] [blame] | 1429 | test_cipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0, |
| 1430 | speed_template_32_40_48); |
| 1431 | test_cipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0, |
| 1432 | speed_template_32_40_48); |
Jussi Kivilinna | 131f754 | 2011-10-18 13:33:38 +0300 | [diff] [blame] | 1433 | test_cipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0, |
| 1434 | speed_template_32_48_64); |
| 1435 | test_cipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0, |
| 1436 | speed_template_32_48_64); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1437 | break; |
| 1438 | |
| 1439 | case 203: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1440 | test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1441 | speed_template_8_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1442 | test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1443 | speed_template_8_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1444 | test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1445 | speed_template_8_32); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1446 | test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1447 | speed_template_8_32); |
Jussi Kivilinna | 7d47b86 | 2011-09-02 01:45:17 +0300 | [diff] [blame] | 1448 | test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0, |
| 1449 | speed_template_8_32); |
| 1450 | test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0, |
| 1451 | speed_template_8_32); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1452 | break; |
| 1453 | |
| 1454 | case 204: |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1455 | test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1456 | speed_template_8); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1457 | test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1458 | speed_template_8); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1459 | test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1460 | speed_template_8); |
Herbert Xu | cba8356 | 2006-08-13 08:26:09 +1000 | [diff] [blame] | 1461 | test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1462 | speed_template_8); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 1463 | break; |
| 1464 | |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1465 | case 205: |
| 1466 | test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1467 | speed_template_16_24_32); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1468 | test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1469 | speed_template_16_24_32); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1470 | test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1471 | speed_template_16_24_32); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1472 | test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1473 | speed_template_16_24_32); |
Jussi Kivilinna | 4de5933 | 2012-03-05 20:26:26 +0200 | [diff] [blame] | 1474 | test_cipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0, |
| 1475 | speed_template_16_24_32); |
| 1476 | test_cipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0, |
| 1477 | speed_template_16_24_32); |
| 1478 | test_cipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0, |
| 1479 | speed_template_32_40_48); |
| 1480 | test_cipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0, |
| 1481 | speed_template_32_40_48); |
| 1482 | test_cipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0, |
| 1483 | speed_template_32_48_64); |
| 1484 | test_cipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0, |
| 1485 | speed_template_32_48_64); |
Noriaki TAKAMIYA | 02ab5a7 | 2007-01-24 21:48:19 +1100 | [diff] [blame] | 1486 | break; |
| 1487 | |
Tan Swee Heng | 5de8f1b | 2007-12-07 17:17:43 +0800 | [diff] [blame] | 1488 | case 206: |
| 1489 | test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0, |
Sebastian Siewior | 477035c | 2008-03-11 21:24:26 +0800 | [diff] [blame] | 1490 | speed_template_16_32); |
Tan Swee Heng | 5de8f1b | 2007-12-07 17:17:43 +0800 | [diff] [blame] | 1491 | break; |
| 1492 | |
Jussi Kivilinna | 7fb7fe4 | 2011-10-18 00:03:03 +0300 | [diff] [blame] | 1493 | case 207: |
| 1494 | test_cipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0, |
| 1495 | speed_template_16_32); |
| 1496 | test_cipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0, |
| 1497 | speed_template_16_32); |
| 1498 | test_cipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0, |
| 1499 | speed_template_16_32); |
| 1500 | test_cipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0, |
| 1501 | speed_template_16_32); |
| 1502 | test_cipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0, |
| 1503 | speed_template_16_32); |
| 1504 | test_cipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0, |
| 1505 | speed_template_16_32); |
Jussi Kivilinna | 87aae4b | 2011-10-18 13:32:39 +0300 | [diff] [blame] | 1506 | test_cipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0, |
| 1507 | speed_template_32_48); |
| 1508 | test_cipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0, |
| 1509 | speed_template_32_48); |
Jussi Kivilinna | 5209c07 | 2011-10-18 13:33:22 +0300 | [diff] [blame] | 1510 | test_cipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0, |
| 1511 | speed_template_32_64); |
| 1512 | test_cipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0, |
| 1513 | speed_template_32_64); |
Jussi Kivilinna | 7fb7fe4 | 2011-10-18 00:03:03 +0300 | [diff] [blame] | 1514 | break; |
| 1515 | |
Jussi Kivilinna | 31b4cd29 | 2012-06-12 16:52:04 +0800 | [diff] [blame] | 1516 | case 208: |
| 1517 | test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0, |
| 1518 | speed_template_8); |
| 1519 | break; |
| 1520 | |
Johannes Goetzfried | a2c5826 | 2012-07-11 19:37:21 +0200 | [diff] [blame] | 1521 | case 209: |
| 1522 | test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, |
| 1523 | speed_template_8_16); |
| 1524 | test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, |
| 1525 | speed_template_8_16); |
| 1526 | test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, |
| 1527 | speed_template_8_16); |
| 1528 | test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, |
| 1529 | speed_template_8_16); |
| 1530 | test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, |
| 1531 | speed_template_8_16); |
| 1532 | test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, |
| 1533 | speed_template_8_16); |
| 1534 | break; |
| 1535 | |
Johannes Goetzfried | 9b8b040 | 2012-07-11 19:38:29 +0200 | [diff] [blame] | 1536 | case 210: |
| 1537 | test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, |
| 1538 | speed_template_16_32); |
| 1539 | test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, |
| 1540 | speed_template_16_32); |
| 1541 | test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, |
| 1542 | speed_template_16_32); |
| 1543 | test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, |
| 1544 | speed_template_16_32); |
| 1545 | test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, |
| 1546 | speed_template_16_32); |
| 1547 | test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, |
| 1548 | speed_template_16_32); |
| 1549 | test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, |
| 1550 | speed_template_32_48); |
| 1551 | test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, |
| 1552 | speed_template_32_48); |
| 1553 | test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, |
| 1554 | speed_template_32_64); |
| 1555 | test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, |
| 1556 | speed_template_32_64); |
| 1557 | break; |
| 1558 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 1559 | case 211: |
| 1560 | test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec, |
Herbert Xu | 34a1c74 | 2015-07-09 07:17:26 +0800 | [diff] [blame] | 1561 | NULL, 0, 16, 16, aead_speed_template_20); |
Vutla, Lokesh | 1425d2d | 2015-07-07 21:01:49 +0530 | [diff] [blame] | 1562 | test_aead_speed("gcm(aes)", ENCRYPT, sec, |
Cyrille Pitchen | f18611d | 2015-11-17 13:37:10 +0100 | [diff] [blame] | 1563 | NULL, 0, 16, 8, speed_template_16_24_32); |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 1564 | break; |
| 1565 | |
Herbert Xu | 4e4aab6 | 2015-06-17 14:04:21 +0800 | [diff] [blame] | 1566 | case 212: |
| 1567 | test_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec, |
Herbert Xu | 34a1c74 | 2015-07-09 07:17:26 +0800 | [diff] [blame] | 1568 | NULL, 0, 16, 16, aead_speed_template_19); |
Herbert Xu | 4e4aab6 | 2015-06-17 14:04:21 +0800 | [diff] [blame] | 1569 | break; |
| 1570 | |
Martin Willi | 2dce063 | 2015-07-16 19:13:59 +0200 | [diff] [blame] | 1571 | case 213: |
| 1572 | test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, sec, |
| 1573 | NULL, 0, 16, 8, aead_speed_template_36); |
| 1574 | break; |
| 1575 | |
| 1576 | case 214: |
| 1577 | test_cipher_speed("chacha20", ENCRYPT, sec, NULL, 0, |
| 1578 | speed_template_32); |
| 1579 | break; |
| 1580 | |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1581 | case 300: |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 1582 | if (alg) { |
| 1583 | test_hash_speed(alg, sec, generic_hash_speed_template); |
| 1584 | break; |
| 1585 | } |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1586 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1587 | case 301: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1588 | test_hash_speed("md4", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1589 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1590 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1591 | case 302: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1592 | test_hash_speed("md5", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1593 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1594 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1595 | case 303: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1596 | test_hash_speed("sha1", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1597 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1598 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1599 | case 304: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1600 | test_hash_speed("sha256", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1601 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1602 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1603 | case 305: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1604 | test_hash_speed("sha384", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1605 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1606 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1607 | case 306: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1608 | test_hash_speed("sha512", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1609 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1610 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1611 | case 307: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1612 | test_hash_speed("wp256", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1613 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1614 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1615 | case 308: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1616 | test_hash_speed("wp384", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1617 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1618 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1619 | case 309: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1620 | test_hash_speed("wp512", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1621 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1622 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1623 | case 310: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1624 | test_hash_speed("tgr128", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1625 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1626 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1627 | case 311: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1628 | test_hash_speed("tgr160", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1629 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1630 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1631 | case 312: |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 1632 | test_hash_speed("tgr192", sec, generic_hash_speed_template); |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1633 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1634 | /* fall through */ |
Jonathan Lynch | cd12fb9 | 2007-11-10 20:08:25 +0800 | [diff] [blame] | 1635 | case 313: |
| 1636 | test_hash_speed("sha224", sec, generic_hash_speed_template); |
| 1637 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1638 | /* fall through */ |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1639 | case 314: |
| 1640 | test_hash_speed("rmd128", sec, generic_hash_speed_template); |
| 1641 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1642 | /* fall through */ |
Adrian-Ken Rueegsegger | fd4adf1 | 2008-05-07 22:16:36 +0800 | [diff] [blame] | 1643 | case 315: |
| 1644 | test_hash_speed("rmd160", sec, generic_hash_speed_template); |
| 1645 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1646 | /* fall through */ |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1647 | case 316: |
| 1648 | test_hash_speed("rmd256", sec, generic_hash_speed_template); |
| 1649 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1650 | /* fall through */ |
Adrian-Ken Rueegsegger | 2998db3 | 2008-05-09 21:29:35 +0800 | [diff] [blame] | 1651 | case 317: |
| 1652 | test_hash_speed("rmd320", sec, generic_hash_speed_template); |
| 1653 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1654 | /* fall through */ |
Huang Ying | 18bcc91 | 2010-03-10 18:30:32 +0800 | [diff] [blame] | 1655 | case 318: |
| 1656 | test_hash_speed("ghash-generic", sec, hash_speed_template_16); |
| 1657 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1658 | /* fall through */ |
Tim Chen | e3899e4 | 2012-09-27 15:44:24 -0700 | [diff] [blame] | 1659 | case 319: |
| 1660 | test_hash_speed("crc32c", sec, generic_hash_speed_template); |
| 1661 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1662 | /* fall through */ |
Herbert Xu | 68411521 | 2013-09-07 12:56:26 +1000 | [diff] [blame] | 1663 | case 320: |
| 1664 | test_hash_speed("crct10dif", sec, generic_hash_speed_template); |
| 1665 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1666 | /* fall through */ |
Martin Willi | 2dce063 | 2015-07-16 19:13:59 +0200 | [diff] [blame] | 1667 | case 321: |
| 1668 | test_hash_speed("poly1305", sec, poly1305_speed_template); |
| 1669 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1670 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1671 | case 322: |
| 1672 | test_hash_speed("sha3-224", sec, generic_hash_speed_template); |
| 1673 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1674 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1675 | case 323: |
| 1676 | test_hash_speed("sha3-256", sec, generic_hash_speed_template); |
| 1677 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1678 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1679 | case 324: |
| 1680 | test_hash_speed("sha3-384", sec, generic_hash_speed_template); |
| 1681 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1682 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1683 | case 325: |
| 1684 | test_hash_speed("sha3-512", sec, generic_hash_speed_template); |
| 1685 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1686 | /* fall through */ |
Gilad Ben-Yossef | b7e2753 | 2017-08-21 13:51:29 +0300 | [diff] [blame] | 1687 | case 326: |
| 1688 | test_hash_speed("sm3", sec, generic_hash_speed_template); |
| 1689 | if (mode > 300 && mode < 400) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1690 | /* fall through */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 1691 | case 399: |
| 1692 | break; |
| 1693 | |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1694 | case 400: |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 1695 | if (alg) { |
| 1696 | test_ahash_speed(alg, sec, generic_hash_speed_template); |
| 1697 | break; |
| 1698 | } |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1699 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1700 | case 401: |
| 1701 | test_ahash_speed("md4", sec, generic_hash_speed_template); |
| 1702 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1703 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1704 | case 402: |
| 1705 | test_ahash_speed("md5", sec, generic_hash_speed_template); |
| 1706 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1707 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1708 | case 403: |
| 1709 | test_ahash_speed("sha1", sec, generic_hash_speed_template); |
| 1710 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1711 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1712 | case 404: |
| 1713 | test_ahash_speed("sha256", sec, generic_hash_speed_template); |
| 1714 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1715 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1716 | case 405: |
| 1717 | test_ahash_speed("sha384", sec, generic_hash_speed_template); |
| 1718 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1719 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1720 | case 406: |
| 1721 | test_ahash_speed("sha512", sec, generic_hash_speed_template); |
| 1722 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1723 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1724 | case 407: |
| 1725 | test_ahash_speed("wp256", sec, generic_hash_speed_template); |
| 1726 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1727 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1728 | case 408: |
| 1729 | test_ahash_speed("wp384", sec, generic_hash_speed_template); |
| 1730 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1731 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1732 | case 409: |
| 1733 | test_ahash_speed("wp512", sec, generic_hash_speed_template); |
| 1734 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1735 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1736 | case 410: |
| 1737 | test_ahash_speed("tgr128", sec, generic_hash_speed_template); |
| 1738 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1739 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1740 | case 411: |
| 1741 | test_ahash_speed("tgr160", sec, generic_hash_speed_template); |
| 1742 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1743 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1744 | case 412: |
| 1745 | test_ahash_speed("tgr192", sec, generic_hash_speed_template); |
| 1746 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1747 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1748 | case 413: |
| 1749 | test_ahash_speed("sha224", sec, generic_hash_speed_template); |
| 1750 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1751 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1752 | case 414: |
| 1753 | test_ahash_speed("rmd128", sec, generic_hash_speed_template); |
| 1754 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1755 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1756 | case 415: |
| 1757 | test_ahash_speed("rmd160", sec, generic_hash_speed_template); |
| 1758 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1759 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1760 | case 416: |
| 1761 | test_ahash_speed("rmd256", sec, generic_hash_speed_template); |
| 1762 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1763 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1764 | case 417: |
| 1765 | test_ahash_speed("rmd320", sec, generic_hash_speed_template); |
| 1766 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1767 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1768 | case 418: |
| 1769 | test_ahash_speed("sha3-224", sec, generic_hash_speed_template); |
| 1770 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1771 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1772 | case 419: |
| 1773 | test_ahash_speed("sha3-256", sec, generic_hash_speed_template); |
| 1774 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1775 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1776 | case 420: |
| 1777 | test_ahash_speed("sha3-384", sec, generic_hash_speed_template); |
| 1778 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1779 | /* fall through */ |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 1780 | case 421: |
| 1781 | test_ahash_speed("sha3-512", sec, generic_hash_speed_template); |
| 1782 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1783 | /* fall through */ |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 1784 | case 422: |
| 1785 | test_mb_ahash_speed("sha1", sec, generic_hash_speed_template); |
| 1786 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1787 | /* fall through */ |
Megha Dey | 087bcd2 | 2016-06-23 18:40:47 -0700 | [diff] [blame] | 1788 | case 423: |
| 1789 | test_mb_ahash_speed("sha256", sec, generic_hash_speed_template); |
| 1790 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1791 | /* fall through */ |
Megha Dey | 14009c4 | 2016-06-27 10:20:09 -0700 | [diff] [blame] | 1792 | case 424: |
| 1793 | test_mb_ahash_speed("sha512", sec, generic_hash_speed_template); |
| 1794 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1795 | /* fall through */ |
Gilad Ben-Yossef | b7e2753 | 2017-08-21 13:51:29 +0300 | [diff] [blame] | 1796 | case 425: |
| 1797 | test_mb_ahash_speed("sm3", sec, generic_hash_speed_template); |
| 1798 | if (mode > 400 && mode < 500) break; |
Gustavo A. R. Silva | 5951722 | 2017-10-09 14:43:21 -0500 | [diff] [blame] | 1799 | /* fall through */ |
David S. Miller | beb63da | 2010-05-19 14:11:21 +1000 | [diff] [blame] | 1800 | case 499: |
| 1801 | break; |
| 1802 | |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1803 | case 500: |
| 1804 | test_acipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, |
| 1805 | speed_template_16_24_32); |
| 1806 | test_acipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, |
| 1807 | speed_template_16_24_32); |
| 1808 | test_acipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, |
| 1809 | speed_template_16_24_32); |
| 1810 | test_acipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, |
| 1811 | speed_template_16_24_32); |
| 1812 | test_acipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, |
| 1813 | speed_template_32_40_48); |
| 1814 | test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, |
| 1815 | speed_template_32_40_48); |
| 1816 | test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, |
Horia Geantă | b66ad0b | 2017-07-19 19:40:32 +0300 | [diff] [blame] | 1817 | speed_template_32_64); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1818 | test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, |
Horia Geantă | b66ad0b | 2017-07-19 19:40:32 +0300 | [diff] [blame] | 1819 | speed_template_32_64); |
Herbert Xu | 1503a24 | 2016-06-29 18:04:14 +0800 | [diff] [blame] | 1820 | test_acipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0, |
| 1821 | speed_template_16_24_32); |
| 1822 | test_acipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0, |
| 1823 | speed_template_16_24_32); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1824 | test_acipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0, |
| 1825 | speed_template_16_24_32); |
| 1826 | test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, |
| 1827 | speed_template_16_24_32); |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 1828 | test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0, |
| 1829 | speed_template_16_24_32); |
| 1830 | test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0, |
| 1831 | speed_template_16_24_32); |
| 1832 | test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0, |
| 1833 | speed_template_16_24_32); |
| 1834 | test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0, |
| 1835 | speed_template_16_24_32); |
Jussi Kivilinna | 69d3150 | 2012-12-28 12:04:58 +0200 | [diff] [blame] | 1836 | test_acipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL, 0, |
| 1837 | speed_template_20_28_36); |
| 1838 | test_acipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL, 0, |
| 1839 | speed_template_20_28_36); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1840 | break; |
| 1841 | |
| 1842 | case 501: |
| 1843 | test_acipher_speed("ecb(des3_ede)", ENCRYPT, sec, |
| 1844 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1845 | speed_template_24); |
| 1846 | test_acipher_speed("ecb(des3_ede)", DECRYPT, sec, |
| 1847 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1848 | speed_template_24); |
| 1849 | test_acipher_speed("cbc(des3_ede)", ENCRYPT, sec, |
| 1850 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1851 | speed_template_24); |
| 1852 | test_acipher_speed("cbc(des3_ede)", DECRYPT, sec, |
| 1853 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1854 | speed_template_24); |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 1855 | test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec, |
| 1856 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1857 | speed_template_24); |
| 1858 | test_acipher_speed("cfb(des3_ede)", DECRYPT, sec, |
| 1859 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1860 | speed_template_24); |
| 1861 | test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec, |
| 1862 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1863 | speed_template_24); |
| 1864 | test_acipher_speed("ofb(des3_ede)", DECRYPT, sec, |
| 1865 | des3_speed_template, DES3_SPEED_VECTORS, |
| 1866 | speed_template_24); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1867 | break; |
| 1868 | |
| 1869 | case 502: |
| 1870 | test_acipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, |
| 1871 | speed_template_8); |
| 1872 | test_acipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, |
| 1873 | speed_template_8); |
| 1874 | test_acipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, |
| 1875 | speed_template_8); |
| 1876 | test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, |
| 1877 | speed_template_8); |
Nicolas Royer | de197533 | 2012-07-01 19:19:47 +0200 | [diff] [blame] | 1878 | test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0, |
| 1879 | speed_template_8); |
| 1880 | test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0, |
| 1881 | speed_template_8); |
| 1882 | test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0, |
| 1883 | speed_template_8); |
| 1884 | test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0, |
| 1885 | speed_template_8); |
Jussi Kivilinna | 3f3baf3 | 2011-10-18 00:02:58 +0300 | [diff] [blame] | 1886 | break; |
| 1887 | |
Jussi Kivilinna | 7fb7fe4 | 2011-10-18 00:03:03 +0300 | [diff] [blame] | 1888 | case 503: |
| 1889 | test_acipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0, |
| 1890 | speed_template_16_32); |
| 1891 | test_acipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0, |
| 1892 | speed_template_16_32); |
| 1893 | test_acipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0, |
| 1894 | speed_template_16_32); |
| 1895 | test_acipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0, |
| 1896 | speed_template_16_32); |
| 1897 | test_acipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0, |
| 1898 | speed_template_16_32); |
| 1899 | test_acipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0, |
| 1900 | speed_template_16_32); |
Jussi Kivilinna | 87aae4b | 2011-10-18 13:32:39 +0300 | [diff] [blame] | 1901 | test_acipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0, |
| 1902 | speed_template_32_48); |
| 1903 | test_acipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0, |
| 1904 | speed_template_32_48); |
Jussi Kivilinna | 5209c07 | 2011-10-18 13:33:22 +0300 | [diff] [blame] | 1905 | test_acipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0, |
| 1906 | speed_template_32_64); |
| 1907 | test_acipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0, |
| 1908 | speed_template_32_64); |
Jussi Kivilinna | 7fb7fe4 | 2011-10-18 00:03:03 +0300 | [diff] [blame] | 1909 | break; |
| 1910 | |
Johannes Goetzfried | 107778b5 | 2012-05-28 15:54:24 +0200 | [diff] [blame] | 1911 | case 504: |
| 1912 | test_acipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, |
| 1913 | speed_template_16_24_32); |
| 1914 | test_acipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, |
| 1915 | speed_template_16_24_32); |
| 1916 | test_acipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, |
| 1917 | speed_template_16_24_32); |
| 1918 | test_acipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, |
| 1919 | speed_template_16_24_32); |
| 1920 | test_acipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0, |
| 1921 | speed_template_16_24_32); |
| 1922 | test_acipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0, |
| 1923 | speed_template_16_24_32); |
| 1924 | test_acipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0, |
| 1925 | speed_template_32_40_48); |
| 1926 | test_acipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0, |
| 1927 | speed_template_32_40_48); |
| 1928 | test_acipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0, |
| 1929 | speed_template_32_48_64); |
| 1930 | test_acipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0, |
| 1931 | speed_template_32_48_64); |
| 1932 | break; |
| 1933 | |
Jussi Kivilinna | 31b4cd29 | 2012-06-12 16:52:04 +0800 | [diff] [blame] | 1934 | case 505: |
| 1935 | test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0, |
| 1936 | speed_template_8); |
| 1937 | break; |
| 1938 | |
Johannes Goetzfried | a2c5826 | 2012-07-11 19:37:21 +0200 | [diff] [blame] | 1939 | case 506: |
| 1940 | test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, |
| 1941 | speed_template_8_16); |
| 1942 | test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, |
| 1943 | speed_template_8_16); |
| 1944 | test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, |
| 1945 | speed_template_8_16); |
| 1946 | test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, |
| 1947 | speed_template_8_16); |
| 1948 | test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, |
| 1949 | speed_template_8_16); |
| 1950 | test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, |
| 1951 | speed_template_8_16); |
| 1952 | break; |
| 1953 | |
Johannes Goetzfried | 9b8b040 | 2012-07-11 19:38:29 +0200 | [diff] [blame] | 1954 | case 507: |
| 1955 | test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, |
| 1956 | speed_template_16_32); |
| 1957 | test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, |
| 1958 | speed_template_16_32); |
| 1959 | test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, |
| 1960 | speed_template_16_32); |
| 1961 | test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, |
| 1962 | speed_template_16_32); |
| 1963 | test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, |
| 1964 | speed_template_16_32); |
| 1965 | test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, |
| 1966 | speed_template_16_32); |
| 1967 | test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, |
| 1968 | speed_template_32_48); |
| 1969 | test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, |
| 1970 | speed_template_32_48); |
| 1971 | test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, |
| 1972 | speed_template_32_64); |
| 1973 | test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, |
| 1974 | speed_template_32_64); |
| 1975 | break; |
| 1976 | |
Jussi Kivilinna | bf9c518 | 2012-10-26 14:48:51 +0300 | [diff] [blame] | 1977 | case 508: |
| 1978 | test_acipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, |
| 1979 | speed_template_16_32); |
| 1980 | test_acipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, |
| 1981 | speed_template_16_32); |
| 1982 | test_acipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, |
| 1983 | speed_template_16_32); |
| 1984 | test_acipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, |
| 1985 | speed_template_16_32); |
| 1986 | test_acipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0, |
| 1987 | speed_template_16_32); |
| 1988 | test_acipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0, |
| 1989 | speed_template_16_32); |
| 1990 | test_acipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0, |
| 1991 | speed_template_32_48); |
| 1992 | test_acipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0, |
| 1993 | speed_template_32_48); |
| 1994 | test_acipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0, |
| 1995 | speed_template_32_64); |
| 1996 | test_acipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0, |
| 1997 | speed_template_32_64); |
| 1998 | break; |
| 1999 | |
Jussi Kivilinna | ad8b7c3 | 2013-04-13 13:46:40 +0300 | [diff] [blame] | 2000 | case 509: |
| 2001 | test_acipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, |
| 2002 | speed_template_8_32); |
| 2003 | test_acipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, |
| 2004 | speed_template_8_32); |
| 2005 | test_acipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, |
| 2006 | speed_template_8_32); |
| 2007 | test_acipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, |
| 2008 | speed_template_8_32); |
| 2009 | test_acipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0, |
| 2010 | speed_template_8_32); |
| 2011 | test_acipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0, |
| 2012 | speed_template_8_32); |
| 2013 | break; |
| 2014 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2015 | case 1000: |
| 2016 | test_available(); |
| 2017 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2018 | } |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2019 | |
| 2020 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2021 | } |
| 2022 | |
Kamalesh Babulal | 3af5b90 | 2008-04-05 21:00:57 +0800 | [diff] [blame] | 2023 | static int __init tcrypt_mod_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2024 | { |
Mikko Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 2025 | int err = -ENOMEM; |
Herbert Xu | f139cfa | 2008-07-31 12:23:53 +0800 | [diff] [blame] | 2026 | int i; |
Mikko Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 2027 | |
Herbert Xu | f139cfa | 2008-07-31 12:23:53 +0800 | [diff] [blame] | 2028 | for (i = 0; i < TVMEMSIZE; i++) { |
| 2029 | tvmem[i] = (void *)__get_free_page(GFP_KERNEL); |
| 2030 | if (!tvmem[i]) |
| 2031 | goto err_free_tv; |
| 2032 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2033 | |
Herbert Xu | 8606813 | 2014-12-04 16:43:29 +0800 | [diff] [blame] | 2034 | err = do_test(alg, type, mask, mode); |
Steffen Klassert | a873a5f | 2009-06-19 19:46:53 +0800 | [diff] [blame] | 2035 | |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2036 | if (err) { |
| 2037 | printk(KERN_ERR "tcrypt: one or more tests failed!\n"); |
| 2038 | goto err_free_tv; |
Rabin Vincent | 76512f2 | 2017-01-18 14:54:05 +0100 | [diff] [blame] | 2039 | } else { |
| 2040 | pr_debug("all tests passed\n"); |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2041 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2042 | |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2043 | /* We intentionaly return -EAGAIN to prevent keeping the module, |
| 2044 | * unless we're running in fips mode. It does all its work from |
| 2045 | * init() and doesn't offer any runtime functionality, but in |
| 2046 | * the fips case, checking for a successful load is helpful. |
Michal Ludvig | 14fdf47 | 2006-05-30 14:49:38 +1000 | [diff] [blame] | 2047 | * => we don't need it in the memory, do we? |
| 2048 | * -- mludvig |
| 2049 | */ |
Jarod Wilson | 4e033a6 | 2009-05-27 15:10:21 +1000 | [diff] [blame] | 2050 | if (!fips_enabled) |
| 2051 | err = -EAGAIN; |
Mikko Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 2052 | |
Herbert Xu | f139cfa | 2008-07-31 12:23:53 +0800 | [diff] [blame] | 2053 | err_free_tv: |
| 2054 | for (i = 0; i < TVMEMSIZE && tvmem[i]; i++) |
| 2055 | free_page((unsigned long)tvmem[i]); |
Mikko Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 2056 | |
| 2057 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2058 | } |
| 2059 | |
| 2060 | /* |
| 2061 | * If an init function is provided, an exit function must also be provided |
| 2062 | * to allow module unload. |
| 2063 | */ |
Kamalesh Babulal | 3af5b90 | 2008-04-05 21:00:57 +0800 | [diff] [blame] | 2064 | static void __exit tcrypt_mod_fini(void) { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2065 | |
Kamalesh Babulal | 3af5b90 | 2008-04-05 21:00:57 +0800 | [diff] [blame] | 2066 | module_init(tcrypt_mod_init); |
| 2067 | module_exit(tcrypt_mod_fini); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2068 | |
Steffen Klassert | a873a5f | 2009-06-19 19:46:53 +0800 | [diff] [blame] | 2069 | module_param(alg, charp, 0); |
| 2070 | module_param(type, uint, 0); |
Herbert Xu | 7be380f | 2009-07-14 16:06:54 +0800 | [diff] [blame] | 2071 | module_param(mask, uint, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2072 | module_param(mode, int, 0); |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 2073 | module_param(sec, uint, 0); |
Herbert Xu | 6a17944 | 2005-06-22 13:29:03 -0700 | [diff] [blame] | 2074 | MODULE_PARM_DESC(sec, "Length in seconds of speed tests " |
| 2075 | "(defaults to zero which uses CPU cycles instead)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2076 | |
| 2077 | MODULE_LICENSE("GPL"); |
| 2078 | MODULE_DESCRIPTION("Quick & dirty crypto testing module"); |
| 2079 | MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>"); |