Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Algorithm testing framework and tests. |
| 3 | * |
| 4 | * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> |
| 5 | * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org> |
| 6 | * Copyright (c) 2007 Nokia Siemens Networks |
| 7 | * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au> |
| 8 | * |
Adrian Hoban | 69435b9 | 2010-11-04 15:02:04 -0400 | [diff] [blame] | 9 | * Updated RFC4106 AES-GCM testing. |
| 10 | * Authors: Aidan O'Mahony (aidan.o.mahony@intel.com) |
| 11 | * Adrian Hoban <adrian.hoban@intel.com> |
| 12 | * Gabriele Paoloni <gabriele.paoloni@intel.com> |
| 13 | * Tadeusz Struk (tadeusz.struk@intel.com) |
| 14 | * Copyright (c) 2010, Intel Corporation. |
| 15 | * |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 16 | * This program is free software; you can redistribute it and/or modify it |
| 17 | * under the terms of the GNU General Public License as published by the Free |
| 18 | * Software Foundation; either version 2 of the License, or (at your option) |
| 19 | * any later version. |
| 20 | * |
| 21 | */ |
| 22 | |
Herbert Xu | 1ce3311 | 2015-04-22 15:06:31 +0800 | [diff] [blame] | 23 | #include <crypto/aead.h> |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 24 | #include <crypto/hash.h> |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 25 | #include <crypto/skcipher.h> |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 26 | #include <linux/err.h> |
Herbert Xu | 1c41b88 | 2015-04-22 13:25:58 +0800 | [diff] [blame] | 27 | #include <linux/fips.h> |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 28 | #include <linux/module.h> |
| 29 | #include <linux/scatterlist.h> |
| 30 | #include <linux/slab.h> |
| 31 | #include <linux/string.h> |
Jarod Wilson | 7647d6c | 2009-05-04 19:44:50 +0800 | [diff] [blame] | 32 | #include <crypto/rng.h> |
Stephan Mueller | 64d1cdf | 2014-05-31 17:25:36 +0200 | [diff] [blame] | 33 | #include <crypto/drbg.h> |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 34 | #include <crypto/akcipher.h> |
Salvatore Benedetto | 802c7f1 | 2016-06-22 17:49:14 +0100 | [diff] [blame] | 35 | #include <crypto/kpp.h> |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 36 | |
| 37 | #include "internal.h" |
Alexander Shishkin | 0b767f9 | 2010-06-03 20:53:43 +1000 | [diff] [blame] | 38 | |
Richard W.M. Jones | 9e5c9fe | 2016-05-03 10:00:17 +0100 | [diff] [blame] | 39 | static bool notests; |
| 40 | module_param(notests, bool, 0644); |
| 41 | MODULE_PARM_DESC(notests, "disable crypto self-tests"); |
| 42 | |
Herbert Xu | 326a634 | 2010-08-06 09:40:28 +0800 | [diff] [blame] | 43 | #ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS |
Alexander Shishkin | 0b767f9 | 2010-06-03 20:53:43 +1000 | [diff] [blame] | 44 | |
| 45 | /* a perfect nop */ |
| 46 | int alg_test(const char *driver, const char *alg, u32 type, u32 mask) |
| 47 | { |
| 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | #else |
| 52 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 53 | #include "testmgr.h" |
| 54 | |
| 55 | /* |
| 56 | * Need slab memory for testing (size in number of pages). |
| 57 | */ |
| 58 | #define XBUFSIZE 8 |
| 59 | |
| 60 | /* |
| 61 | * Indexes into the xbuf to simulate cross-page access. |
| 62 | */ |
| 63 | #define IDX1 32 |
| 64 | #define IDX2 32400 |
| 65 | #define IDX3 1 |
| 66 | #define IDX4 8193 |
| 67 | #define IDX5 22222 |
| 68 | #define IDX6 17101 |
| 69 | #define IDX7 27333 |
| 70 | #define IDX8 3000 |
| 71 | |
| 72 | /* |
| 73 | * Used by test_cipher() |
| 74 | */ |
| 75 | #define ENCRYPT 1 |
| 76 | #define DECRYPT 0 |
| 77 | |
| 78 | struct tcrypt_result { |
| 79 | struct completion completion; |
| 80 | int err; |
| 81 | }; |
| 82 | |
| 83 | struct aead_test_suite { |
| 84 | struct { |
| 85 | struct aead_testvec *vecs; |
| 86 | unsigned int count; |
| 87 | } enc, dec; |
| 88 | }; |
| 89 | |
| 90 | struct cipher_test_suite { |
| 91 | struct { |
| 92 | struct cipher_testvec *vecs; |
| 93 | unsigned int count; |
| 94 | } enc, dec; |
| 95 | }; |
| 96 | |
| 97 | struct comp_test_suite { |
| 98 | struct { |
| 99 | struct comp_testvec *vecs; |
| 100 | unsigned int count; |
| 101 | } comp, decomp; |
| 102 | }; |
| 103 | |
| 104 | struct hash_test_suite { |
| 105 | struct hash_testvec *vecs; |
| 106 | unsigned int count; |
| 107 | }; |
| 108 | |
Jarod Wilson | 7647d6c | 2009-05-04 19:44:50 +0800 | [diff] [blame] | 109 | struct cprng_test_suite { |
| 110 | struct cprng_testvec *vecs; |
| 111 | unsigned int count; |
| 112 | }; |
| 113 | |
Stephan Mueller | 64d1cdf | 2014-05-31 17:25:36 +0200 | [diff] [blame] | 114 | struct drbg_test_suite { |
| 115 | struct drbg_testvec *vecs; |
| 116 | unsigned int count; |
| 117 | }; |
| 118 | |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 119 | struct akcipher_test_suite { |
| 120 | struct akcipher_testvec *vecs; |
| 121 | unsigned int count; |
| 122 | }; |
| 123 | |
Salvatore Benedetto | 802c7f1 | 2016-06-22 17:49:14 +0100 | [diff] [blame] | 124 | struct kpp_test_suite { |
| 125 | struct kpp_testvec *vecs; |
| 126 | unsigned int count; |
| 127 | }; |
| 128 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 129 | struct alg_test_desc { |
| 130 | const char *alg; |
| 131 | int (*test)(const struct alg_test_desc *desc, const char *driver, |
| 132 | u32 type, u32 mask); |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 133 | int fips_allowed; /* set if alg is allowed in fips mode */ |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 134 | |
| 135 | union { |
| 136 | struct aead_test_suite aead; |
| 137 | struct cipher_test_suite cipher; |
| 138 | struct comp_test_suite comp; |
| 139 | struct hash_test_suite hash; |
Jarod Wilson | 7647d6c | 2009-05-04 19:44:50 +0800 | [diff] [blame] | 140 | struct cprng_test_suite cprng; |
Stephan Mueller | 64d1cdf | 2014-05-31 17:25:36 +0200 | [diff] [blame] | 141 | struct drbg_test_suite drbg; |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 142 | struct akcipher_test_suite akcipher; |
Salvatore Benedetto | 802c7f1 | 2016-06-22 17:49:14 +0100 | [diff] [blame] | 143 | struct kpp_test_suite kpp; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 144 | } suite; |
| 145 | }; |
| 146 | |
| 147 | static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 }; |
| 148 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 149 | static void hexdump(unsigned char *buf, unsigned int len) |
| 150 | { |
| 151 | print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET, |
| 152 | 16, 1, |
| 153 | buf, len, false); |
| 154 | } |
| 155 | |
| 156 | static void tcrypt_complete(struct crypto_async_request *req, int err) |
| 157 | { |
| 158 | struct tcrypt_result *res = req->data; |
| 159 | |
| 160 | if (err == -EINPROGRESS) |
| 161 | return; |
| 162 | |
| 163 | res->err = err; |
| 164 | complete(&res->completion); |
| 165 | } |
| 166 | |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 167 | static int testmgr_alloc_buf(char *buf[XBUFSIZE]) |
| 168 | { |
| 169 | int i; |
| 170 | |
| 171 | for (i = 0; i < XBUFSIZE; i++) { |
| 172 | buf[i] = (void *)__get_free_page(GFP_KERNEL); |
| 173 | if (!buf[i]) |
| 174 | goto err_free_buf; |
| 175 | } |
| 176 | |
| 177 | return 0; |
| 178 | |
| 179 | err_free_buf: |
| 180 | while (i-- > 0) |
| 181 | free_page((unsigned long)buf[i]); |
| 182 | |
| 183 | return -ENOMEM; |
| 184 | } |
| 185 | |
| 186 | static void testmgr_free_buf(char *buf[XBUFSIZE]) |
| 187 | { |
| 188 | int i; |
| 189 | |
| 190 | for (i = 0; i < XBUFSIZE; i++) |
| 191 | free_page((unsigned long)buf[i]); |
| 192 | } |
| 193 | |
Cristian Stoica | d4c85f9 | 2014-08-08 12:30:04 +0300 | [diff] [blame] | 194 | static int wait_async_op(struct tcrypt_result *tr, int ret) |
David S. Miller | a8f1a05 | 2010-05-19 14:12:03 +1000 | [diff] [blame] | 195 | { |
| 196 | if (ret == -EINPROGRESS || ret == -EBUSY) { |
Rabin Vincent | 8a45ac1 | 2015-01-09 16:25:28 +0100 | [diff] [blame] | 197 | wait_for_completion(&tr->completion); |
Wolfram Sang | 16735d0 | 2013-11-14 14:32:02 -0800 | [diff] [blame] | 198 | reinit_completion(&tr->completion); |
Rabin Vincent | 8a45ac1 | 2015-01-09 16:25:28 +0100 | [diff] [blame] | 199 | ret = tr->err; |
David S. Miller | a8f1a05 | 2010-05-19 14:12:03 +1000 | [diff] [blame] | 200 | } |
| 201 | return ret; |
| 202 | } |
| 203 | |
Wang, Rui Y | 018ba95 | 2016-02-03 18:26:57 +0800 | [diff] [blame] | 204 | static int ahash_partial_update(struct ahash_request **preq, |
| 205 | struct crypto_ahash *tfm, struct hash_testvec *template, |
| 206 | void *hash_buff, int k, int temp, struct scatterlist *sg, |
| 207 | const char *algo, char *result, struct tcrypt_result *tresult) |
| 208 | { |
| 209 | char *state; |
| 210 | struct ahash_request *req; |
| 211 | int statesize, ret = -EINVAL; |
Jan Stancek | 7bcb87b | 2016-09-28 16:38:37 +0200 | [diff] [blame] | 212 | const char guard[] = { 0x00, 0xba, 0xad, 0x00 }; |
Wang, Rui Y | 018ba95 | 2016-02-03 18:26:57 +0800 | [diff] [blame] | 213 | |
| 214 | req = *preq; |
| 215 | statesize = crypto_ahash_statesize( |
| 216 | crypto_ahash_reqtfm(req)); |
Jan Stancek | 7bcb87b | 2016-09-28 16:38:37 +0200 | [diff] [blame] | 217 | state = kmalloc(statesize + sizeof(guard), GFP_KERNEL); |
Wang, Rui Y | 018ba95 | 2016-02-03 18:26:57 +0800 | [diff] [blame] | 218 | if (!state) { |
| 219 | pr_err("alt: hash: Failed to alloc state for %s\n", algo); |
| 220 | goto out_nostate; |
| 221 | } |
Jan Stancek | 7bcb87b | 2016-09-28 16:38:37 +0200 | [diff] [blame] | 222 | memcpy(state + statesize, guard, sizeof(guard)); |
Wang, Rui Y | 018ba95 | 2016-02-03 18:26:57 +0800 | [diff] [blame] | 223 | ret = crypto_ahash_export(req, state); |
Jan Stancek | 7bcb87b | 2016-09-28 16:38:37 +0200 | [diff] [blame] | 224 | WARN_ON(memcmp(state + statesize, guard, sizeof(guard))); |
Wang, Rui Y | 018ba95 | 2016-02-03 18:26:57 +0800 | [diff] [blame] | 225 | if (ret) { |
| 226 | pr_err("alt: hash: Failed to export() for %s\n", algo); |
| 227 | goto out; |
| 228 | } |
| 229 | ahash_request_free(req); |
| 230 | req = ahash_request_alloc(tfm, GFP_KERNEL); |
| 231 | if (!req) { |
| 232 | pr_err("alg: hash: Failed to alloc request for %s\n", algo); |
| 233 | goto out_noreq; |
| 234 | } |
| 235 | ahash_request_set_callback(req, |
| 236 | CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 237 | tcrypt_complete, tresult); |
| 238 | |
| 239 | memcpy(hash_buff, template->plaintext + temp, |
| 240 | template->tap[k]); |
| 241 | sg_init_one(&sg[0], hash_buff, template->tap[k]); |
| 242 | ahash_request_set_crypt(req, sg, result, template->tap[k]); |
| 243 | ret = crypto_ahash_import(req, state); |
| 244 | if (ret) { |
| 245 | pr_err("alg: hash: Failed to import() for %s\n", algo); |
| 246 | goto out; |
| 247 | } |
| 248 | ret = wait_async_op(tresult, crypto_ahash_update(req)); |
| 249 | if (ret) |
| 250 | goto out; |
| 251 | *preq = req; |
| 252 | ret = 0; |
| 253 | goto out_noreq; |
| 254 | out: |
| 255 | ahash_request_free(req); |
| 256 | out_noreq: |
| 257 | kfree(state); |
| 258 | out_nostate: |
| 259 | return ret; |
| 260 | } |
| 261 | |
Jussi Kivilinna | da5ffe1 | 2013-06-13 17:37:55 +0300 | [diff] [blame] | 262 | static int __test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, |
| 263 | unsigned int tcount, bool use_digest, |
| 264 | const int align_offset) |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 265 | { |
| 266 | const char *algo = crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm)); |
| 267 | unsigned int i, j, k, temp; |
| 268 | struct scatterlist sg[8]; |
Horia Geanta | 29b77e5 | 2014-07-23 11:59:38 +0300 | [diff] [blame] | 269 | char *result; |
| 270 | char *key; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 271 | struct ahash_request *req; |
| 272 | struct tcrypt_result tresult; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 273 | void *hash_buff; |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 274 | char *xbuf[XBUFSIZE]; |
| 275 | int ret = -ENOMEM; |
| 276 | |
Horia Geanta | 29b77e5 | 2014-07-23 11:59:38 +0300 | [diff] [blame] | 277 | result = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL); |
| 278 | if (!result) |
| 279 | return ret; |
| 280 | key = kmalloc(MAX_KEYLEN, GFP_KERNEL); |
| 281 | if (!key) |
| 282 | goto out_nobuf; |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 283 | if (testmgr_alloc_buf(xbuf)) |
| 284 | goto out_nobuf; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 285 | |
| 286 | init_completion(&tresult.completion); |
| 287 | |
| 288 | req = ahash_request_alloc(tfm, GFP_KERNEL); |
| 289 | if (!req) { |
| 290 | printk(KERN_ERR "alg: hash: Failed to allocate request for " |
| 291 | "%s\n", algo); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 292 | goto out_noreq; |
| 293 | } |
| 294 | ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 295 | tcrypt_complete, &tresult); |
| 296 | |
Herbert Xu | a0cfae5 | 2009-05-29 16:23:12 +1000 | [diff] [blame] | 297 | j = 0; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 298 | for (i = 0; i < tcount; i++) { |
Herbert Xu | a0cfae5 | 2009-05-29 16:23:12 +1000 | [diff] [blame] | 299 | if (template[i].np) |
| 300 | continue; |
| 301 | |
Jussi Kivilinna | da5ffe1 | 2013-06-13 17:37:55 +0300 | [diff] [blame] | 302 | ret = -EINVAL; |
| 303 | if (WARN_ON(align_offset + template[i].psize > PAGE_SIZE)) |
| 304 | goto out; |
| 305 | |
Herbert Xu | a0cfae5 | 2009-05-29 16:23:12 +1000 | [diff] [blame] | 306 | j++; |
Horia Geanta | 29b77e5 | 2014-07-23 11:59:38 +0300 | [diff] [blame] | 307 | memset(result, 0, MAX_DIGEST_SIZE); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 308 | |
| 309 | hash_buff = xbuf[0]; |
Jussi Kivilinna | da5ffe1 | 2013-06-13 17:37:55 +0300 | [diff] [blame] | 310 | hash_buff += align_offset; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 311 | |
| 312 | memcpy(hash_buff, template[i].plaintext, template[i].psize); |
| 313 | sg_init_one(&sg[0], hash_buff, template[i].psize); |
| 314 | |
| 315 | if (template[i].ksize) { |
| 316 | crypto_ahash_clear_flags(tfm, ~0); |
Horia Geanta | 29b77e5 | 2014-07-23 11:59:38 +0300 | [diff] [blame] | 317 | if (template[i].ksize > MAX_KEYLEN) { |
| 318 | pr_err("alg: hash: setkey failed on test %d for %s: key size %d > %d\n", |
| 319 | j, algo, template[i].ksize, MAX_KEYLEN); |
| 320 | ret = -EINVAL; |
| 321 | goto out; |
| 322 | } |
| 323 | memcpy(key, template[i].key, template[i].ksize); |
| 324 | ret = crypto_ahash_setkey(tfm, key, template[i].ksize); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 325 | if (ret) { |
| 326 | printk(KERN_ERR "alg: hash: setkey failed on " |
Herbert Xu | a0cfae5 | 2009-05-29 16:23:12 +1000 | [diff] [blame] | 327 | "test %d for %s: ret=%d\n", j, algo, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 328 | -ret); |
| 329 | goto out; |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | ahash_request_set_crypt(req, sg, result, template[i].psize); |
David S. Miller | a8f1a05 | 2010-05-19 14:12:03 +1000 | [diff] [blame] | 334 | if (use_digest) { |
Cristian Stoica | d4c85f9 | 2014-08-08 12:30:04 +0300 | [diff] [blame] | 335 | ret = wait_async_op(&tresult, crypto_ahash_digest(req)); |
David S. Miller | a8f1a05 | 2010-05-19 14:12:03 +1000 | [diff] [blame] | 336 | if (ret) { |
| 337 | pr_err("alg: hash: digest failed on test %d " |
| 338 | "for %s: ret=%d\n", j, algo, -ret); |
| 339 | goto out; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 340 | } |
David S. Miller | a8f1a05 | 2010-05-19 14:12:03 +1000 | [diff] [blame] | 341 | } else { |
Cristian Stoica | d4c85f9 | 2014-08-08 12:30:04 +0300 | [diff] [blame] | 342 | ret = wait_async_op(&tresult, crypto_ahash_init(req)); |
David S. Miller | a8f1a05 | 2010-05-19 14:12:03 +1000 | [diff] [blame] | 343 | if (ret) { |
| 344 | pr_err("alt: hash: init failed on test %d " |
| 345 | "for %s: ret=%d\n", j, algo, -ret); |
| 346 | goto out; |
| 347 | } |
Cristian Stoica | d4c85f9 | 2014-08-08 12:30:04 +0300 | [diff] [blame] | 348 | ret = wait_async_op(&tresult, crypto_ahash_update(req)); |
David S. Miller | a8f1a05 | 2010-05-19 14:12:03 +1000 | [diff] [blame] | 349 | if (ret) { |
| 350 | pr_err("alt: hash: update failed on test %d " |
| 351 | "for %s: ret=%d\n", j, algo, -ret); |
| 352 | goto out; |
| 353 | } |
Cristian Stoica | d4c85f9 | 2014-08-08 12:30:04 +0300 | [diff] [blame] | 354 | ret = wait_async_op(&tresult, crypto_ahash_final(req)); |
David S. Miller | a8f1a05 | 2010-05-19 14:12:03 +1000 | [diff] [blame] | 355 | if (ret) { |
| 356 | pr_err("alt: hash: final failed on test %d " |
| 357 | "for %s: ret=%d\n", j, algo, -ret); |
| 358 | goto out; |
| 359 | } |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | if (memcmp(result, template[i].digest, |
| 363 | crypto_ahash_digestsize(tfm))) { |
| 364 | printk(KERN_ERR "alg: hash: Test %d failed for %s\n", |
Herbert Xu | a0cfae5 | 2009-05-29 16:23:12 +1000 | [diff] [blame] | 365 | j, algo); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 366 | hexdump(result, crypto_ahash_digestsize(tfm)); |
| 367 | ret = -EINVAL; |
| 368 | goto out; |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | j = 0; |
| 373 | for (i = 0; i < tcount; i++) { |
Jussi Kivilinna | da5ffe1 | 2013-06-13 17:37:55 +0300 | [diff] [blame] | 374 | /* alignment tests are only done with continuous buffers */ |
| 375 | if (align_offset != 0) |
| 376 | break; |
| 377 | |
Cristian Stoica | 5f2b424 | 2014-08-08 14:27:50 +0300 | [diff] [blame] | 378 | if (!template[i].np) |
| 379 | continue; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 380 | |
Cristian Stoica | 5f2b424 | 2014-08-08 14:27:50 +0300 | [diff] [blame] | 381 | j++; |
| 382 | memset(result, 0, MAX_DIGEST_SIZE); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 383 | |
Cristian Stoica | 5f2b424 | 2014-08-08 14:27:50 +0300 | [diff] [blame] | 384 | temp = 0; |
| 385 | sg_init_table(sg, template[i].np); |
| 386 | ret = -EINVAL; |
| 387 | for (k = 0; k < template[i].np; k++) { |
| 388 | if (WARN_ON(offset_in_page(IDX[k]) + |
| 389 | template[i].tap[k] > PAGE_SIZE)) |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 390 | goto out; |
Cristian Stoica | 5f2b424 | 2014-08-08 14:27:50 +0300 | [diff] [blame] | 391 | sg_set_buf(&sg[k], |
| 392 | memcpy(xbuf[IDX[k] >> PAGE_SHIFT] + |
| 393 | offset_in_page(IDX[k]), |
| 394 | template[i].plaintext + temp, |
| 395 | template[i].tap[k]), |
| 396 | template[i].tap[k]); |
| 397 | temp += template[i].tap[k]; |
| 398 | } |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 399 | |
Cristian Stoica | 5f2b424 | 2014-08-08 14:27:50 +0300 | [diff] [blame] | 400 | if (template[i].ksize) { |
| 401 | if (template[i].ksize > MAX_KEYLEN) { |
| 402 | pr_err("alg: hash: setkey failed on test %d for %s: key size %d > %d\n", |
| 403 | j, algo, template[i].ksize, MAX_KEYLEN); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 404 | ret = -EINVAL; |
| 405 | goto out; |
| 406 | } |
Cristian Stoica | 5f2b424 | 2014-08-08 14:27:50 +0300 | [diff] [blame] | 407 | crypto_ahash_clear_flags(tfm, ~0); |
| 408 | memcpy(key, template[i].key, template[i].ksize); |
| 409 | ret = crypto_ahash_setkey(tfm, key, template[i].ksize); |
| 410 | |
| 411 | if (ret) { |
| 412 | printk(KERN_ERR "alg: hash: setkey " |
| 413 | "failed on chunking test %d " |
| 414 | "for %s: ret=%d\n", j, algo, -ret); |
| 415 | goto out; |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | ahash_request_set_crypt(req, sg, result, template[i].psize); |
| 420 | ret = crypto_ahash_digest(req); |
| 421 | switch (ret) { |
| 422 | case 0: |
| 423 | break; |
| 424 | case -EINPROGRESS: |
| 425 | case -EBUSY: |
Rabin Vincent | 8a45ac1 | 2015-01-09 16:25:28 +0100 | [diff] [blame] | 426 | wait_for_completion(&tresult.completion); |
| 427 | reinit_completion(&tresult.completion); |
| 428 | ret = tresult.err; |
| 429 | if (!ret) |
Cristian Stoica | 5f2b424 | 2014-08-08 14:27:50 +0300 | [diff] [blame] | 430 | break; |
Cristian Stoica | 5f2b424 | 2014-08-08 14:27:50 +0300 | [diff] [blame] | 431 | /* fall through */ |
| 432 | default: |
| 433 | printk(KERN_ERR "alg: hash: digest failed " |
| 434 | "on chunking test %d for %s: " |
| 435 | "ret=%d\n", j, algo, -ret); |
| 436 | goto out; |
| 437 | } |
| 438 | |
| 439 | if (memcmp(result, template[i].digest, |
| 440 | crypto_ahash_digestsize(tfm))) { |
| 441 | printk(KERN_ERR "alg: hash: Chunking test %d " |
| 442 | "failed for %s\n", j, algo); |
| 443 | hexdump(result, crypto_ahash_digestsize(tfm)); |
| 444 | ret = -EINVAL; |
| 445 | goto out; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 446 | } |
| 447 | } |
| 448 | |
Wang, Rui Y | 018ba95 | 2016-02-03 18:26:57 +0800 | [diff] [blame] | 449 | /* partial update exercise */ |
| 450 | j = 0; |
| 451 | for (i = 0; i < tcount; i++) { |
| 452 | /* alignment tests are only done with continuous buffers */ |
| 453 | if (align_offset != 0) |
| 454 | break; |
| 455 | |
| 456 | if (template[i].np < 2) |
| 457 | continue; |
| 458 | |
| 459 | j++; |
| 460 | memset(result, 0, MAX_DIGEST_SIZE); |
| 461 | |
| 462 | ret = -EINVAL; |
| 463 | hash_buff = xbuf[0]; |
| 464 | memcpy(hash_buff, template[i].plaintext, |
| 465 | template[i].tap[0]); |
| 466 | sg_init_one(&sg[0], hash_buff, template[i].tap[0]); |
| 467 | |
| 468 | if (template[i].ksize) { |
| 469 | crypto_ahash_clear_flags(tfm, ~0); |
| 470 | if (template[i].ksize > MAX_KEYLEN) { |
| 471 | pr_err("alg: hash: setkey failed on test %d for %s: key size %d > %d\n", |
| 472 | j, algo, template[i].ksize, MAX_KEYLEN); |
| 473 | ret = -EINVAL; |
| 474 | goto out; |
| 475 | } |
| 476 | memcpy(key, template[i].key, template[i].ksize); |
| 477 | ret = crypto_ahash_setkey(tfm, key, template[i].ksize); |
| 478 | if (ret) { |
| 479 | pr_err("alg: hash: setkey failed on test %d for %s: ret=%d\n", |
| 480 | j, algo, -ret); |
| 481 | goto out; |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | ahash_request_set_crypt(req, sg, result, template[i].tap[0]); |
| 486 | ret = wait_async_op(&tresult, crypto_ahash_init(req)); |
| 487 | if (ret) { |
| 488 | pr_err("alt: hash: init failed on test %d for %s: ret=%d\n", |
| 489 | j, algo, -ret); |
| 490 | goto out; |
| 491 | } |
| 492 | ret = wait_async_op(&tresult, crypto_ahash_update(req)); |
| 493 | if (ret) { |
| 494 | pr_err("alt: hash: update failed on test %d for %s: ret=%d\n", |
| 495 | j, algo, -ret); |
| 496 | goto out; |
| 497 | } |
| 498 | |
| 499 | temp = template[i].tap[0]; |
| 500 | for (k = 1; k < template[i].np; k++) { |
| 501 | ret = ahash_partial_update(&req, tfm, &template[i], |
| 502 | hash_buff, k, temp, &sg[0], algo, result, |
| 503 | &tresult); |
| 504 | if (ret) { |
| 505 | pr_err("hash: partial update failed on test %d for %s: ret=%d\n", |
| 506 | j, algo, -ret); |
| 507 | goto out_noreq; |
| 508 | } |
| 509 | temp += template[i].tap[k]; |
| 510 | } |
| 511 | ret = wait_async_op(&tresult, crypto_ahash_final(req)); |
| 512 | if (ret) { |
| 513 | pr_err("alt: hash: final failed on test %d for %s: ret=%d\n", |
| 514 | j, algo, -ret); |
| 515 | goto out; |
| 516 | } |
| 517 | if (memcmp(result, template[i].digest, |
| 518 | crypto_ahash_digestsize(tfm))) { |
| 519 | pr_err("alg: hash: Partial Test %d failed for %s\n", |
| 520 | j, algo); |
| 521 | hexdump(result, crypto_ahash_digestsize(tfm)); |
| 522 | ret = -EINVAL; |
| 523 | goto out; |
| 524 | } |
| 525 | } |
| 526 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 527 | ret = 0; |
| 528 | |
| 529 | out: |
| 530 | ahash_request_free(req); |
| 531 | out_noreq: |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 532 | testmgr_free_buf(xbuf); |
| 533 | out_nobuf: |
Horia Geanta | 29b77e5 | 2014-07-23 11:59:38 +0300 | [diff] [blame] | 534 | kfree(key); |
| 535 | kfree(result); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 536 | return ret; |
| 537 | } |
| 538 | |
Jussi Kivilinna | da5ffe1 | 2013-06-13 17:37:55 +0300 | [diff] [blame] | 539 | static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, |
| 540 | unsigned int tcount, bool use_digest) |
| 541 | { |
| 542 | unsigned int alignmask; |
| 543 | int ret; |
| 544 | |
| 545 | ret = __test_hash(tfm, template, tcount, use_digest, 0); |
| 546 | if (ret) |
| 547 | return ret; |
| 548 | |
| 549 | /* test unaligned buffers, check with one byte offset */ |
| 550 | ret = __test_hash(tfm, template, tcount, use_digest, 1); |
| 551 | if (ret) |
| 552 | return ret; |
| 553 | |
| 554 | alignmask = crypto_tfm_alg_alignmask(&tfm->base); |
| 555 | if (alignmask) { |
| 556 | /* Check if alignment mask for tfm is correctly set. */ |
| 557 | ret = __test_hash(tfm, template, tcount, use_digest, |
| 558 | alignmask + 1); |
| 559 | if (ret) |
| 560 | return ret; |
| 561 | } |
| 562 | |
| 563 | return 0; |
| 564 | } |
| 565 | |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 566 | static int __test_aead(struct crypto_aead *tfm, int enc, |
| 567 | struct aead_testvec *template, unsigned int tcount, |
Jussi Kivilinna | 58dcf54 | 2013-06-13 17:37:50 +0300 | [diff] [blame] | 568 | const bool diff_dst, const int align_offset) |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 569 | { |
| 570 | const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)); |
| 571 | unsigned int i, j, k, n, temp; |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 572 | int ret = -ENOMEM; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 573 | char *q; |
| 574 | char *key; |
| 575 | struct aead_request *req; |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 576 | struct scatterlist *sg; |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 577 | struct scatterlist *sgout; |
| 578 | const char *e, *d; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 579 | struct tcrypt_result result; |
Cristian Stoica | 424a5da | 2015-01-28 11:03:05 +0200 | [diff] [blame] | 580 | unsigned int authsize, iv_len; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 581 | void *input; |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 582 | void *output; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 583 | void *assoc; |
Tadeusz Struk | 9bac019 | 2014-05-19 09:51:33 -0700 | [diff] [blame] | 584 | char *iv; |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 585 | char *xbuf[XBUFSIZE]; |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 586 | char *xoutbuf[XBUFSIZE]; |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 587 | char *axbuf[XBUFSIZE]; |
| 588 | |
Tadeusz Struk | 9bac019 | 2014-05-19 09:51:33 -0700 | [diff] [blame] | 589 | iv = kzalloc(MAX_IVLEN, GFP_KERNEL); |
| 590 | if (!iv) |
| 591 | return ret; |
Horia Geanta | 29b77e5 | 2014-07-23 11:59:38 +0300 | [diff] [blame] | 592 | key = kmalloc(MAX_KEYLEN, GFP_KERNEL); |
| 593 | if (!key) |
| 594 | goto out_noxbuf; |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 595 | if (testmgr_alloc_buf(xbuf)) |
| 596 | goto out_noxbuf; |
| 597 | if (testmgr_alloc_buf(axbuf)) |
| 598 | goto out_noaxbuf; |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 599 | if (diff_dst && testmgr_alloc_buf(xoutbuf)) |
| 600 | goto out_nooutbuf; |
| 601 | |
| 602 | /* avoid "the frame size is larger than 1024 bytes" compiler warning */ |
Herbert Xu | 8a525fc | 2015-05-27 16:03:43 +0800 | [diff] [blame] | 603 | sg = kmalloc(sizeof(*sg) * 8 * (diff_dst ? 4 : 2), GFP_KERNEL); |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 604 | if (!sg) |
| 605 | goto out_nosg; |
Herbert Xu | 8a525fc | 2015-05-27 16:03:43 +0800 | [diff] [blame] | 606 | sgout = &sg[16]; |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 607 | |
| 608 | if (diff_dst) |
| 609 | d = "-ddst"; |
| 610 | else |
| 611 | d = ""; |
| 612 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 613 | if (enc == ENCRYPT) |
| 614 | e = "encryption"; |
| 615 | else |
| 616 | e = "decryption"; |
| 617 | |
| 618 | init_completion(&result.completion); |
| 619 | |
| 620 | req = aead_request_alloc(tfm, GFP_KERNEL); |
| 621 | if (!req) { |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 622 | pr_err("alg: aead%s: Failed to allocate request for %s\n", |
| 623 | d, algo); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 624 | goto out; |
| 625 | } |
| 626 | |
| 627 | aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 628 | tcrypt_complete, &result); |
| 629 | |
Jerome Marchand | abfa7f4 | 2016-02-03 13:58:12 +0100 | [diff] [blame] | 630 | iv_len = crypto_aead_ivsize(tfm); |
| 631 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 632 | for (i = 0, j = 0; i < tcount; i++) { |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 633 | if (template[i].np) |
| 634 | continue; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 635 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 636 | j++; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 637 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 638 | /* some templates have no input data but they will |
| 639 | * touch input |
| 640 | */ |
| 641 | input = xbuf[0]; |
| 642 | input += align_offset; |
| 643 | assoc = axbuf[0]; |
| 644 | |
| 645 | ret = -EINVAL; |
| 646 | if (WARN_ON(align_offset + template[i].ilen > |
| 647 | PAGE_SIZE || template[i].alen > PAGE_SIZE)) |
| 648 | goto out; |
| 649 | |
| 650 | memcpy(input, template[i].input, template[i].ilen); |
| 651 | memcpy(assoc, template[i].assoc, template[i].alen); |
| 652 | if (template[i].iv) |
Cristian Stoica | 424a5da | 2015-01-28 11:03:05 +0200 | [diff] [blame] | 653 | memcpy(iv, template[i].iv, iv_len); |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 654 | else |
Cristian Stoica | 424a5da | 2015-01-28 11:03:05 +0200 | [diff] [blame] | 655 | memset(iv, 0, iv_len); |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 656 | |
| 657 | crypto_aead_clear_flags(tfm, ~0); |
| 658 | if (template[i].wk) |
| 659 | crypto_aead_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY); |
| 660 | |
| 661 | if (template[i].klen > MAX_KEYLEN) { |
| 662 | pr_err("alg: aead%s: setkey failed on test %d for %s: key size %d > %d\n", |
| 663 | d, j, algo, template[i].klen, |
| 664 | MAX_KEYLEN); |
Herbert Xu | fd57f22 | 2009-05-29 16:05:42 +1000 | [diff] [blame] | 665 | ret = -EINVAL; |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 666 | goto out; |
| 667 | } |
| 668 | memcpy(key, template[i].key, template[i].klen); |
Herbert Xu | fd57f22 | 2009-05-29 16:05:42 +1000 | [diff] [blame] | 669 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 670 | ret = crypto_aead_setkey(tfm, key, template[i].klen); |
Yanjiang Jin | 0fae0c1 | 2016-07-29 16:32:09 +0800 | [diff] [blame] | 671 | if (template[i].fail == !ret) { |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 672 | pr_err("alg: aead%s: setkey failed on test %d for %s: flags=%x\n", |
| 673 | d, j, algo, crypto_aead_get_flags(tfm)); |
| 674 | goto out; |
| 675 | } else if (ret) |
| 676 | continue; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 677 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 678 | authsize = abs(template[i].rlen - template[i].ilen); |
| 679 | ret = crypto_aead_setauthsize(tfm, authsize); |
| 680 | if (ret) { |
| 681 | pr_err("alg: aead%s: Failed to set authsize to %u on test %d for %s\n", |
| 682 | d, authsize, j, algo); |
| 683 | goto out; |
| 684 | } |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 685 | |
Herbert Xu | 8a525fc | 2015-05-27 16:03:43 +0800 | [diff] [blame] | 686 | k = !!template[i].alen; |
| 687 | sg_init_table(sg, k + 1); |
| 688 | sg_set_buf(&sg[0], assoc, template[i].alen); |
| 689 | sg_set_buf(&sg[k], input, |
| 690 | template[i].ilen + (enc ? authsize : 0)); |
| 691 | output = input; |
| 692 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 693 | if (diff_dst) { |
Herbert Xu | 8a525fc | 2015-05-27 16:03:43 +0800 | [diff] [blame] | 694 | sg_init_table(sgout, k + 1); |
| 695 | sg_set_buf(&sgout[0], assoc, template[i].alen); |
| 696 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 697 | output = xoutbuf[0]; |
| 698 | output += align_offset; |
Herbert Xu | 8a525fc | 2015-05-27 16:03:43 +0800 | [diff] [blame] | 699 | sg_set_buf(&sgout[k], output, |
| 700 | template[i].rlen + (enc ? 0 : authsize)); |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 701 | } |
| 702 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 703 | aead_request_set_crypt(req, sg, (diff_dst) ? sgout : sg, |
| 704 | template[i].ilen, iv); |
| 705 | |
Herbert Xu | 8a525fc | 2015-05-27 16:03:43 +0800 | [diff] [blame] | 706 | aead_request_set_ad(req, template[i].alen); |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 707 | |
| 708 | ret = enc ? crypto_aead_encrypt(req) : crypto_aead_decrypt(req); |
| 709 | |
| 710 | switch (ret) { |
| 711 | case 0: |
| 712 | if (template[i].novrfy) { |
| 713 | /* verification was supposed to fail */ |
| 714 | pr_err("alg: aead%s: %s failed on test %d for %s: ret was 0, expected -EBADMSG\n", |
| 715 | d, e, j, algo); |
| 716 | /* so really, we got a bad message */ |
| 717 | ret = -EBADMSG; |
Horia Geanta | 29b77e5 | 2014-07-23 11:59:38 +0300 | [diff] [blame] | 718 | goto out; |
| 719 | } |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 720 | break; |
| 721 | case -EINPROGRESS: |
| 722 | case -EBUSY: |
Rabin Vincent | 8a45ac1 | 2015-01-09 16:25:28 +0100 | [diff] [blame] | 723 | wait_for_completion(&result.completion); |
| 724 | reinit_completion(&result.completion); |
| 725 | ret = result.err; |
| 726 | if (!ret) |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 727 | break; |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 728 | case -EBADMSG: |
| 729 | if (template[i].novrfy) |
| 730 | /* verification failure was expected */ |
| 731 | continue; |
| 732 | /* fall through */ |
| 733 | default: |
| 734 | pr_err("alg: aead%s: %s failed on test %d for %s: ret=%d\n", |
| 735 | d, e, j, algo, -ret); |
| 736 | goto out; |
| 737 | } |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 738 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 739 | q = output; |
| 740 | if (memcmp(q, template[i].result, template[i].rlen)) { |
| 741 | pr_err("alg: aead%s: Test %d failed on %s for %s\n", |
| 742 | d, j, e, algo); |
| 743 | hexdump(q, template[i].rlen); |
| 744 | ret = -EINVAL; |
| 745 | goto out; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 746 | } |
| 747 | } |
| 748 | |
| 749 | for (i = 0, j = 0; i < tcount; i++) { |
Jussi Kivilinna | 58dcf54 | 2013-06-13 17:37:50 +0300 | [diff] [blame] | 750 | /* alignment tests are only done with continuous buffers */ |
| 751 | if (align_offset != 0) |
| 752 | break; |
| 753 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 754 | if (!template[i].np) |
| 755 | continue; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 756 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 757 | j++; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 758 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 759 | if (template[i].iv) |
Jerome Marchand | abfa7f4 | 2016-02-03 13:58:12 +0100 | [diff] [blame] | 760 | memcpy(iv, template[i].iv, iv_len); |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 761 | else |
| 762 | memset(iv, 0, MAX_IVLEN); |
| 763 | |
| 764 | crypto_aead_clear_flags(tfm, ~0); |
| 765 | if (template[i].wk) |
| 766 | crypto_aead_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY); |
| 767 | if (template[i].klen > MAX_KEYLEN) { |
| 768 | pr_err("alg: aead%s: setkey failed on test %d for %s: key size %d > %d\n", |
| 769 | d, j, algo, template[i].klen, MAX_KEYLEN); |
| 770 | ret = -EINVAL; |
| 771 | goto out; |
| 772 | } |
| 773 | memcpy(key, template[i].key, template[i].klen); |
| 774 | |
| 775 | ret = crypto_aead_setkey(tfm, key, template[i].klen); |
Yanjiang Jin | 0fae0c1 | 2016-07-29 16:32:09 +0800 | [diff] [blame] | 776 | if (template[i].fail == !ret) { |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 777 | pr_err("alg: aead%s: setkey failed on chunk test %d for %s: flags=%x\n", |
| 778 | d, j, algo, crypto_aead_get_flags(tfm)); |
| 779 | goto out; |
| 780 | } else if (ret) |
| 781 | continue; |
| 782 | |
| 783 | authsize = abs(template[i].rlen - template[i].ilen); |
| 784 | |
| 785 | ret = -EINVAL; |
Herbert Xu | 8a525fc | 2015-05-27 16:03:43 +0800 | [diff] [blame] | 786 | sg_init_table(sg, template[i].anp + template[i].np); |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 787 | if (diff_dst) |
Herbert Xu | 8a525fc | 2015-05-27 16:03:43 +0800 | [diff] [blame] | 788 | sg_init_table(sgout, template[i].anp + template[i].np); |
| 789 | |
| 790 | ret = -EINVAL; |
| 791 | for (k = 0, temp = 0; k < template[i].anp; k++) { |
| 792 | if (WARN_ON(offset_in_page(IDX[k]) + |
| 793 | template[i].atap[k] > PAGE_SIZE)) |
| 794 | goto out; |
| 795 | sg_set_buf(&sg[k], |
| 796 | memcpy(axbuf[IDX[k] >> PAGE_SHIFT] + |
| 797 | offset_in_page(IDX[k]), |
| 798 | template[i].assoc + temp, |
| 799 | template[i].atap[k]), |
| 800 | template[i].atap[k]); |
| 801 | if (diff_dst) |
| 802 | sg_set_buf(&sgout[k], |
| 803 | axbuf[IDX[k] >> PAGE_SHIFT] + |
| 804 | offset_in_page(IDX[k]), |
| 805 | template[i].atap[k]); |
| 806 | temp += template[i].atap[k]; |
| 807 | } |
| 808 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 809 | for (k = 0, temp = 0; k < template[i].np; k++) { |
| 810 | if (WARN_ON(offset_in_page(IDX[k]) + |
| 811 | template[i].tap[k] > PAGE_SIZE)) |
| 812 | goto out; |
| 813 | |
| 814 | q = xbuf[IDX[k] >> PAGE_SHIFT] + offset_in_page(IDX[k]); |
| 815 | memcpy(q, template[i].input + temp, template[i].tap[k]); |
Herbert Xu | 8a525fc | 2015-05-27 16:03:43 +0800 | [diff] [blame] | 816 | sg_set_buf(&sg[template[i].anp + k], |
| 817 | q, template[i].tap[k]); |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 818 | |
| 819 | if (diff_dst) { |
| 820 | q = xoutbuf[IDX[k] >> PAGE_SHIFT] + |
| 821 | offset_in_page(IDX[k]); |
| 822 | |
| 823 | memset(q, 0, template[i].tap[k]); |
| 824 | |
Herbert Xu | 8a525fc | 2015-05-27 16:03:43 +0800 | [diff] [blame] | 825 | sg_set_buf(&sgout[template[i].anp + k], |
| 826 | q, template[i].tap[k]); |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 827 | } |
| 828 | |
| 829 | n = template[i].tap[k]; |
| 830 | if (k == template[i].np - 1 && enc) |
| 831 | n += authsize; |
| 832 | if (offset_in_page(q) + n < PAGE_SIZE) |
| 833 | q[n] = 0; |
| 834 | |
| 835 | temp += template[i].tap[k]; |
| 836 | } |
| 837 | |
| 838 | ret = crypto_aead_setauthsize(tfm, authsize); |
| 839 | if (ret) { |
| 840 | pr_err("alg: aead%s: Failed to set authsize to %u on chunk test %d for %s\n", |
| 841 | d, authsize, j, algo); |
| 842 | goto out; |
| 843 | } |
| 844 | |
| 845 | if (enc) { |
Herbert Xu | 8a525fc | 2015-05-27 16:03:43 +0800 | [diff] [blame] | 846 | if (WARN_ON(sg[template[i].anp + k - 1].offset + |
| 847 | sg[template[i].anp + k - 1].length + |
| 848 | authsize > PAGE_SIZE)) { |
Horia Geanta | 29b77e5 | 2014-07-23 11:59:38 +0300 | [diff] [blame] | 849 | ret = -EINVAL; |
| 850 | goto out; |
| 851 | } |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 852 | |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 853 | if (diff_dst) |
Herbert Xu | 8a525fc | 2015-05-27 16:03:43 +0800 | [diff] [blame] | 854 | sgout[template[i].anp + k - 1].length += |
| 855 | authsize; |
| 856 | sg[template[i].anp + k - 1].length += authsize; |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 857 | } |
| 858 | |
| 859 | aead_request_set_crypt(req, sg, (diff_dst) ? sgout : sg, |
| 860 | template[i].ilen, |
| 861 | iv); |
| 862 | |
Herbert Xu | 8a525fc | 2015-05-27 16:03:43 +0800 | [diff] [blame] | 863 | aead_request_set_ad(req, template[i].alen); |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 864 | |
| 865 | ret = enc ? crypto_aead_encrypt(req) : crypto_aead_decrypt(req); |
| 866 | |
| 867 | switch (ret) { |
| 868 | case 0: |
| 869 | if (template[i].novrfy) { |
| 870 | /* verification was supposed to fail */ |
| 871 | pr_err("alg: aead%s: %s failed on chunk test %d for %s: ret was 0, expected -EBADMSG\n", |
| 872 | d, e, j, algo); |
| 873 | /* so really, we got a bad message */ |
| 874 | ret = -EBADMSG; |
| 875 | goto out; |
| 876 | } |
| 877 | break; |
| 878 | case -EINPROGRESS: |
| 879 | case -EBUSY: |
Rabin Vincent | 8a45ac1 | 2015-01-09 16:25:28 +0100 | [diff] [blame] | 880 | wait_for_completion(&result.completion); |
| 881 | reinit_completion(&result.completion); |
| 882 | ret = result.err; |
| 883 | if (!ret) |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 884 | break; |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 885 | case -EBADMSG: |
| 886 | if (template[i].novrfy) |
| 887 | /* verification failure was expected */ |
| 888 | continue; |
| 889 | /* fall through */ |
| 890 | default: |
| 891 | pr_err("alg: aead%s: %s failed on chunk test %d for %s: ret=%d\n", |
| 892 | d, e, j, algo, -ret); |
| 893 | goto out; |
| 894 | } |
| 895 | |
| 896 | ret = -EINVAL; |
| 897 | for (k = 0, temp = 0; k < template[i].np; k++) { |
| 898 | if (diff_dst) |
| 899 | q = xoutbuf[IDX[k] >> PAGE_SHIFT] + |
| 900 | offset_in_page(IDX[k]); |
| 901 | else |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 902 | q = xbuf[IDX[k] >> PAGE_SHIFT] + |
| 903 | offset_in_page(IDX[k]); |
| 904 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 905 | n = template[i].tap[k]; |
| 906 | if (k == template[i].np - 1) |
| 907 | n += enc ? authsize : -authsize; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 908 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 909 | if (memcmp(q, template[i].result + temp, n)) { |
| 910 | pr_err("alg: aead%s: Chunk test %d failed on %s at page %u for %s\n", |
| 911 | d, j, e, k, algo); |
| 912 | hexdump(q, n); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 913 | goto out; |
| 914 | } |
| 915 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 916 | q += n; |
| 917 | if (k == template[i].np - 1 && !enc) { |
| 918 | if (!diff_dst && |
| 919 | memcmp(q, template[i].input + |
| 920 | temp + n, authsize)) |
| 921 | n = authsize; |
Horia Geanta | 8ec25c5 | 2013-11-28 15:11:18 +0200 | [diff] [blame] | 922 | else |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 923 | n = 0; |
| 924 | } else { |
| 925 | for (n = 0; offset_in_page(q + n) && q[n]; n++) |
| 926 | ; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 927 | } |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 928 | if (n) { |
| 929 | pr_err("alg: aead%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n", |
| 930 | d, j, e, k, algo, n); |
| 931 | hexdump(q, n); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 932 | goto out; |
| 933 | } |
| 934 | |
Cristian Stoica | 05b1d33 | 2014-07-28 13:11:23 +0300 | [diff] [blame] | 935 | temp += template[i].tap[k]; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 936 | } |
| 937 | } |
| 938 | |
| 939 | ret = 0; |
| 940 | |
| 941 | out: |
| 942 | aead_request_free(req); |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 943 | kfree(sg); |
| 944 | out_nosg: |
| 945 | if (diff_dst) |
| 946 | testmgr_free_buf(xoutbuf); |
| 947 | out_nooutbuf: |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 948 | testmgr_free_buf(axbuf); |
| 949 | out_noaxbuf: |
| 950 | testmgr_free_buf(xbuf); |
| 951 | out_noxbuf: |
Horia Geanta | 29b77e5 | 2014-07-23 11:59:38 +0300 | [diff] [blame] | 952 | kfree(key); |
Tadeusz Struk | 9bac019 | 2014-05-19 09:51:33 -0700 | [diff] [blame] | 953 | kfree(iv); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 954 | return ret; |
| 955 | } |
| 956 | |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 957 | static int test_aead(struct crypto_aead *tfm, int enc, |
| 958 | struct aead_testvec *template, unsigned int tcount) |
| 959 | { |
Jussi Kivilinna | 58dcf54 | 2013-06-13 17:37:50 +0300 | [diff] [blame] | 960 | unsigned int alignmask; |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 961 | int ret; |
| 962 | |
| 963 | /* test 'dst == src' case */ |
Jussi Kivilinna | 58dcf54 | 2013-06-13 17:37:50 +0300 | [diff] [blame] | 964 | ret = __test_aead(tfm, enc, template, tcount, false, 0); |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 965 | if (ret) |
| 966 | return ret; |
| 967 | |
| 968 | /* test 'dst != src' case */ |
Jussi Kivilinna | 58dcf54 | 2013-06-13 17:37:50 +0300 | [diff] [blame] | 969 | ret = __test_aead(tfm, enc, template, tcount, true, 0); |
| 970 | if (ret) |
| 971 | return ret; |
| 972 | |
| 973 | /* test unaligned buffers, check with one byte offset */ |
| 974 | ret = __test_aead(tfm, enc, template, tcount, true, 1); |
| 975 | if (ret) |
| 976 | return ret; |
| 977 | |
| 978 | alignmask = crypto_tfm_alg_alignmask(&tfm->base); |
| 979 | if (alignmask) { |
| 980 | /* Check if alignment mask for tfm is correctly set. */ |
| 981 | ret = __test_aead(tfm, enc, template, tcount, true, |
| 982 | alignmask + 1); |
| 983 | if (ret) |
| 984 | return ret; |
| 985 | } |
| 986 | |
| 987 | return 0; |
Jussi Kivilinna | d8a32ac | 2012-09-21 10:26:52 +0300 | [diff] [blame] | 988 | } |
| 989 | |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 990 | static int test_cipher(struct crypto_cipher *tfm, int enc, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 991 | struct cipher_testvec *template, unsigned int tcount) |
| 992 | { |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 993 | const char *algo = crypto_tfm_alg_driver_name(crypto_cipher_tfm(tfm)); |
| 994 | unsigned int i, j, k; |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 995 | char *q; |
| 996 | const char *e; |
| 997 | void *data; |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 998 | char *xbuf[XBUFSIZE]; |
| 999 | int ret = -ENOMEM; |
| 1000 | |
| 1001 | if (testmgr_alloc_buf(xbuf)) |
| 1002 | goto out_nobuf; |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 1003 | |
| 1004 | if (enc == ENCRYPT) |
| 1005 | e = "encryption"; |
| 1006 | else |
| 1007 | e = "decryption"; |
| 1008 | |
| 1009 | j = 0; |
| 1010 | for (i = 0; i < tcount; i++) { |
| 1011 | if (template[i].np) |
| 1012 | continue; |
| 1013 | |
Stephan Mueller | 10faa8c | 2016-08-25 15:15:01 +0200 | [diff] [blame] | 1014 | if (fips_enabled && template[i].fips_skip) |
| 1015 | continue; |
| 1016 | |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 1017 | j++; |
| 1018 | |
Herbert Xu | fd57f22 | 2009-05-29 16:05:42 +1000 | [diff] [blame] | 1019 | ret = -EINVAL; |
| 1020 | if (WARN_ON(template[i].ilen > PAGE_SIZE)) |
| 1021 | goto out; |
| 1022 | |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 1023 | data = xbuf[0]; |
| 1024 | memcpy(data, template[i].input, template[i].ilen); |
| 1025 | |
| 1026 | crypto_cipher_clear_flags(tfm, ~0); |
| 1027 | if (template[i].wk) |
| 1028 | crypto_cipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY); |
| 1029 | |
| 1030 | ret = crypto_cipher_setkey(tfm, template[i].key, |
| 1031 | template[i].klen); |
Yanjiang Jin | 0fae0c1 | 2016-07-29 16:32:09 +0800 | [diff] [blame] | 1032 | if (template[i].fail == !ret) { |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 1033 | printk(KERN_ERR "alg: cipher: setkey failed " |
| 1034 | "on test %d for %s: flags=%x\n", j, |
| 1035 | algo, crypto_cipher_get_flags(tfm)); |
| 1036 | goto out; |
| 1037 | } else if (ret) |
| 1038 | continue; |
| 1039 | |
| 1040 | for (k = 0; k < template[i].ilen; |
| 1041 | k += crypto_cipher_blocksize(tfm)) { |
| 1042 | if (enc) |
| 1043 | crypto_cipher_encrypt_one(tfm, data + k, |
| 1044 | data + k); |
| 1045 | else |
| 1046 | crypto_cipher_decrypt_one(tfm, data + k, |
| 1047 | data + k); |
| 1048 | } |
| 1049 | |
| 1050 | q = data; |
| 1051 | if (memcmp(q, template[i].result, template[i].rlen)) { |
| 1052 | printk(KERN_ERR "alg: cipher: Test %d failed " |
| 1053 | "on %s for %s\n", j, e, algo); |
| 1054 | hexdump(q, template[i].rlen); |
| 1055 | ret = -EINVAL; |
| 1056 | goto out; |
| 1057 | } |
| 1058 | } |
| 1059 | |
| 1060 | ret = 0; |
| 1061 | |
| 1062 | out: |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 1063 | testmgr_free_buf(xbuf); |
| 1064 | out_nobuf: |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 1065 | return ret; |
| 1066 | } |
| 1067 | |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1068 | static int __test_skcipher(struct crypto_skcipher *tfm, int enc, |
Jussi Kivilinna | 08d6af8 | 2012-09-21 10:26:47 +0300 | [diff] [blame] | 1069 | struct cipher_testvec *template, unsigned int tcount, |
Jussi Kivilinna | 3a338f2 | 2013-06-13 17:37:45 +0300 | [diff] [blame] | 1070 | const bool diff_dst, const int align_offset) |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 1071 | { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1072 | const char *algo = |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1073 | crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1074 | unsigned int i, j, k, n, temp; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1075 | char *q; |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1076 | struct skcipher_request *req; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1077 | struct scatterlist sg[8]; |
Jussi Kivilinna | 08d6af8 | 2012-09-21 10:26:47 +0300 | [diff] [blame] | 1078 | struct scatterlist sgout[8]; |
| 1079 | const char *e, *d; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1080 | struct tcrypt_result result; |
| 1081 | void *data; |
| 1082 | char iv[MAX_IVLEN]; |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 1083 | char *xbuf[XBUFSIZE]; |
Jussi Kivilinna | 08d6af8 | 2012-09-21 10:26:47 +0300 | [diff] [blame] | 1084 | char *xoutbuf[XBUFSIZE]; |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 1085 | int ret = -ENOMEM; |
Andrey Ryabinin | 84cba17 | 2015-09-10 13:11:55 +0300 | [diff] [blame] | 1086 | unsigned int ivsize = crypto_skcipher_ivsize(tfm); |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 1087 | |
| 1088 | if (testmgr_alloc_buf(xbuf)) |
| 1089 | goto out_nobuf; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1090 | |
Jussi Kivilinna | 08d6af8 | 2012-09-21 10:26:47 +0300 | [diff] [blame] | 1091 | if (diff_dst && testmgr_alloc_buf(xoutbuf)) |
| 1092 | goto out_nooutbuf; |
| 1093 | |
| 1094 | if (diff_dst) |
| 1095 | d = "-ddst"; |
| 1096 | else |
| 1097 | d = ""; |
| 1098 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1099 | if (enc == ENCRYPT) |
| 1100 | e = "encryption"; |
| 1101 | else |
| 1102 | e = "decryption"; |
| 1103 | |
| 1104 | init_completion(&result.completion); |
| 1105 | |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1106 | req = skcipher_request_alloc(tfm, GFP_KERNEL); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1107 | if (!req) { |
Jussi Kivilinna | 08d6af8 | 2012-09-21 10:26:47 +0300 | [diff] [blame] | 1108 | pr_err("alg: skcipher%s: Failed to allocate request for %s\n", |
| 1109 | d, algo); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1110 | goto out; |
| 1111 | } |
| 1112 | |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1113 | skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 1114 | tcrypt_complete, &result); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1115 | |
| 1116 | j = 0; |
| 1117 | for (i = 0; i < tcount; i++) { |
Cristian Stoica | bbb9a7d | 2014-08-08 14:27:52 +0300 | [diff] [blame] | 1118 | if (template[i].np && !template[i].also_non_np) |
| 1119 | continue; |
| 1120 | |
Stephan Mueller | 10faa8c | 2016-08-25 15:15:01 +0200 | [diff] [blame] | 1121 | if (fips_enabled && template[i].fips_skip) |
| 1122 | continue; |
| 1123 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1124 | if (template[i].iv) |
Andrey Ryabinin | 84cba17 | 2015-09-10 13:11:55 +0300 | [diff] [blame] | 1125 | memcpy(iv, template[i].iv, ivsize); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1126 | else |
| 1127 | memset(iv, 0, MAX_IVLEN); |
| 1128 | |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1129 | j++; |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1130 | ret = -EINVAL; |
| 1131 | if (WARN_ON(align_offset + template[i].ilen > PAGE_SIZE)) |
| 1132 | goto out; |
| 1133 | |
| 1134 | data = xbuf[0]; |
| 1135 | data += align_offset; |
| 1136 | memcpy(data, template[i].input, template[i].ilen); |
| 1137 | |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1138 | crypto_skcipher_clear_flags(tfm, ~0); |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1139 | if (template[i].wk) |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1140 | crypto_skcipher_set_flags(tfm, |
| 1141 | CRYPTO_TFM_REQ_WEAK_KEY); |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1142 | |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1143 | ret = crypto_skcipher_setkey(tfm, template[i].key, |
| 1144 | template[i].klen); |
Yanjiang Jin | 0fae0c1 | 2016-07-29 16:32:09 +0800 | [diff] [blame] | 1145 | if (template[i].fail == !ret) { |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1146 | pr_err("alg: skcipher%s: setkey failed on test %d for %s: flags=%x\n", |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1147 | d, j, algo, crypto_skcipher_get_flags(tfm)); |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1148 | goto out; |
| 1149 | } else if (ret) |
| 1150 | continue; |
| 1151 | |
| 1152 | sg_init_one(&sg[0], data, template[i].ilen); |
| 1153 | if (diff_dst) { |
| 1154 | data = xoutbuf[0]; |
Jussi Kivilinna | 3a338f2 | 2013-06-13 17:37:45 +0300 | [diff] [blame] | 1155 | data += align_offset; |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1156 | sg_init_one(&sgout[0], data, template[i].ilen); |
| 1157 | } |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1158 | |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1159 | skcipher_request_set_crypt(req, sg, (diff_dst) ? sgout : sg, |
| 1160 | template[i].ilen, iv); |
| 1161 | ret = enc ? crypto_skcipher_encrypt(req) : |
| 1162 | crypto_skcipher_decrypt(req); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1163 | |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1164 | switch (ret) { |
| 1165 | case 0: |
| 1166 | break; |
| 1167 | case -EINPROGRESS: |
| 1168 | case -EBUSY: |
Rabin Vincent | 8a45ac1 | 2015-01-09 16:25:28 +0100 | [diff] [blame] | 1169 | wait_for_completion(&result.completion); |
| 1170 | reinit_completion(&result.completion); |
| 1171 | ret = result.err; |
| 1172 | if (!ret) |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1173 | break; |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1174 | /* fall through */ |
| 1175 | default: |
| 1176 | pr_err("alg: skcipher%s: %s failed on test %d for %s: ret=%d\n", |
| 1177 | d, e, j, algo, -ret); |
| 1178 | goto out; |
| 1179 | } |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1180 | |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1181 | q = data; |
| 1182 | if (memcmp(q, template[i].result, template[i].rlen)) { |
Boris BREZILLON | 8a826a3 | 2015-06-16 11:46:46 +0200 | [diff] [blame] | 1183 | pr_err("alg: skcipher%s: Test %d failed (invalid result) on %s for %s\n", |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1184 | d, j, e, algo); |
| 1185 | hexdump(q, template[i].rlen); |
| 1186 | ret = -EINVAL; |
| 1187 | goto out; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1188 | } |
Boris BREZILLON | 8a826a3 | 2015-06-16 11:46:46 +0200 | [diff] [blame] | 1189 | |
| 1190 | if (template[i].iv_out && |
| 1191 | memcmp(iv, template[i].iv_out, |
| 1192 | crypto_skcipher_ivsize(tfm))) { |
| 1193 | pr_err("alg: skcipher%s: Test %d failed (invalid output IV) on %s for %s\n", |
| 1194 | d, j, e, algo); |
| 1195 | hexdump(iv, crypto_skcipher_ivsize(tfm)); |
| 1196 | ret = -EINVAL; |
| 1197 | goto out; |
| 1198 | } |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1199 | } |
| 1200 | |
| 1201 | j = 0; |
| 1202 | for (i = 0; i < tcount; i++) { |
Jussi Kivilinna | 3a338f2 | 2013-06-13 17:37:45 +0300 | [diff] [blame] | 1203 | /* alignment tests are only done with continuous buffers */ |
| 1204 | if (align_offset != 0) |
| 1205 | break; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1206 | |
Cristian Stoica | bbb9a7d | 2014-08-08 14:27:52 +0300 | [diff] [blame] | 1207 | if (!template[i].np) |
| 1208 | continue; |
| 1209 | |
Stephan Mueller | 10faa8c | 2016-08-25 15:15:01 +0200 | [diff] [blame] | 1210 | if (fips_enabled && template[i].fips_skip) |
| 1211 | continue; |
| 1212 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1213 | if (template[i].iv) |
Andrey Ryabinin | 84cba17 | 2015-09-10 13:11:55 +0300 | [diff] [blame] | 1214 | memcpy(iv, template[i].iv, ivsize); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1215 | else |
| 1216 | memset(iv, 0, MAX_IVLEN); |
| 1217 | |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1218 | j++; |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1219 | crypto_skcipher_clear_flags(tfm, ~0); |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1220 | if (template[i].wk) |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1221 | crypto_skcipher_set_flags(tfm, |
| 1222 | CRYPTO_TFM_REQ_WEAK_KEY); |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1223 | |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1224 | ret = crypto_skcipher_setkey(tfm, template[i].key, |
| 1225 | template[i].klen); |
Yanjiang Jin | 0fae0c1 | 2016-07-29 16:32:09 +0800 | [diff] [blame] | 1226 | if (template[i].fail == !ret) { |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1227 | pr_err("alg: skcipher%s: setkey failed on chunk test %d for %s: flags=%x\n", |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1228 | d, j, algo, crypto_skcipher_get_flags(tfm)); |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1229 | goto out; |
| 1230 | } else if (ret) |
| 1231 | continue; |
| 1232 | |
| 1233 | temp = 0; |
| 1234 | ret = -EINVAL; |
| 1235 | sg_init_table(sg, template[i].np); |
| 1236 | if (diff_dst) |
| 1237 | sg_init_table(sgout, template[i].np); |
| 1238 | for (k = 0; k < template[i].np; k++) { |
| 1239 | if (WARN_ON(offset_in_page(IDX[k]) + |
| 1240 | template[i].tap[k] > PAGE_SIZE)) |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1241 | goto out; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1242 | |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1243 | q = xbuf[IDX[k] >> PAGE_SHIFT] + offset_in_page(IDX[k]); |
| 1244 | |
| 1245 | memcpy(q, template[i].input + temp, template[i].tap[k]); |
| 1246 | |
| 1247 | if (offset_in_page(q) + template[i].tap[k] < PAGE_SIZE) |
| 1248 | q[template[i].tap[k]] = 0; |
| 1249 | |
| 1250 | sg_set_buf(&sg[k], q, template[i].tap[k]); |
| 1251 | if (diff_dst) { |
| 1252 | q = xoutbuf[IDX[k] >> PAGE_SHIFT] + |
| 1253 | offset_in_page(IDX[k]); |
| 1254 | |
| 1255 | sg_set_buf(&sgout[k], q, template[i].tap[k]); |
| 1256 | |
| 1257 | memset(q, 0, template[i].tap[k]); |
| 1258 | if (offset_in_page(q) + |
| 1259 | template[i].tap[k] < PAGE_SIZE) |
| 1260 | q[template[i].tap[k]] = 0; |
| 1261 | } |
| 1262 | |
| 1263 | temp += template[i].tap[k]; |
| 1264 | } |
| 1265 | |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1266 | skcipher_request_set_crypt(req, sg, (diff_dst) ? sgout : sg, |
| 1267 | template[i].ilen, iv); |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1268 | |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1269 | ret = enc ? crypto_skcipher_encrypt(req) : |
| 1270 | crypto_skcipher_decrypt(req); |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1271 | |
| 1272 | switch (ret) { |
| 1273 | case 0: |
| 1274 | break; |
| 1275 | case -EINPROGRESS: |
| 1276 | case -EBUSY: |
Rabin Vincent | 8a45ac1 | 2015-01-09 16:25:28 +0100 | [diff] [blame] | 1277 | wait_for_completion(&result.completion); |
| 1278 | reinit_completion(&result.completion); |
| 1279 | ret = result.err; |
| 1280 | if (!ret) |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1281 | break; |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1282 | /* fall through */ |
| 1283 | default: |
| 1284 | pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n", |
| 1285 | d, e, j, algo, -ret); |
| 1286 | goto out; |
| 1287 | } |
| 1288 | |
| 1289 | temp = 0; |
| 1290 | ret = -EINVAL; |
| 1291 | for (k = 0; k < template[i].np; k++) { |
Jussi Kivilinna | 08d6af8 | 2012-09-21 10:26:47 +0300 | [diff] [blame] | 1292 | if (diff_dst) |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1293 | q = xoutbuf[IDX[k] >> PAGE_SHIFT] + |
| 1294 | offset_in_page(IDX[k]); |
| 1295 | else |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1296 | q = xbuf[IDX[k] >> PAGE_SHIFT] + |
| 1297 | offset_in_page(IDX[k]); |
| 1298 | |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1299 | if (memcmp(q, template[i].result + temp, |
| 1300 | template[i].tap[k])) { |
| 1301 | pr_err("alg: skcipher%s: Chunk test %d failed on %s at page %u for %s\n", |
| 1302 | d, j, e, k, algo); |
| 1303 | hexdump(q, template[i].tap[k]); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1304 | goto out; |
| 1305 | } |
| 1306 | |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1307 | q += template[i].tap[k]; |
| 1308 | for (n = 0; offset_in_page(q + n) && q[n]; n++) |
| 1309 | ; |
| 1310 | if (n) { |
| 1311 | pr_err("alg: skcipher%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n", |
| 1312 | d, j, e, k, algo, n); |
| 1313 | hexdump(q, n); |
| 1314 | goto out; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1315 | } |
Cristian Stoica | a1aa44a | 2014-08-08 14:27:51 +0300 | [diff] [blame] | 1316 | temp += template[i].tap[k]; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1317 | } |
| 1318 | } |
| 1319 | |
| 1320 | ret = 0; |
| 1321 | |
| 1322 | out: |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1323 | skcipher_request_free(req); |
Jussi Kivilinna | 08d6af8 | 2012-09-21 10:26:47 +0300 | [diff] [blame] | 1324 | if (diff_dst) |
| 1325 | testmgr_free_buf(xoutbuf); |
| 1326 | out_nooutbuf: |
Herbert Xu | f8b0d4d | 2009-05-06 14:15:47 +0800 | [diff] [blame] | 1327 | testmgr_free_buf(xbuf); |
| 1328 | out_nobuf: |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1329 | return ret; |
| 1330 | } |
| 1331 | |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1332 | static int test_skcipher(struct crypto_skcipher *tfm, int enc, |
Jussi Kivilinna | 08d6af8 | 2012-09-21 10:26:47 +0300 | [diff] [blame] | 1333 | struct cipher_testvec *template, unsigned int tcount) |
| 1334 | { |
Jussi Kivilinna | 3a338f2 | 2013-06-13 17:37:45 +0300 | [diff] [blame] | 1335 | unsigned int alignmask; |
Jussi Kivilinna | 08d6af8 | 2012-09-21 10:26:47 +0300 | [diff] [blame] | 1336 | int ret; |
| 1337 | |
| 1338 | /* test 'dst == src' case */ |
Jussi Kivilinna | 3a338f2 | 2013-06-13 17:37:45 +0300 | [diff] [blame] | 1339 | ret = __test_skcipher(tfm, enc, template, tcount, false, 0); |
Jussi Kivilinna | 08d6af8 | 2012-09-21 10:26:47 +0300 | [diff] [blame] | 1340 | if (ret) |
| 1341 | return ret; |
| 1342 | |
| 1343 | /* test 'dst != src' case */ |
Jussi Kivilinna | 3a338f2 | 2013-06-13 17:37:45 +0300 | [diff] [blame] | 1344 | ret = __test_skcipher(tfm, enc, template, tcount, true, 0); |
| 1345 | if (ret) |
| 1346 | return ret; |
| 1347 | |
| 1348 | /* test unaligned buffers, check with one byte offset */ |
| 1349 | ret = __test_skcipher(tfm, enc, template, tcount, true, 1); |
| 1350 | if (ret) |
| 1351 | return ret; |
| 1352 | |
| 1353 | alignmask = crypto_tfm_alg_alignmask(&tfm->base); |
| 1354 | if (alignmask) { |
| 1355 | /* Check if alignment mask for tfm is correctly set. */ |
| 1356 | ret = __test_skcipher(tfm, enc, template, tcount, true, |
| 1357 | alignmask + 1); |
| 1358 | if (ret) |
| 1359 | return ret; |
| 1360 | } |
| 1361 | |
| 1362 | return 0; |
Jussi Kivilinna | 08d6af8 | 2012-09-21 10:26:47 +0300 | [diff] [blame] | 1363 | } |
| 1364 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1365 | static int test_comp(struct crypto_comp *tfm, struct comp_testvec *ctemplate, |
| 1366 | struct comp_testvec *dtemplate, int ctcount, int dtcount) |
| 1367 | { |
| 1368 | const char *algo = crypto_tfm_alg_driver_name(crypto_comp_tfm(tfm)); |
| 1369 | unsigned int i; |
| 1370 | char result[COMP_BUF_SIZE]; |
| 1371 | int ret; |
| 1372 | |
| 1373 | for (i = 0; i < ctcount; i++) { |
Geert Uytterhoeven | c79cf91 | 2009-03-29 15:44:19 +0800 | [diff] [blame] | 1374 | int ilen; |
| 1375 | unsigned int dlen = COMP_BUF_SIZE; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1376 | |
| 1377 | memset(result, 0, sizeof (result)); |
| 1378 | |
| 1379 | ilen = ctemplate[i].inlen; |
| 1380 | ret = crypto_comp_compress(tfm, ctemplate[i].input, |
| 1381 | ilen, result, &dlen); |
| 1382 | if (ret) { |
| 1383 | printk(KERN_ERR "alg: comp: compression failed " |
| 1384 | "on test %d for %s: ret=%d\n", i + 1, algo, |
| 1385 | -ret); |
| 1386 | goto out; |
| 1387 | } |
| 1388 | |
Geert Uytterhoeven | b812eb0 | 2008-11-28 20:51:28 +0800 | [diff] [blame] | 1389 | if (dlen != ctemplate[i].outlen) { |
| 1390 | printk(KERN_ERR "alg: comp: Compression test %d " |
| 1391 | "failed for %s: output len = %d\n", i + 1, algo, |
| 1392 | dlen); |
| 1393 | ret = -EINVAL; |
| 1394 | goto out; |
| 1395 | } |
| 1396 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1397 | if (memcmp(result, ctemplate[i].output, dlen)) { |
| 1398 | printk(KERN_ERR "alg: comp: Compression test %d " |
| 1399 | "failed for %s\n", i + 1, algo); |
| 1400 | hexdump(result, dlen); |
| 1401 | ret = -EINVAL; |
| 1402 | goto out; |
| 1403 | } |
| 1404 | } |
| 1405 | |
| 1406 | for (i = 0; i < dtcount; i++) { |
Geert Uytterhoeven | c79cf91 | 2009-03-29 15:44:19 +0800 | [diff] [blame] | 1407 | int ilen; |
| 1408 | unsigned int dlen = COMP_BUF_SIZE; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1409 | |
| 1410 | memset(result, 0, sizeof (result)); |
| 1411 | |
| 1412 | ilen = dtemplate[i].inlen; |
| 1413 | ret = crypto_comp_decompress(tfm, dtemplate[i].input, |
| 1414 | ilen, result, &dlen); |
| 1415 | if (ret) { |
| 1416 | printk(KERN_ERR "alg: comp: decompression failed " |
| 1417 | "on test %d for %s: ret=%d\n", i + 1, algo, |
| 1418 | -ret); |
| 1419 | goto out; |
| 1420 | } |
| 1421 | |
Geert Uytterhoeven | b812eb0 | 2008-11-28 20:51:28 +0800 | [diff] [blame] | 1422 | if (dlen != dtemplate[i].outlen) { |
| 1423 | printk(KERN_ERR "alg: comp: Decompression test %d " |
| 1424 | "failed for %s: output len = %d\n", i + 1, algo, |
| 1425 | dlen); |
| 1426 | ret = -EINVAL; |
| 1427 | goto out; |
| 1428 | } |
| 1429 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1430 | if (memcmp(result, dtemplate[i].output, dlen)) { |
| 1431 | printk(KERN_ERR "alg: comp: Decompression test %d " |
| 1432 | "failed for %s\n", i + 1, algo); |
| 1433 | hexdump(result, dlen); |
| 1434 | ret = -EINVAL; |
| 1435 | goto out; |
| 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | ret = 0; |
| 1440 | |
| 1441 | out: |
| 1442 | return ret; |
| 1443 | } |
| 1444 | |
Jarod Wilson | 7647d6c | 2009-05-04 19:44:50 +0800 | [diff] [blame] | 1445 | static int test_cprng(struct crypto_rng *tfm, struct cprng_testvec *template, |
| 1446 | unsigned int tcount) |
| 1447 | { |
| 1448 | const char *algo = crypto_tfm_alg_driver_name(crypto_rng_tfm(tfm)); |
Felipe Contreras | fa4ef8a | 2009-10-27 19:04:42 +0800 | [diff] [blame] | 1449 | int err = 0, i, j, seedsize; |
Jarod Wilson | 7647d6c | 2009-05-04 19:44:50 +0800 | [diff] [blame] | 1450 | u8 *seed; |
| 1451 | char result[32]; |
| 1452 | |
| 1453 | seedsize = crypto_rng_seedsize(tfm); |
| 1454 | |
| 1455 | seed = kmalloc(seedsize, GFP_KERNEL); |
| 1456 | if (!seed) { |
| 1457 | printk(KERN_ERR "alg: cprng: Failed to allocate seed space " |
| 1458 | "for %s\n", algo); |
| 1459 | return -ENOMEM; |
| 1460 | } |
| 1461 | |
| 1462 | for (i = 0; i < tcount; i++) { |
| 1463 | memset(result, 0, 32); |
| 1464 | |
| 1465 | memcpy(seed, template[i].v, template[i].vlen); |
| 1466 | memcpy(seed + template[i].vlen, template[i].key, |
| 1467 | template[i].klen); |
| 1468 | memcpy(seed + template[i].vlen + template[i].klen, |
| 1469 | template[i].dt, template[i].dtlen); |
| 1470 | |
| 1471 | err = crypto_rng_reset(tfm, seed, seedsize); |
| 1472 | if (err) { |
| 1473 | printk(KERN_ERR "alg: cprng: Failed to reset rng " |
| 1474 | "for %s\n", algo); |
| 1475 | goto out; |
| 1476 | } |
| 1477 | |
| 1478 | for (j = 0; j < template[i].loops; j++) { |
| 1479 | err = crypto_rng_get_bytes(tfm, result, |
| 1480 | template[i].rlen); |
Stephan Mueller | 19e60e1 | 2015-03-10 17:00:36 +0100 | [diff] [blame] | 1481 | if (err < 0) { |
Jarod Wilson | 7647d6c | 2009-05-04 19:44:50 +0800 | [diff] [blame] | 1482 | printk(KERN_ERR "alg: cprng: Failed to obtain " |
| 1483 | "the correct amount of random data for " |
Stephan Mueller | 19e60e1 | 2015-03-10 17:00:36 +0100 | [diff] [blame] | 1484 | "%s (requested %d)\n", algo, |
| 1485 | template[i].rlen); |
Jarod Wilson | 7647d6c | 2009-05-04 19:44:50 +0800 | [diff] [blame] | 1486 | goto out; |
| 1487 | } |
| 1488 | } |
| 1489 | |
| 1490 | err = memcmp(result, template[i].result, |
| 1491 | template[i].rlen); |
| 1492 | if (err) { |
| 1493 | printk(KERN_ERR "alg: cprng: Test %d failed for %s\n", |
| 1494 | i, algo); |
| 1495 | hexdump(result, template[i].rlen); |
| 1496 | err = -EINVAL; |
| 1497 | goto out; |
| 1498 | } |
| 1499 | } |
| 1500 | |
| 1501 | out: |
| 1502 | kfree(seed); |
| 1503 | return err; |
| 1504 | } |
| 1505 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1506 | static int alg_test_aead(const struct alg_test_desc *desc, const char *driver, |
| 1507 | u32 type, u32 mask) |
| 1508 | { |
| 1509 | struct crypto_aead *tfm; |
| 1510 | int err = 0; |
| 1511 | |
Stephan Mueller | 425a882 | 2015-03-30 21:56:31 +0200 | [diff] [blame] | 1512 | tfm = crypto_alloc_aead(driver, type | CRYPTO_ALG_INTERNAL, mask); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1513 | if (IS_ERR(tfm)) { |
| 1514 | printk(KERN_ERR "alg: aead: Failed to load transform for %s: " |
| 1515 | "%ld\n", driver, PTR_ERR(tfm)); |
| 1516 | return PTR_ERR(tfm); |
| 1517 | } |
| 1518 | |
| 1519 | if (desc->suite.aead.enc.vecs) { |
| 1520 | err = test_aead(tfm, ENCRYPT, desc->suite.aead.enc.vecs, |
| 1521 | desc->suite.aead.enc.count); |
| 1522 | if (err) |
| 1523 | goto out; |
| 1524 | } |
| 1525 | |
| 1526 | if (!err && desc->suite.aead.dec.vecs) |
| 1527 | err = test_aead(tfm, DECRYPT, desc->suite.aead.dec.vecs, |
| 1528 | desc->suite.aead.dec.count); |
| 1529 | |
| 1530 | out: |
| 1531 | crypto_free_aead(tfm); |
| 1532 | return err; |
| 1533 | } |
| 1534 | |
| 1535 | static int alg_test_cipher(const struct alg_test_desc *desc, |
| 1536 | const char *driver, u32 type, u32 mask) |
| 1537 | { |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 1538 | struct crypto_cipher *tfm; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1539 | int err = 0; |
| 1540 | |
Stephan Mueller | 425a882 | 2015-03-30 21:56:31 +0200 | [diff] [blame] | 1541 | tfm = crypto_alloc_cipher(driver, type | CRYPTO_ALG_INTERNAL, mask); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1542 | if (IS_ERR(tfm)) { |
| 1543 | printk(KERN_ERR "alg: cipher: Failed to load transform for " |
| 1544 | "%s: %ld\n", driver, PTR_ERR(tfm)); |
| 1545 | return PTR_ERR(tfm); |
| 1546 | } |
| 1547 | |
| 1548 | if (desc->suite.cipher.enc.vecs) { |
| 1549 | err = test_cipher(tfm, ENCRYPT, desc->suite.cipher.enc.vecs, |
| 1550 | desc->suite.cipher.enc.count); |
| 1551 | if (err) |
| 1552 | goto out; |
| 1553 | } |
| 1554 | |
| 1555 | if (desc->suite.cipher.dec.vecs) |
| 1556 | err = test_cipher(tfm, DECRYPT, desc->suite.cipher.dec.vecs, |
| 1557 | desc->suite.cipher.dec.count); |
| 1558 | |
| 1559 | out: |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 1560 | crypto_free_cipher(tfm); |
| 1561 | return err; |
| 1562 | } |
| 1563 | |
| 1564 | static int alg_test_skcipher(const struct alg_test_desc *desc, |
| 1565 | const char *driver, u32 type, u32 mask) |
| 1566 | { |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1567 | struct crypto_skcipher *tfm; |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 1568 | int err = 0; |
| 1569 | |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1570 | tfm = crypto_alloc_skcipher(driver, type | CRYPTO_ALG_INTERNAL, mask); |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 1571 | if (IS_ERR(tfm)) { |
| 1572 | printk(KERN_ERR "alg: skcipher: Failed to load transform for " |
| 1573 | "%s: %ld\n", driver, PTR_ERR(tfm)); |
| 1574 | return PTR_ERR(tfm); |
| 1575 | } |
| 1576 | |
| 1577 | if (desc->suite.cipher.enc.vecs) { |
| 1578 | err = test_skcipher(tfm, ENCRYPT, desc->suite.cipher.enc.vecs, |
| 1579 | desc->suite.cipher.enc.count); |
| 1580 | if (err) |
| 1581 | goto out; |
| 1582 | } |
| 1583 | |
| 1584 | if (desc->suite.cipher.dec.vecs) |
| 1585 | err = test_skcipher(tfm, DECRYPT, desc->suite.cipher.dec.vecs, |
| 1586 | desc->suite.cipher.dec.count); |
| 1587 | |
| 1588 | out: |
Herbert Xu | 12773d9 | 2015-08-20 15:21:46 +0800 | [diff] [blame] | 1589 | crypto_free_skcipher(tfm); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1590 | return err; |
| 1591 | } |
| 1592 | |
| 1593 | static int alg_test_comp(const struct alg_test_desc *desc, const char *driver, |
| 1594 | u32 type, u32 mask) |
| 1595 | { |
| 1596 | struct crypto_comp *tfm; |
| 1597 | int err; |
| 1598 | |
| 1599 | tfm = crypto_alloc_comp(driver, type, mask); |
| 1600 | if (IS_ERR(tfm)) { |
| 1601 | printk(KERN_ERR "alg: comp: Failed to load transform for %s: " |
| 1602 | "%ld\n", driver, PTR_ERR(tfm)); |
| 1603 | return PTR_ERR(tfm); |
| 1604 | } |
| 1605 | |
| 1606 | err = test_comp(tfm, desc->suite.comp.comp.vecs, |
| 1607 | desc->suite.comp.decomp.vecs, |
| 1608 | desc->suite.comp.comp.count, |
| 1609 | desc->suite.comp.decomp.count); |
| 1610 | |
| 1611 | crypto_free_comp(tfm); |
| 1612 | return err; |
| 1613 | } |
| 1614 | |
| 1615 | static int alg_test_hash(const struct alg_test_desc *desc, const char *driver, |
| 1616 | u32 type, u32 mask) |
| 1617 | { |
| 1618 | struct crypto_ahash *tfm; |
| 1619 | int err; |
| 1620 | |
Stephan Mueller | 425a882 | 2015-03-30 21:56:31 +0200 | [diff] [blame] | 1621 | tfm = crypto_alloc_ahash(driver, type | CRYPTO_ALG_INTERNAL, mask); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1622 | if (IS_ERR(tfm)) { |
| 1623 | printk(KERN_ERR "alg: hash: Failed to load transform for %s: " |
| 1624 | "%ld\n", driver, PTR_ERR(tfm)); |
| 1625 | return PTR_ERR(tfm); |
| 1626 | } |
| 1627 | |
David S. Miller | a8f1a05 | 2010-05-19 14:12:03 +1000 | [diff] [blame] | 1628 | err = test_hash(tfm, desc->suite.hash.vecs, |
| 1629 | desc->suite.hash.count, true); |
| 1630 | if (!err) |
| 1631 | err = test_hash(tfm, desc->suite.hash.vecs, |
| 1632 | desc->suite.hash.count, false); |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 1633 | |
| 1634 | crypto_free_ahash(tfm); |
| 1635 | return err; |
| 1636 | } |
| 1637 | |
Herbert Xu | 8e3ee85 | 2008-11-07 14:58:52 +0800 | [diff] [blame] | 1638 | static int alg_test_crc32c(const struct alg_test_desc *desc, |
| 1639 | const char *driver, u32 type, u32 mask) |
| 1640 | { |
| 1641 | struct crypto_shash *tfm; |
| 1642 | u32 val; |
| 1643 | int err; |
| 1644 | |
| 1645 | err = alg_test_hash(desc, driver, type, mask); |
| 1646 | if (err) |
| 1647 | goto out; |
| 1648 | |
Stephan Mueller | 425a882 | 2015-03-30 21:56:31 +0200 | [diff] [blame] | 1649 | tfm = crypto_alloc_shash(driver, type | CRYPTO_ALG_INTERNAL, mask); |
Herbert Xu | 8e3ee85 | 2008-11-07 14:58:52 +0800 | [diff] [blame] | 1650 | if (IS_ERR(tfm)) { |
| 1651 | printk(KERN_ERR "alg: crc32c: Failed to load transform for %s: " |
| 1652 | "%ld\n", driver, PTR_ERR(tfm)); |
| 1653 | err = PTR_ERR(tfm); |
| 1654 | goto out; |
| 1655 | } |
| 1656 | |
| 1657 | do { |
Jan-Simon Möller | 4c5c302 | 2012-07-02 13:48:30 +0200 | [diff] [blame] | 1658 | SHASH_DESC_ON_STACK(shash, tfm); |
| 1659 | u32 *ctx = (u32 *)shash_desc_ctx(shash); |
Herbert Xu | 8e3ee85 | 2008-11-07 14:58:52 +0800 | [diff] [blame] | 1660 | |
Jan-Simon Möller | 4c5c302 | 2012-07-02 13:48:30 +0200 | [diff] [blame] | 1661 | shash->tfm = tfm; |
| 1662 | shash->flags = 0; |
Herbert Xu | 8e3ee85 | 2008-11-07 14:58:52 +0800 | [diff] [blame] | 1663 | |
Jan-Simon Möller | 4c5c302 | 2012-07-02 13:48:30 +0200 | [diff] [blame] | 1664 | *ctx = le32_to_cpu(420553207); |
| 1665 | err = crypto_shash_final(shash, (u8 *)&val); |
Herbert Xu | 8e3ee85 | 2008-11-07 14:58:52 +0800 | [diff] [blame] | 1666 | if (err) { |
| 1667 | printk(KERN_ERR "alg: crc32c: Operation failed for " |
| 1668 | "%s: %d\n", driver, err); |
| 1669 | break; |
| 1670 | } |
| 1671 | |
| 1672 | if (val != ~420553207) { |
| 1673 | printk(KERN_ERR "alg: crc32c: Test failed for %s: " |
| 1674 | "%d\n", driver, val); |
| 1675 | err = -EINVAL; |
| 1676 | } |
| 1677 | } while (0); |
| 1678 | |
| 1679 | crypto_free_shash(tfm); |
| 1680 | |
| 1681 | out: |
| 1682 | return err; |
| 1683 | } |
| 1684 | |
Jarod Wilson | 7647d6c | 2009-05-04 19:44:50 +0800 | [diff] [blame] | 1685 | static int alg_test_cprng(const struct alg_test_desc *desc, const char *driver, |
| 1686 | u32 type, u32 mask) |
| 1687 | { |
| 1688 | struct crypto_rng *rng; |
| 1689 | int err; |
| 1690 | |
Stephan Mueller | 425a882 | 2015-03-30 21:56:31 +0200 | [diff] [blame] | 1691 | rng = crypto_alloc_rng(driver, type | CRYPTO_ALG_INTERNAL, mask); |
Jarod Wilson | 7647d6c | 2009-05-04 19:44:50 +0800 | [diff] [blame] | 1692 | if (IS_ERR(rng)) { |
| 1693 | printk(KERN_ERR "alg: cprng: Failed to load transform for %s: " |
| 1694 | "%ld\n", driver, PTR_ERR(rng)); |
| 1695 | return PTR_ERR(rng); |
| 1696 | } |
| 1697 | |
| 1698 | err = test_cprng(rng, desc->suite.cprng.vecs, desc->suite.cprng.count); |
| 1699 | |
| 1700 | crypto_free_rng(rng); |
| 1701 | |
| 1702 | return err; |
| 1703 | } |
| 1704 | |
Stephan Mueller | 64d1cdf | 2014-05-31 17:25:36 +0200 | [diff] [blame] | 1705 | |
| 1706 | static int drbg_cavs_test(struct drbg_testvec *test, int pr, |
| 1707 | const char *driver, u32 type, u32 mask) |
| 1708 | { |
| 1709 | int ret = -EAGAIN; |
| 1710 | struct crypto_rng *drng; |
| 1711 | struct drbg_test_data test_data; |
| 1712 | struct drbg_string addtl, pers, testentropy; |
| 1713 | unsigned char *buf = kzalloc(test->expectedlen, GFP_KERNEL); |
| 1714 | |
| 1715 | if (!buf) |
| 1716 | return -ENOMEM; |
| 1717 | |
Stephan Mueller | 425a882 | 2015-03-30 21:56:31 +0200 | [diff] [blame] | 1718 | drng = crypto_alloc_rng(driver, type | CRYPTO_ALG_INTERNAL, mask); |
Stephan Mueller | 64d1cdf | 2014-05-31 17:25:36 +0200 | [diff] [blame] | 1719 | if (IS_ERR(drng)) { |
Jarod Wilson | 2fc0d25 | 2014-07-29 15:47:56 -0400 | [diff] [blame] | 1720 | printk(KERN_ERR "alg: drbg: could not allocate DRNG handle for " |
Stephan Mueller | 64d1cdf | 2014-05-31 17:25:36 +0200 | [diff] [blame] | 1721 | "%s\n", driver); |
| 1722 | kzfree(buf); |
| 1723 | return -ENOMEM; |
| 1724 | } |
| 1725 | |
| 1726 | test_data.testentropy = &testentropy; |
| 1727 | drbg_string_fill(&testentropy, test->entropy, test->entropylen); |
| 1728 | drbg_string_fill(&pers, test->pers, test->perslen); |
| 1729 | ret = crypto_drbg_reset_test(drng, &pers, &test_data); |
| 1730 | if (ret) { |
| 1731 | printk(KERN_ERR "alg: drbg: Failed to reset rng\n"); |
| 1732 | goto outbuf; |
| 1733 | } |
| 1734 | |
| 1735 | drbg_string_fill(&addtl, test->addtla, test->addtllen); |
| 1736 | if (pr) { |
| 1737 | drbg_string_fill(&testentropy, test->entpra, test->entprlen); |
| 1738 | ret = crypto_drbg_get_bytes_addtl_test(drng, |
| 1739 | buf, test->expectedlen, &addtl, &test_data); |
| 1740 | } else { |
| 1741 | ret = crypto_drbg_get_bytes_addtl(drng, |
| 1742 | buf, test->expectedlen, &addtl); |
| 1743 | } |
Stephan Mueller | 19e60e1 | 2015-03-10 17:00:36 +0100 | [diff] [blame] | 1744 | if (ret < 0) { |
Jarod Wilson | 2fc0d25 | 2014-07-29 15:47:56 -0400 | [diff] [blame] | 1745 | printk(KERN_ERR "alg: drbg: could not obtain random data for " |
Stephan Mueller | 64d1cdf | 2014-05-31 17:25:36 +0200 | [diff] [blame] | 1746 | "driver %s\n", driver); |
| 1747 | goto outbuf; |
| 1748 | } |
| 1749 | |
| 1750 | drbg_string_fill(&addtl, test->addtlb, test->addtllen); |
| 1751 | if (pr) { |
| 1752 | drbg_string_fill(&testentropy, test->entprb, test->entprlen); |
| 1753 | ret = crypto_drbg_get_bytes_addtl_test(drng, |
| 1754 | buf, test->expectedlen, &addtl, &test_data); |
| 1755 | } else { |
| 1756 | ret = crypto_drbg_get_bytes_addtl(drng, |
| 1757 | buf, test->expectedlen, &addtl); |
| 1758 | } |
Stephan Mueller | 19e60e1 | 2015-03-10 17:00:36 +0100 | [diff] [blame] | 1759 | if (ret < 0) { |
Jarod Wilson | 2fc0d25 | 2014-07-29 15:47:56 -0400 | [diff] [blame] | 1760 | printk(KERN_ERR "alg: drbg: could not obtain random data for " |
Stephan Mueller | 64d1cdf | 2014-05-31 17:25:36 +0200 | [diff] [blame] | 1761 | "driver %s\n", driver); |
| 1762 | goto outbuf; |
| 1763 | } |
| 1764 | |
| 1765 | ret = memcmp(test->expected, buf, test->expectedlen); |
| 1766 | |
| 1767 | outbuf: |
| 1768 | crypto_free_rng(drng); |
| 1769 | kzfree(buf); |
| 1770 | return ret; |
| 1771 | } |
| 1772 | |
| 1773 | |
| 1774 | static int alg_test_drbg(const struct alg_test_desc *desc, const char *driver, |
| 1775 | u32 type, u32 mask) |
| 1776 | { |
| 1777 | int err = 0; |
| 1778 | int pr = 0; |
| 1779 | int i = 0; |
| 1780 | struct drbg_testvec *template = desc->suite.drbg.vecs; |
| 1781 | unsigned int tcount = desc->suite.drbg.count; |
| 1782 | |
| 1783 | if (0 == memcmp(driver, "drbg_pr_", 8)) |
| 1784 | pr = 1; |
| 1785 | |
| 1786 | for (i = 0; i < tcount; i++) { |
| 1787 | err = drbg_cavs_test(&template[i], pr, driver, type, mask); |
| 1788 | if (err) { |
| 1789 | printk(KERN_ERR "alg: drbg: Test %d failed for %s\n", |
| 1790 | i, driver); |
| 1791 | err = -EINVAL; |
| 1792 | break; |
| 1793 | } |
| 1794 | } |
| 1795 | return err; |
| 1796 | |
| 1797 | } |
| 1798 | |
Salvatore Benedetto | 802c7f1 | 2016-06-22 17:49:14 +0100 | [diff] [blame] | 1799 | static int do_test_kpp(struct crypto_kpp *tfm, struct kpp_testvec *vec, |
| 1800 | const char *alg) |
| 1801 | { |
| 1802 | struct kpp_request *req; |
| 1803 | void *input_buf = NULL; |
| 1804 | void *output_buf = NULL; |
| 1805 | struct tcrypt_result result; |
| 1806 | unsigned int out_len_max; |
| 1807 | int err = -ENOMEM; |
| 1808 | struct scatterlist src, dst; |
| 1809 | |
| 1810 | req = kpp_request_alloc(tfm, GFP_KERNEL); |
| 1811 | if (!req) |
| 1812 | return err; |
| 1813 | |
| 1814 | init_completion(&result.completion); |
| 1815 | |
| 1816 | err = crypto_kpp_set_secret(tfm, vec->secret, vec->secret_size); |
| 1817 | if (err < 0) |
| 1818 | goto free_req; |
| 1819 | |
| 1820 | out_len_max = crypto_kpp_maxsize(tfm); |
| 1821 | output_buf = kzalloc(out_len_max, GFP_KERNEL); |
| 1822 | if (!output_buf) { |
| 1823 | err = -ENOMEM; |
| 1824 | goto free_req; |
| 1825 | } |
| 1826 | |
| 1827 | /* Use appropriate parameter as base */ |
| 1828 | kpp_request_set_input(req, NULL, 0); |
| 1829 | sg_init_one(&dst, output_buf, out_len_max); |
| 1830 | kpp_request_set_output(req, &dst, out_len_max); |
| 1831 | kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 1832 | tcrypt_complete, &result); |
| 1833 | |
| 1834 | /* Compute public key */ |
| 1835 | err = wait_async_op(&result, crypto_kpp_generate_public_key(req)); |
| 1836 | if (err) { |
| 1837 | pr_err("alg: %s: generate public key test failed. err %d\n", |
| 1838 | alg, err); |
| 1839 | goto free_output; |
| 1840 | } |
| 1841 | /* Verify calculated public key */ |
| 1842 | if (memcmp(vec->expected_a_public, sg_virt(req->dst), |
| 1843 | vec->expected_a_public_size)) { |
| 1844 | pr_err("alg: %s: generate public key test failed. Invalid output\n", |
| 1845 | alg); |
| 1846 | err = -EINVAL; |
| 1847 | goto free_output; |
| 1848 | } |
| 1849 | |
| 1850 | /* Calculate shared secret key by using counter part (b) public key. */ |
| 1851 | input_buf = kzalloc(vec->b_public_size, GFP_KERNEL); |
| 1852 | if (!input_buf) { |
| 1853 | err = -ENOMEM; |
| 1854 | goto free_output; |
| 1855 | } |
| 1856 | |
| 1857 | memcpy(input_buf, vec->b_public, vec->b_public_size); |
| 1858 | sg_init_one(&src, input_buf, vec->b_public_size); |
| 1859 | sg_init_one(&dst, output_buf, out_len_max); |
| 1860 | kpp_request_set_input(req, &src, vec->b_public_size); |
| 1861 | kpp_request_set_output(req, &dst, out_len_max); |
| 1862 | kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 1863 | tcrypt_complete, &result); |
| 1864 | err = wait_async_op(&result, crypto_kpp_compute_shared_secret(req)); |
| 1865 | if (err) { |
| 1866 | pr_err("alg: %s: compute shard secret test failed. err %d\n", |
| 1867 | alg, err); |
| 1868 | goto free_all; |
| 1869 | } |
| 1870 | /* |
| 1871 | * verify shared secret from which the user will derive |
| 1872 | * secret key by executing whatever hash it has chosen |
| 1873 | */ |
| 1874 | if (memcmp(vec->expected_ss, sg_virt(req->dst), |
| 1875 | vec->expected_ss_size)) { |
| 1876 | pr_err("alg: %s: compute shared secret test failed. Invalid output\n", |
| 1877 | alg); |
| 1878 | err = -EINVAL; |
| 1879 | } |
| 1880 | |
| 1881 | free_all: |
| 1882 | kfree(input_buf); |
| 1883 | free_output: |
| 1884 | kfree(output_buf); |
| 1885 | free_req: |
| 1886 | kpp_request_free(req); |
| 1887 | return err; |
| 1888 | } |
| 1889 | |
| 1890 | static int test_kpp(struct crypto_kpp *tfm, const char *alg, |
| 1891 | struct kpp_testvec *vecs, unsigned int tcount) |
| 1892 | { |
| 1893 | int ret, i; |
| 1894 | |
| 1895 | for (i = 0; i < tcount; i++) { |
| 1896 | ret = do_test_kpp(tfm, vecs++, alg); |
| 1897 | if (ret) { |
| 1898 | pr_err("alg: %s: test failed on vector %d, err=%d\n", |
| 1899 | alg, i + 1, ret); |
| 1900 | return ret; |
| 1901 | } |
| 1902 | } |
| 1903 | return 0; |
| 1904 | } |
| 1905 | |
| 1906 | static int alg_test_kpp(const struct alg_test_desc *desc, const char *driver, |
| 1907 | u32 type, u32 mask) |
| 1908 | { |
| 1909 | struct crypto_kpp *tfm; |
| 1910 | int err = 0; |
| 1911 | |
| 1912 | tfm = crypto_alloc_kpp(driver, type | CRYPTO_ALG_INTERNAL, mask); |
| 1913 | if (IS_ERR(tfm)) { |
| 1914 | pr_err("alg: kpp: Failed to load tfm for %s: %ld\n", |
| 1915 | driver, PTR_ERR(tfm)); |
| 1916 | return PTR_ERR(tfm); |
| 1917 | } |
| 1918 | if (desc->suite.kpp.vecs) |
| 1919 | err = test_kpp(tfm, desc->alg, desc->suite.kpp.vecs, |
| 1920 | desc->suite.kpp.count); |
| 1921 | |
| 1922 | crypto_free_kpp(tfm); |
| 1923 | return err; |
| 1924 | } |
| 1925 | |
Herbert Xu | 50d2b643 | 2016-06-29 19:32:20 +0800 | [diff] [blame] | 1926 | static int test_akcipher_one(struct crypto_akcipher *tfm, |
| 1927 | struct akcipher_testvec *vecs) |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 1928 | { |
Herbert Xu | df27b26 | 2016-05-05 16:42:49 +0800 | [diff] [blame] | 1929 | char *xbuf[XBUFSIZE]; |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 1930 | struct akcipher_request *req; |
| 1931 | void *outbuf_enc = NULL; |
| 1932 | void *outbuf_dec = NULL; |
| 1933 | struct tcrypt_result result; |
| 1934 | unsigned int out_len_max, out_len = 0; |
| 1935 | int err = -ENOMEM; |
Tadeusz Struk | 22287b0 | 2015-10-08 09:26:55 -0700 | [diff] [blame] | 1936 | struct scatterlist src, dst, src_tab[2]; |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 1937 | |
Herbert Xu | df27b26 | 2016-05-05 16:42:49 +0800 | [diff] [blame] | 1938 | if (testmgr_alloc_buf(xbuf)) |
| 1939 | return err; |
| 1940 | |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 1941 | req = akcipher_request_alloc(tfm, GFP_KERNEL); |
| 1942 | if (!req) |
Herbert Xu | df27b26 | 2016-05-05 16:42:49 +0800 | [diff] [blame] | 1943 | goto free_xbuf; |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 1944 | |
| 1945 | init_completion(&result.completion); |
Tadeusz Struk | 22287b0 | 2015-10-08 09:26:55 -0700 | [diff] [blame] | 1946 | |
| 1947 | if (vecs->public_key_vec) |
| 1948 | err = crypto_akcipher_set_pub_key(tfm, vecs->key, |
| 1949 | vecs->key_len); |
| 1950 | else |
| 1951 | err = crypto_akcipher_set_priv_key(tfm, vecs->key, |
| 1952 | vecs->key_len); |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 1953 | if (err) |
| 1954 | goto free_req; |
| 1955 | |
Salvatore Benedetto | 57763f5 | 2016-07-04 10:52:34 +0100 | [diff] [blame] | 1956 | err = -ENOMEM; |
Tadeusz Struk | 22287b0 | 2015-10-08 09:26:55 -0700 | [diff] [blame] | 1957 | out_len_max = crypto_akcipher_maxsize(tfm); |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 1958 | outbuf_enc = kzalloc(out_len_max, GFP_KERNEL); |
| 1959 | if (!outbuf_enc) |
| 1960 | goto free_req; |
| 1961 | |
Herbert Xu | df27b26 | 2016-05-05 16:42:49 +0800 | [diff] [blame] | 1962 | if (WARN_ON(vecs->m_size > PAGE_SIZE)) |
| 1963 | goto free_all; |
| 1964 | |
| 1965 | memcpy(xbuf[0], vecs->m, vecs->m_size); |
| 1966 | |
Tadeusz Struk | 22287b0 | 2015-10-08 09:26:55 -0700 | [diff] [blame] | 1967 | sg_init_table(src_tab, 2); |
Herbert Xu | df27b26 | 2016-05-05 16:42:49 +0800 | [diff] [blame] | 1968 | sg_set_buf(&src_tab[0], xbuf[0], 8); |
| 1969 | sg_set_buf(&src_tab[1], xbuf[0] + 8, vecs->m_size - 8); |
Tadeusz Struk | 22287b0 | 2015-10-08 09:26:55 -0700 | [diff] [blame] | 1970 | sg_init_one(&dst, outbuf_enc, out_len_max); |
| 1971 | akcipher_request_set_crypt(req, src_tab, &dst, vecs->m_size, |
| 1972 | out_len_max); |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 1973 | akcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 1974 | tcrypt_complete, &result); |
| 1975 | |
| 1976 | /* Run RSA encrypt - c = m^e mod n;*/ |
| 1977 | err = wait_async_op(&result, crypto_akcipher_encrypt(req)); |
| 1978 | if (err) { |
Herbert Xu | 50d2b643 | 2016-06-29 19:32:20 +0800 | [diff] [blame] | 1979 | pr_err("alg: akcipher: encrypt test failed. err %d\n", err); |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 1980 | goto free_all; |
| 1981 | } |
Tadeusz Struk | 22287b0 | 2015-10-08 09:26:55 -0700 | [diff] [blame] | 1982 | if (req->dst_len != vecs->c_size) { |
Herbert Xu | 50d2b643 | 2016-06-29 19:32:20 +0800 | [diff] [blame] | 1983 | pr_err("alg: akcipher: encrypt test failed. Invalid output len\n"); |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 1984 | err = -EINVAL; |
| 1985 | goto free_all; |
| 1986 | } |
| 1987 | /* verify that encrypted message is equal to expected */ |
Herbert Xu | df27b26 | 2016-05-05 16:42:49 +0800 | [diff] [blame] | 1988 | if (memcmp(vecs->c, outbuf_enc, vecs->c_size)) { |
Herbert Xu | 50d2b643 | 2016-06-29 19:32:20 +0800 | [diff] [blame] | 1989 | pr_err("alg: akcipher: encrypt test failed. Invalid output\n"); |
| 1990 | hexdump(outbuf_enc, vecs->c_size); |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 1991 | err = -EINVAL; |
| 1992 | goto free_all; |
| 1993 | } |
| 1994 | /* Don't invoke decrypt for vectors with public key */ |
| 1995 | if (vecs->public_key_vec) { |
| 1996 | err = 0; |
| 1997 | goto free_all; |
| 1998 | } |
| 1999 | outbuf_dec = kzalloc(out_len_max, GFP_KERNEL); |
| 2000 | if (!outbuf_dec) { |
| 2001 | err = -ENOMEM; |
| 2002 | goto free_all; |
| 2003 | } |
Herbert Xu | df27b26 | 2016-05-05 16:42:49 +0800 | [diff] [blame] | 2004 | |
| 2005 | if (WARN_ON(vecs->c_size > PAGE_SIZE)) |
| 2006 | goto free_all; |
| 2007 | |
| 2008 | memcpy(xbuf[0], vecs->c, vecs->c_size); |
| 2009 | |
| 2010 | sg_init_one(&src, xbuf[0], vecs->c_size); |
Tadeusz Struk | 22287b0 | 2015-10-08 09:26:55 -0700 | [diff] [blame] | 2011 | sg_init_one(&dst, outbuf_dec, out_len_max); |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 2012 | init_completion(&result.completion); |
Tadeusz Struk | 22287b0 | 2015-10-08 09:26:55 -0700 | [diff] [blame] | 2013 | akcipher_request_set_crypt(req, &src, &dst, vecs->c_size, out_len_max); |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 2014 | |
| 2015 | /* Run RSA decrypt - m = c^d mod n;*/ |
| 2016 | err = wait_async_op(&result, crypto_akcipher_decrypt(req)); |
| 2017 | if (err) { |
Herbert Xu | 50d2b643 | 2016-06-29 19:32:20 +0800 | [diff] [blame] | 2018 | pr_err("alg: akcipher: decrypt test failed. err %d\n", err); |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 2019 | goto free_all; |
| 2020 | } |
| 2021 | out_len = req->dst_len; |
Herbert Xu | 50d2b643 | 2016-06-29 19:32:20 +0800 | [diff] [blame] | 2022 | if (out_len < vecs->m_size) { |
| 2023 | pr_err("alg: akcipher: decrypt test failed. " |
| 2024 | "Invalid output len %u\n", out_len); |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 2025 | err = -EINVAL; |
| 2026 | goto free_all; |
| 2027 | } |
| 2028 | /* verify that decrypted message is equal to the original msg */ |
Herbert Xu | 50d2b643 | 2016-06-29 19:32:20 +0800 | [diff] [blame] | 2029 | if (memchr_inv(outbuf_dec, 0, out_len - vecs->m_size) || |
| 2030 | memcmp(vecs->m, outbuf_dec + out_len - vecs->m_size, |
| 2031 | vecs->m_size)) { |
| 2032 | pr_err("alg: akcipher: decrypt test failed. Invalid output\n"); |
| 2033 | hexdump(outbuf_dec, out_len); |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 2034 | err = -EINVAL; |
| 2035 | } |
| 2036 | free_all: |
| 2037 | kfree(outbuf_dec); |
| 2038 | kfree(outbuf_enc); |
| 2039 | free_req: |
| 2040 | akcipher_request_free(req); |
Herbert Xu | df27b26 | 2016-05-05 16:42:49 +0800 | [diff] [blame] | 2041 | free_xbuf: |
| 2042 | testmgr_free_buf(xbuf); |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 2043 | return err; |
| 2044 | } |
| 2045 | |
Herbert Xu | 50d2b643 | 2016-06-29 19:32:20 +0800 | [diff] [blame] | 2046 | static int test_akcipher(struct crypto_akcipher *tfm, const char *alg, |
| 2047 | struct akcipher_testvec *vecs, unsigned int tcount) |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 2048 | { |
Herbert Xu | 15226e4 | 2016-07-18 18:20:10 +0800 | [diff] [blame] | 2049 | const char *algo = |
| 2050 | crypto_tfm_alg_driver_name(crypto_akcipher_tfm(tfm)); |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 2051 | int ret, i; |
| 2052 | |
| 2053 | for (i = 0; i < tcount; i++) { |
Herbert Xu | 50d2b643 | 2016-06-29 19:32:20 +0800 | [diff] [blame] | 2054 | ret = test_akcipher_one(tfm, vecs++); |
| 2055 | if (!ret) |
| 2056 | continue; |
| 2057 | |
Herbert Xu | 15226e4 | 2016-07-18 18:20:10 +0800 | [diff] [blame] | 2058 | pr_err("alg: akcipher: test %d failed for %s, err=%d\n", |
| 2059 | i + 1, algo, ret); |
Herbert Xu | 50d2b643 | 2016-06-29 19:32:20 +0800 | [diff] [blame] | 2060 | return ret; |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 2061 | } |
| 2062 | return 0; |
| 2063 | } |
| 2064 | |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 2065 | static int alg_test_akcipher(const struct alg_test_desc *desc, |
| 2066 | const char *driver, u32 type, u32 mask) |
| 2067 | { |
| 2068 | struct crypto_akcipher *tfm; |
| 2069 | int err = 0; |
| 2070 | |
| 2071 | tfm = crypto_alloc_akcipher(driver, type | CRYPTO_ALG_INTERNAL, mask); |
| 2072 | if (IS_ERR(tfm)) { |
| 2073 | pr_err("alg: akcipher: Failed to load tfm for %s: %ld\n", |
| 2074 | driver, PTR_ERR(tfm)); |
| 2075 | return PTR_ERR(tfm); |
| 2076 | } |
| 2077 | if (desc->suite.akcipher.vecs) |
| 2078 | err = test_akcipher(tfm, desc->alg, desc->suite.akcipher.vecs, |
| 2079 | desc->suite.akcipher.count); |
| 2080 | |
| 2081 | crypto_free_akcipher(tfm); |
| 2082 | return err; |
| 2083 | } |
| 2084 | |
Youquan, Song | 863b557 | 2009-12-23 19:45:20 +0800 | [diff] [blame] | 2085 | static int alg_test_null(const struct alg_test_desc *desc, |
| 2086 | const char *driver, u32 type, u32 mask) |
| 2087 | { |
| 2088 | return 0; |
| 2089 | } |
| 2090 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2091 | /* Please keep this list sorted by algorithm name. */ |
| 2092 | static const struct alg_test_desc alg_test_descs[] = { |
| 2093 | { |
Johannes Goetzfried | 4d6d6a2 | 2012-07-11 19:37:37 +0200 | [diff] [blame] | 2094 | .alg = "__cbc-cast5-avx", |
| 2095 | .test = alg_test_null, |
Johannes Goetzfried | 4d6d6a2 | 2012-07-11 19:37:37 +0200 | [diff] [blame] | 2096 | }, { |
Johannes Goetzfried | 4ea1277 | 2012-07-11 19:38:57 +0200 | [diff] [blame] | 2097 | .alg = "__cbc-cast6-avx", |
| 2098 | .test = alg_test_null, |
Johannes Goetzfried | 4ea1277 | 2012-07-11 19:38:57 +0200 | [diff] [blame] | 2099 | }, { |
Johannes Goetzfried | 7efe407 | 2012-06-12 16:47:43 +0800 | [diff] [blame] | 2100 | .alg = "__cbc-serpent-avx", |
| 2101 | .test = alg_test_null, |
Johannes Goetzfried | 7efe407 | 2012-06-12 16:47:43 +0800 | [diff] [blame] | 2102 | }, { |
Jussi Kivilinna | 56d76c9 | 2013-04-13 13:46:55 +0300 | [diff] [blame] | 2103 | .alg = "__cbc-serpent-avx2", |
| 2104 | .test = alg_test_null, |
| 2105 | }, { |
Jussi Kivilinna | 937c30d | 2011-11-09 16:26:25 +0200 | [diff] [blame] | 2106 | .alg = "__cbc-serpent-sse2", |
| 2107 | .test = alg_test_null, |
Jussi Kivilinna | 937c30d | 2011-11-09 16:26:25 +0200 | [diff] [blame] | 2108 | }, { |
Johannes Goetzfried | 107778b | 2012-05-28 15:54:24 +0200 | [diff] [blame] | 2109 | .alg = "__cbc-twofish-avx", |
| 2110 | .test = alg_test_null, |
Johannes Goetzfried | 107778b | 2012-05-28 15:54:24 +0200 | [diff] [blame] | 2111 | }, { |
Youquan, Song | 863b557 | 2009-12-23 19:45:20 +0800 | [diff] [blame] | 2112 | .alg = "__driver-cbc-aes-aesni", |
| 2113 | .test = alg_test_null, |
Milan Broz | 6c79294 | 2012-06-29 22:08:09 +0200 | [diff] [blame] | 2114 | .fips_allowed = 1, |
Youquan, Song | 863b557 | 2009-12-23 19:45:20 +0800 | [diff] [blame] | 2115 | }, { |
Jussi Kivilinna | d9b1d2e | 2012-10-26 14:49:01 +0300 | [diff] [blame] | 2116 | .alg = "__driver-cbc-camellia-aesni", |
| 2117 | .test = alg_test_null, |
Jussi Kivilinna | d9b1d2e | 2012-10-26 14:49:01 +0300 | [diff] [blame] | 2118 | }, { |
Jussi Kivilinna | f3f935a | 2013-04-13 13:47:00 +0300 | [diff] [blame] | 2119 | .alg = "__driver-cbc-camellia-aesni-avx2", |
| 2120 | .test = alg_test_null, |
| 2121 | }, { |
Johannes Goetzfried | 4d6d6a2 | 2012-07-11 19:37:37 +0200 | [diff] [blame] | 2122 | .alg = "__driver-cbc-cast5-avx", |
| 2123 | .test = alg_test_null, |
Johannes Goetzfried | 4d6d6a2 | 2012-07-11 19:37:37 +0200 | [diff] [blame] | 2124 | }, { |
Johannes Goetzfried | 4ea1277 | 2012-07-11 19:38:57 +0200 | [diff] [blame] | 2125 | .alg = "__driver-cbc-cast6-avx", |
| 2126 | .test = alg_test_null, |
Johannes Goetzfried | 4ea1277 | 2012-07-11 19:38:57 +0200 | [diff] [blame] | 2127 | }, { |
Johannes Goetzfried | 7efe407 | 2012-06-12 16:47:43 +0800 | [diff] [blame] | 2128 | .alg = "__driver-cbc-serpent-avx", |
| 2129 | .test = alg_test_null, |
Johannes Goetzfried | 7efe407 | 2012-06-12 16:47:43 +0800 | [diff] [blame] | 2130 | }, { |
Jussi Kivilinna | 56d76c9 | 2013-04-13 13:46:55 +0300 | [diff] [blame] | 2131 | .alg = "__driver-cbc-serpent-avx2", |
| 2132 | .test = alg_test_null, |
| 2133 | }, { |
Jussi Kivilinna | 937c30d | 2011-11-09 16:26:25 +0200 | [diff] [blame] | 2134 | .alg = "__driver-cbc-serpent-sse2", |
| 2135 | .test = alg_test_null, |
Jussi Kivilinna | 937c30d | 2011-11-09 16:26:25 +0200 | [diff] [blame] | 2136 | }, { |
Johannes Goetzfried | 107778b | 2012-05-28 15:54:24 +0200 | [diff] [blame] | 2137 | .alg = "__driver-cbc-twofish-avx", |
| 2138 | .test = alg_test_null, |
Johannes Goetzfried | 107778b | 2012-05-28 15:54:24 +0200 | [diff] [blame] | 2139 | }, { |
Youquan, Song | 863b557 | 2009-12-23 19:45:20 +0800 | [diff] [blame] | 2140 | .alg = "__driver-ecb-aes-aesni", |
| 2141 | .test = alg_test_null, |
Milan Broz | 6c79294 | 2012-06-29 22:08:09 +0200 | [diff] [blame] | 2142 | .fips_allowed = 1, |
Youquan, Song | 863b557 | 2009-12-23 19:45:20 +0800 | [diff] [blame] | 2143 | }, { |
Jussi Kivilinna | d9b1d2e | 2012-10-26 14:49:01 +0300 | [diff] [blame] | 2144 | .alg = "__driver-ecb-camellia-aesni", |
| 2145 | .test = alg_test_null, |
Jussi Kivilinna | d9b1d2e | 2012-10-26 14:49:01 +0300 | [diff] [blame] | 2146 | }, { |
Jussi Kivilinna | f3f935a | 2013-04-13 13:47:00 +0300 | [diff] [blame] | 2147 | .alg = "__driver-ecb-camellia-aesni-avx2", |
| 2148 | .test = alg_test_null, |
| 2149 | }, { |
Johannes Goetzfried | 4d6d6a2 | 2012-07-11 19:37:37 +0200 | [diff] [blame] | 2150 | .alg = "__driver-ecb-cast5-avx", |
| 2151 | .test = alg_test_null, |
Johannes Goetzfried | 4d6d6a2 | 2012-07-11 19:37:37 +0200 | [diff] [blame] | 2152 | }, { |
Johannes Goetzfried | 4ea1277 | 2012-07-11 19:38:57 +0200 | [diff] [blame] | 2153 | .alg = "__driver-ecb-cast6-avx", |
| 2154 | .test = alg_test_null, |
Johannes Goetzfried | 4ea1277 | 2012-07-11 19:38:57 +0200 | [diff] [blame] | 2155 | }, { |
Johannes Goetzfried | 7efe407 | 2012-06-12 16:47:43 +0800 | [diff] [blame] | 2156 | .alg = "__driver-ecb-serpent-avx", |
| 2157 | .test = alg_test_null, |
Johannes Goetzfried | 7efe407 | 2012-06-12 16:47:43 +0800 | [diff] [blame] | 2158 | }, { |
Jussi Kivilinna | 56d76c9 | 2013-04-13 13:46:55 +0300 | [diff] [blame] | 2159 | .alg = "__driver-ecb-serpent-avx2", |
| 2160 | .test = alg_test_null, |
| 2161 | }, { |
Jussi Kivilinna | 937c30d | 2011-11-09 16:26:25 +0200 | [diff] [blame] | 2162 | .alg = "__driver-ecb-serpent-sse2", |
| 2163 | .test = alg_test_null, |
Jussi Kivilinna | 937c30d | 2011-11-09 16:26:25 +0200 | [diff] [blame] | 2164 | }, { |
Johannes Goetzfried | 107778b | 2012-05-28 15:54:24 +0200 | [diff] [blame] | 2165 | .alg = "__driver-ecb-twofish-avx", |
| 2166 | .test = alg_test_null, |
Johannes Goetzfried | 107778b | 2012-05-28 15:54:24 +0200 | [diff] [blame] | 2167 | }, { |
Tadeusz Struk | 9d77b6c | 2015-06-24 09:01:30 -0700 | [diff] [blame] | 2168 | .alg = "__driver-gcm-aes-aesni", |
| 2169 | .test = alg_test_null, |
| 2170 | .fips_allowed = 1, |
| 2171 | }, { |
Youquan, Song | 863b557 | 2009-12-23 19:45:20 +0800 | [diff] [blame] | 2172 | .alg = "__ghash-pclmulqdqni", |
| 2173 | .test = alg_test_null, |
Milan Broz | 6c79294 | 2012-06-29 22:08:09 +0200 | [diff] [blame] | 2174 | .fips_allowed = 1, |
Youquan, Song | 863b557 | 2009-12-23 19:45:20 +0800 | [diff] [blame] | 2175 | }, { |
Jarod Wilson | e08ca2d | 2009-05-04 19:46:29 +0800 | [diff] [blame] | 2176 | .alg = "ansi_cprng", |
| 2177 | .test = alg_test_cprng, |
| 2178 | .suite = { |
| 2179 | .cprng = { |
| 2180 | .vecs = ansi_cprng_aes_tv_template, |
| 2181 | .count = ANSI_CPRNG_AES_TEST_VECTORS |
| 2182 | } |
| 2183 | } |
| 2184 | }, { |
Horia Geanta | bca4feb | 2014-03-14 17:46:51 +0200 | [diff] [blame] | 2185 | .alg = "authenc(hmac(md5),ecb(cipher_null))", |
| 2186 | .test = alg_test_aead, |
Horia Geanta | bca4feb | 2014-03-14 17:46:51 +0200 | [diff] [blame] | 2187 | .suite = { |
| 2188 | .aead = { |
| 2189 | .enc = { |
| 2190 | .vecs = hmac_md5_ecb_cipher_null_enc_tv_template, |
| 2191 | .count = HMAC_MD5_ECB_CIPHER_NULL_ENC_TEST_VECTORS |
| 2192 | }, |
| 2193 | .dec = { |
| 2194 | .vecs = hmac_md5_ecb_cipher_null_dec_tv_template, |
| 2195 | .count = HMAC_MD5_ECB_CIPHER_NULL_DEC_TEST_VECTORS |
| 2196 | } |
| 2197 | } |
| 2198 | } |
| 2199 | }, { |
Herbert Xu | a4198fd | 2015-07-30 17:53:23 +0800 | [diff] [blame] | 2200 | .alg = "authenc(hmac(sha1),cbc(aes))", |
Horia Geanta | e46e9a4 | 2012-07-03 19:16:54 +0300 | [diff] [blame] | 2201 | .test = alg_test_aead, |
Horia Geanta | e46e9a4 | 2012-07-03 19:16:54 +0300 | [diff] [blame] | 2202 | .suite = { |
| 2203 | .aead = { |
| 2204 | .enc = { |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2205 | .vecs = |
| 2206 | hmac_sha1_aes_cbc_enc_tv_temp, |
| 2207 | .count = |
| 2208 | HMAC_SHA1_AES_CBC_ENC_TEST_VEC |
| 2209 | } |
| 2210 | } |
| 2211 | } |
| 2212 | }, { |
Herbert Xu | a4198fd | 2015-07-30 17:53:23 +0800 | [diff] [blame] | 2213 | .alg = "authenc(hmac(sha1),cbc(des))", |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2214 | .test = alg_test_aead, |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2215 | .suite = { |
| 2216 | .aead = { |
| 2217 | .enc = { |
| 2218 | .vecs = |
| 2219 | hmac_sha1_des_cbc_enc_tv_temp, |
| 2220 | .count = |
| 2221 | HMAC_SHA1_DES_CBC_ENC_TEST_VEC |
| 2222 | } |
| 2223 | } |
| 2224 | } |
| 2225 | }, { |
Herbert Xu | a4198fd | 2015-07-30 17:53:23 +0800 | [diff] [blame] | 2226 | .alg = "authenc(hmac(sha1),cbc(des3_ede))", |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2227 | .test = alg_test_aead, |
Marcus Meissner | ed1afac | 2016-02-05 14:23:33 +0100 | [diff] [blame] | 2228 | .fips_allowed = 1, |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2229 | .suite = { |
| 2230 | .aead = { |
| 2231 | .enc = { |
| 2232 | .vecs = |
| 2233 | hmac_sha1_des3_ede_cbc_enc_tv_temp, |
| 2234 | .count = |
| 2235 | HMAC_SHA1_DES3_EDE_CBC_ENC_TEST_VEC |
Horia Geanta | e46e9a4 | 2012-07-03 19:16:54 +0300 | [diff] [blame] | 2236 | } |
| 2237 | } |
| 2238 | } |
| 2239 | }, { |
Marcus Meissner | fb16abc | 2016-02-06 11:53:07 +0100 | [diff] [blame] | 2240 | .alg = "authenc(hmac(sha1),ctr(aes))", |
| 2241 | .test = alg_test_null, |
| 2242 | .fips_allowed = 1, |
| 2243 | }, { |
Horia Geanta | bca4feb | 2014-03-14 17:46:51 +0200 | [diff] [blame] | 2244 | .alg = "authenc(hmac(sha1),ecb(cipher_null))", |
| 2245 | .test = alg_test_aead, |
Horia Geanta | bca4feb | 2014-03-14 17:46:51 +0200 | [diff] [blame] | 2246 | .suite = { |
| 2247 | .aead = { |
| 2248 | .enc = { |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2249 | .vecs = |
| 2250 | hmac_sha1_ecb_cipher_null_enc_tv_temp, |
| 2251 | .count = |
| 2252 | HMAC_SHA1_ECB_CIPHER_NULL_ENC_TEST_VEC |
Horia Geanta | bca4feb | 2014-03-14 17:46:51 +0200 | [diff] [blame] | 2253 | }, |
| 2254 | .dec = { |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2255 | .vecs = |
| 2256 | hmac_sha1_ecb_cipher_null_dec_tv_temp, |
| 2257 | .count = |
| 2258 | HMAC_SHA1_ECB_CIPHER_NULL_DEC_TEST_VEC |
| 2259 | } |
| 2260 | } |
| 2261 | } |
| 2262 | }, { |
Marcus Meissner | 8888690 | 2016-02-19 13:34:28 +0100 | [diff] [blame] | 2263 | .alg = "authenc(hmac(sha1),rfc3686(ctr(aes)))", |
| 2264 | .test = alg_test_null, |
| 2265 | .fips_allowed = 1, |
| 2266 | }, { |
Herbert Xu | a4198fd | 2015-07-30 17:53:23 +0800 | [diff] [blame] | 2267 | .alg = "authenc(hmac(sha224),cbc(des))", |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2268 | .test = alg_test_aead, |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2269 | .suite = { |
| 2270 | .aead = { |
| 2271 | .enc = { |
| 2272 | .vecs = |
| 2273 | hmac_sha224_des_cbc_enc_tv_temp, |
| 2274 | .count = |
| 2275 | HMAC_SHA224_DES_CBC_ENC_TEST_VEC |
| 2276 | } |
| 2277 | } |
| 2278 | } |
| 2279 | }, { |
Herbert Xu | a4198fd | 2015-07-30 17:53:23 +0800 | [diff] [blame] | 2280 | .alg = "authenc(hmac(sha224),cbc(des3_ede))", |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2281 | .test = alg_test_aead, |
Marcus Meissner | ed1afac | 2016-02-05 14:23:33 +0100 | [diff] [blame] | 2282 | .fips_allowed = 1, |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2283 | .suite = { |
| 2284 | .aead = { |
| 2285 | .enc = { |
| 2286 | .vecs = |
| 2287 | hmac_sha224_des3_ede_cbc_enc_tv_temp, |
| 2288 | .count = |
| 2289 | HMAC_SHA224_DES3_EDE_CBC_ENC_TEST_VEC |
Horia Geanta | bca4feb | 2014-03-14 17:46:51 +0200 | [diff] [blame] | 2290 | } |
| 2291 | } |
| 2292 | } |
| 2293 | }, { |
Herbert Xu | a4198fd | 2015-07-30 17:53:23 +0800 | [diff] [blame] | 2294 | .alg = "authenc(hmac(sha256),cbc(aes))", |
Horia Geanta | e46e9a4 | 2012-07-03 19:16:54 +0300 | [diff] [blame] | 2295 | .test = alg_test_aead, |
Marcus Meissner | ed1afac | 2016-02-05 14:23:33 +0100 | [diff] [blame] | 2296 | .fips_allowed = 1, |
Horia Geanta | e46e9a4 | 2012-07-03 19:16:54 +0300 | [diff] [blame] | 2297 | .suite = { |
| 2298 | .aead = { |
| 2299 | .enc = { |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2300 | .vecs = |
| 2301 | hmac_sha256_aes_cbc_enc_tv_temp, |
| 2302 | .count = |
| 2303 | HMAC_SHA256_AES_CBC_ENC_TEST_VEC |
| 2304 | } |
| 2305 | } |
| 2306 | } |
| 2307 | }, { |
Herbert Xu | a4198fd | 2015-07-30 17:53:23 +0800 | [diff] [blame] | 2308 | .alg = "authenc(hmac(sha256),cbc(des))", |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2309 | .test = alg_test_aead, |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2310 | .suite = { |
| 2311 | .aead = { |
| 2312 | .enc = { |
| 2313 | .vecs = |
| 2314 | hmac_sha256_des_cbc_enc_tv_temp, |
| 2315 | .count = |
| 2316 | HMAC_SHA256_DES_CBC_ENC_TEST_VEC |
| 2317 | } |
| 2318 | } |
| 2319 | } |
| 2320 | }, { |
Herbert Xu | a4198fd | 2015-07-30 17:53:23 +0800 | [diff] [blame] | 2321 | .alg = "authenc(hmac(sha256),cbc(des3_ede))", |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2322 | .test = alg_test_aead, |
Marcus Meissner | ed1afac | 2016-02-05 14:23:33 +0100 | [diff] [blame] | 2323 | .fips_allowed = 1, |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2324 | .suite = { |
| 2325 | .aead = { |
| 2326 | .enc = { |
| 2327 | .vecs = |
| 2328 | hmac_sha256_des3_ede_cbc_enc_tv_temp, |
| 2329 | .count = |
| 2330 | HMAC_SHA256_DES3_EDE_CBC_ENC_TEST_VEC |
| 2331 | } |
| 2332 | } |
| 2333 | } |
| 2334 | }, { |
Marcus Meissner | fb16abc | 2016-02-06 11:53:07 +0100 | [diff] [blame] | 2335 | .alg = "authenc(hmac(sha256),ctr(aes))", |
| 2336 | .test = alg_test_null, |
| 2337 | .fips_allowed = 1, |
| 2338 | }, { |
Marcus Meissner | 8888690 | 2016-02-19 13:34:28 +0100 | [diff] [blame] | 2339 | .alg = "authenc(hmac(sha256),rfc3686(ctr(aes)))", |
| 2340 | .test = alg_test_null, |
| 2341 | .fips_allowed = 1, |
| 2342 | }, { |
Herbert Xu | a4198fd | 2015-07-30 17:53:23 +0800 | [diff] [blame] | 2343 | .alg = "authenc(hmac(sha384),cbc(des))", |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2344 | .test = alg_test_aead, |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2345 | .suite = { |
| 2346 | .aead = { |
| 2347 | .enc = { |
| 2348 | .vecs = |
| 2349 | hmac_sha384_des_cbc_enc_tv_temp, |
| 2350 | .count = |
| 2351 | HMAC_SHA384_DES_CBC_ENC_TEST_VEC |
| 2352 | } |
| 2353 | } |
| 2354 | } |
| 2355 | }, { |
Herbert Xu | a4198fd | 2015-07-30 17:53:23 +0800 | [diff] [blame] | 2356 | .alg = "authenc(hmac(sha384),cbc(des3_ede))", |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2357 | .test = alg_test_aead, |
Marcus Meissner | ed1afac | 2016-02-05 14:23:33 +0100 | [diff] [blame] | 2358 | .fips_allowed = 1, |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2359 | .suite = { |
| 2360 | .aead = { |
| 2361 | .enc = { |
| 2362 | .vecs = |
| 2363 | hmac_sha384_des3_ede_cbc_enc_tv_temp, |
| 2364 | .count = |
| 2365 | HMAC_SHA384_DES3_EDE_CBC_ENC_TEST_VEC |
Horia Geanta | e46e9a4 | 2012-07-03 19:16:54 +0300 | [diff] [blame] | 2366 | } |
| 2367 | } |
| 2368 | } |
| 2369 | }, { |
Marcus Meissner | fb16abc | 2016-02-06 11:53:07 +0100 | [diff] [blame] | 2370 | .alg = "authenc(hmac(sha384),ctr(aes))", |
| 2371 | .test = alg_test_null, |
| 2372 | .fips_allowed = 1, |
| 2373 | }, { |
Marcus Meissner | 8888690 | 2016-02-19 13:34:28 +0100 | [diff] [blame] | 2374 | .alg = "authenc(hmac(sha384),rfc3686(ctr(aes)))", |
| 2375 | .test = alg_test_null, |
| 2376 | .fips_allowed = 1, |
| 2377 | }, { |
Herbert Xu | a4198fd | 2015-07-30 17:53:23 +0800 | [diff] [blame] | 2378 | .alg = "authenc(hmac(sha512),cbc(aes))", |
Marcus Meissner | ed1afac | 2016-02-05 14:23:33 +0100 | [diff] [blame] | 2379 | .fips_allowed = 1, |
Horia Geanta | e46e9a4 | 2012-07-03 19:16:54 +0300 | [diff] [blame] | 2380 | .test = alg_test_aead, |
Horia Geanta | e46e9a4 | 2012-07-03 19:16:54 +0300 | [diff] [blame] | 2381 | .suite = { |
| 2382 | .aead = { |
| 2383 | .enc = { |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2384 | .vecs = |
| 2385 | hmac_sha512_aes_cbc_enc_tv_temp, |
| 2386 | .count = |
| 2387 | HMAC_SHA512_AES_CBC_ENC_TEST_VEC |
| 2388 | } |
| 2389 | } |
| 2390 | } |
| 2391 | }, { |
Herbert Xu | a4198fd | 2015-07-30 17:53:23 +0800 | [diff] [blame] | 2392 | .alg = "authenc(hmac(sha512),cbc(des))", |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2393 | .test = alg_test_aead, |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2394 | .suite = { |
| 2395 | .aead = { |
| 2396 | .enc = { |
| 2397 | .vecs = |
| 2398 | hmac_sha512_des_cbc_enc_tv_temp, |
| 2399 | .count = |
| 2400 | HMAC_SHA512_DES_CBC_ENC_TEST_VEC |
| 2401 | } |
| 2402 | } |
| 2403 | } |
| 2404 | }, { |
Herbert Xu | a4198fd | 2015-07-30 17:53:23 +0800 | [diff] [blame] | 2405 | .alg = "authenc(hmac(sha512),cbc(des3_ede))", |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2406 | .test = alg_test_aead, |
Marcus Meissner | ed1afac | 2016-02-05 14:23:33 +0100 | [diff] [blame] | 2407 | .fips_allowed = 1, |
Nitesh Lal | 5208ed2 | 2014-05-21 17:09:08 +0530 | [diff] [blame] | 2408 | .suite = { |
| 2409 | .aead = { |
| 2410 | .enc = { |
| 2411 | .vecs = |
| 2412 | hmac_sha512_des3_ede_cbc_enc_tv_temp, |
| 2413 | .count = |
| 2414 | HMAC_SHA512_DES3_EDE_CBC_ENC_TEST_VEC |
Horia Geanta | e46e9a4 | 2012-07-03 19:16:54 +0300 | [diff] [blame] | 2415 | } |
| 2416 | } |
| 2417 | } |
| 2418 | }, { |
Marcus Meissner | fb16abc | 2016-02-06 11:53:07 +0100 | [diff] [blame] | 2419 | .alg = "authenc(hmac(sha512),ctr(aes))", |
| 2420 | .test = alg_test_null, |
| 2421 | .fips_allowed = 1, |
| 2422 | }, { |
Marcus Meissner | 8888690 | 2016-02-19 13:34:28 +0100 | [diff] [blame] | 2423 | .alg = "authenc(hmac(sha512),rfc3686(ctr(aes)))", |
| 2424 | .test = alg_test_null, |
| 2425 | .fips_allowed = 1, |
| 2426 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2427 | .alg = "cbc(aes)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 2428 | .test = alg_test_skcipher, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 2429 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2430 | .suite = { |
| 2431 | .cipher = { |
| 2432 | .enc = { |
| 2433 | .vecs = aes_cbc_enc_tv_template, |
| 2434 | .count = AES_CBC_ENC_TEST_VECTORS |
| 2435 | }, |
| 2436 | .dec = { |
| 2437 | .vecs = aes_cbc_dec_tv_template, |
| 2438 | .count = AES_CBC_DEC_TEST_VECTORS |
| 2439 | } |
| 2440 | } |
| 2441 | } |
| 2442 | }, { |
| 2443 | .alg = "cbc(anubis)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 2444 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2445 | .suite = { |
| 2446 | .cipher = { |
| 2447 | .enc = { |
| 2448 | .vecs = anubis_cbc_enc_tv_template, |
| 2449 | .count = ANUBIS_CBC_ENC_TEST_VECTORS |
| 2450 | }, |
| 2451 | .dec = { |
| 2452 | .vecs = anubis_cbc_dec_tv_template, |
| 2453 | .count = ANUBIS_CBC_DEC_TEST_VECTORS |
| 2454 | } |
| 2455 | } |
| 2456 | } |
| 2457 | }, { |
| 2458 | .alg = "cbc(blowfish)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 2459 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2460 | .suite = { |
| 2461 | .cipher = { |
| 2462 | .enc = { |
| 2463 | .vecs = bf_cbc_enc_tv_template, |
| 2464 | .count = BF_CBC_ENC_TEST_VECTORS |
| 2465 | }, |
| 2466 | .dec = { |
| 2467 | .vecs = bf_cbc_dec_tv_template, |
| 2468 | .count = BF_CBC_DEC_TEST_VECTORS |
| 2469 | } |
| 2470 | } |
| 2471 | } |
| 2472 | }, { |
| 2473 | .alg = "cbc(camellia)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 2474 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2475 | .suite = { |
| 2476 | .cipher = { |
| 2477 | .enc = { |
| 2478 | .vecs = camellia_cbc_enc_tv_template, |
| 2479 | .count = CAMELLIA_CBC_ENC_TEST_VECTORS |
| 2480 | }, |
| 2481 | .dec = { |
| 2482 | .vecs = camellia_cbc_dec_tv_template, |
| 2483 | .count = CAMELLIA_CBC_DEC_TEST_VECTORS |
| 2484 | } |
| 2485 | } |
| 2486 | } |
| 2487 | }, { |
Johannes Goetzfried | a2c5826 | 2012-07-11 19:37:21 +0200 | [diff] [blame] | 2488 | .alg = "cbc(cast5)", |
| 2489 | .test = alg_test_skcipher, |
| 2490 | .suite = { |
| 2491 | .cipher = { |
| 2492 | .enc = { |
| 2493 | .vecs = cast5_cbc_enc_tv_template, |
| 2494 | .count = CAST5_CBC_ENC_TEST_VECTORS |
| 2495 | }, |
| 2496 | .dec = { |
| 2497 | .vecs = cast5_cbc_dec_tv_template, |
| 2498 | .count = CAST5_CBC_DEC_TEST_VECTORS |
| 2499 | } |
| 2500 | } |
| 2501 | } |
| 2502 | }, { |
Johannes Goetzfried | 9b8b040 | 2012-07-11 19:38:29 +0200 | [diff] [blame] | 2503 | .alg = "cbc(cast6)", |
| 2504 | .test = alg_test_skcipher, |
| 2505 | .suite = { |
| 2506 | .cipher = { |
| 2507 | .enc = { |
| 2508 | .vecs = cast6_cbc_enc_tv_template, |
| 2509 | .count = CAST6_CBC_ENC_TEST_VECTORS |
| 2510 | }, |
| 2511 | .dec = { |
| 2512 | .vecs = cast6_cbc_dec_tv_template, |
| 2513 | .count = CAST6_CBC_DEC_TEST_VECTORS |
| 2514 | } |
| 2515 | } |
| 2516 | } |
| 2517 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2518 | .alg = "cbc(des)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 2519 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2520 | .suite = { |
| 2521 | .cipher = { |
| 2522 | .enc = { |
| 2523 | .vecs = des_cbc_enc_tv_template, |
| 2524 | .count = DES_CBC_ENC_TEST_VECTORS |
| 2525 | }, |
| 2526 | .dec = { |
| 2527 | .vecs = des_cbc_dec_tv_template, |
| 2528 | .count = DES_CBC_DEC_TEST_VECTORS |
| 2529 | } |
| 2530 | } |
| 2531 | } |
| 2532 | }, { |
| 2533 | .alg = "cbc(des3_ede)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 2534 | .test = alg_test_skcipher, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 2535 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2536 | .suite = { |
| 2537 | .cipher = { |
| 2538 | .enc = { |
| 2539 | .vecs = des3_ede_cbc_enc_tv_template, |
| 2540 | .count = DES3_EDE_CBC_ENC_TEST_VECTORS |
| 2541 | }, |
| 2542 | .dec = { |
| 2543 | .vecs = des3_ede_cbc_dec_tv_template, |
| 2544 | .count = DES3_EDE_CBC_DEC_TEST_VECTORS |
| 2545 | } |
| 2546 | } |
| 2547 | } |
| 2548 | }, { |
Jussi Kivilinna | 9d25917 | 2011-10-18 00:02:53 +0300 | [diff] [blame] | 2549 | .alg = "cbc(serpent)", |
| 2550 | .test = alg_test_skcipher, |
| 2551 | .suite = { |
| 2552 | .cipher = { |
| 2553 | .enc = { |
| 2554 | .vecs = serpent_cbc_enc_tv_template, |
| 2555 | .count = SERPENT_CBC_ENC_TEST_VECTORS |
| 2556 | }, |
| 2557 | .dec = { |
| 2558 | .vecs = serpent_cbc_dec_tv_template, |
| 2559 | .count = SERPENT_CBC_DEC_TEST_VECTORS |
| 2560 | } |
| 2561 | } |
| 2562 | } |
| 2563 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2564 | .alg = "cbc(twofish)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 2565 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2566 | .suite = { |
| 2567 | .cipher = { |
| 2568 | .enc = { |
| 2569 | .vecs = tf_cbc_enc_tv_template, |
| 2570 | .count = TF_CBC_ENC_TEST_VECTORS |
| 2571 | }, |
| 2572 | .dec = { |
| 2573 | .vecs = tf_cbc_dec_tv_template, |
| 2574 | .count = TF_CBC_DEC_TEST_VECTORS |
| 2575 | } |
| 2576 | } |
| 2577 | } |
| 2578 | }, { |
| 2579 | .alg = "ccm(aes)", |
| 2580 | .test = alg_test_aead, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 2581 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2582 | .suite = { |
| 2583 | .aead = { |
| 2584 | .enc = { |
| 2585 | .vecs = aes_ccm_enc_tv_template, |
| 2586 | .count = AES_CCM_ENC_TEST_VECTORS |
| 2587 | }, |
| 2588 | .dec = { |
| 2589 | .vecs = aes_ccm_dec_tv_template, |
| 2590 | .count = AES_CCM_DEC_TEST_VECTORS |
| 2591 | } |
| 2592 | } |
| 2593 | } |
| 2594 | }, { |
Martin Willi | 3590ebf | 2015-06-01 13:43:57 +0200 | [diff] [blame] | 2595 | .alg = "chacha20", |
| 2596 | .test = alg_test_skcipher, |
| 2597 | .suite = { |
| 2598 | .cipher = { |
| 2599 | .enc = { |
| 2600 | .vecs = chacha20_enc_tv_template, |
| 2601 | .count = CHACHA20_ENC_TEST_VECTORS |
| 2602 | }, |
| 2603 | .dec = { |
| 2604 | .vecs = chacha20_enc_tv_template, |
| 2605 | .count = CHACHA20_ENC_TEST_VECTORS |
| 2606 | }, |
| 2607 | } |
| 2608 | } |
| 2609 | }, { |
Jussi Kivilinna | 93b5e86 | 2013-04-08 10:48:44 +0300 | [diff] [blame] | 2610 | .alg = "cmac(aes)", |
Stephan Mueller | 8f18375 | 2015-08-19 08:42:07 +0200 | [diff] [blame] | 2611 | .fips_allowed = 1, |
Jussi Kivilinna | 93b5e86 | 2013-04-08 10:48:44 +0300 | [diff] [blame] | 2612 | .test = alg_test_hash, |
| 2613 | .suite = { |
| 2614 | .hash = { |
| 2615 | .vecs = aes_cmac128_tv_template, |
| 2616 | .count = CMAC_AES_TEST_VECTORS |
| 2617 | } |
| 2618 | } |
| 2619 | }, { |
| 2620 | .alg = "cmac(des3_ede)", |
Stephan Mueller | 8f18375 | 2015-08-19 08:42:07 +0200 | [diff] [blame] | 2621 | .fips_allowed = 1, |
Jussi Kivilinna | 93b5e86 | 2013-04-08 10:48:44 +0300 | [diff] [blame] | 2622 | .test = alg_test_hash, |
| 2623 | .suite = { |
| 2624 | .hash = { |
| 2625 | .vecs = des3_ede_cmac64_tv_template, |
| 2626 | .count = CMAC_DES3_EDE_TEST_VECTORS |
| 2627 | } |
| 2628 | } |
| 2629 | }, { |
Jussi Kivilinna | e448370 | 2013-04-07 16:43:56 +0300 | [diff] [blame] | 2630 | .alg = "compress_null", |
| 2631 | .test = alg_test_null, |
| 2632 | }, { |
Ard Biesheuvel | ebb3472 | 2015-05-04 11:00:17 +0200 | [diff] [blame] | 2633 | .alg = "crc32", |
| 2634 | .test = alg_test_hash, |
| 2635 | .suite = { |
| 2636 | .hash = { |
| 2637 | .vecs = crc32_tv_template, |
| 2638 | .count = CRC32_TEST_VECTORS |
| 2639 | } |
| 2640 | } |
| 2641 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2642 | .alg = "crc32c", |
Herbert Xu | 8e3ee85 | 2008-11-07 14:58:52 +0800 | [diff] [blame] | 2643 | .test = alg_test_crc32c, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 2644 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2645 | .suite = { |
| 2646 | .hash = { |
| 2647 | .vecs = crc32c_tv_template, |
| 2648 | .count = CRC32C_TEST_VECTORS |
| 2649 | } |
| 2650 | } |
| 2651 | }, { |
Herbert Xu | 68411521 | 2013-09-07 12:56:26 +1000 | [diff] [blame] | 2652 | .alg = "crct10dif", |
| 2653 | .test = alg_test_hash, |
| 2654 | .fips_allowed = 1, |
| 2655 | .suite = { |
| 2656 | .hash = { |
| 2657 | .vecs = crct10dif_tv_template, |
| 2658 | .count = CRCT10DIF_TEST_VECTORS |
| 2659 | } |
| 2660 | } |
| 2661 | }, { |
Milan Broz | 6c79294 | 2012-06-29 22:08:09 +0200 | [diff] [blame] | 2662 | .alg = "cryptd(__driver-cbc-aes-aesni)", |
| 2663 | .test = alg_test_null, |
| 2664 | .fips_allowed = 1, |
Milan Broz | 6c79294 | 2012-06-29 22:08:09 +0200 | [diff] [blame] | 2665 | }, { |
Jussi Kivilinna | d9b1d2e | 2012-10-26 14:49:01 +0300 | [diff] [blame] | 2666 | .alg = "cryptd(__driver-cbc-camellia-aesni)", |
| 2667 | .test = alg_test_null, |
Jussi Kivilinna | d9b1d2e | 2012-10-26 14:49:01 +0300 | [diff] [blame] | 2668 | }, { |
Jussi Kivilinna | f3f935a | 2013-04-13 13:47:00 +0300 | [diff] [blame] | 2669 | .alg = "cryptd(__driver-cbc-camellia-aesni-avx2)", |
| 2670 | .test = alg_test_null, |
| 2671 | }, { |
Jussi Kivilinna | 56d76c9 | 2013-04-13 13:46:55 +0300 | [diff] [blame] | 2672 | .alg = "cryptd(__driver-cbc-serpent-avx2)", |
| 2673 | .test = alg_test_null, |
| 2674 | }, { |
Youquan, Song | 863b557 | 2009-12-23 19:45:20 +0800 | [diff] [blame] | 2675 | .alg = "cryptd(__driver-ecb-aes-aesni)", |
| 2676 | .test = alg_test_null, |
Milan Broz | 6c79294 | 2012-06-29 22:08:09 +0200 | [diff] [blame] | 2677 | .fips_allowed = 1, |
Youquan, Song | 863b557 | 2009-12-23 19:45:20 +0800 | [diff] [blame] | 2678 | }, { |
Jussi Kivilinna | d9b1d2e | 2012-10-26 14:49:01 +0300 | [diff] [blame] | 2679 | .alg = "cryptd(__driver-ecb-camellia-aesni)", |
| 2680 | .test = alg_test_null, |
Jussi Kivilinna | d9b1d2e | 2012-10-26 14:49:01 +0300 | [diff] [blame] | 2681 | }, { |
Jussi Kivilinna | f3f935a | 2013-04-13 13:47:00 +0300 | [diff] [blame] | 2682 | .alg = "cryptd(__driver-ecb-camellia-aesni-avx2)", |
| 2683 | .test = alg_test_null, |
| 2684 | }, { |
Johannes Goetzfried | 4d6d6a2 | 2012-07-11 19:37:37 +0200 | [diff] [blame] | 2685 | .alg = "cryptd(__driver-ecb-cast5-avx)", |
| 2686 | .test = alg_test_null, |
Johannes Goetzfried | 4d6d6a2 | 2012-07-11 19:37:37 +0200 | [diff] [blame] | 2687 | }, { |
Johannes Goetzfried | 4ea1277 | 2012-07-11 19:38:57 +0200 | [diff] [blame] | 2688 | .alg = "cryptd(__driver-ecb-cast6-avx)", |
| 2689 | .test = alg_test_null, |
Johannes Goetzfried | 4ea1277 | 2012-07-11 19:38:57 +0200 | [diff] [blame] | 2690 | }, { |
Johannes Goetzfried | 7efe407 | 2012-06-12 16:47:43 +0800 | [diff] [blame] | 2691 | .alg = "cryptd(__driver-ecb-serpent-avx)", |
| 2692 | .test = alg_test_null, |
Johannes Goetzfried | 7efe407 | 2012-06-12 16:47:43 +0800 | [diff] [blame] | 2693 | }, { |
Jussi Kivilinna | 56d76c9 | 2013-04-13 13:46:55 +0300 | [diff] [blame] | 2694 | .alg = "cryptd(__driver-ecb-serpent-avx2)", |
| 2695 | .test = alg_test_null, |
| 2696 | }, { |
Jussi Kivilinna | 937c30d | 2011-11-09 16:26:25 +0200 | [diff] [blame] | 2697 | .alg = "cryptd(__driver-ecb-serpent-sse2)", |
| 2698 | .test = alg_test_null, |
Jussi Kivilinna | 937c30d | 2011-11-09 16:26:25 +0200 | [diff] [blame] | 2699 | }, { |
Johannes Goetzfried | 107778b | 2012-05-28 15:54:24 +0200 | [diff] [blame] | 2700 | .alg = "cryptd(__driver-ecb-twofish-avx)", |
| 2701 | .test = alg_test_null, |
Johannes Goetzfried | 107778b | 2012-05-28 15:54:24 +0200 | [diff] [blame] | 2702 | }, { |
Milan Broz | 6c79294 | 2012-06-29 22:08:09 +0200 | [diff] [blame] | 2703 | .alg = "cryptd(__driver-gcm-aes-aesni)", |
| 2704 | .test = alg_test_null, |
| 2705 | .fips_allowed = 1, |
Milan Broz | 6c79294 | 2012-06-29 22:08:09 +0200 | [diff] [blame] | 2706 | }, { |
Youquan, Song | 863b557 | 2009-12-23 19:45:20 +0800 | [diff] [blame] | 2707 | .alg = "cryptd(__ghash-pclmulqdqni)", |
| 2708 | .test = alg_test_null, |
Milan Broz | 6c79294 | 2012-06-29 22:08:09 +0200 | [diff] [blame] | 2709 | .fips_allowed = 1, |
Youquan, Song | 863b557 | 2009-12-23 19:45:20 +0800 | [diff] [blame] | 2710 | }, { |
Jarod Wilson | f7cb80f | 2009-05-06 17:29:17 +0800 | [diff] [blame] | 2711 | .alg = "ctr(aes)", |
| 2712 | .test = alg_test_skcipher, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 2713 | .fips_allowed = 1, |
Jarod Wilson | f7cb80f | 2009-05-06 17:29:17 +0800 | [diff] [blame] | 2714 | .suite = { |
| 2715 | .cipher = { |
| 2716 | .enc = { |
| 2717 | .vecs = aes_ctr_enc_tv_template, |
| 2718 | .count = AES_CTR_ENC_TEST_VECTORS |
| 2719 | }, |
| 2720 | .dec = { |
| 2721 | .vecs = aes_ctr_dec_tv_template, |
| 2722 | .count = AES_CTR_DEC_TEST_VECTORS |
| 2723 | } |
| 2724 | } |
| 2725 | } |
| 2726 | }, { |
Jussi Kivilinna | 85b63e3 | 2011-10-10 23:03:03 +0300 | [diff] [blame] | 2727 | .alg = "ctr(blowfish)", |
| 2728 | .test = alg_test_skcipher, |
| 2729 | .suite = { |
| 2730 | .cipher = { |
| 2731 | .enc = { |
| 2732 | .vecs = bf_ctr_enc_tv_template, |
| 2733 | .count = BF_CTR_ENC_TEST_VECTORS |
| 2734 | }, |
| 2735 | .dec = { |
| 2736 | .vecs = bf_ctr_dec_tv_template, |
| 2737 | .count = BF_CTR_DEC_TEST_VECTORS |
| 2738 | } |
| 2739 | } |
| 2740 | } |
| 2741 | }, { |
Jussi Kivilinna | 0840605 | 2012-03-05 20:26:21 +0200 | [diff] [blame] | 2742 | .alg = "ctr(camellia)", |
| 2743 | .test = alg_test_skcipher, |
| 2744 | .suite = { |
| 2745 | .cipher = { |
| 2746 | .enc = { |
| 2747 | .vecs = camellia_ctr_enc_tv_template, |
| 2748 | .count = CAMELLIA_CTR_ENC_TEST_VECTORS |
| 2749 | }, |
| 2750 | .dec = { |
| 2751 | .vecs = camellia_ctr_dec_tv_template, |
| 2752 | .count = CAMELLIA_CTR_DEC_TEST_VECTORS |
| 2753 | } |
| 2754 | } |
| 2755 | } |
| 2756 | }, { |
Johannes Goetzfried | a2c5826 | 2012-07-11 19:37:21 +0200 | [diff] [blame] | 2757 | .alg = "ctr(cast5)", |
| 2758 | .test = alg_test_skcipher, |
| 2759 | .suite = { |
| 2760 | .cipher = { |
| 2761 | .enc = { |
| 2762 | .vecs = cast5_ctr_enc_tv_template, |
| 2763 | .count = CAST5_CTR_ENC_TEST_VECTORS |
| 2764 | }, |
| 2765 | .dec = { |
| 2766 | .vecs = cast5_ctr_dec_tv_template, |
| 2767 | .count = CAST5_CTR_DEC_TEST_VECTORS |
| 2768 | } |
| 2769 | } |
| 2770 | } |
| 2771 | }, { |
Johannes Goetzfried | 9b8b040 | 2012-07-11 19:38:29 +0200 | [diff] [blame] | 2772 | .alg = "ctr(cast6)", |
| 2773 | .test = alg_test_skcipher, |
| 2774 | .suite = { |
| 2775 | .cipher = { |
| 2776 | .enc = { |
| 2777 | .vecs = cast6_ctr_enc_tv_template, |
| 2778 | .count = CAST6_CTR_ENC_TEST_VECTORS |
| 2779 | }, |
| 2780 | .dec = { |
| 2781 | .vecs = cast6_ctr_dec_tv_template, |
| 2782 | .count = CAST6_CTR_DEC_TEST_VECTORS |
| 2783 | } |
| 2784 | } |
| 2785 | } |
| 2786 | }, { |
Jussi Kivilinna | 8163fc3 | 2012-10-20 14:53:07 +0300 | [diff] [blame] | 2787 | .alg = "ctr(des)", |
| 2788 | .test = alg_test_skcipher, |
| 2789 | .suite = { |
| 2790 | .cipher = { |
| 2791 | .enc = { |
| 2792 | .vecs = des_ctr_enc_tv_template, |
| 2793 | .count = DES_CTR_ENC_TEST_VECTORS |
| 2794 | }, |
| 2795 | .dec = { |
| 2796 | .vecs = des_ctr_dec_tv_template, |
| 2797 | .count = DES_CTR_DEC_TEST_VECTORS |
| 2798 | } |
| 2799 | } |
| 2800 | } |
| 2801 | }, { |
Jussi Kivilinna | e080b17 | 2012-10-20 14:53:12 +0300 | [diff] [blame] | 2802 | .alg = "ctr(des3_ede)", |
| 2803 | .test = alg_test_skcipher, |
| 2804 | .suite = { |
| 2805 | .cipher = { |
| 2806 | .enc = { |
| 2807 | .vecs = des3_ede_ctr_enc_tv_template, |
| 2808 | .count = DES3_EDE_CTR_ENC_TEST_VECTORS |
| 2809 | }, |
| 2810 | .dec = { |
| 2811 | .vecs = des3_ede_ctr_dec_tv_template, |
| 2812 | .count = DES3_EDE_CTR_DEC_TEST_VECTORS |
| 2813 | } |
| 2814 | } |
| 2815 | } |
| 2816 | }, { |
Jussi Kivilinna | 9d25917 | 2011-10-18 00:02:53 +0300 | [diff] [blame] | 2817 | .alg = "ctr(serpent)", |
| 2818 | .test = alg_test_skcipher, |
| 2819 | .suite = { |
| 2820 | .cipher = { |
| 2821 | .enc = { |
| 2822 | .vecs = serpent_ctr_enc_tv_template, |
| 2823 | .count = SERPENT_CTR_ENC_TEST_VECTORS |
| 2824 | }, |
| 2825 | .dec = { |
| 2826 | .vecs = serpent_ctr_dec_tv_template, |
| 2827 | .count = SERPENT_CTR_DEC_TEST_VECTORS |
| 2828 | } |
| 2829 | } |
| 2830 | } |
| 2831 | }, { |
Jussi Kivilinna | 573da62 | 2011-10-10 23:03:12 +0300 | [diff] [blame] | 2832 | .alg = "ctr(twofish)", |
| 2833 | .test = alg_test_skcipher, |
| 2834 | .suite = { |
| 2835 | .cipher = { |
| 2836 | .enc = { |
| 2837 | .vecs = tf_ctr_enc_tv_template, |
| 2838 | .count = TF_CTR_ENC_TEST_VECTORS |
| 2839 | }, |
| 2840 | .dec = { |
| 2841 | .vecs = tf_ctr_dec_tv_template, |
| 2842 | .count = TF_CTR_DEC_TEST_VECTORS |
| 2843 | } |
| 2844 | } |
| 2845 | } |
| 2846 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2847 | .alg = "cts(cbc(aes))", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 2848 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2849 | .suite = { |
| 2850 | .cipher = { |
| 2851 | .enc = { |
| 2852 | .vecs = cts_mode_enc_tv_template, |
| 2853 | .count = CTS_MODE_ENC_TEST_VECTORS |
| 2854 | }, |
| 2855 | .dec = { |
| 2856 | .vecs = cts_mode_dec_tv_template, |
| 2857 | .count = CTS_MODE_DEC_TEST_VECTORS |
| 2858 | } |
| 2859 | } |
| 2860 | } |
| 2861 | }, { |
| 2862 | .alg = "deflate", |
| 2863 | .test = alg_test_comp, |
Milan Broz | 0818904 | 2012-12-06 17:16:28 +0800 | [diff] [blame] | 2864 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 2865 | .suite = { |
| 2866 | .comp = { |
| 2867 | .comp = { |
| 2868 | .vecs = deflate_comp_tv_template, |
| 2869 | .count = DEFLATE_COMP_TEST_VECTORS |
| 2870 | }, |
| 2871 | .decomp = { |
| 2872 | .vecs = deflate_decomp_tv_template, |
| 2873 | .count = DEFLATE_DECOMP_TEST_VECTORS |
| 2874 | } |
| 2875 | } |
| 2876 | } |
| 2877 | }, { |
Salvatore Benedetto | 802c7f1 | 2016-06-22 17:49:14 +0100 | [diff] [blame] | 2878 | .alg = "dh", |
| 2879 | .test = alg_test_kpp, |
| 2880 | .fips_allowed = 1, |
| 2881 | .suite = { |
| 2882 | .kpp = { |
| 2883 | .vecs = dh_tv_template, |
| 2884 | .count = DH_TEST_VECTORS |
| 2885 | } |
| 2886 | } |
| 2887 | }, { |
Jussi Kivilinna | e448370 | 2013-04-07 16:43:56 +0300 | [diff] [blame] | 2888 | .alg = "digest_null", |
| 2889 | .test = alg_test_null, |
| 2890 | }, { |
Stephan Mueller | 64d1cdf | 2014-05-31 17:25:36 +0200 | [diff] [blame] | 2891 | .alg = "drbg_nopr_ctr_aes128", |
| 2892 | .test = alg_test_drbg, |
| 2893 | .fips_allowed = 1, |
| 2894 | .suite = { |
| 2895 | .drbg = { |
| 2896 | .vecs = drbg_nopr_ctr_aes128_tv_template, |
| 2897 | .count = ARRAY_SIZE(drbg_nopr_ctr_aes128_tv_template) |
| 2898 | } |
| 2899 | } |
| 2900 | }, { |
| 2901 | .alg = "drbg_nopr_ctr_aes192", |
| 2902 | .test = alg_test_drbg, |
| 2903 | .fips_allowed = 1, |
| 2904 | .suite = { |
| 2905 | .drbg = { |
| 2906 | .vecs = drbg_nopr_ctr_aes192_tv_template, |
| 2907 | .count = ARRAY_SIZE(drbg_nopr_ctr_aes192_tv_template) |
| 2908 | } |
| 2909 | } |
| 2910 | }, { |
| 2911 | .alg = "drbg_nopr_ctr_aes256", |
| 2912 | .test = alg_test_drbg, |
| 2913 | .fips_allowed = 1, |
| 2914 | .suite = { |
| 2915 | .drbg = { |
| 2916 | .vecs = drbg_nopr_ctr_aes256_tv_template, |
| 2917 | .count = ARRAY_SIZE(drbg_nopr_ctr_aes256_tv_template) |
| 2918 | } |
| 2919 | } |
| 2920 | }, { |
| 2921 | /* |
| 2922 | * There is no need to specifically test the DRBG with every |
| 2923 | * backend cipher -- covered by drbg_nopr_hmac_sha256 test |
| 2924 | */ |
| 2925 | .alg = "drbg_nopr_hmac_sha1", |
| 2926 | .fips_allowed = 1, |
| 2927 | .test = alg_test_null, |
| 2928 | }, { |
| 2929 | .alg = "drbg_nopr_hmac_sha256", |
| 2930 | .test = alg_test_drbg, |
| 2931 | .fips_allowed = 1, |
| 2932 | .suite = { |
| 2933 | .drbg = { |
| 2934 | .vecs = drbg_nopr_hmac_sha256_tv_template, |
| 2935 | .count = |
| 2936 | ARRAY_SIZE(drbg_nopr_hmac_sha256_tv_template) |
| 2937 | } |
| 2938 | } |
| 2939 | }, { |
| 2940 | /* covered by drbg_nopr_hmac_sha256 test */ |
| 2941 | .alg = "drbg_nopr_hmac_sha384", |
| 2942 | .fips_allowed = 1, |
| 2943 | .test = alg_test_null, |
| 2944 | }, { |
| 2945 | .alg = "drbg_nopr_hmac_sha512", |
| 2946 | .test = alg_test_null, |
| 2947 | .fips_allowed = 1, |
| 2948 | }, { |
| 2949 | .alg = "drbg_nopr_sha1", |
| 2950 | .fips_allowed = 1, |
| 2951 | .test = alg_test_null, |
| 2952 | }, { |
| 2953 | .alg = "drbg_nopr_sha256", |
| 2954 | .test = alg_test_drbg, |
| 2955 | .fips_allowed = 1, |
| 2956 | .suite = { |
| 2957 | .drbg = { |
| 2958 | .vecs = drbg_nopr_sha256_tv_template, |
| 2959 | .count = ARRAY_SIZE(drbg_nopr_sha256_tv_template) |
| 2960 | } |
| 2961 | } |
| 2962 | }, { |
| 2963 | /* covered by drbg_nopr_sha256 test */ |
| 2964 | .alg = "drbg_nopr_sha384", |
| 2965 | .fips_allowed = 1, |
| 2966 | .test = alg_test_null, |
| 2967 | }, { |
| 2968 | .alg = "drbg_nopr_sha512", |
| 2969 | .fips_allowed = 1, |
| 2970 | .test = alg_test_null, |
| 2971 | }, { |
| 2972 | .alg = "drbg_pr_ctr_aes128", |
| 2973 | .test = alg_test_drbg, |
| 2974 | .fips_allowed = 1, |
| 2975 | .suite = { |
| 2976 | .drbg = { |
| 2977 | .vecs = drbg_pr_ctr_aes128_tv_template, |
| 2978 | .count = ARRAY_SIZE(drbg_pr_ctr_aes128_tv_template) |
| 2979 | } |
| 2980 | } |
| 2981 | }, { |
| 2982 | /* covered by drbg_pr_ctr_aes128 test */ |
| 2983 | .alg = "drbg_pr_ctr_aes192", |
| 2984 | .fips_allowed = 1, |
| 2985 | .test = alg_test_null, |
| 2986 | }, { |
| 2987 | .alg = "drbg_pr_ctr_aes256", |
| 2988 | .fips_allowed = 1, |
| 2989 | .test = alg_test_null, |
| 2990 | }, { |
| 2991 | .alg = "drbg_pr_hmac_sha1", |
| 2992 | .fips_allowed = 1, |
| 2993 | .test = alg_test_null, |
| 2994 | }, { |
| 2995 | .alg = "drbg_pr_hmac_sha256", |
| 2996 | .test = alg_test_drbg, |
| 2997 | .fips_allowed = 1, |
| 2998 | .suite = { |
| 2999 | .drbg = { |
| 3000 | .vecs = drbg_pr_hmac_sha256_tv_template, |
| 3001 | .count = ARRAY_SIZE(drbg_pr_hmac_sha256_tv_template) |
| 3002 | } |
| 3003 | } |
| 3004 | }, { |
| 3005 | /* covered by drbg_pr_hmac_sha256 test */ |
| 3006 | .alg = "drbg_pr_hmac_sha384", |
| 3007 | .fips_allowed = 1, |
| 3008 | .test = alg_test_null, |
| 3009 | }, { |
| 3010 | .alg = "drbg_pr_hmac_sha512", |
| 3011 | .test = alg_test_null, |
| 3012 | .fips_allowed = 1, |
| 3013 | }, { |
| 3014 | .alg = "drbg_pr_sha1", |
| 3015 | .fips_allowed = 1, |
| 3016 | .test = alg_test_null, |
| 3017 | }, { |
| 3018 | .alg = "drbg_pr_sha256", |
| 3019 | .test = alg_test_drbg, |
| 3020 | .fips_allowed = 1, |
| 3021 | .suite = { |
| 3022 | .drbg = { |
| 3023 | .vecs = drbg_pr_sha256_tv_template, |
| 3024 | .count = ARRAY_SIZE(drbg_pr_sha256_tv_template) |
| 3025 | } |
| 3026 | } |
| 3027 | }, { |
| 3028 | /* covered by drbg_pr_sha256 test */ |
| 3029 | .alg = "drbg_pr_sha384", |
| 3030 | .fips_allowed = 1, |
| 3031 | .test = alg_test_null, |
| 3032 | }, { |
| 3033 | .alg = "drbg_pr_sha512", |
| 3034 | .fips_allowed = 1, |
| 3035 | .test = alg_test_null, |
| 3036 | }, { |
Youquan, Song | 863b557 | 2009-12-23 19:45:20 +0800 | [diff] [blame] | 3037 | .alg = "ecb(__aes-aesni)", |
| 3038 | .test = alg_test_null, |
Milan Broz | 6c79294 | 2012-06-29 22:08:09 +0200 | [diff] [blame] | 3039 | .fips_allowed = 1, |
Youquan, Song | 863b557 | 2009-12-23 19:45:20 +0800 | [diff] [blame] | 3040 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3041 | .alg = "ecb(aes)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3042 | .test = alg_test_skcipher, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3043 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3044 | .suite = { |
| 3045 | .cipher = { |
| 3046 | .enc = { |
| 3047 | .vecs = aes_enc_tv_template, |
| 3048 | .count = AES_ENC_TEST_VECTORS |
| 3049 | }, |
| 3050 | .dec = { |
| 3051 | .vecs = aes_dec_tv_template, |
| 3052 | .count = AES_DEC_TEST_VECTORS |
| 3053 | } |
| 3054 | } |
| 3055 | } |
| 3056 | }, { |
| 3057 | .alg = "ecb(anubis)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3058 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3059 | .suite = { |
| 3060 | .cipher = { |
| 3061 | .enc = { |
| 3062 | .vecs = anubis_enc_tv_template, |
| 3063 | .count = ANUBIS_ENC_TEST_VECTORS |
| 3064 | }, |
| 3065 | .dec = { |
| 3066 | .vecs = anubis_dec_tv_template, |
| 3067 | .count = ANUBIS_DEC_TEST_VECTORS |
| 3068 | } |
| 3069 | } |
| 3070 | } |
| 3071 | }, { |
| 3072 | .alg = "ecb(arc4)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3073 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3074 | .suite = { |
| 3075 | .cipher = { |
| 3076 | .enc = { |
| 3077 | .vecs = arc4_enc_tv_template, |
| 3078 | .count = ARC4_ENC_TEST_VECTORS |
| 3079 | }, |
| 3080 | .dec = { |
| 3081 | .vecs = arc4_dec_tv_template, |
| 3082 | .count = ARC4_DEC_TEST_VECTORS |
| 3083 | } |
| 3084 | } |
| 3085 | } |
| 3086 | }, { |
| 3087 | .alg = "ecb(blowfish)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3088 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3089 | .suite = { |
| 3090 | .cipher = { |
| 3091 | .enc = { |
| 3092 | .vecs = bf_enc_tv_template, |
| 3093 | .count = BF_ENC_TEST_VECTORS |
| 3094 | }, |
| 3095 | .dec = { |
| 3096 | .vecs = bf_dec_tv_template, |
| 3097 | .count = BF_DEC_TEST_VECTORS |
| 3098 | } |
| 3099 | } |
| 3100 | } |
| 3101 | }, { |
| 3102 | .alg = "ecb(camellia)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3103 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3104 | .suite = { |
| 3105 | .cipher = { |
| 3106 | .enc = { |
| 3107 | .vecs = camellia_enc_tv_template, |
| 3108 | .count = CAMELLIA_ENC_TEST_VECTORS |
| 3109 | }, |
| 3110 | .dec = { |
| 3111 | .vecs = camellia_dec_tv_template, |
| 3112 | .count = CAMELLIA_DEC_TEST_VECTORS |
| 3113 | } |
| 3114 | } |
| 3115 | } |
| 3116 | }, { |
| 3117 | .alg = "ecb(cast5)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3118 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3119 | .suite = { |
| 3120 | .cipher = { |
| 3121 | .enc = { |
| 3122 | .vecs = cast5_enc_tv_template, |
| 3123 | .count = CAST5_ENC_TEST_VECTORS |
| 3124 | }, |
| 3125 | .dec = { |
| 3126 | .vecs = cast5_dec_tv_template, |
| 3127 | .count = CAST5_DEC_TEST_VECTORS |
| 3128 | } |
| 3129 | } |
| 3130 | } |
| 3131 | }, { |
| 3132 | .alg = "ecb(cast6)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3133 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3134 | .suite = { |
| 3135 | .cipher = { |
| 3136 | .enc = { |
| 3137 | .vecs = cast6_enc_tv_template, |
| 3138 | .count = CAST6_ENC_TEST_VECTORS |
| 3139 | }, |
| 3140 | .dec = { |
| 3141 | .vecs = cast6_dec_tv_template, |
| 3142 | .count = CAST6_DEC_TEST_VECTORS |
| 3143 | } |
| 3144 | } |
| 3145 | } |
| 3146 | }, { |
Jussi Kivilinna | e448370 | 2013-04-07 16:43:56 +0300 | [diff] [blame] | 3147 | .alg = "ecb(cipher_null)", |
| 3148 | .test = alg_test_null, |
| 3149 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3150 | .alg = "ecb(des)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3151 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3152 | .suite = { |
| 3153 | .cipher = { |
| 3154 | .enc = { |
| 3155 | .vecs = des_enc_tv_template, |
| 3156 | .count = DES_ENC_TEST_VECTORS |
| 3157 | }, |
| 3158 | .dec = { |
| 3159 | .vecs = des_dec_tv_template, |
| 3160 | .count = DES_DEC_TEST_VECTORS |
| 3161 | } |
| 3162 | } |
| 3163 | } |
| 3164 | }, { |
| 3165 | .alg = "ecb(des3_ede)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3166 | .test = alg_test_skcipher, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3167 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3168 | .suite = { |
| 3169 | .cipher = { |
| 3170 | .enc = { |
| 3171 | .vecs = des3_ede_enc_tv_template, |
| 3172 | .count = DES3_EDE_ENC_TEST_VECTORS |
| 3173 | }, |
| 3174 | .dec = { |
| 3175 | .vecs = des3_ede_dec_tv_template, |
| 3176 | .count = DES3_EDE_DEC_TEST_VECTORS |
| 3177 | } |
| 3178 | } |
| 3179 | } |
| 3180 | }, { |
Jussi Kivilinna | 66e5bd0 | 2013-01-19 13:31:36 +0200 | [diff] [blame] | 3181 | .alg = "ecb(fcrypt)", |
| 3182 | .test = alg_test_skcipher, |
| 3183 | .suite = { |
| 3184 | .cipher = { |
| 3185 | .enc = { |
| 3186 | .vecs = fcrypt_pcbc_enc_tv_template, |
| 3187 | .count = 1 |
| 3188 | }, |
| 3189 | .dec = { |
| 3190 | .vecs = fcrypt_pcbc_dec_tv_template, |
| 3191 | .count = 1 |
| 3192 | } |
| 3193 | } |
| 3194 | } |
| 3195 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3196 | .alg = "ecb(khazad)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3197 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3198 | .suite = { |
| 3199 | .cipher = { |
| 3200 | .enc = { |
| 3201 | .vecs = khazad_enc_tv_template, |
| 3202 | .count = KHAZAD_ENC_TEST_VECTORS |
| 3203 | }, |
| 3204 | .dec = { |
| 3205 | .vecs = khazad_dec_tv_template, |
| 3206 | .count = KHAZAD_DEC_TEST_VECTORS |
| 3207 | } |
| 3208 | } |
| 3209 | } |
| 3210 | }, { |
| 3211 | .alg = "ecb(seed)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3212 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3213 | .suite = { |
| 3214 | .cipher = { |
| 3215 | .enc = { |
| 3216 | .vecs = seed_enc_tv_template, |
| 3217 | .count = SEED_ENC_TEST_VECTORS |
| 3218 | }, |
| 3219 | .dec = { |
| 3220 | .vecs = seed_dec_tv_template, |
| 3221 | .count = SEED_DEC_TEST_VECTORS |
| 3222 | } |
| 3223 | } |
| 3224 | } |
| 3225 | }, { |
| 3226 | .alg = "ecb(serpent)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3227 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3228 | .suite = { |
| 3229 | .cipher = { |
| 3230 | .enc = { |
| 3231 | .vecs = serpent_enc_tv_template, |
| 3232 | .count = SERPENT_ENC_TEST_VECTORS |
| 3233 | }, |
| 3234 | .dec = { |
| 3235 | .vecs = serpent_dec_tv_template, |
| 3236 | .count = SERPENT_DEC_TEST_VECTORS |
| 3237 | } |
| 3238 | } |
| 3239 | } |
| 3240 | }, { |
| 3241 | .alg = "ecb(tea)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3242 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3243 | .suite = { |
| 3244 | .cipher = { |
| 3245 | .enc = { |
| 3246 | .vecs = tea_enc_tv_template, |
| 3247 | .count = TEA_ENC_TEST_VECTORS |
| 3248 | }, |
| 3249 | .dec = { |
| 3250 | .vecs = tea_dec_tv_template, |
| 3251 | .count = TEA_DEC_TEST_VECTORS |
| 3252 | } |
| 3253 | } |
| 3254 | } |
| 3255 | }, { |
| 3256 | .alg = "ecb(tnepres)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3257 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3258 | .suite = { |
| 3259 | .cipher = { |
| 3260 | .enc = { |
| 3261 | .vecs = tnepres_enc_tv_template, |
| 3262 | .count = TNEPRES_ENC_TEST_VECTORS |
| 3263 | }, |
| 3264 | .dec = { |
| 3265 | .vecs = tnepres_dec_tv_template, |
| 3266 | .count = TNEPRES_DEC_TEST_VECTORS |
| 3267 | } |
| 3268 | } |
| 3269 | } |
| 3270 | }, { |
| 3271 | .alg = "ecb(twofish)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3272 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3273 | .suite = { |
| 3274 | .cipher = { |
| 3275 | .enc = { |
| 3276 | .vecs = tf_enc_tv_template, |
| 3277 | .count = TF_ENC_TEST_VECTORS |
| 3278 | }, |
| 3279 | .dec = { |
| 3280 | .vecs = tf_dec_tv_template, |
| 3281 | .count = TF_DEC_TEST_VECTORS |
| 3282 | } |
| 3283 | } |
| 3284 | } |
| 3285 | }, { |
| 3286 | .alg = "ecb(xeta)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3287 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3288 | .suite = { |
| 3289 | .cipher = { |
| 3290 | .enc = { |
| 3291 | .vecs = xeta_enc_tv_template, |
| 3292 | .count = XETA_ENC_TEST_VECTORS |
| 3293 | }, |
| 3294 | .dec = { |
| 3295 | .vecs = xeta_dec_tv_template, |
| 3296 | .count = XETA_DEC_TEST_VECTORS |
| 3297 | } |
| 3298 | } |
| 3299 | } |
| 3300 | }, { |
| 3301 | .alg = "ecb(xtea)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3302 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3303 | .suite = { |
| 3304 | .cipher = { |
| 3305 | .enc = { |
| 3306 | .vecs = xtea_enc_tv_template, |
| 3307 | .count = XTEA_ENC_TEST_VECTORS |
| 3308 | }, |
| 3309 | .dec = { |
| 3310 | .vecs = xtea_dec_tv_template, |
| 3311 | .count = XTEA_DEC_TEST_VECTORS |
| 3312 | } |
| 3313 | } |
| 3314 | } |
| 3315 | }, { |
Salvatore Benedetto | 3c4b239 | 2016-06-22 17:49:15 +0100 | [diff] [blame] | 3316 | .alg = "ecdh", |
| 3317 | .test = alg_test_kpp, |
| 3318 | .fips_allowed = 1, |
| 3319 | .suite = { |
| 3320 | .kpp = { |
| 3321 | .vecs = ecdh_tv_template, |
| 3322 | .count = ECDH_TEST_VECTORS |
| 3323 | } |
| 3324 | } |
| 3325 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3326 | .alg = "gcm(aes)", |
| 3327 | .test = alg_test_aead, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3328 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3329 | .suite = { |
| 3330 | .aead = { |
| 3331 | .enc = { |
| 3332 | .vecs = aes_gcm_enc_tv_template, |
| 3333 | .count = AES_GCM_ENC_TEST_VECTORS |
| 3334 | }, |
| 3335 | .dec = { |
| 3336 | .vecs = aes_gcm_dec_tv_template, |
| 3337 | .count = AES_GCM_DEC_TEST_VECTORS |
| 3338 | } |
| 3339 | } |
| 3340 | } |
| 3341 | }, { |
Youquan, Song | 507069c | 2009-11-23 20:23:04 +0800 | [diff] [blame] | 3342 | .alg = "ghash", |
| 3343 | .test = alg_test_hash, |
Jarod Wilson | 18c0ebd | 2011-01-29 15:14:35 +1100 | [diff] [blame] | 3344 | .fips_allowed = 1, |
Youquan, Song | 507069c | 2009-11-23 20:23:04 +0800 | [diff] [blame] | 3345 | .suite = { |
| 3346 | .hash = { |
| 3347 | .vecs = ghash_tv_template, |
| 3348 | .count = GHASH_TEST_VECTORS |
| 3349 | } |
| 3350 | } |
| 3351 | }, { |
Sonic Zhang | a482b08 | 2012-05-25 17:54:13 +0800 | [diff] [blame] | 3352 | .alg = "hmac(crc32)", |
| 3353 | .test = alg_test_hash, |
| 3354 | .suite = { |
| 3355 | .hash = { |
| 3356 | .vecs = bfin_crc_tv_template, |
| 3357 | .count = BFIN_CRC_TEST_VECTORS |
| 3358 | } |
| 3359 | } |
| 3360 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3361 | .alg = "hmac(md5)", |
| 3362 | .test = alg_test_hash, |
| 3363 | .suite = { |
| 3364 | .hash = { |
| 3365 | .vecs = hmac_md5_tv_template, |
| 3366 | .count = HMAC_MD5_TEST_VECTORS |
| 3367 | } |
| 3368 | } |
| 3369 | }, { |
| 3370 | .alg = "hmac(rmd128)", |
| 3371 | .test = alg_test_hash, |
| 3372 | .suite = { |
| 3373 | .hash = { |
| 3374 | .vecs = hmac_rmd128_tv_template, |
| 3375 | .count = HMAC_RMD128_TEST_VECTORS |
| 3376 | } |
| 3377 | } |
| 3378 | }, { |
| 3379 | .alg = "hmac(rmd160)", |
| 3380 | .test = alg_test_hash, |
| 3381 | .suite = { |
| 3382 | .hash = { |
| 3383 | .vecs = hmac_rmd160_tv_template, |
| 3384 | .count = HMAC_RMD160_TEST_VECTORS |
| 3385 | } |
| 3386 | } |
| 3387 | }, { |
| 3388 | .alg = "hmac(sha1)", |
| 3389 | .test = alg_test_hash, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3390 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3391 | .suite = { |
| 3392 | .hash = { |
| 3393 | .vecs = hmac_sha1_tv_template, |
| 3394 | .count = HMAC_SHA1_TEST_VECTORS |
| 3395 | } |
| 3396 | } |
| 3397 | }, { |
| 3398 | .alg = "hmac(sha224)", |
| 3399 | .test = alg_test_hash, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3400 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3401 | .suite = { |
| 3402 | .hash = { |
| 3403 | .vecs = hmac_sha224_tv_template, |
| 3404 | .count = HMAC_SHA224_TEST_VECTORS |
| 3405 | } |
| 3406 | } |
| 3407 | }, { |
| 3408 | .alg = "hmac(sha256)", |
| 3409 | .test = alg_test_hash, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3410 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3411 | .suite = { |
| 3412 | .hash = { |
| 3413 | .vecs = hmac_sha256_tv_template, |
| 3414 | .count = HMAC_SHA256_TEST_VECTORS |
| 3415 | } |
| 3416 | } |
| 3417 | }, { |
raveendra padasalagi | 98eca72 | 2016-07-01 11:16:54 +0530 | [diff] [blame] | 3418 | .alg = "hmac(sha3-224)", |
| 3419 | .test = alg_test_hash, |
| 3420 | .fips_allowed = 1, |
| 3421 | .suite = { |
| 3422 | .hash = { |
| 3423 | .vecs = hmac_sha3_224_tv_template, |
| 3424 | .count = HMAC_SHA3_224_TEST_VECTORS |
| 3425 | } |
| 3426 | } |
| 3427 | }, { |
| 3428 | .alg = "hmac(sha3-256)", |
| 3429 | .test = alg_test_hash, |
| 3430 | .fips_allowed = 1, |
| 3431 | .suite = { |
| 3432 | .hash = { |
| 3433 | .vecs = hmac_sha3_256_tv_template, |
| 3434 | .count = HMAC_SHA3_256_TEST_VECTORS |
| 3435 | } |
| 3436 | } |
| 3437 | }, { |
| 3438 | .alg = "hmac(sha3-384)", |
| 3439 | .test = alg_test_hash, |
| 3440 | .fips_allowed = 1, |
| 3441 | .suite = { |
| 3442 | .hash = { |
| 3443 | .vecs = hmac_sha3_384_tv_template, |
| 3444 | .count = HMAC_SHA3_384_TEST_VECTORS |
| 3445 | } |
| 3446 | } |
| 3447 | }, { |
| 3448 | .alg = "hmac(sha3-512)", |
| 3449 | .test = alg_test_hash, |
| 3450 | .fips_allowed = 1, |
| 3451 | .suite = { |
| 3452 | .hash = { |
| 3453 | .vecs = hmac_sha3_512_tv_template, |
| 3454 | .count = HMAC_SHA3_512_TEST_VECTORS |
| 3455 | } |
| 3456 | } |
| 3457 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3458 | .alg = "hmac(sha384)", |
| 3459 | .test = alg_test_hash, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3460 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3461 | .suite = { |
| 3462 | .hash = { |
| 3463 | .vecs = hmac_sha384_tv_template, |
| 3464 | .count = HMAC_SHA384_TEST_VECTORS |
| 3465 | } |
| 3466 | } |
| 3467 | }, { |
| 3468 | .alg = "hmac(sha512)", |
| 3469 | .test = alg_test_hash, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3470 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3471 | .suite = { |
| 3472 | .hash = { |
| 3473 | .vecs = hmac_sha512_tv_template, |
| 3474 | .count = HMAC_SHA512_TEST_VECTORS |
| 3475 | } |
| 3476 | } |
| 3477 | }, { |
Stephan Mueller | bb5530e | 2015-05-25 15:10:20 +0200 | [diff] [blame] | 3478 | .alg = "jitterentropy_rng", |
| 3479 | .fips_allowed = 1, |
| 3480 | .test = alg_test_null, |
| 3481 | }, { |
Stephan Mueller | 3535198 | 2015-09-21 20:59:56 +0200 | [diff] [blame] | 3482 | .alg = "kw(aes)", |
| 3483 | .test = alg_test_skcipher, |
| 3484 | .fips_allowed = 1, |
| 3485 | .suite = { |
| 3486 | .cipher = { |
| 3487 | .enc = { |
| 3488 | .vecs = aes_kw_enc_tv_template, |
| 3489 | .count = ARRAY_SIZE(aes_kw_enc_tv_template) |
| 3490 | }, |
| 3491 | .dec = { |
| 3492 | .vecs = aes_kw_dec_tv_template, |
| 3493 | .count = ARRAY_SIZE(aes_kw_dec_tv_template) |
| 3494 | } |
| 3495 | } |
| 3496 | } |
| 3497 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3498 | .alg = "lrw(aes)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3499 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3500 | .suite = { |
| 3501 | .cipher = { |
| 3502 | .enc = { |
| 3503 | .vecs = aes_lrw_enc_tv_template, |
| 3504 | .count = AES_LRW_ENC_TEST_VECTORS |
| 3505 | }, |
| 3506 | .dec = { |
| 3507 | .vecs = aes_lrw_dec_tv_template, |
| 3508 | .count = AES_LRW_DEC_TEST_VECTORS |
| 3509 | } |
| 3510 | } |
| 3511 | } |
| 3512 | }, { |
Jussi Kivilinna | 0840605 | 2012-03-05 20:26:21 +0200 | [diff] [blame] | 3513 | .alg = "lrw(camellia)", |
| 3514 | .test = alg_test_skcipher, |
| 3515 | .suite = { |
| 3516 | .cipher = { |
| 3517 | .enc = { |
| 3518 | .vecs = camellia_lrw_enc_tv_template, |
| 3519 | .count = CAMELLIA_LRW_ENC_TEST_VECTORS |
| 3520 | }, |
| 3521 | .dec = { |
| 3522 | .vecs = camellia_lrw_dec_tv_template, |
| 3523 | .count = CAMELLIA_LRW_DEC_TEST_VECTORS |
| 3524 | } |
| 3525 | } |
| 3526 | } |
| 3527 | }, { |
Johannes Goetzfried | 9b8b040 | 2012-07-11 19:38:29 +0200 | [diff] [blame] | 3528 | .alg = "lrw(cast6)", |
| 3529 | .test = alg_test_skcipher, |
| 3530 | .suite = { |
| 3531 | .cipher = { |
| 3532 | .enc = { |
| 3533 | .vecs = cast6_lrw_enc_tv_template, |
| 3534 | .count = CAST6_LRW_ENC_TEST_VECTORS |
| 3535 | }, |
| 3536 | .dec = { |
| 3537 | .vecs = cast6_lrw_dec_tv_template, |
| 3538 | .count = CAST6_LRW_DEC_TEST_VECTORS |
| 3539 | } |
| 3540 | } |
| 3541 | } |
| 3542 | }, { |
Jussi Kivilinna | d7bfc0f | 2011-10-18 13:32:34 +0300 | [diff] [blame] | 3543 | .alg = "lrw(serpent)", |
| 3544 | .test = alg_test_skcipher, |
| 3545 | .suite = { |
| 3546 | .cipher = { |
| 3547 | .enc = { |
| 3548 | .vecs = serpent_lrw_enc_tv_template, |
| 3549 | .count = SERPENT_LRW_ENC_TEST_VECTORS |
| 3550 | }, |
| 3551 | .dec = { |
| 3552 | .vecs = serpent_lrw_dec_tv_template, |
| 3553 | .count = SERPENT_LRW_DEC_TEST_VECTORS |
| 3554 | } |
| 3555 | } |
| 3556 | } |
| 3557 | }, { |
Jussi Kivilinna | 0b2a155 | 2011-10-18 13:32:50 +0300 | [diff] [blame] | 3558 | .alg = "lrw(twofish)", |
| 3559 | .test = alg_test_skcipher, |
| 3560 | .suite = { |
| 3561 | .cipher = { |
| 3562 | .enc = { |
| 3563 | .vecs = tf_lrw_enc_tv_template, |
| 3564 | .count = TF_LRW_ENC_TEST_VECTORS |
| 3565 | }, |
| 3566 | .dec = { |
| 3567 | .vecs = tf_lrw_dec_tv_template, |
| 3568 | .count = TF_LRW_DEC_TEST_VECTORS |
| 3569 | } |
| 3570 | } |
| 3571 | } |
| 3572 | }, { |
KOVACS Krisztian | 1443cc9 | 2014-08-22 10:44:36 +0200 | [diff] [blame] | 3573 | .alg = "lz4", |
| 3574 | .test = alg_test_comp, |
| 3575 | .fips_allowed = 1, |
| 3576 | .suite = { |
| 3577 | .comp = { |
| 3578 | .comp = { |
| 3579 | .vecs = lz4_comp_tv_template, |
| 3580 | .count = LZ4_COMP_TEST_VECTORS |
| 3581 | }, |
| 3582 | .decomp = { |
| 3583 | .vecs = lz4_decomp_tv_template, |
| 3584 | .count = LZ4_DECOMP_TEST_VECTORS |
| 3585 | } |
| 3586 | } |
| 3587 | } |
| 3588 | }, { |
| 3589 | .alg = "lz4hc", |
| 3590 | .test = alg_test_comp, |
| 3591 | .fips_allowed = 1, |
| 3592 | .suite = { |
| 3593 | .comp = { |
| 3594 | .comp = { |
| 3595 | .vecs = lz4hc_comp_tv_template, |
| 3596 | .count = LZ4HC_COMP_TEST_VECTORS |
| 3597 | }, |
| 3598 | .decomp = { |
| 3599 | .vecs = lz4hc_decomp_tv_template, |
| 3600 | .count = LZ4HC_DECOMP_TEST_VECTORS |
| 3601 | } |
| 3602 | } |
| 3603 | } |
| 3604 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3605 | .alg = "lzo", |
| 3606 | .test = alg_test_comp, |
Milan Broz | 0818904 | 2012-12-06 17:16:28 +0800 | [diff] [blame] | 3607 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3608 | .suite = { |
| 3609 | .comp = { |
| 3610 | .comp = { |
| 3611 | .vecs = lzo_comp_tv_template, |
| 3612 | .count = LZO_COMP_TEST_VECTORS |
| 3613 | }, |
| 3614 | .decomp = { |
| 3615 | .vecs = lzo_decomp_tv_template, |
| 3616 | .count = LZO_DECOMP_TEST_VECTORS |
| 3617 | } |
| 3618 | } |
| 3619 | } |
| 3620 | }, { |
| 3621 | .alg = "md4", |
| 3622 | .test = alg_test_hash, |
| 3623 | .suite = { |
| 3624 | .hash = { |
| 3625 | .vecs = md4_tv_template, |
| 3626 | .count = MD4_TEST_VECTORS |
| 3627 | } |
| 3628 | } |
| 3629 | }, { |
| 3630 | .alg = "md5", |
| 3631 | .test = alg_test_hash, |
| 3632 | .suite = { |
| 3633 | .hash = { |
| 3634 | .vecs = md5_tv_template, |
| 3635 | .count = MD5_TEST_VECTORS |
| 3636 | } |
| 3637 | } |
| 3638 | }, { |
| 3639 | .alg = "michael_mic", |
| 3640 | .test = alg_test_hash, |
| 3641 | .suite = { |
| 3642 | .hash = { |
| 3643 | .vecs = michael_mic_tv_template, |
| 3644 | .count = MICHAEL_MIC_TEST_VECTORS |
| 3645 | } |
| 3646 | } |
| 3647 | }, { |
Puneet Saxena | ba0e14a | 2011-05-04 15:04:10 +1000 | [diff] [blame] | 3648 | .alg = "ofb(aes)", |
| 3649 | .test = alg_test_skcipher, |
| 3650 | .fips_allowed = 1, |
| 3651 | .suite = { |
| 3652 | .cipher = { |
| 3653 | .enc = { |
| 3654 | .vecs = aes_ofb_enc_tv_template, |
| 3655 | .count = AES_OFB_ENC_TEST_VECTORS |
| 3656 | }, |
| 3657 | .dec = { |
| 3658 | .vecs = aes_ofb_dec_tv_template, |
| 3659 | .count = AES_OFB_DEC_TEST_VECTORS |
| 3660 | } |
| 3661 | } |
| 3662 | } |
| 3663 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3664 | .alg = "pcbc(fcrypt)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3665 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3666 | .suite = { |
| 3667 | .cipher = { |
| 3668 | .enc = { |
| 3669 | .vecs = fcrypt_pcbc_enc_tv_template, |
| 3670 | .count = FCRYPT_ENC_TEST_VECTORS |
| 3671 | }, |
| 3672 | .dec = { |
| 3673 | .vecs = fcrypt_pcbc_dec_tv_template, |
| 3674 | .count = FCRYPT_DEC_TEST_VECTORS |
| 3675 | } |
| 3676 | } |
| 3677 | } |
| 3678 | }, { |
Martin Willi | eee9dc6 | 2015-06-01 13:43:59 +0200 | [diff] [blame] | 3679 | .alg = "poly1305", |
| 3680 | .test = alg_test_hash, |
| 3681 | .suite = { |
| 3682 | .hash = { |
| 3683 | .vecs = poly1305_tv_template, |
| 3684 | .count = POLY1305_TEST_VECTORS |
| 3685 | } |
| 3686 | } |
| 3687 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3688 | .alg = "rfc3686(ctr(aes))", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3689 | .test = alg_test_skcipher, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3690 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3691 | .suite = { |
| 3692 | .cipher = { |
| 3693 | .enc = { |
Jarod Wilson | f7cb80f | 2009-05-06 17:29:17 +0800 | [diff] [blame] | 3694 | .vecs = aes_ctr_rfc3686_enc_tv_template, |
| 3695 | .count = AES_CTR_3686_ENC_TEST_VECTORS |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3696 | }, |
| 3697 | .dec = { |
Jarod Wilson | f7cb80f | 2009-05-06 17:29:17 +0800 | [diff] [blame] | 3698 | .vecs = aes_ctr_rfc3686_dec_tv_template, |
| 3699 | .count = AES_CTR_3686_DEC_TEST_VECTORS |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3700 | } |
| 3701 | } |
| 3702 | } |
| 3703 | }, { |
Herbert Xu | 3f31a74 | 2015-07-09 07:17:34 +0800 | [diff] [blame] | 3704 | .alg = "rfc4106(gcm(aes))", |
Adrian Hoban | 69435b9 | 2010-11-04 15:02:04 -0400 | [diff] [blame] | 3705 | .test = alg_test_aead, |
Jarod Wilson | db71f29 | 2015-01-23 12:42:15 -0500 | [diff] [blame] | 3706 | .fips_allowed = 1, |
Adrian Hoban | 69435b9 | 2010-11-04 15:02:04 -0400 | [diff] [blame] | 3707 | .suite = { |
| 3708 | .aead = { |
| 3709 | .enc = { |
| 3710 | .vecs = aes_gcm_rfc4106_enc_tv_template, |
| 3711 | .count = AES_GCM_4106_ENC_TEST_VECTORS |
| 3712 | }, |
| 3713 | .dec = { |
| 3714 | .vecs = aes_gcm_rfc4106_dec_tv_template, |
| 3715 | .count = AES_GCM_4106_DEC_TEST_VECTORS |
| 3716 | } |
| 3717 | } |
| 3718 | } |
| 3719 | }, { |
Herbert Xu | 544c436 | 2015-07-14 16:53:22 +0800 | [diff] [blame] | 3720 | .alg = "rfc4309(ccm(aes))", |
Jarod Wilson | 5d66732 | 2009-05-04 19:23:40 +0800 | [diff] [blame] | 3721 | .test = alg_test_aead, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3722 | .fips_allowed = 1, |
Jarod Wilson | 5d66732 | 2009-05-04 19:23:40 +0800 | [diff] [blame] | 3723 | .suite = { |
| 3724 | .aead = { |
| 3725 | .enc = { |
| 3726 | .vecs = aes_ccm_rfc4309_enc_tv_template, |
| 3727 | .count = AES_CCM_4309_ENC_TEST_VECTORS |
| 3728 | }, |
| 3729 | .dec = { |
| 3730 | .vecs = aes_ccm_rfc4309_dec_tv_template, |
| 3731 | .count = AES_CCM_4309_DEC_TEST_VECTORS |
| 3732 | } |
| 3733 | } |
| 3734 | } |
| 3735 | }, { |
Herbert Xu | bb68745 | 2015-06-16 13:54:24 +0800 | [diff] [blame] | 3736 | .alg = "rfc4543(gcm(aes))", |
Jussi Kivilinna | e9b7441 | 2013-04-07 16:43:51 +0300 | [diff] [blame] | 3737 | .test = alg_test_aead, |
| 3738 | .suite = { |
| 3739 | .aead = { |
| 3740 | .enc = { |
| 3741 | .vecs = aes_gcm_rfc4543_enc_tv_template, |
| 3742 | .count = AES_GCM_4543_ENC_TEST_VECTORS |
| 3743 | }, |
| 3744 | .dec = { |
| 3745 | .vecs = aes_gcm_rfc4543_dec_tv_template, |
| 3746 | .count = AES_GCM_4543_DEC_TEST_VECTORS |
| 3747 | }, |
| 3748 | } |
| 3749 | } |
| 3750 | }, { |
Martin Willi | af2b76b | 2015-06-01 13:44:01 +0200 | [diff] [blame] | 3751 | .alg = "rfc7539(chacha20,poly1305)", |
| 3752 | .test = alg_test_aead, |
| 3753 | .suite = { |
| 3754 | .aead = { |
| 3755 | .enc = { |
| 3756 | .vecs = rfc7539_enc_tv_template, |
| 3757 | .count = RFC7539_ENC_TEST_VECTORS |
| 3758 | }, |
| 3759 | .dec = { |
| 3760 | .vecs = rfc7539_dec_tv_template, |
| 3761 | .count = RFC7539_DEC_TEST_VECTORS |
| 3762 | }, |
| 3763 | } |
| 3764 | } |
| 3765 | }, { |
Martin Willi | 5900758 | 2015-06-01 13:44:03 +0200 | [diff] [blame] | 3766 | .alg = "rfc7539esp(chacha20,poly1305)", |
| 3767 | .test = alg_test_aead, |
| 3768 | .suite = { |
| 3769 | .aead = { |
| 3770 | .enc = { |
| 3771 | .vecs = rfc7539esp_enc_tv_template, |
| 3772 | .count = RFC7539ESP_ENC_TEST_VECTORS |
| 3773 | }, |
| 3774 | .dec = { |
| 3775 | .vecs = rfc7539esp_dec_tv_template, |
| 3776 | .count = RFC7539ESP_DEC_TEST_VECTORS |
| 3777 | }, |
| 3778 | } |
| 3779 | } |
| 3780 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3781 | .alg = "rmd128", |
| 3782 | .test = alg_test_hash, |
| 3783 | .suite = { |
| 3784 | .hash = { |
| 3785 | .vecs = rmd128_tv_template, |
| 3786 | .count = RMD128_TEST_VECTORS |
| 3787 | } |
| 3788 | } |
| 3789 | }, { |
| 3790 | .alg = "rmd160", |
| 3791 | .test = alg_test_hash, |
| 3792 | .suite = { |
| 3793 | .hash = { |
| 3794 | .vecs = rmd160_tv_template, |
| 3795 | .count = RMD160_TEST_VECTORS |
| 3796 | } |
| 3797 | } |
| 3798 | }, { |
| 3799 | .alg = "rmd256", |
| 3800 | .test = alg_test_hash, |
| 3801 | .suite = { |
| 3802 | .hash = { |
| 3803 | .vecs = rmd256_tv_template, |
| 3804 | .count = RMD256_TEST_VECTORS |
| 3805 | } |
| 3806 | } |
| 3807 | }, { |
| 3808 | .alg = "rmd320", |
| 3809 | .test = alg_test_hash, |
| 3810 | .suite = { |
| 3811 | .hash = { |
| 3812 | .vecs = rmd320_tv_template, |
| 3813 | .count = RMD320_TEST_VECTORS |
| 3814 | } |
| 3815 | } |
| 3816 | }, { |
Tadeusz Struk | 946cc46 | 2015-06-16 10:31:06 -0700 | [diff] [blame] | 3817 | .alg = "rsa", |
| 3818 | .test = alg_test_akcipher, |
| 3819 | .fips_allowed = 1, |
| 3820 | .suite = { |
| 3821 | .akcipher = { |
| 3822 | .vecs = rsa_tv_template, |
| 3823 | .count = RSA_TEST_VECTORS |
| 3824 | } |
| 3825 | } |
| 3826 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3827 | .alg = "salsa20", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 3828 | .test = alg_test_skcipher, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3829 | .suite = { |
| 3830 | .cipher = { |
| 3831 | .enc = { |
| 3832 | .vecs = salsa20_stream_enc_tv_template, |
| 3833 | .count = SALSA20_STREAM_ENC_TEST_VECTORS |
| 3834 | } |
| 3835 | } |
| 3836 | } |
| 3837 | }, { |
| 3838 | .alg = "sha1", |
| 3839 | .test = alg_test_hash, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3840 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3841 | .suite = { |
| 3842 | .hash = { |
| 3843 | .vecs = sha1_tv_template, |
| 3844 | .count = SHA1_TEST_VECTORS |
| 3845 | } |
| 3846 | } |
| 3847 | }, { |
| 3848 | .alg = "sha224", |
| 3849 | .test = alg_test_hash, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3850 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3851 | .suite = { |
| 3852 | .hash = { |
| 3853 | .vecs = sha224_tv_template, |
| 3854 | .count = SHA224_TEST_VECTORS |
| 3855 | } |
| 3856 | } |
| 3857 | }, { |
| 3858 | .alg = "sha256", |
| 3859 | .test = alg_test_hash, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3860 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3861 | .suite = { |
| 3862 | .hash = { |
| 3863 | .vecs = sha256_tv_template, |
| 3864 | .count = SHA256_TEST_VECTORS |
| 3865 | } |
| 3866 | } |
| 3867 | }, { |
raveendra padasalagi | 79cc6ab | 2016-06-17 10:30:36 +0530 | [diff] [blame] | 3868 | .alg = "sha3-224", |
| 3869 | .test = alg_test_hash, |
| 3870 | .fips_allowed = 1, |
| 3871 | .suite = { |
| 3872 | .hash = { |
| 3873 | .vecs = sha3_224_tv_template, |
| 3874 | .count = SHA3_224_TEST_VECTORS |
| 3875 | } |
| 3876 | } |
| 3877 | }, { |
| 3878 | .alg = "sha3-256", |
| 3879 | .test = alg_test_hash, |
| 3880 | .fips_allowed = 1, |
| 3881 | .suite = { |
| 3882 | .hash = { |
| 3883 | .vecs = sha3_256_tv_template, |
| 3884 | .count = SHA3_256_TEST_VECTORS |
| 3885 | } |
| 3886 | } |
| 3887 | }, { |
| 3888 | .alg = "sha3-384", |
| 3889 | .test = alg_test_hash, |
| 3890 | .fips_allowed = 1, |
| 3891 | .suite = { |
| 3892 | .hash = { |
| 3893 | .vecs = sha3_384_tv_template, |
| 3894 | .count = SHA3_384_TEST_VECTORS |
| 3895 | } |
| 3896 | } |
| 3897 | }, { |
| 3898 | .alg = "sha3-512", |
| 3899 | .test = alg_test_hash, |
| 3900 | .fips_allowed = 1, |
| 3901 | .suite = { |
| 3902 | .hash = { |
| 3903 | .vecs = sha3_512_tv_template, |
| 3904 | .count = SHA3_512_TEST_VECTORS |
| 3905 | } |
| 3906 | } |
| 3907 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3908 | .alg = "sha384", |
| 3909 | .test = alg_test_hash, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3910 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3911 | .suite = { |
| 3912 | .hash = { |
| 3913 | .vecs = sha384_tv_template, |
| 3914 | .count = SHA384_TEST_VECTORS |
| 3915 | } |
| 3916 | } |
| 3917 | }, { |
| 3918 | .alg = "sha512", |
| 3919 | .test = alg_test_hash, |
Jarod Wilson | a1915d5 | 2009-05-15 15:16:03 +1000 | [diff] [blame] | 3920 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3921 | .suite = { |
| 3922 | .hash = { |
| 3923 | .vecs = sha512_tv_template, |
| 3924 | .count = SHA512_TEST_VECTORS |
| 3925 | } |
| 3926 | } |
| 3927 | }, { |
| 3928 | .alg = "tgr128", |
| 3929 | .test = alg_test_hash, |
| 3930 | .suite = { |
| 3931 | .hash = { |
| 3932 | .vecs = tgr128_tv_template, |
| 3933 | .count = TGR128_TEST_VECTORS |
| 3934 | } |
| 3935 | } |
| 3936 | }, { |
| 3937 | .alg = "tgr160", |
| 3938 | .test = alg_test_hash, |
| 3939 | .suite = { |
| 3940 | .hash = { |
| 3941 | .vecs = tgr160_tv_template, |
| 3942 | .count = TGR160_TEST_VECTORS |
| 3943 | } |
| 3944 | } |
| 3945 | }, { |
| 3946 | .alg = "tgr192", |
| 3947 | .test = alg_test_hash, |
| 3948 | .suite = { |
| 3949 | .hash = { |
| 3950 | .vecs = tgr192_tv_template, |
| 3951 | .count = TGR192_TEST_VECTORS |
| 3952 | } |
| 3953 | } |
| 3954 | }, { |
Shane Wang | f1939f7 | 2009-09-02 20:05:22 +1000 | [diff] [blame] | 3955 | .alg = "vmac(aes)", |
| 3956 | .test = alg_test_hash, |
| 3957 | .suite = { |
| 3958 | .hash = { |
| 3959 | .vecs = aes_vmac128_tv_template, |
| 3960 | .count = VMAC_AES_TEST_VECTORS |
| 3961 | } |
| 3962 | } |
| 3963 | }, { |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 3964 | .alg = "wp256", |
| 3965 | .test = alg_test_hash, |
| 3966 | .suite = { |
| 3967 | .hash = { |
| 3968 | .vecs = wp256_tv_template, |
| 3969 | .count = WP256_TEST_VECTORS |
| 3970 | } |
| 3971 | } |
| 3972 | }, { |
| 3973 | .alg = "wp384", |
| 3974 | .test = alg_test_hash, |
| 3975 | .suite = { |
| 3976 | .hash = { |
| 3977 | .vecs = wp384_tv_template, |
| 3978 | .count = WP384_TEST_VECTORS |
| 3979 | } |
| 3980 | } |
| 3981 | }, { |
| 3982 | .alg = "wp512", |
| 3983 | .test = alg_test_hash, |
| 3984 | .suite = { |
| 3985 | .hash = { |
| 3986 | .vecs = wp512_tv_template, |
| 3987 | .count = WP512_TEST_VECTORS |
| 3988 | } |
| 3989 | } |
| 3990 | }, { |
| 3991 | .alg = "xcbc(aes)", |
| 3992 | .test = alg_test_hash, |
| 3993 | .suite = { |
| 3994 | .hash = { |
| 3995 | .vecs = aes_xcbc128_tv_template, |
| 3996 | .count = XCBC_AES_TEST_VECTORS |
| 3997 | } |
| 3998 | } |
| 3999 | }, { |
| 4000 | .alg = "xts(aes)", |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 4001 | .test = alg_test_skcipher, |
Jarod Wilson | 2918aa8 | 2011-01-29 15:14:01 +1100 | [diff] [blame] | 4002 | .fips_allowed = 1, |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 4003 | .suite = { |
| 4004 | .cipher = { |
| 4005 | .enc = { |
| 4006 | .vecs = aes_xts_enc_tv_template, |
| 4007 | .count = AES_XTS_ENC_TEST_VECTORS |
| 4008 | }, |
| 4009 | .dec = { |
| 4010 | .vecs = aes_xts_dec_tv_template, |
| 4011 | .count = AES_XTS_DEC_TEST_VECTORS |
| 4012 | } |
| 4013 | } |
| 4014 | } |
Geert Uytterhoeven | 0c01aed | 2009-03-04 15:42:15 +0800 | [diff] [blame] | 4015 | }, { |
Jussi Kivilinna | 0840605 | 2012-03-05 20:26:21 +0200 | [diff] [blame] | 4016 | .alg = "xts(camellia)", |
| 4017 | .test = alg_test_skcipher, |
| 4018 | .suite = { |
| 4019 | .cipher = { |
| 4020 | .enc = { |
| 4021 | .vecs = camellia_xts_enc_tv_template, |
| 4022 | .count = CAMELLIA_XTS_ENC_TEST_VECTORS |
| 4023 | }, |
| 4024 | .dec = { |
| 4025 | .vecs = camellia_xts_dec_tv_template, |
| 4026 | .count = CAMELLIA_XTS_DEC_TEST_VECTORS |
| 4027 | } |
| 4028 | } |
| 4029 | } |
| 4030 | }, { |
Johannes Goetzfried | 9b8b040 | 2012-07-11 19:38:29 +0200 | [diff] [blame] | 4031 | .alg = "xts(cast6)", |
| 4032 | .test = alg_test_skcipher, |
| 4033 | .suite = { |
| 4034 | .cipher = { |
| 4035 | .enc = { |
| 4036 | .vecs = cast6_xts_enc_tv_template, |
| 4037 | .count = CAST6_XTS_ENC_TEST_VECTORS |
| 4038 | }, |
| 4039 | .dec = { |
| 4040 | .vecs = cast6_xts_dec_tv_template, |
| 4041 | .count = CAST6_XTS_DEC_TEST_VECTORS |
| 4042 | } |
| 4043 | } |
| 4044 | } |
| 4045 | }, { |
Jussi Kivilinna | 18be20b | 2011-10-18 13:33:17 +0300 | [diff] [blame] | 4046 | .alg = "xts(serpent)", |
| 4047 | .test = alg_test_skcipher, |
| 4048 | .suite = { |
| 4049 | .cipher = { |
| 4050 | .enc = { |
| 4051 | .vecs = serpent_xts_enc_tv_template, |
| 4052 | .count = SERPENT_XTS_ENC_TEST_VECTORS |
| 4053 | }, |
| 4054 | .dec = { |
| 4055 | .vecs = serpent_xts_dec_tv_template, |
| 4056 | .count = SERPENT_XTS_DEC_TEST_VECTORS |
| 4057 | } |
| 4058 | } |
| 4059 | } |
| 4060 | }, { |
Jussi Kivilinna | aed265b | 2011-10-18 13:33:33 +0300 | [diff] [blame] | 4061 | .alg = "xts(twofish)", |
| 4062 | .test = alg_test_skcipher, |
| 4063 | .suite = { |
| 4064 | .cipher = { |
| 4065 | .enc = { |
| 4066 | .vecs = tf_xts_enc_tv_template, |
| 4067 | .count = TF_XTS_ENC_TEST_VECTORS |
| 4068 | }, |
| 4069 | .dec = { |
| 4070 | .vecs = tf_xts_dec_tv_template, |
| 4071 | .count = TF_XTS_DEC_TEST_VECTORS |
| 4072 | } |
| 4073 | } |
| 4074 | } |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 4075 | } |
| 4076 | }; |
| 4077 | |
Jussi Kivilinna | 5714758 | 2013-06-13 17:37:40 +0300 | [diff] [blame] | 4078 | static bool alg_test_descs_checked; |
| 4079 | |
| 4080 | static void alg_test_descs_check_order(void) |
| 4081 | { |
| 4082 | int i; |
| 4083 | |
| 4084 | /* only check once */ |
| 4085 | if (alg_test_descs_checked) |
| 4086 | return; |
| 4087 | |
| 4088 | alg_test_descs_checked = true; |
| 4089 | |
| 4090 | for (i = 1; i < ARRAY_SIZE(alg_test_descs); i++) { |
| 4091 | int diff = strcmp(alg_test_descs[i - 1].alg, |
| 4092 | alg_test_descs[i].alg); |
| 4093 | |
| 4094 | if (WARN_ON(diff > 0)) { |
| 4095 | pr_warn("testmgr: alg_test_descs entries in wrong order: '%s' before '%s'\n", |
| 4096 | alg_test_descs[i - 1].alg, |
| 4097 | alg_test_descs[i].alg); |
| 4098 | } |
| 4099 | |
| 4100 | if (WARN_ON(diff == 0)) { |
| 4101 | pr_warn("testmgr: duplicate alg_test_descs entry: '%s'\n", |
| 4102 | alg_test_descs[i].alg); |
| 4103 | } |
| 4104 | } |
| 4105 | } |
| 4106 | |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 4107 | static int alg_find_test(const char *alg) |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 4108 | { |
| 4109 | int start = 0; |
| 4110 | int end = ARRAY_SIZE(alg_test_descs); |
| 4111 | |
| 4112 | while (start < end) { |
| 4113 | int i = (start + end) / 2; |
| 4114 | int diff = strcmp(alg_test_descs[i].alg, alg); |
| 4115 | |
| 4116 | if (diff > 0) { |
| 4117 | end = i; |
| 4118 | continue; |
| 4119 | } |
| 4120 | |
| 4121 | if (diff < 0) { |
| 4122 | start = i + 1; |
| 4123 | continue; |
| 4124 | } |
| 4125 | |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 4126 | return i; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 4127 | } |
| 4128 | |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 4129 | return -1; |
| 4130 | } |
| 4131 | |
| 4132 | int alg_test(const char *driver, const char *alg, u32 type, u32 mask) |
| 4133 | { |
| 4134 | int i; |
Herbert Xu | a68f661 | 2009-07-02 16:32:12 +0800 | [diff] [blame] | 4135 | int j; |
Neil Horman | d12d6b6 | 2008-10-12 20:36:51 +0800 | [diff] [blame] | 4136 | int rc; |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 4137 | |
Richard W.M. Jones | 9e5c9fe | 2016-05-03 10:00:17 +0100 | [diff] [blame] | 4138 | if (!fips_enabled && notests) { |
| 4139 | printk_once(KERN_INFO "alg: self-tests disabled\n"); |
| 4140 | return 0; |
| 4141 | } |
| 4142 | |
Jussi Kivilinna | 5714758 | 2013-06-13 17:37:40 +0300 | [diff] [blame] | 4143 | alg_test_descs_check_order(); |
| 4144 | |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 4145 | if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) { |
| 4146 | char nalg[CRYPTO_MAX_ALG_NAME]; |
| 4147 | |
| 4148 | if (snprintf(nalg, sizeof(nalg), "ecb(%s)", alg) >= |
| 4149 | sizeof(nalg)) |
| 4150 | return -ENAMETOOLONG; |
| 4151 | |
| 4152 | i = alg_find_test(nalg); |
| 4153 | if (i < 0) |
| 4154 | goto notest; |
| 4155 | |
Jarod Wilson | a3bef3a | 2009-05-15 15:17:05 +1000 | [diff] [blame] | 4156 | if (fips_enabled && !alg_test_descs[i].fips_allowed) |
| 4157 | goto non_fips_alg; |
| 4158 | |
Jarod Wilson | 941fb32 | 2009-05-04 19:49:23 +0800 | [diff] [blame] | 4159 | rc = alg_test_cipher(alg_test_descs + i, driver, type, mask); |
| 4160 | goto test_done; |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 4161 | } |
| 4162 | |
| 4163 | i = alg_find_test(alg); |
Herbert Xu | a68f661 | 2009-07-02 16:32:12 +0800 | [diff] [blame] | 4164 | j = alg_find_test(driver); |
| 4165 | if (i < 0 && j < 0) |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 4166 | goto notest; |
| 4167 | |
Herbert Xu | a68f661 | 2009-07-02 16:32:12 +0800 | [diff] [blame] | 4168 | if (fips_enabled && ((i >= 0 && !alg_test_descs[i].fips_allowed) || |
| 4169 | (j >= 0 && !alg_test_descs[j].fips_allowed))) |
Jarod Wilson | a3bef3a | 2009-05-15 15:17:05 +1000 | [diff] [blame] | 4170 | goto non_fips_alg; |
| 4171 | |
Herbert Xu | a68f661 | 2009-07-02 16:32:12 +0800 | [diff] [blame] | 4172 | rc = 0; |
| 4173 | if (i >= 0) |
| 4174 | rc |= alg_test_descs[i].test(alg_test_descs + i, driver, |
| 4175 | type, mask); |
Cristian Stoica | 032c8ca | 2013-07-18 18:57:07 +0300 | [diff] [blame] | 4176 | if (j >= 0 && j != i) |
Herbert Xu | a68f661 | 2009-07-02 16:32:12 +0800 | [diff] [blame] | 4177 | rc |= alg_test_descs[j].test(alg_test_descs + j, driver, |
| 4178 | type, mask); |
| 4179 | |
Jarod Wilson | 941fb32 | 2009-05-04 19:49:23 +0800 | [diff] [blame] | 4180 | test_done: |
Neil Horman | d12d6b6 | 2008-10-12 20:36:51 +0800 | [diff] [blame] | 4181 | if (fips_enabled && rc) |
| 4182 | panic("%s: %s alg self test failed in fips mode!\n", driver, alg); |
| 4183 | |
Jarod Wilson | 29ecd4a | 2009-05-04 19:51:17 +0800 | [diff] [blame] | 4184 | if (fips_enabled && !rc) |
Masanari Iida | 3e8cffd | 2014-10-07 00:37:54 +0900 | [diff] [blame] | 4185 | pr_info("alg: self-tests for %s (%s) passed\n", driver, alg); |
Jarod Wilson | 29ecd4a | 2009-05-04 19:51:17 +0800 | [diff] [blame] | 4186 | |
Neil Horman | d12d6b6 | 2008-10-12 20:36:51 +0800 | [diff] [blame] | 4187 | return rc; |
Herbert Xu | 1aa4ecd | 2008-08-17 17:01:56 +1000 | [diff] [blame] | 4188 | |
| 4189 | notest: |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 4190 | printk(KERN_INFO "alg: No test for %s (%s)\n", alg, driver); |
| 4191 | return 0; |
Jarod Wilson | a3bef3a | 2009-05-15 15:17:05 +1000 | [diff] [blame] | 4192 | non_fips_alg: |
| 4193 | return -EINVAL; |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 4194 | } |
Alexander Shishkin | 0b767f9 | 2010-06-03 20:53:43 +1000 | [diff] [blame] | 4195 | |
Herbert Xu | 326a634 | 2010-08-06 09:40:28 +0800 | [diff] [blame] | 4196 | #endif /* CONFIG_CRYPTO_MANAGER_DISABLE_TESTS */ |
Alexander Shishkin | 0b767f9 | 2010-06-03 20:53:43 +1000 | [diff] [blame] | 4197 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 4198 | EXPORT_SYMBOL_GPL(alg_test); |