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