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