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