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