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