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