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