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