kernel: bump 4.9 to 4.9.82
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.9 / 804-crypto-support-layerscape.patch
1 From a3310d64d7cb1ba0f9279e77d21f13a75fa66ab5 Mon Sep 17 00:00:00 2001
2 From: Yangbo Lu <yangbo.lu@nxp.com>
3 Date: Wed, 17 Jan 2018 15:29:23 +0800
4 Subject: [PATCH 16/30] crypto: support layerscape
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 This is an integrated patch for layerscape sec support.
10
11 Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
12 Signed-off-by: Fabio Estevam <festevam@gmail.com>
13 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
14 Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
15 Signed-off-by: Tudor Ambarus <tudor-dan.ambarus@nxp.com>
16 Signed-off-by: Eric Biggers <ebiggers@google.com>
17 Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
18 Signed-off-by: Xulin Sun <xulin.sun@windriver.com>
19 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
20 Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
21 Signed-off-by: Tudor Ambarus <tudor-dan.ambarus@nxp.com>
22 Signed-off-by: Andrew Lutomirski <luto@kernel.org>
23 Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
24 Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
25 Signed-off-by: Marcelo Cerri <marcelo.cerri@canonical.com>
26 Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
27 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
28 Signed-off-by: Laura Abbott <labbott@redhat.com>
29 Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
30 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
31 ---
32 crypto/Kconfig | 30 +
33 crypto/Makefile | 4 +
34 crypto/acompress.c | 169 +
35 crypto/algboss.c | 12 +-
36 crypto/crypto_user.c | 19 +
37 crypto/scompress.c | 356 ++
38 crypto/tcrypt.c | 17 +-
39 crypto/testmgr.c | 1708 +++---
40 crypto/testmgr.h | 1125 ++--
41 crypto/tls.c | 607 +++
42 drivers/crypto/caam/Kconfig | 77 +-
43 drivers/crypto/caam/Makefile | 16 +-
44 drivers/crypto/caam/caamalg.c | 2171 ++------
45 drivers/crypto/caam/caamalg_desc.c | 1961 +++++++
46 drivers/crypto/caam/caamalg_desc.h | 127 +
47 drivers/crypto/caam/caamalg_qi.c | 2929 ++++++++++
48 drivers/crypto/caam/caamalg_qi2.c | 5920 +++++++++++++++++++++
49 drivers/crypto/caam/caamalg_qi2.h | 281 +
50 drivers/crypto/caam/caamhash.c | 550 +-
51 drivers/crypto/caam/caamhash_desc.c | 108 +
52 drivers/crypto/caam/caamhash_desc.h | 49 +
53 drivers/crypto/caam/caampkc.c | 471 +-
54 drivers/crypto/caam/caampkc.h | 58 +
55 drivers/crypto/caam/caamrng.c | 16 +-
56 drivers/crypto/caam/compat.h | 1 +
57 drivers/crypto/caam/ctrl.c | 358 +-
58 drivers/crypto/caam/ctrl.h | 2 +
59 drivers/crypto/caam/desc.h | 84 +-
60 drivers/crypto/caam/desc_constr.h | 180 +-
61 drivers/crypto/caam/dpseci.c | 859 +++
62 drivers/crypto/caam/dpseci.h | 395 ++
63 drivers/crypto/caam/dpseci_cmd.h | 261 +
64 drivers/crypto/caam/error.c | 127 +-
65 drivers/crypto/caam/error.h | 10 +-
66 drivers/crypto/caam/intern.h | 31 +-
67 drivers/crypto/caam/jr.c | 72 +-
68 drivers/crypto/caam/jr.h | 2 +
69 drivers/crypto/caam/key_gen.c | 32 +-
70 drivers/crypto/caam/key_gen.h | 36 +-
71 drivers/crypto/caam/pdb.h | 62 +
72 drivers/crypto/caam/pkc_desc.c | 36 +
73 drivers/crypto/caam/qi.c | 797 +++
74 drivers/crypto/caam/qi.h | 204 +
75 drivers/crypto/caam/regs.h | 63 +-
76 drivers/crypto/caam/sg_sw_qm.h | 126 +
77 drivers/crypto/caam/sg_sw_qm2.h | 81 +
78 drivers/crypto/caam/sg_sw_sec4.h | 60 +-
79 drivers/net/wireless/rsi/rsi_91x_usb.c | 2 +-
80 drivers/staging/wilc1000/linux_wlan.c | 2 +-
81 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +-
82 include/crypto/acompress.h | 269 +
83 include/crypto/internal/acompress.h | 81 +
84 include/crypto/internal/scompress.h | 136 +
85 include/linux/crypto.h | 3 +
86 include/uapi/linux/cryptouser.h | 5 +
87 scripts/spelling.txt | 3 +
88 sound/soc/amd/acp-pcm-dma.c | 2 +-
89 57 files changed, 19177 insertions(+), 3988 deletions(-)
90 create mode 100644 crypto/acompress.c
91 create mode 100644 crypto/scompress.c
92 create mode 100644 crypto/tls.c
93 create mode 100644 drivers/crypto/caam/caamalg_desc.c
94 create mode 100644 drivers/crypto/caam/caamalg_desc.h
95 create mode 100644 drivers/crypto/caam/caamalg_qi.c
96 create mode 100644 drivers/crypto/caam/caamalg_qi2.c
97 create mode 100644 drivers/crypto/caam/caamalg_qi2.h
98 create mode 100644 drivers/crypto/caam/caamhash_desc.c
99 create mode 100644 drivers/crypto/caam/caamhash_desc.h
100 create mode 100644 drivers/crypto/caam/dpseci.c
101 create mode 100644 drivers/crypto/caam/dpseci.h
102 create mode 100644 drivers/crypto/caam/dpseci_cmd.h
103 create mode 100644 drivers/crypto/caam/qi.c
104 create mode 100644 drivers/crypto/caam/qi.h
105 create mode 100644 drivers/crypto/caam/sg_sw_qm.h
106 create mode 100644 drivers/crypto/caam/sg_sw_qm2.h
107 create mode 100644 include/crypto/acompress.h
108 create mode 100644 include/crypto/internal/acompress.h
109 create mode 100644 include/crypto/internal/scompress.h
110
111 --- a/crypto/Kconfig
112 +++ b/crypto/Kconfig
113 @@ -102,6 +102,15 @@ config CRYPTO_KPP
114 select CRYPTO_ALGAPI
115 select CRYPTO_KPP2
116
117 +config CRYPTO_ACOMP2
118 + tristate
119 + select CRYPTO_ALGAPI2
120 +
121 +config CRYPTO_ACOMP
122 + tristate
123 + select CRYPTO_ALGAPI
124 + select CRYPTO_ACOMP2
125 +
126 config CRYPTO_RSA
127 tristate "RSA algorithm"
128 select CRYPTO_AKCIPHER
129 @@ -138,6 +147,7 @@ config CRYPTO_MANAGER2
130 select CRYPTO_BLKCIPHER2 if !CRYPTO_MANAGER_DISABLE_TESTS
131 select CRYPTO_AKCIPHER2 if !CRYPTO_MANAGER_DISABLE_TESTS
132 select CRYPTO_KPP2 if !CRYPTO_MANAGER_DISABLE_TESTS
133 + select CRYPTO_ACOMP2 if !CRYPTO_MANAGER_DISABLE_TESTS
134
135 config CRYPTO_USER
136 tristate "Userspace cryptographic algorithm configuration"
137 @@ -295,6 +305,26 @@ config CRYPTO_ECHAINIV
138 a sequence number xored with a salt. This is the default
139 algorithm for CBC.
140
141 +config CRYPTO_TLS
142 + tristate "TLS support"
143 + select CRYPTO_AEAD
144 + select CRYPTO_BLKCIPHER
145 + select CRYPTO_MANAGER
146 + select CRYPTO_HASH
147 + select CRYPTO_NULL
148 + select CRYPTO_AUTHENC
149 + help
150 + Support for TLS 1.0 record encryption and decryption
151 +
152 + This module adds support for encryption/decryption of TLS 1.0 frames
153 + using blockcipher algorithms. The name of the resulting algorithm is
154 + "tls10(hmac(<digest>),cbc(<cipher>))". By default, the generic base
155 + algorithms are used (e.g. aes-generic, sha1-generic), but hardware
156 + accelerated versions will be used automatically if available.
157 +
158 + User-space applications (OpenSSL, GnuTLS) can offload TLS 1.0
159 + operations through AF_ALG or cryptodev interfaces
160 +
161 comment "Block modes"
162
163 config CRYPTO_CBC
164 --- a/crypto/Makefile
165 +++ b/crypto/Makefile
166 @@ -51,6 +51,9 @@ rsa_generic-y += rsa_helper.o
167 rsa_generic-y += rsa-pkcs1pad.o
168 obj-$(CONFIG_CRYPTO_RSA) += rsa_generic.o
169
170 +obj-$(CONFIG_CRYPTO_ACOMP2) += acompress.o
171 +obj-$(CONFIG_CRYPTO_ACOMP2) += scompress.o
172 +
173 cryptomgr-y := algboss.o testmgr.o
174
175 obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o
176 @@ -115,6 +118,7 @@ obj-$(CONFIG_CRYPTO_CRC32C) += crc32c_ge
177 obj-$(CONFIG_CRYPTO_CRC32) += crc32_generic.o
178 obj-$(CONFIG_CRYPTO_CRCT10DIF) += crct10dif_common.o crct10dif_generic.o
179 obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
180 +obj-$(CONFIG_CRYPTO_TLS) += tls.o
181 obj-$(CONFIG_CRYPTO_LZO) += lzo.o
182 obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
183 obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o
184 --- /dev/null
185 +++ b/crypto/acompress.c
186 @@ -0,0 +1,169 @@
187 +/*
188 + * Asynchronous Compression operations
189 + *
190 + * Copyright (c) 2016, Intel Corporation
191 + * Authors: Weigang Li <weigang.li@intel.com>
192 + * Giovanni Cabiddu <giovanni.cabiddu@intel.com>
193 + *
194 + * This program is free software; you can redistribute it and/or modify it
195 + * under the terms of the GNU General Public License as published by the Free
196 + * Software Foundation; either version 2 of the License, or (at your option)
197 + * any later version.
198 + *
199 + */
200 +#include <linux/errno.h>
201 +#include <linux/kernel.h>
202 +#include <linux/module.h>
203 +#include <linux/seq_file.h>
204 +#include <linux/slab.h>
205 +#include <linux/string.h>
206 +#include <linux/crypto.h>
207 +#include <crypto/algapi.h>
208 +#include <linux/cryptouser.h>
209 +#include <net/netlink.h>
210 +#include <crypto/internal/acompress.h>
211 +#include <crypto/internal/scompress.h>
212 +#include "internal.h"
213 +
214 +static const struct crypto_type crypto_acomp_type;
215 +
216 +#ifdef CONFIG_NET
217 +static int crypto_acomp_report(struct sk_buff *skb, struct crypto_alg *alg)
218 +{
219 + struct crypto_report_acomp racomp;
220 +
221 + strncpy(racomp.type, "acomp", sizeof(racomp.type));
222 +
223 + if (nla_put(skb, CRYPTOCFGA_REPORT_ACOMP,
224 + sizeof(struct crypto_report_acomp), &racomp))
225 + goto nla_put_failure;
226 + return 0;
227 +
228 +nla_put_failure:
229 + return -EMSGSIZE;
230 +}
231 +#else
232 +static int crypto_acomp_report(struct sk_buff *skb, struct crypto_alg *alg)
233 +{
234 + return -ENOSYS;
235 +}
236 +#endif
237 +
238 +static void crypto_acomp_show(struct seq_file *m, struct crypto_alg *alg)
239 + __attribute__ ((unused));
240 +
241 +static void crypto_acomp_show(struct seq_file *m, struct crypto_alg *alg)
242 +{
243 + seq_puts(m, "type : acomp\n");
244 +}
245 +
246 +static void crypto_acomp_exit_tfm(struct crypto_tfm *tfm)
247 +{
248 + struct crypto_acomp *acomp = __crypto_acomp_tfm(tfm);
249 + struct acomp_alg *alg = crypto_acomp_alg(acomp);
250 +
251 + alg->exit(acomp);
252 +}
253 +
254 +static int crypto_acomp_init_tfm(struct crypto_tfm *tfm)
255 +{
256 + struct crypto_acomp *acomp = __crypto_acomp_tfm(tfm);
257 + struct acomp_alg *alg = crypto_acomp_alg(acomp);
258 +
259 + if (tfm->__crt_alg->cra_type != &crypto_acomp_type)
260 + return crypto_init_scomp_ops_async(tfm);
261 +
262 + acomp->compress = alg->compress;
263 + acomp->decompress = alg->decompress;
264 + acomp->dst_free = alg->dst_free;
265 + acomp->reqsize = alg->reqsize;
266 +
267 + if (alg->exit)
268 + acomp->base.exit = crypto_acomp_exit_tfm;
269 +
270 + if (alg->init)
271 + return alg->init(acomp);
272 +
273 + return 0;
274 +}
275 +
276 +static unsigned int crypto_acomp_extsize(struct crypto_alg *alg)
277 +{
278 + int extsize = crypto_alg_extsize(alg);
279 +
280 + if (alg->cra_type != &crypto_acomp_type)
281 + extsize += sizeof(struct crypto_scomp *);
282 +
283 + return extsize;
284 +}
285 +
286 +static const struct crypto_type crypto_acomp_type = {
287 + .extsize = crypto_acomp_extsize,
288 + .init_tfm = crypto_acomp_init_tfm,
289 +#ifdef CONFIG_PROC_FS
290 + .show = crypto_acomp_show,
291 +#endif
292 + .report = crypto_acomp_report,
293 + .maskclear = ~CRYPTO_ALG_TYPE_MASK,
294 + .maskset = CRYPTO_ALG_TYPE_ACOMPRESS_MASK,
295 + .type = CRYPTO_ALG_TYPE_ACOMPRESS,
296 + .tfmsize = offsetof(struct crypto_acomp, base),
297 +};
298 +
299 +struct crypto_acomp *crypto_alloc_acomp(const char *alg_name, u32 type,
300 + u32 mask)
301 +{
302 + return crypto_alloc_tfm(alg_name, &crypto_acomp_type, type, mask);
303 +}
304 +EXPORT_SYMBOL_GPL(crypto_alloc_acomp);
305 +
306 +struct acomp_req *acomp_request_alloc(struct crypto_acomp *acomp)
307 +{
308 + struct crypto_tfm *tfm = crypto_acomp_tfm(acomp);
309 + struct acomp_req *req;
310 +
311 + req = __acomp_request_alloc(acomp);
312 + if (req && (tfm->__crt_alg->cra_type != &crypto_acomp_type))
313 + return crypto_acomp_scomp_alloc_ctx(req);
314 +
315 + return req;
316 +}
317 +EXPORT_SYMBOL_GPL(acomp_request_alloc);
318 +
319 +void acomp_request_free(struct acomp_req *req)
320 +{
321 + struct crypto_acomp *acomp = crypto_acomp_reqtfm(req);
322 + struct crypto_tfm *tfm = crypto_acomp_tfm(acomp);
323 +
324 + if (tfm->__crt_alg->cra_type != &crypto_acomp_type)
325 + crypto_acomp_scomp_free_ctx(req);
326 +
327 + if (req->flags & CRYPTO_ACOMP_ALLOC_OUTPUT) {
328 + acomp->dst_free(req->dst);
329 + req->dst = NULL;
330 + }
331 +
332 + __acomp_request_free(req);
333 +}
334 +EXPORT_SYMBOL_GPL(acomp_request_free);
335 +
336 +int crypto_register_acomp(struct acomp_alg *alg)
337 +{
338 + struct crypto_alg *base = &alg->base;
339 +
340 + base->cra_type = &crypto_acomp_type;
341 + base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
342 + base->cra_flags |= CRYPTO_ALG_TYPE_ACOMPRESS;
343 +
344 + return crypto_register_alg(base);
345 +}
346 +EXPORT_SYMBOL_GPL(crypto_register_acomp);
347 +
348 +int crypto_unregister_acomp(struct acomp_alg *alg)
349 +{
350 + return crypto_unregister_alg(&alg->base);
351 +}
352 +EXPORT_SYMBOL_GPL(crypto_unregister_acomp);
353 +
354 +MODULE_LICENSE("GPL");
355 +MODULE_DESCRIPTION("Asynchronous compression type");
356 --- a/crypto/algboss.c
357 +++ b/crypto/algboss.c
358 @@ -247,17 +247,9 @@ static int cryptomgr_schedule_test(struc
359 memcpy(param->alg, alg->cra_name, sizeof(param->alg));
360 type = alg->cra_flags;
361
362 - /* This piece of crap needs to disappear into per-type test hooks. */
363 -#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
364 - type |= CRYPTO_ALG_TESTED;
365 -#else
366 - if (!((type ^ CRYPTO_ALG_TYPE_BLKCIPHER) &
367 - CRYPTO_ALG_TYPE_BLKCIPHER_MASK) && !(type & CRYPTO_ALG_GENIV) &&
368 - ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
369 - CRYPTO_ALG_TYPE_BLKCIPHER ? alg->cra_blkcipher.ivsize :
370 - alg->cra_ablkcipher.ivsize))
371 + /* Do not test internal algorithms. */
372 + if (type & CRYPTO_ALG_INTERNAL)
373 type |= CRYPTO_ALG_TESTED;
374 -#endif
375
376 param->type = type;
377
378 --- a/crypto/crypto_user.c
379 +++ b/crypto/crypto_user.c
380 @@ -112,6 +112,21 @@ nla_put_failure:
381 return -EMSGSIZE;
382 }
383
384 +static int crypto_report_acomp(struct sk_buff *skb, struct crypto_alg *alg)
385 +{
386 + struct crypto_report_acomp racomp;
387 +
388 + strncpy(racomp.type, "acomp", sizeof(racomp.type));
389 +
390 + if (nla_put(skb, CRYPTOCFGA_REPORT_ACOMP,
391 + sizeof(struct crypto_report_acomp), &racomp))
392 + goto nla_put_failure;
393 + return 0;
394 +
395 +nla_put_failure:
396 + return -EMSGSIZE;
397 +}
398 +
399 static int crypto_report_akcipher(struct sk_buff *skb, struct crypto_alg *alg)
400 {
401 struct crypto_report_akcipher rakcipher;
402 @@ -186,7 +201,11 @@ static int crypto_report_one(struct cryp
403 goto nla_put_failure;
404
405 break;
406 + case CRYPTO_ALG_TYPE_ACOMPRESS:
407 + if (crypto_report_acomp(skb, alg))
408 + goto nla_put_failure;
409
410 + break;
411 case CRYPTO_ALG_TYPE_AKCIPHER:
412 if (crypto_report_akcipher(skb, alg))
413 goto nla_put_failure;
414 --- /dev/null
415 +++ b/crypto/scompress.c
416 @@ -0,0 +1,356 @@
417 +/*
418 + * Synchronous Compression operations
419 + *
420 + * Copyright 2015 LG Electronics Inc.
421 + * Copyright (c) 2016, Intel Corporation
422 + * Author: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
423 + *
424 + * This program is free software; you can redistribute it and/or modify it
425 + * under the terms of the GNU General Public License as published by the Free
426 + * Software Foundation; either version 2 of the License, or (at your option)
427 + * any later version.
428 + *
429 + */
430 +#include <linux/errno.h>
431 +#include <linux/kernel.h>
432 +#include <linux/module.h>
433 +#include <linux/seq_file.h>
434 +#include <linux/slab.h>
435 +#include <linux/string.h>
436 +#include <linux/crypto.h>
437 +#include <linux/vmalloc.h>
438 +#include <crypto/algapi.h>
439 +#include <linux/cryptouser.h>
440 +#include <net/netlink.h>
441 +#include <linux/scatterlist.h>
442 +#include <crypto/scatterwalk.h>
443 +#include <crypto/internal/acompress.h>
444 +#include <crypto/internal/scompress.h>
445 +#include "internal.h"
446 +
447 +static const struct crypto_type crypto_scomp_type;
448 +static void * __percpu *scomp_src_scratches;
449 +static void * __percpu *scomp_dst_scratches;
450 +static int scomp_scratch_users;
451 +static DEFINE_MUTEX(scomp_lock);
452 +
453 +#ifdef CONFIG_NET
454 +static int crypto_scomp_report(struct sk_buff *skb, struct crypto_alg *alg)
455 +{
456 + struct crypto_report_comp rscomp;
457 +
458 + strncpy(rscomp.type, "scomp", sizeof(rscomp.type));
459 +
460 + if (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS,
461 + sizeof(struct crypto_report_comp), &rscomp))
462 + goto nla_put_failure;
463 + return 0;
464 +
465 +nla_put_failure:
466 + return -EMSGSIZE;
467 +}
468 +#else
469 +static int crypto_scomp_report(struct sk_buff *skb, struct crypto_alg *alg)
470 +{
471 + return -ENOSYS;
472 +}
473 +#endif
474 +
475 +static void crypto_scomp_show(struct seq_file *m, struct crypto_alg *alg)
476 + __attribute__ ((unused));
477 +
478 +static void crypto_scomp_show(struct seq_file *m, struct crypto_alg *alg)
479 +{
480 + seq_puts(m, "type : scomp\n");
481 +}
482 +
483 +static int crypto_scomp_init_tfm(struct crypto_tfm *tfm)
484 +{
485 + return 0;
486 +}
487 +
488 +static void crypto_scomp_free_scratches(void * __percpu *scratches)
489 +{
490 + int i;
491 +
492 + if (!scratches)
493 + return;
494 +
495 + for_each_possible_cpu(i)
496 + vfree(*per_cpu_ptr(scratches, i));
497 +
498 + free_percpu(scratches);
499 +}
500 +
501 +static void * __percpu *crypto_scomp_alloc_scratches(void)
502 +{
503 + void * __percpu *scratches;
504 + int i;
505 +
506 + scratches = alloc_percpu(void *);
507 + if (!scratches)
508 + return NULL;
509 +
510 + for_each_possible_cpu(i) {
511 + void *scratch;
512 +
513 + scratch = vmalloc_node(SCOMP_SCRATCH_SIZE, cpu_to_node(i));
514 + if (!scratch)
515 + goto error;
516 + *per_cpu_ptr(scratches, i) = scratch;
517 + }
518 +
519 + return scratches;
520 +
521 +error:
522 + crypto_scomp_free_scratches(scratches);
523 + return NULL;
524 +}
525 +
526 +static void crypto_scomp_free_all_scratches(void)
527 +{
528 + if (!--scomp_scratch_users) {
529 + crypto_scomp_free_scratches(scomp_src_scratches);
530 + crypto_scomp_free_scratches(scomp_dst_scratches);
531 + scomp_src_scratches = NULL;
532 + scomp_dst_scratches = NULL;
533 + }
534 +}
535 +
536 +static int crypto_scomp_alloc_all_scratches(void)
537 +{
538 + if (!scomp_scratch_users++) {
539 + scomp_src_scratches = crypto_scomp_alloc_scratches();
540 + if (!scomp_src_scratches)
541 + return -ENOMEM;
542 + scomp_dst_scratches = crypto_scomp_alloc_scratches();
543 + if (!scomp_dst_scratches)
544 + return -ENOMEM;
545 + }
546 + return 0;
547 +}
548 +
549 +static void crypto_scomp_sg_free(struct scatterlist *sgl)
550 +{
551 + int i, n;
552 + struct page *page;
553 +
554 + if (!sgl)
555 + return;
556 +
557 + n = sg_nents(sgl);
558 + for_each_sg(sgl, sgl, n, i) {
559 + page = sg_page(sgl);
560 + if (page)
561 + __free_page(page);
562 + }
563 +
564 + kfree(sgl);
565 +}
566 +
567 +static struct scatterlist *crypto_scomp_sg_alloc(size_t size, gfp_t gfp)
568 +{
569 + struct scatterlist *sgl;
570 + struct page *page;
571 + int i, n;
572 +
573 + n = ((size - 1) >> PAGE_SHIFT) + 1;
574 +
575 + sgl = kmalloc_array(n, sizeof(struct scatterlist), gfp);
576 + if (!sgl)
577 + return NULL;
578 +
579 + sg_init_table(sgl, n);
580 +
581 + for (i = 0; i < n; i++) {
582 + page = alloc_page(gfp);
583 + if (!page)
584 + goto err;
585 + sg_set_page(sgl + i, page, PAGE_SIZE, 0);
586 + }
587 +
588 + return sgl;
589 +
590 +err:
591 + sg_mark_end(sgl + i);
592 + crypto_scomp_sg_free(sgl);
593 + return NULL;
594 +}
595 +
596 +static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
597 +{
598 + struct crypto_acomp *tfm = crypto_acomp_reqtfm(req);
599 + void **tfm_ctx = acomp_tfm_ctx(tfm);
600 + struct crypto_scomp *scomp = *tfm_ctx;
601 + void **ctx = acomp_request_ctx(req);
602 + const int cpu = get_cpu();
603 + u8 *scratch_src = *per_cpu_ptr(scomp_src_scratches, cpu);
604 + u8 *scratch_dst = *per_cpu_ptr(scomp_dst_scratches, cpu);
605 + int ret;
606 +
607 + if (!req->src || !req->slen || req->slen > SCOMP_SCRATCH_SIZE) {
608 + ret = -EINVAL;
609 + goto out;
610 + }
611 +
612 + if (req->dst && !req->dlen) {
613 + ret = -EINVAL;
614 + goto out;
615 + }
616 +
617 + if (!req->dlen || req->dlen > SCOMP_SCRATCH_SIZE)
618 + req->dlen = SCOMP_SCRATCH_SIZE;
619 +
620 + scatterwalk_map_and_copy(scratch_src, req->src, 0, req->slen, 0);
621 + if (dir)
622 + ret = crypto_scomp_compress(scomp, scratch_src, req->slen,
623 + scratch_dst, &req->dlen, *ctx);
624 + else
625 + ret = crypto_scomp_decompress(scomp, scratch_src, req->slen,
626 + scratch_dst, &req->dlen, *ctx);
627 + if (!ret) {
628 + if (!req->dst) {
629 + req->dst = crypto_scomp_sg_alloc(req->dlen,
630 + req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ?
631 + GFP_KERNEL : GFP_ATOMIC);
632 + if (!req->dst)
633 + goto out;
634 + }
635 + scatterwalk_map_and_copy(scratch_dst, req->dst, 0, req->dlen,
636 + 1);
637 + }
638 +out:
639 + put_cpu();
640 + return ret;
641 +}
642 +
643 +static int scomp_acomp_compress(struct acomp_req *req)
644 +{
645 + return scomp_acomp_comp_decomp(req, 1);
646 +}
647 +
648 +static int scomp_acomp_decompress(struct acomp_req *req)
649 +{
650 + return scomp_acomp_comp_decomp(req, 0);
651 +}
652 +
653 +static void crypto_exit_scomp_ops_async(struct crypto_tfm *tfm)
654 +{
655 + struct crypto_scomp **ctx = crypto_tfm_ctx(tfm);
656 +
657 + crypto_free_scomp(*ctx);
658 +}
659 +
660 +int crypto_init_scomp_ops_async(struct crypto_tfm *tfm)
661 +{
662 + struct crypto_alg *calg = tfm->__crt_alg;
663 + struct crypto_acomp *crt = __crypto_acomp_tfm(tfm);
664 + struct crypto_scomp **ctx = crypto_tfm_ctx(tfm);
665 + struct crypto_scomp *scomp;
666 +
667 + if (!crypto_mod_get(calg))
668 + return -EAGAIN;
669 +
670 + scomp = crypto_create_tfm(calg, &crypto_scomp_type);
671 + if (IS_ERR(scomp)) {
672 + crypto_mod_put(calg);
673 + return PTR_ERR(scomp);
674 + }
675 +
676 + *ctx = scomp;
677 + tfm->exit = crypto_exit_scomp_ops_async;
678 +
679 + crt->compress = scomp_acomp_compress;
680 + crt->decompress = scomp_acomp_decompress;
681 + crt->dst_free = crypto_scomp_sg_free;
682 + crt->reqsize = sizeof(void *);
683 +
684 + return 0;
685 +}
686 +
687 +struct acomp_req *crypto_acomp_scomp_alloc_ctx(struct acomp_req *req)
688 +{
689 + struct crypto_acomp *acomp = crypto_acomp_reqtfm(req);
690 + struct crypto_tfm *tfm = crypto_acomp_tfm(acomp);
691 + struct crypto_scomp **tfm_ctx = crypto_tfm_ctx(tfm);
692 + struct crypto_scomp *scomp = *tfm_ctx;
693 + void *ctx;
694 +
695 + ctx = crypto_scomp_alloc_ctx(scomp);
696 + if (IS_ERR(ctx)) {
697 + kfree(req);
698 + return NULL;
699 + }
700 +
701 + *req->__ctx = ctx;
702 +
703 + return req;
704 +}
705 +
706 +void crypto_acomp_scomp_free_ctx(struct acomp_req *req)
707 +{
708 + struct crypto_acomp *acomp = crypto_acomp_reqtfm(req);
709 + struct crypto_tfm *tfm = crypto_acomp_tfm(acomp);
710 + struct crypto_scomp **tfm_ctx = crypto_tfm_ctx(tfm);
711 + struct crypto_scomp *scomp = *tfm_ctx;
712 + void *ctx = *req->__ctx;
713 +
714 + if (ctx)
715 + crypto_scomp_free_ctx(scomp, ctx);
716 +}
717 +
718 +static const struct crypto_type crypto_scomp_type = {
719 + .extsize = crypto_alg_extsize,
720 + .init_tfm = crypto_scomp_init_tfm,
721 +#ifdef CONFIG_PROC_FS
722 + .show = crypto_scomp_show,
723 +#endif
724 + .report = crypto_scomp_report,
725 + .maskclear = ~CRYPTO_ALG_TYPE_MASK,
726 + .maskset = CRYPTO_ALG_TYPE_MASK,
727 + .type = CRYPTO_ALG_TYPE_SCOMPRESS,
728 + .tfmsize = offsetof(struct crypto_scomp, base),
729 +};
730 +
731 +int crypto_register_scomp(struct scomp_alg *alg)
732 +{
733 + struct crypto_alg *base = &alg->base;
734 + int ret = -ENOMEM;
735 +
736 + mutex_lock(&scomp_lock);
737 + if (crypto_scomp_alloc_all_scratches())
738 + goto error;
739 +
740 + base->cra_type = &crypto_scomp_type;
741 + base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
742 + base->cra_flags |= CRYPTO_ALG_TYPE_SCOMPRESS;
743 +
744 + ret = crypto_register_alg(base);
745 + if (ret)
746 + goto error;
747 +
748 + mutex_unlock(&scomp_lock);
749 + return ret;
750 +
751 +error:
752 + crypto_scomp_free_all_scratches();
753 + mutex_unlock(&scomp_lock);
754 + return ret;
755 +}
756 +EXPORT_SYMBOL_GPL(crypto_register_scomp);
757 +
758 +int crypto_unregister_scomp(struct scomp_alg *alg)
759 +{
760 + int ret;
761 +
762 + mutex_lock(&scomp_lock);
763 + ret = crypto_unregister_alg(&alg->base);
764 + crypto_scomp_free_all_scratches();
765 + mutex_unlock(&scomp_lock);
766 +
767 + return ret;
768 +}
769 +EXPORT_SYMBOL_GPL(crypto_unregister_scomp);
770 +
771 +MODULE_LICENSE("GPL");
772 +MODULE_DESCRIPTION("Synchronous compression type");
773 --- a/crypto/tcrypt.c
774 +++ b/crypto/tcrypt.c
775 @@ -74,7 +74,7 @@ static char *check[] = {
776 "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
777 "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320",
778 "lzo", "cts", "zlib", "sha3-224", "sha3-256", "sha3-384", "sha3-512",
779 - NULL
780 + "rsa", NULL
781 };
782
783 struct tcrypt_result {
784 @@ -1333,6 +1333,10 @@ static int do_test(const char *alg, u32
785 ret += tcrypt_test("hmac(sha3-512)");
786 break;
787
788 + case 115:
789 + ret += tcrypt_test("rsa");
790 + break;
791 +
792 case 150:
793 ret += tcrypt_test("ansi_cprng");
794 break;
795 @@ -1394,6 +1398,9 @@ static int do_test(const char *alg, u32
796 case 190:
797 ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))");
798 break;
799 + case 191:
800 + ret += tcrypt_test("tls10(hmac(sha1),cbc(aes))");
801 + break;
802 case 200:
803 test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
804 speed_template_16_24_32);
805 @@ -1408,9 +1415,9 @@ static int do_test(const char *alg, u32
806 test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
807 speed_template_32_40_48);
808 test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
809 - speed_template_32_48_64);
810 + speed_template_32_64);
811 test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
812 - speed_template_32_48_64);
813 + speed_template_32_64);
814 test_cipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
815 speed_template_16_24_32);
816 test_cipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
817 @@ -1841,9 +1848,9 @@ static int do_test(const char *alg, u32
818 test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
819 speed_template_32_40_48);
820 test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
821 - speed_template_32_48_64);
822 + speed_template_32_64);
823 test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
824 - speed_template_32_48_64);
825 + speed_template_32_64);
826 test_acipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
827 speed_template_16_24_32);
828 test_acipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
829 --- a/crypto/testmgr.c
830 +++ b/crypto/testmgr.c
831 @@ -33,6 +33,7 @@
832 #include <crypto/drbg.h>
833 #include <crypto/akcipher.h>
834 #include <crypto/kpp.h>
835 +#include <crypto/acompress.h>
836
837 #include "internal.h"
838
839 @@ -62,7 +63,7 @@ int alg_test(const char *driver, const c
840 */
841 #define IDX1 32
842 #define IDX2 32400
843 -#define IDX3 1
844 +#define IDX3 1511
845 #define IDX4 8193
846 #define IDX5 22222
847 #define IDX6 17101
848 @@ -82,47 +83,54 @@ struct tcrypt_result {
849
850 struct aead_test_suite {
851 struct {
852 - struct aead_testvec *vecs;
853 + const struct aead_testvec *vecs;
854 unsigned int count;
855 } enc, dec;
856 };
857
858 struct cipher_test_suite {
859 struct {
860 - struct cipher_testvec *vecs;
861 + const struct cipher_testvec *vecs;
862 unsigned int count;
863 } enc, dec;
864 };
865
866 struct comp_test_suite {
867 struct {
868 - struct comp_testvec *vecs;
869 + const struct comp_testvec *vecs;
870 unsigned int count;
871 } comp, decomp;
872 };
873
874 struct hash_test_suite {
875 - struct hash_testvec *vecs;
876 + const struct hash_testvec *vecs;
877 unsigned int count;
878 };
879
880 struct cprng_test_suite {
881 - struct cprng_testvec *vecs;
882 + const struct cprng_testvec *vecs;
883 unsigned int count;
884 };
885
886 struct drbg_test_suite {
887 - struct drbg_testvec *vecs;
888 + const struct drbg_testvec *vecs;
889 unsigned int count;
890 };
891
892 +struct tls_test_suite {
893 + struct {
894 + struct tls_testvec *vecs;
895 + unsigned int count;
896 + } enc, dec;
897 +};
898 +
899 struct akcipher_test_suite {
900 - struct akcipher_testvec *vecs;
901 + const struct akcipher_testvec *vecs;
902 unsigned int count;
903 };
904
905 struct kpp_test_suite {
906 - struct kpp_testvec *vecs;
907 + const struct kpp_testvec *vecs;
908 unsigned int count;
909 };
910
911 @@ -139,12 +147,14 @@ struct alg_test_desc {
912 struct hash_test_suite hash;
913 struct cprng_test_suite cprng;
914 struct drbg_test_suite drbg;
915 + struct tls_test_suite tls;
916 struct akcipher_test_suite akcipher;
917 struct kpp_test_suite kpp;
918 } suite;
919 };
920
921 -static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 };
922 +static const unsigned int IDX[8] = {
923 + IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 };
924
925 static void hexdump(unsigned char *buf, unsigned int len)
926 {
927 @@ -202,7 +212,7 @@ static int wait_async_op(struct tcrypt_r
928 }
929
930 static int ahash_partial_update(struct ahash_request **preq,
931 - struct crypto_ahash *tfm, struct hash_testvec *template,
932 + struct crypto_ahash *tfm, const struct hash_testvec *template,
933 void *hash_buff, int k, int temp, struct scatterlist *sg,
934 const char *algo, char *result, struct tcrypt_result *tresult)
935 {
936 @@ -259,11 +269,12 @@ out_nostate:
937 return ret;
938 }
939
940 -static int __test_hash(struct crypto_ahash *tfm, struct hash_testvec *template,
941 - unsigned int tcount, bool use_digest,
942 - const int align_offset)
943 +static int __test_hash(struct crypto_ahash *tfm,
944 + const struct hash_testvec *template, unsigned int tcount,
945 + bool use_digest, const int align_offset)
946 {
947 const char *algo = crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm));
948 + size_t digest_size = crypto_ahash_digestsize(tfm);
949 unsigned int i, j, k, temp;
950 struct scatterlist sg[8];
951 char *result;
952 @@ -274,7 +285,7 @@ static int __test_hash(struct crypto_aha
953 char *xbuf[XBUFSIZE];
954 int ret = -ENOMEM;
955
956 - result = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL);
957 + result = kmalloc(digest_size, GFP_KERNEL);
958 if (!result)
959 return ret;
960 key = kmalloc(MAX_KEYLEN, GFP_KERNEL);
961 @@ -304,7 +315,7 @@ static int __test_hash(struct crypto_aha
962 goto out;
963
964 j++;
965 - memset(result, 0, MAX_DIGEST_SIZE);
966 + memset(result, 0, digest_size);
967
968 hash_buff = xbuf[0];
969 hash_buff += align_offset;
970 @@ -379,7 +390,7 @@ static int __test_hash(struct crypto_aha
971 continue;
972
973 j++;
974 - memset(result, 0, MAX_DIGEST_SIZE);
975 + memset(result, 0, digest_size);
976
977 temp = 0;
978 sg_init_table(sg, template[i].np);
979 @@ -457,7 +468,7 @@ static int __test_hash(struct crypto_aha
980 continue;
981
982 j++;
983 - memset(result, 0, MAX_DIGEST_SIZE);
984 + memset(result, 0, digest_size);
985
986 ret = -EINVAL;
987 hash_buff = xbuf[0];
988 @@ -536,7 +547,8 @@ out_nobuf:
989 return ret;
990 }
991
992 -static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template,
993 +static int test_hash(struct crypto_ahash *tfm,
994 + const struct hash_testvec *template,
995 unsigned int tcount, bool use_digest)
996 {
997 unsigned int alignmask;
998 @@ -564,7 +576,7 @@ static int test_hash(struct crypto_ahash
999 }
1000
1001 static int __test_aead(struct crypto_aead *tfm, int enc,
1002 - struct aead_testvec *template, unsigned int tcount,
1003 + const struct aead_testvec *template, unsigned int tcount,
1004 const bool diff_dst, const int align_offset)
1005 {
1006 const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm));
1007 @@ -955,7 +967,7 @@ out_noxbuf:
1008 }
1009
1010 static int test_aead(struct crypto_aead *tfm, int enc,
1011 - struct aead_testvec *template, unsigned int tcount)
1012 + const struct aead_testvec *template, unsigned int tcount)
1013 {
1014 unsigned int alignmask;
1015 int ret;
1016 @@ -987,8 +999,236 @@ static int test_aead(struct crypto_aead
1017 return 0;
1018 }
1019
1020 +static int __test_tls(struct crypto_aead *tfm, int enc,
1021 + struct tls_testvec *template, unsigned int tcount,
1022 + const bool diff_dst)
1023 +{
1024 + const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm));
1025 + unsigned int i, k, authsize;
1026 + char *q;
1027 + struct aead_request *req;
1028 + struct scatterlist *sg;
1029 + struct scatterlist *sgout;
1030 + const char *e, *d;
1031 + struct tcrypt_result result;
1032 + void *input;
1033 + void *output;
1034 + void *assoc;
1035 + char *iv;
1036 + char *key;
1037 + char *xbuf[XBUFSIZE];
1038 + char *xoutbuf[XBUFSIZE];
1039 + char *axbuf[XBUFSIZE];
1040 + int ret = -ENOMEM;
1041 +
1042 + if (testmgr_alloc_buf(xbuf))
1043 + goto out_noxbuf;
1044 +
1045 + if (diff_dst && testmgr_alloc_buf(xoutbuf))
1046 + goto out_nooutbuf;
1047 +
1048 + if (testmgr_alloc_buf(axbuf))
1049 + goto out_noaxbuf;
1050 +
1051 + iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
1052 + if (!iv)
1053 + goto out_noiv;
1054 +
1055 + key = kzalloc(MAX_KEYLEN, GFP_KERNEL);
1056 + if (!key)
1057 + goto out_nokey;
1058 +
1059 + sg = kmalloc(sizeof(*sg) * 8 * (diff_dst ? 2 : 1), GFP_KERNEL);
1060 + if (!sg)
1061 + goto out_nosg;
1062 +
1063 + sgout = sg + 8;
1064 +
1065 + d = diff_dst ? "-ddst" : "";
1066 + e = enc ? "encryption" : "decryption";
1067 +
1068 + init_completion(&result.completion);
1069 +
1070 + req = aead_request_alloc(tfm, GFP_KERNEL);
1071 + if (!req) {
1072 + pr_err("alg: tls%s: Failed to allocate request for %s\n",
1073 + d, algo);
1074 + goto out;
1075 + }
1076 +
1077 + aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
1078 + tcrypt_complete, &result);
1079 +
1080 + for (i = 0; i < tcount; i++) {
1081 + input = xbuf[0];
1082 + assoc = axbuf[0];
1083 +
1084 + ret = -EINVAL;
1085 + if (WARN_ON(template[i].ilen > PAGE_SIZE ||
1086 + template[i].alen > PAGE_SIZE))
1087 + goto out;
1088 +
1089 + memcpy(assoc, template[i].assoc, template[i].alen);
1090 + memcpy(input, template[i].input, template[i].ilen);
1091 +
1092 + if (template[i].iv)
1093 + memcpy(iv, template[i].iv, MAX_IVLEN);
1094 + else
1095 + memset(iv, 0, MAX_IVLEN);
1096 +
1097 + crypto_aead_clear_flags(tfm, ~0);
1098 +
1099 + if (template[i].klen > MAX_KEYLEN) {
1100 + pr_err("alg: aead%s: setkey failed on test %d for %s: key size %d > %d\n",
1101 + d, i, algo, template[i].klen, MAX_KEYLEN);
1102 + ret = -EINVAL;
1103 + goto out;
1104 + }
1105 + memcpy(key, template[i].key, template[i].klen);
1106 +
1107 + ret = crypto_aead_setkey(tfm, key, template[i].klen);
1108 + if (!ret == template[i].fail) {
1109 + pr_err("alg: tls%s: setkey failed on test %d for %s: flags=%x\n",
1110 + d, i, algo, crypto_aead_get_flags(tfm));
1111 + goto out;
1112 + } else if (ret)
1113 + continue;
1114 +
1115 + authsize = 20;
1116 + ret = crypto_aead_setauthsize(tfm, authsize);
1117 + if (ret) {
1118 + pr_err("alg: aead%s: Failed to set authsize to %u on test %d for %s\n",
1119 + d, authsize, i, algo);
1120 + goto out;
1121 + }
1122 +
1123 + k = !!template[i].alen;
1124 + sg_init_table(sg, k + 1);
1125 + sg_set_buf(&sg[0], assoc, template[i].alen);
1126 + sg_set_buf(&sg[k], input, (enc ? template[i].rlen :
1127 + template[i].ilen));
1128 + output = input;
1129 +
1130 + if (diff_dst) {
1131 + sg_init_table(sgout, k + 1);
1132 + sg_set_buf(&sgout[0], assoc, template[i].alen);
1133 +
1134 + output = xoutbuf[0];
1135 + sg_set_buf(&sgout[k], output,
1136 + (enc ? template[i].rlen : template[i].ilen));
1137 + }
1138 +
1139 + aead_request_set_crypt(req, sg, (diff_dst) ? sgout : sg,
1140 + template[i].ilen, iv);
1141 +
1142 + aead_request_set_ad(req, template[i].alen);
1143 +
1144 + ret = enc ? crypto_aead_encrypt(req) : crypto_aead_decrypt(req);
1145 +
1146 + switch (ret) {
1147 + case 0:
1148 + if (template[i].novrfy) {
1149 + /* verification was supposed to fail */
1150 + pr_err("alg: tls%s: %s failed on test %d for %s: ret was 0, expected -EBADMSG\n",
1151 + d, e, i, algo);
1152 + /* so really, we got a bad message */
1153 + ret = -EBADMSG;
1154 + goto out;
1155 + }
1156 + break;
1157 + case -EINPROGRESS:
1158 + case -EBUSY:
1159 + wait_for_completion(&result.completion);
1160 + reinit_completion(&result.completion);
1161 + ret = result.err;
1162 + if (!ret)
1163 + break;
1164 + case -EBADMSG:
1165 + /* verification failure was expected */
1166 + if (template[i].novrfy)
1167 + continue;
1168 + /* fall through */
1169 + default:
1170 + pr_err("alg: tls%s: %s failed on test %d for %s: ret=%d\n",
1171 + d, e, i, algo, -ret);
1172 + goto out;
1173 + }
1174 +
1175 + q = output;
1176 + if (memcmp(q, template[i].result, template[i].rlen)) {
1177 + pr_err("alg: tls%s: Test %d failed on %s for %s\n",
1178 + d, i, e, algo);
1179 + hexdump(q, template[i].rlen);
1180 + pr_err("should be:\n");
1181 + hexdump(template[i].result, template[i].rlen);
1182 + ret = -EINVAL;
1183 + goto out;
1184 + }
1185 + }
1186 +
1187 +out:
1188 + aead_request_free(req);
1189 +
1190 + kfree(sg);
1191 +out_nosg:
1192 + kfree(key);
1193 +out_nokey:
1194 + kfree(iv);
1195 +out_noiv:
1196 + testmgr_free_buf(axbuf);
1197 +out_noaxbuf:
1198 + if (diff_dst)
1199 + testmgr_free_buf(xoutbuf);
1200 +out_nooutbuf:
1201 + testmgr_free_buf(xbuf);
1202 +out_noxbuf:
1203 + return ret;
1204 +}
1205 +
1206 +static int test_tls(struct crypto_aead *tfm, int enc,
1207 + struct tls_testvec *template, unsigned int tcount)
1208 +{
1209 + int ret;
1210 + /* test 'dst == src' case */
1211 + ret = __test_tls(tfm, enc, template, tcount, false);
1212 + if (ret)
1213 + return ret;
1214 + /* test 'dst != src' case */
1215 + return __test_tls(tfm, enc, template, tcount, true);
1216 +}
1217 +
1218 +static int alg_test_tls(const struct alg_test_desc *desc, const char *driver,
1219 + u32 type, u32 mask)
1220 +{
1221 + struct crypto_aead *tfm;
1222 + int err = 0;
1223 +
1224 + tfm = crypto_alloc_aead(driver, type, mask);
1225 + if (IS_ERR(tfm)) {
1226 + pr_err("alg: aead: Failed to load transform for %s: %ld\n",
1227 + driver, PTR_ERR(tfm));
1228 + return PTR_ERR(tfm);
1229 + }
1230 +
1231 + if (desc->suite.tls.enc.vecs) {
1232 + err = test_tls(tfm, ENCRYPT, desc->suite.tls.enc.vecs,
1233 + desc->suite.tls.enc.count);
1234 + if (err)
1235 + goto out;
1236 + }
1237 +
1238 + if (!err && desc->suite.tls.dec.vecs)
1239 + err = test_tls(tfm, DECRYPT, desc->suite.tls.dec.vecs,
1240 + desc->suite.tls.dec.count);
1241 +
1242 +out:
1243 + crypto_free_aead(tfm);
1244 + return err;
1245 +}
1246 +
1247 static int test_cipher(struct crypto_cipher *tfm, int enc,
1248 - struct cipher_testvec *template, unsigned int tcount)
1249 + const struct cipher_testvec *template,
1250 + unsigned int tcount)
1251 {
1252 const char *algo = crypto_tfm_alg_driver_name(crypto_cipher_tfm(tfm));
1253 unsigned int i, j, k;
1254 @@ -1066,7 +1306,8 @@ out_nobuf:
1255 }
1256
1257 static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
1258 - struct cipher_testvec *template, unsigned int tcount,
1259 + const struct cipher_testvec *template,
1260 + unsigned int tcount,
1261 const bool diff_dst, const int align_offset)
1262 {
1263 const char *algo =
1264 @@ -1079,12 +1320,16 @@ static int __test_skcipher(struct crypto
1265 const char *e, *d;
1266 struct tcrypt_result result;
1267 void *data;
1268 - char iv[MAX_IVLEN];
1269 + char *iv;
1270 char *xbuf[XBUFSIZE];
1271 char *xoutbuf[XBUFSIZE];
1272 int ret = -ENOMEM;
1273 unsigned int ivsize = crypto_skcipher_ivsize(tfm);
1274
1275 + iv = kmalloc(MAX_IVLEN, GFP_KERNEL);
1276 + if (!iv)
1277 + return ret;
1278 +
1279 if (testmgr_alloc_buf(xbuf))
1280 goto out_nobuf;
1281
1282 @@ -1325,12 +1570,14 @@ out:
1283 testmgr_free_buf(xoutbuf);
1284 out_nooutbuf:
1285 testmgr_free_buf(xbuf);
1286 + kfree(iv);
1287 out_nobuf:
1288 return ret;
1289 }
1290
1291 static int test_skcipher(struct crypto_skcipher *tfm, int enc,
1292 - struct cipher_testvec *template, unsigned int tcount)
1293 + const struct cipher_testvec *template,
1294 + unsigned int tcount)
1295 {
1296 unsigned int alignmask;
1297 int ret;
1298 @@ -1362,8 +1609,10 @@ static int test_skcipher(struct crypto_s
1299 return 0;
1300 }
1301
1302 -static int test_comp(struct crypto_comp *tfm, struct comp_testvec *ctemplate,
1303 - struct comp_testvec *dtemplate, int ctcount, int dtcount)
1304 +static int test_comp(struct crypto_comp *tfm,
1305 + const struct comp_testvec *ctemplate,
1306 + const struct comp_testvec *dtemplate,
1307 + int ctcount, int dtcount)
1308 {
1309 const char *algo = crypto_tfm_alg_driver_name(crypto_comp_tfm(tfm));
1310 unsigned int i;
1311 @@ -1442,7 +1691,154 @@ out:
1312 return ret;
1313 }
1314
1315 -static int test_cprng(struct crypto_rng *tfm, struct cprng_testvec *template,
1316 +static int test_acomp(struct crypto_acomp *tfm,
1317 + const struct comp_testvec *ctemplate,
1318 + const struct comp_testvec *dtemplate,
1319 + int ctcount, int dtcount)
1320 +{
1321 + const char *algo = crypto_tfm_alg_driver_name(crypto_acomp_tfm(tfm));
1322 + unsigned int i;
1323 + char *output;
1324 + int ret;
1325 + struct scatterlist src, dst;
1326 + struct acomp_req *req;
1327 + struct tcrypt_result result;
1328 +
1329 + output = kmalloc(COMP_BUF_SIZE, GFP_KERNEL);
1330 + if (!output)
1331 + return -ENOMEM;
1332 +
1333 + for (i = 0; i < ctcount; i++) {
1334 + unsigned int dlen = COMP_BUF_SIZE;
1335 + int ilen = ctemplate[i].inlen;
1336 + void *input_vec;
1337 +
1338 + input_vec = kmemdup(ctemplate[i].input, ilen, GFP_KERNEL);
1339 + if (!input_vec) {
1340 + ret = -ENOMEM;
1341 + goto out;
1342 + }
1343 +
1344 + memset(output, 0, dlen);
1345 + init_completion(&result.completion);
1346 + sg_init_one(&src, input_vec, ilen);
1347 + sg_init_one(&dst, output, dlen);
1348 +
1349 + req = acomp_request_alloc(tfm);
1350 + if (!req) {
1351 + pr_err("alg: acomp: request alloc failed for %s\n",
1352 + algo);
1353 + kfree(input_vec);
1354 + ret = -ENOMEM;
1355 + goto out;
1356 + }
1357 +
1358 + acomp_request_set_params(req, &src, &dst, ilen, dlen);
1359 + acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
1360 + tcrypt_complete, &result);
1361 +
1362 + ret = wait_async_op(&result, crypto_acomp_compress(req));
1363 + if (ret) {
1364 + pr_err("alg: acomp: compression failed on test %d for %s: ret=%d\n",
1365 + i + 1, algo, -ret);
1366 + kfree(input_vec);
1367 + acomp_request_free(req);
1368 + goto out;
1369 + }
1370 +
1371 + if (req->dlen != ctemplate[i].outlen) {
1372 + pr_err("alg: acomp: Compression test %d failed for %s: output len = %d\n",
1373 + i + 1, algo, req->dlen);
1374 + ret = -EINVAL;
1375 + kfree(input_vec);
1376 + acomp_request_free(req);
1377 + goto out;
1378 + }
1379 +
1380 + if (memcmp(output, ctemplate[i].output, req->dlen)) {
1381 + pr_err("alg: acomp: Compression test %d failed for %s\n",
1382 + i + 1, algo);
1383 + hexdump(output, req->dlen);
1384 + ret = -EINVAL;
1385 + kfree(input_vec);
1386 + acomp_request_free(req);
1387 + goto out;
1388 + }
1389 +
1390 + kfree(input_vec);
1391 + acomp_request_free(req);
1392 + }
1393 +
1394 + for (i = 0; i < dtcount; i++) {
1395 + unsigned int dlen = COMP_BUF_SIZE;
1396 + int ilen = dtemplate[i].inlen;
1397 + void *input_vec;
1398 +
1399 + input_vec = kmemdup(dtemplate[i].input, ilen, GFP_KERNEL);
1400 + if (!input_vec) {
1401 + ret = -ENOMEM;
1402 + goto out;
1403 + }
1404 +
1405 + memset(output, 0, dlen);
1406 + init_completion(&result.completion);
1407 + sg_init_one(&src, input_vec, ilen);
1408 + sg_init_one(&dst, output, dlen);
1409 +
1410 + req = acomp_request_alloc(tfm);
1411 + if (!req) {
1412 + pr_err("alg: acomp: request alloc failed for %s\n",
1413 + algo);
1414 + kfree(input_vec);
1415 + ret = -ENOMEM;
1416 + goto out;
1417 + }
1418 +
1419 + acomp_request_set_params(req, &src, &dst, ilen, dlen);
1420 + acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
1421 + tcrypt_complete, &result);
1422 +
1423 + ret = wait_async_op(&result, crypto_acomp_decompress(req));
1424 + if (ret) {
1425 + pr_err("alg: acomp: decompression failed on test %d for %s: ret=%d\n",
1426 + i + 1, algo, -ret);
1427 + kfree(input_vec);
1428 + acomp_request_free(req);
1429 + goto out;
1430 + }
1431 +
1432 + if (req->dlen != dtemplate[i].outlen) {
1433 + pr_err("alg: acomp: Decompression test %d failed for %s: output len = %d\n",
1434 + i + 1, algo, req->dlen);
1435 + ret = -EINVAL;
1436 + kfree(input_vec);
1437 + acomp_request_free(req);
1438 + goto out;
1439 + }
1440 +
1441 + if (memcmp(output, dtemplate[i].output, req->dlen)) {
1442 + pr_err("alg: acomp: Decompression test %d failed for %s\n",
1443 + i + 1, algo);
1444 + hexdump(output, req->dlen);
1445 + ret = -EINVAL;
1446 + kfree(input_vec);
1447 + acomp_request_free(req);
1448 + goto out;
1449 + }
1450 +
1451 + kfree(input_vec);
1452 + acomp_request_free(req);
1453 + }
1454 +
1455 + ret = 0;
1456 +
1457 +out:
1458 + kfree(output);
1459 + return ret;
1460 +}
1461 +
1462 +static int test_cprng(struct crypto_rng *tfm,
1463 + const struct cprng_testvec *template,
1464 unsigned int tcount)
1465 {
1466 const char *algo = crypto_tfm_alg_driver_name(crypto_rng_tfm(tfm));
1467 @@ -1509,7 +1905,7 @@ static int alg_test_aead(const struct al
1468 struct crypto_aead *tfm;
1469 int err = 0;
1470
1471 - tfm = crypto_alloc_aead(driver, type | CRYPTO_ALG_INTERNAL, mask);
1472 + tfm = crypto_alloc_aead(driver, type, mask);
1473 if (IS_ERR(tfm)) {
1474 printk(KERN_ERR "alg: aead: Failed to load transform for %s: "
1475 "%ld\n", driver, PTR_ERR(tfm));
1476 @@ -1538,7 +1934,7 @@ static int alg_test_cipher(const struct
1477 struct crypto_cipher *tfm;
1478 int err = 0;
1479
1480 - tfm = crypto_alloc_cipher(driver, type | CRYPTO_ALG_INTERNAL, mask);
1481 + tfm = crypto_alloc_cipher(driver, type, mask);
1482 if (IS_ERR(tfm)) {
1483 printk(KERN_ERR "alg: cipher: Failed to load transform for "
1484 "%s: %ld\n", driver, PTR_ERR(tfm));
1485 @@ -1567,7 +1963,7 @@ static int alg_test_skcipher(const struc
1486 struct crypto_skcipher *tfm;
1487 int err = 0;
1488
1489 - tfm = crypto_alloc_skcipher(driver, type | CRYPTO_ALG_INTERNAL, mask);
1490 + tfm = crypto_alloc_skcipher(driver, type, mask);
1491 if (IS_ERR(tfm)) {
1492 printk(KERN_ERR "alg: skcipher: Failed to load transform for "
1493 "%s: %ld\n", driver, PTR_ERR(tfm));
1494 @@ -1593,22 +1989,38 @@ out:
1495 static int alg_test_comp(const struct alg_test_desc *desc, const char *driver,
1496 u32 type, u32 mask)
1497 {
1498 - struct crypto_comp *tfm;
1499 + struct crypto_comp *comp;
1500 + struct crypto_acomp *acomp;
1501 int err;
1502 + u32 algo_type = type & CRYPTO_ALG_TYPE_ACOMPRESS_MASK;
1503
1504 - tfm = crypto_alloc_comp(driver, type, mask);
1505 - if (IS_ERR(tfm)) {
1506 - printk(KERN_ERR "alg: comp: Failed to load transform for %s: "
1507 - "%ld\n", driver, PTR_ERR(tfm));
1508 - return PTR_ERR(tfm);
1509 - }
1510 + if (algo_type == CRYPTO_ALG_TYPE_ACOMPRESS) {
1511 + acomp = crypto_alloc_acomp(driver, type, mask);
1512 + if (IS_ERR(acomp)) {
1513 + pr_err("alg: acomp: Failed to load transform for %s: %ld\n",
1514 + driver, PTR_ERR(acomp));
1515 + return PTR_ERR(acomp);
1516 + }
1517 + err = test_acomp(acomp, desc->suite.comp.comp.vecs,
1518 + desc->suite.comp.decomp.vecs,
1519 + desc->suite.comp.comp.count,
1520 + desc->suite.comp.decomp.count);
1521 + crypto_free_acomp(acomp);
1522 + } else {
1523 + comp = crypto_alloc_comp(driver, type, mask);
1524 + if (IS_ERR(comp)) {
1525 + pr_err("alg: comp: Failed to load transform for %s: %ld\n",
1526 + driver, PTR_ERR(comp));
1527 + return PTR_ERR(comp);
1528 + }
1529
1530 - err = test_comp(tfm, desc->suite.comp.comp.vecs,
1531 - desc->suite.comp.decomp.vecs,
1532 - desc->suite.comp.comp.count,
1533 - desc->suite.comp.decomp.count);
1534 + err = test_comp(comp, desc->suite.comp.comp.vecs,
1535 + desc->suite.comp.decomp.vecs,
1536 + desc->suite.comp.comp.count,
1537 + desc->suite.comp.decomp.count);
1538
1539 - crypto_free_comp(tfm);
1540 + crypto_free_comp(comp);
1541 + }
1542 return err;
1543 }
1544
1545 @@ -1618,7 +2030,7 @@ static int alg_test_hash(const struct al
1546 struct crypto_ahash *tfm;
1547 int err;
1548
1549 - tfm = crypto_alloc_ahash(driver, type | CRYPTO_ALG_INTERNAL, mask);
1550 + tfm = crypto_alloc_ahash(driver, type, mask);
1551 if (IS_ERR(tfm)) {
1552 printk(KERN_ERR "alg: hash: Failed to load transform for %s: "
1553 "%ld\n", driver, PTR_ERR(tfm));
1554 @@ -1646,7 +2058,7 @@ static int alg_test_crc32c(const struct
1555 if (err)
1556 goto out;
1557
1558 - tfm = crypto_alloc_shash(driver, type | CRYPTO_ALG_INTERNAL, mask);
1559 + tfm = crypto_alloc_shash(driver, type, mask);
1560 if (IS_ERR(tfm)) {
1561 printk(KERN_ERR "alg: crc32c: Failed to load transform for %s: "
1562 "%ld\n", driver, PTR_ERR(tfm));
1563 @@ -1688,7 +2100,7 @@ static int alg_test_cprng(const struct a
1564 struct crypto_rng *rng;
1565 int err;
1566
1567 - rng = crypto_alloc_rng(driver, type | CRYPTO_ALG_INTERNAL, mask);
1568 + rng = crypto_alloc_rng(driver, type, mask);
1569 if (IS_ERR(rng)) {
1570 printk(KERN_ERR "alg: cprng: Failed to load transform for %s: "
1571 "%ld\n", driver, PTR_ERR(rng));
1572 @@ -1703,7 +2115,7 @@ static int alg_test_cprng(const struct a
1573 }
1574
1575
1576 -static int drbg_cavs_test(struct drbg_testvec *test, int pr,
1577 +static int drbg_cavs_test(const struct drbg_testvec *test, int pr,
1578 const char *driver, u32 type, u32 mask)
1579 {
1580 int ret = -EAGAIN;
1581 @@ -1715,7 +2127,7 @@ static int drbg_cavs_test(struct drbg_te
1582 if (!buf)
1583 return -ENOMEM;
1584
1585 - drng = crypto_alloc_rng(driver, type | CRYPTO_ALG_INTERNAL, mask);
1586 + drng = crypto_alloc_rng(driver, type, mask);
1587 if (IS_ERR(drng)) {
1588 printk(KERN_ERR "alg: drbg: could not allocate DRNG handle for "
1589 "%s\n", driver);
1590 @@ -1777,7 +2189,7 @@ static int alg_test_drbg(const struct al
1591 int err = 0;
1592 int pr = 0;
1593 int i = 0;
1594 - struct drbg_testvec *template = desc->suite.drbg.vecs;
1595 + const struct drbg_testvec *template = desc->suite.drbg.vecs;
1596 unsigned int tcount = desc->suite.drbg.count;
1597
1598 if (0 == memcmp(driver, "drbg_pr_", 8))
1599 @@ -1796,7 +2208,7 @@ static int alg_test_drbg(const struct al
1600
1601 }
1602
1603 -static int do_test_kpp(struct crypto_kpp *tfm, struct kpp_testvec *vec,
1604 +static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec,
1605 const char *alg)
1606 {
1607 struct kpp_request *req;
1608 @@ -1888,7 +2300,7 @@ free_req:
1609 }
1610
1611 static int test_kpp(struct crypto_kpp *tfm, const char *alg,
1612 - struct kpp_testvec *vecs, unsigned int tcount)
1613 + const struct kpp_testvec *vecs, unsigned int tcount)
1614 {
1615 int ret, i;
1616
1617 @@ -1909,7 +2321,7 @@ static int alg_test_kpp(const struct alg
1618 struct crypto_kpp *tfm;
1619 int err = 0;
1620
1621 - tfm = crypto_alloc_kpp(driver, type | CRYPTO_ALG_INTERNAL, mask);
1622 + tfm = crypto_alloc_kpp(driver, type, mask);
1623 if (IS_ERR(tfm)) {
1624 pr_err("alg: kpp: Failed to load tfm for %s: %ld\n",
1625 driver, PTR_ERR(tfm));
1626 @@ -1924,7 +2336,7 @@ static int alg_test_kpp(const struct alg
1627 }
1628
1629 static int test_akcipher_one(struct crypto_akcipher *tfm,
1630 - struct akcipher_testvec *vecs)
1631 + const struct akcipher_testvec *vecs)
1632 {
1633 char *xbuf[XBUFSIZE];
1634 struct akcipher_request *req;
1635 @@ -2044,7 +2456,8 @@ free_xbuf:
1636 }
1637
1638 static int test_akcipher(struct crypto_akcipher *tfm, const char *alg,
1639 - struct akcipher_testvec *vecs, unsigned int tcount)
1640 + const struct akcipher_testvec *vecs,
1641 + unsigned int tcount)
1642 {
1643 const char *algo =
1644 crypto_tfm_alg_driver_name(crypto_akcipher_tfm(tfm));
1645 @@ -2068,7 +2481,7 @@ static int alg_test_akcipher(const struc
1646 struct crypto_akcipher *tfm;
1647 int err = 0;
1648
1649 - tfm = crypto_alloc_akcipher(driver, type | CRYPTO_ALG_INTERNAL, mask);
1650 + tfm = crypto_alloc_akcipher(driver, type, mask);
1651 if (IS_ERR(tfm)) {
1652 pr_err("alg: akcipher: Failed to load tfm for %s: %ld\n",
1653 driver, PTR_ERR(tfm));
1654 @@ -2088,112 +2501,23 @@ static int alg_test_null(const struct al
1655 return 0;
1656 }
1657
1658 +#define __VECS(tv) { .vecs = tv, .count = ARRAY_SIZE(tv) }
1659 +
1660 /* Please keep this list sorted by algorithm name. */
1661 static const struct alg_test_desc alg_test_descs[] = {
1662 {
1663 - .alg = "__cbc-cast5-avx",
1664 - .test = alg_test_null,
1665 - }, {
1666 - .alg = "__cbc-cast6-avx",
1667 - .test = alg_test_null,
1668 - }, {
1669 - .alg = "__cbc-serpent-avx",
1670 - .test = alg_test_null,
1671 - }, {
1672 - .alg = "__cbc-serpent-avx2",
1673 - .test = alg_test_null,
1674 - }, {
1675 - .alg = "__cbc-serpent-sse2",
1676 - .test = alg_test_null,
1677 - }, {
1678 - .alg = "__cbc-twofish-avx",
1679 - .test = alg_test_null,
1680 - }, {
1681 - .alg = "__driver-cbc-aes-aesni",
1682 - .test = alg_test_null,
1683 - .fips_allowed = 1,
1684 - }, {
1685 - .alg = "__driver-cbc-camellia-aesni",
1686 - .test = alg_test_null,
1687 - }, {
1688 - .alg = "__driver-cbc-camellia-aesni-avx2",
1689 - .test = alg_test_null,
1690 - }, {
1691 - .alg = "__driver-cbc-cast5-avx",
1692 - .test = alg_test_null,
1693 - }, {
1694 - .alg = "__driver-cbc-cast6-avx",
1695 - .test = alg_test_null,
1696 - }, {
1697 - .alg = "__driver-cbc-serpent-avx",
1698 - .test = alg_test_null,
1699 - }, {
1700 - .alg = "__driver-cbc-serpent-avx2",
1701 - .test = alg_test_null,
1702 - }, {
1703 - .alg = "__driver-cbc-serpent-sse2",
1704 - .test = alg_test_null,
1705 - }, {
1706 - .alg = "__driver-cbc-twofish-avx",
1707 - .test = alg_test_null,
1708 - }, {
1709 - .alg = "__driver-ecb-aes-aesni",
1710 - .test = alg_test_null,
1711 - .fips_allowed = 1,
1712 - }, {
1713 - .alg = "__driver-ecb-camellia-aesni",
1714 - .test = alg_test_null,
1715 - }, {
1716 - .alg = "__driver-ecb-camellia-aesni-avx2",
1717 - .test = alg_test_null,
1718 - }, {
1719 - .alg = "__driver-ecb-cast5-avx",
1720 - .test = alg_test_null,
1721 - }, {
1722 - .alg = "__driver-ecb-cast6-avx",
1723 - .test = alg_test_null,
1724 - }, {
1725 - .alg = "__driver-ecb-serpent-avx",
1726 - .test = alg_test_null,
1727 - }, {
1728 - .alg = "__driver-ecb-serpent-avx2",
1729 - .test = alg_test_null,
1730 - }, {
1731 - .alg = "__driver-ecb-serpent-sse2",
1732 - .test = alg_test_null,
1733 - }, {
1734 - .alg = "__driver-ecb-twofish-avx",
1735 - .test = alg_test_null,
1736 - }, {
1737 - .alg = "__driver-gcm-aes-aesni",
1738 - .test = alg_test_null,
1739 - .fips_allowed = 1,
1740 - }, {
1741 - .alg = "__ghash-pclmulqdqni",
1742 - .test = alg_test_null,
1743 - .fips_allowed = 1,
1744 - }, {
1745 .alg = "ansi_cprng",
1746 .test = alg_test_cprng,
1747 .suite = {
1748 - .cprng = {
1749 - .vecs = ansi_cprng_aes_tv_template,
1750 - .count = ANSI_CPRNG_AES_TEST_VECTORS
1751 - }
1752 + .cprng = __VECS(ansi_cprng_aes_tv_template)
1753 }
1754 }, {
1755 .alg = "authenc(hmac(md5),ecb(cipher_null))",
1756 .test = alg_test_aead,
1757 .suite = {
1758 .aead = {
1759 - .enc = {
1760 - .vecs = hmac_md5_ecb_cipher_null_enc_tv_template,
1761 - .count = HMAC_MD5_ECB_CIPHER_NULL_ENC_TEST_VECTORS
1762 - },
1763 - .dec = {
1764 - .vecs = hmac_md5_ecb_cipher_null_dec_tv_template,
1765 - .count = HMAC_MD5_ECB_CIPHER_NULL_DEC_TEST_VECTORS
1766 - }
1767 + .enc = __VECS(hmac_md5_ecb_cipher_null_enc_tv_template),
1768 + .dec = __VECS(hmac_md5_ecb_cipher_null_dec_tv_template)
1769 }
1770 }
1771 }, {
1772 @@ -2201,12 +2525,7 @@ static const struct alg_test_desc alg_te
1773 .test = alg_test_aead,
1774 .suite = {
1775 .aead = {
1776 - .enc = {
1777 - .vecs =
1778 - hmac_sha1_aes_cbc_enc_tv_temp,
1779 - .count =
1780 - HMAC_SHA1_AES_CBC_ENC_TEST_VEC
1781 - }
1782 + .enc = __VECS(hmac_sha1_aes_cbc_enc_tv_temp)
1783 }
1784 }
1785 }, {
1786 @@ -2214,12 +2533,7 @@ static const struct alg_test_desc alg_te
1787 .test = alg_test_aead,
1788 .suite = {
1789 .aead = {
1790 - .enc = {
1791 - .vecs =
1792 - hmac_sha1_des_cbc_enc_tv_temp,
1793 - .count =
1794 - HMAC_SHA1_DES_CBC_ENC_TEST_VEC
1795 - }
1796 + .enc = __VECS(hmac_sha1_des_cbc_enc_tv_temp)
1797 }
1798 }
1799 }, {
1800 @@ -2228,12 +2542,7 @@ static const struct alg_test_desc alg_te
1801 .fips_allowed = 1,
1802 .suite = {
1803 .aead = {
1804 - .enc = {
1805 - .vecs =
1806 - hmac_sha1_des3_ede_cbc_enc_tv_temp,
1807 - .count =
1808 - HMAC_SHA1_DES3_EDE_CBC_ENC_TEST_VEC
1809 - }
1810 + .enc = __VECS(hmac_sha1_des3_ede_cbc_enc_tv_temp)
1811 }
1812 }
1813 }, {
1814 @@ -2245,18 +2554,8 @@ static const struct alg_test_desc alg_te
1815 .test = alg_test_aead,
1816 .suite = {
1817 .aead = {
1818 - .enc = {
1819 - .vecs =
1820 - hmac_sha1_ecb_cipher_null_enc_tv_temp,
1821 - .count =
1822 - HMAC_SHA1_ECB_CIPHER_NULL_ENC_TEST_VEC
1823 - },
1824 - .dec = {
1825 - .vecs =
1826 - hmac_sha1_ecb_cipher_null_dec_tv_temp,
1827 - .count =
1828 - HMAC_SHA1_ECB_CIPHER_NULL_DEC_TEST_VEC
1829 - }
1830 + .enc = __VECS(hmac_sha1_ecb_cipher_null_enc_tv_temp),
1831 + .dec = __VECS(hmac_sha1_ecb_cipher_null_dec_tv_temp)
1832 }
1833 }
1834 }, {
1835 @@ -2268,12 +2567,7 @@ static const struct alg_test_desc alg_te
1836 .test = alg_test_aead,
1837 .suite = {
1838 .aead = {
1839 - .enc = {
1840 - .vecs =
1841 - hmac_sha224_des_cbc_enc_tv_temp,
1842 - .count =
1843 - HMAC_SHA224_DES_CBC_ENC_TEST_VEC
1844 - }
1845 + .enc = __VECS(hmac_sha224_des_cbc_enc_tv_temp)
1846 }
1847 }
1848 }, {
1849 @@ -2282,12 +2576,7 @@ static const struct alg_test_desc alg_te
1850 .fips_allowed = 1,
1851 .suite = {
1852 .aead = {
1853 - .enc = {
1854 - .vecs =
1855 - hmac_sha224_des3_ede_cbc_enc_tv_temp,
1856 - .count =
1857 - HMAC_SHA224_DES3_EDE_CBC_ENC_TEST_VEC
1858 - }
1859 + .enc = __VECS(hmac_sha224_des3_ede_cbc_enc_tv_temp)
1860 }
1861 }
1862 }, {
1863 @@ -2296,12 +2585,7 @@ static const struct alg_test_desc alg_te
1864 .fips_allowed = 1,
1865 .suite = {
1866 .aead = {
1867 - .enc = {
1868 - .vecs =
1869 - hmac_sha256_aes_cbc_enc_tv_temp,
1870 - .count =
1871 - HMAC_SHA256_AES_CBC_ENC_TEST_VEC
1872 - }
1873 + .enc = __VECS(hmac_sha256_aes_cbc_enc_tv_temp)
1874 }
1875 }
1876 }, {
1877 @@ -2309,12 +2593,7 @@ static const struct alg_test_desc alg_te
1878 .test = alg_test_aead,
1879 .suite = {
1880 .aead = {
1881 - .enc = {
1882 - .vecs =
1883 - hmac_sha256_des_cbc_enc_tv_temp,
1884 - .count =
1885 - HMAC_SHA256_DES_CBC_ENC_TEST_VEC
1886 - }
1887 + .enc = __VECS(hmac_sha256_des_cbc_enc_tv_temp)
1888 }
1889 }
1890 }, {
1891 @@ -2323,12 +2602,7 @@ static const struct alg_test_desc alg_te
1892 .fips_allowed = 1,
1893 .suite = {
1894 .aead = {
1895 - .enc = {
1896 - .vecs =
1897 - hmac_sha256_des3_ede_cbc_enc_tv_temp,
1898 - .count =
1899 - HMAC_SHA256_DES3_EDE_CBC_ENC_TEST_VEC
1900 - }
1901 + .enc = __VECS(hmac_sha256_des3_ede_cbc_enc_tv_temp)
1902 }
1903 }
1904 }, {
1905 @@ -2344,12 +2618,7 @@ static const struct alg_test_desc alg_te
1906 .test = alg_test_aead,
1907 .suite = {
1908 .aead = {
1909 - .enc = {
1910 - .vecs =
1911 - hmac_sha384_des_cbc_enc_tv_temp,
1912 - .count =
1913 - HMAC_SHA384_DES_CBC_ENC_TEST_VEC
1914 - }
1915 + .enc = __VECS(hmac_sha384_des_cbc_enc_tv_temp)
1916 }
1917 }
1918 }, {
1919 @@ -2358,12 +2627,7 @@ static const struct alg_test_desc alg_te
1920 .fips_allowed = 1,
1921 .suite = {
1922 .aead = {
1923 - .enc = {
1924 - .vecs =
1925 - hmac_sha384_des3_ede_cbc_enc_tv_temp,
1926 - .count =
1927 - HMAC_SHA384_DES3_EDE_CBC_ENC_TEST_VEC
1928 - }
1929 + .enc = __VECS(hmac_sha384_des3_ede_cbc_enc_tv_temp)
1930 }
1931 }
1932 }, {
1933 @@ -2380,12 +2644,7 @@ static const struct alg_test_desc alg_te
1934 .test = alg_test_aead,
1935 .suite = {
1936 .aead = {
1937 - .enc = {
1938 - .vecs =
1939 - hmac_sha512_aes_cbc_enc_tv_temp,
1940 - .count =
1941 - HMAC_SHA512_AES_CBC_ENC_TEST_VEC
1942 - }
1943 + .enc = __VECS(hmac_sha512_aes_cbc_enc_tv_temp)
1944 }
1945 }
1946 }, {
1947 @@ -2393,12 +2652,7 @@ static const struct alg_test_desc alg_te
1948 .test = alg_test_aead,
1949 .suite = {
1950 .aead = {
1951 - .enc = {
1952 - .vecs =
1953 - hmac_sha512_des_cbc_enc_tv_temp,
1954 - .count =
1955 - HMAC_SHA512_DES_CBC_ENC_TEST_VEC
1956 - }
1957 + .enc = __VECS(hmac_sha512_des_cbc_enc_tv_temp)
1958 }
1959 }
1960 }, {
1961 @@ -2407,12 +2661,7 @@ static const struct alg_test_desc alg_te
1962 .fips_allowed = 1,
1963 .suite = {
1964 .aead = {
1965 - .enc = {
1966 - .vecs =
1967 - hmac_sha512_des3_ede_cbc_enc_tv_temp,
1968 - .count =
1969 - HMAC_SHA512_DES3_EDE_CBC_ENC_TEST_VEC
1970 - }
1971 + .enc = __VECS(hmac_sha512_des3_ede_cbc_enc_tv_temp)
1972 }
1973 }
1974 }, {
1975 @@ -2429,14 +2678,8 @@ static const struct alg_test_desc alg_te
1976 .fips_allowed = 1,
1977 .suite = {
1978 .cipher = {
1979 - .enc = {
1980 - .vecs = aes_cbc_enc_tv_template,
1981 - .count = AES_CBC_ENC_TEST_VECTORS
1982 - },
1983 - .dec = {
1984 - .vecs = aes_cbc_dec_tv_template,
1985 - .count = AES_CBC_DEC_TEST_VECTORS
1986 - }
1987 + .enc = __VECS(aes_cbc_enc_tv_template),
1988 + .dec = __VECS(aes_cbc_dec_tv_template)
1989 }
1990 }
1991 }, {
1992 @@ -2444,14 +2687,8 @@ static const struct alg_test_desc alg_te
1993 .test = alg_test_skcipher,
1994 .suite = {
1995 .cipher = {
1996 - .enc = {
1997 - .vecs = anubis_cbc_enc_tv_template,
1998 - .count = ANUBIS_CBC_ENC_TEST_VECTORS
1999 - },
2000 - .dec = {
2001 - .vecs = anubis_cbc_dec_tv_template,
2002 - .count = ANUBIS_CBC_DEC_TEST_VECTORS
2003 - }
2004 + .enc = __VECS(anubis_cbc_enc_tv_template),
2005 + .dec = __VECS(anubis_cbc_dec_tv_template)
2006 }
2007 }
2008 }, {
2009 @@ -2459,14 +2696,8 @@ static const struct alg_test_desc alg_te
2010 .test = alg_test_skcipher,
2011 .suite = {
2012 .cipher = {
2013 - .enc = {
2014 - .vecs = bf_cbc_enc_tv_template,
2015 - .count = BF_CBC_ENC_TEST_VECTORS
2016 - },
2017 - .dec = {
2018 - .vecs = bf_cbc_dec_tv_template,
2019 - .count = BF_CBC_DEC_TEST_VECTORS
2020 - }
2021 + .enc = __VECS(bf_cbc_enc_tv_template),
2022 + .dec = __VECS(bf_cbc_dec_tv_template)
2023 }
2024 }
2025 }, {
2026 @@ -2474,14 +2705,8 @@ static const struct alg_test_desc alg_te
2027 .test = alg_test_skcipher,
2028 .suite = {
2029 .cipher = {
2030 - .enc = {
2031 - .vecs = camellia_cbc_enc_tv_template,
2032 - .count = CAMELLIA_CBC_ENC_TEST_VECTORS
2033 - },
2034 - .dec = {
2035 - .vecs = camellia_cbc_dec_tv_template,
2036 - .count = CAMELLIA_CBC_DEC_TEST_VECTORS
2037 - }
2038 + .enc = __VECS(camellia_cbc_enc_tv_template),
2039 + .dec = __VECS(camellia_cbc_dec_tv_template)
2040 }
2041 }
2042 }, {
2043 @@ -2489,14 +2714,8 @@ static const struct alg_test_desc alg_te
2044 .test = alg_test_skcipher,
2045 .suite = {
2046 .cipher = {
2047 - .enc = {
2048 - .vecs = cast5_cbc_enc_tv_template,
2049 - .count = CAST5_CBC_ENC_TEST_VECTORS
2050 - },
2051 - .dec = {
2052 - .vecs = cast5_cbc_dec_tv_template,
2053 - .count = CAST5_CBC_DEC_TEST_VECTORS
2054 - }
2055 + .enc = __VECS(cast5_cbc_enc_tv_template),
2056 + .dec = __VECS(cast5_cbc_dec_tv_template)
2057 }
2058 }
2059 }, {
2060 @@ -2504,14 +2723,8 @@ static const struct alg_test_desc alg_te
2061 .test = alg_test_skcipher,
2062 .suite = {
2063 .cipher = {
2064 - .enc = {
2065 - .vecs = cast6_cbc_enc_tv_template,
2066 - .count = CAST6_CBC_ENC_TEST_VECTORS
2067 - },
2068 - .dec = {
2069 - .vecs = cast6_cbc_dec_tv_template,
2070 - .count = CAST6_CBC_DEC_TEST_VECTORS
2071 - }
2072 + .enc = __VECS(cast6_cbc_enc_tv_template),
2073 + .dec = __VECS(cast6_cbc_dec_tv_template)
2074 }
2075 }
2076 }, {
2077 @@ -2519,14 +2732,8 @@ static const struct alg_test_desc alg_te
2078 .test = alg_test_skcipher,
2079 .suite = {
2080 .cipher = {
2081 - .enc = {
2082 - .vecs = des_cbc_enc_tv_template,
2083 - .count = DES_CBC_ENC_TEST_VECTORS
2084 - },
2085 - .dec = {
2086 - .vecs = des_cbc_dec_tv_template,
2087 - .count = DES_CBC_DEC_TEST_VECTORS
2088 - }
2089 + .enc = __VECS(des_cbc_enc_tv_template),
2090 + .dec = __VECS(des_cbc_dec_tv_template)
2091 }
2092 }
2093 }, {
2094 @@ -2535,14 +2742,8 @@ static const struct alg_test_desc alg_te
2095 .fips_allowed = 1,
2096 .suite = {
2097 .cipher = {
2098 - .enc = {
2099 - .vecs = des3_ede_cbc_enc_tv_template,
2100 - .count = DES3_EDE_CBC_ENC_TEST_VECTORS
2101 - },
2102 - .dec = {
2103 - .vecs = des3_ede_cbc_dec_tv_template,
2104 - .count = DES3_EDE_CBC_DEC_TEST_VECTORS
2105 - }
2106 + .enc = __VECS(des3_ede_cbc_enc_tv_template),
2107 + .dec = __VECS(des3_ede_cbc_dec_tv_template)
2108 }
2109 }
2110 }, {
2111 @@ -2550,14 +2751,8 @@ static const struct alg_test_desc alg_te
2112 .test = alg_test_skcipher,
2113 .suite = {
2114 .cipher = {
2115 - .enc = {
2116 - .vecs = serpent_cbc_enc_tv_template,
2117 - .count = SERPENT_CBC_ENC_TEST_VECTORS
2118 - },
2119 - .dec = {
2120 - .vecs = serpent_cbc_dec_tv_template,
2121 - .count = SERPENT_CBC_DEC_TEST_VECTORS
2122 - }
2123 + .enc = __VECS(serpent_cbc_enc_tv_template),
2124 + .dec = __VECS(serpent_cbc_dec_tv_template)
2125 }
2126 }
2127 }, {
2128 @@ -2565,30 +2760,25 @@ static const struct alg_test_desc alg_te
2129 .test = alg_test_skcipher,
2130 .suite = {
2131 .cipher = {
2132 - .enc = {
2133 - .vecs = tf_cbc_enc_tv_template,
2134 - .count = TF_CBC_ENC_TEST_VECTORS
2135 - },
2136 - .dec = {
2137 - .vecs = tf_cbc_dec_tv_template,
2138 - .count = TF_CBC_DEC_TEST_VECTORS
2139 - }
2140 + .enc = __VECS(tf_cbc_enc_tv_template),
2141 + .dec = __VECS(tf_cbc_dec_tv_template)
2142 }
2143 }
2144 }, {
2145 + .alg = "cbcmac(aes)",
2146 + .fips_allowed = 1,
2147 + .test = alg_test_hash,
2148 + .suite = {
2149 + .hash = __VECS(aes_cbcmac_tv_template)
2150 + }
2151 + }, {
2152 .alg = "ccm(aes)",
2153 .test = alg_test_aead,
2154 .fips_allowed = 1,
2155 .suite = {
2156 .aead = {
2157 - .enc = {
2158 - .vecs = aes_ccm_enc_tv_template,
2159 - .count = AES_CCM_ENC_TEST_VECTORS
2160 - },
2161 - .dec = {
2162 - .vecs = aes_ccm_dec_tv_template,
2163 - .count = AES_CCM_DEC_TEST_VECTORS
2164 - }
2165 + .enc = __VECS(aes_ccm_enc_tv_template),
2166 + .dec = __VECS(aes_ccm_dec_tv_template)
2167 }
2168 }
2169 }, {
2170 @@ -2596,14 +2786,8 @@ static const struct alg_test_desc alg_te
2171 .test = alg_test_skcipher,
2172 .suite = {
2173 .cipher = {
2174 - .enc = {
2175 - .vecs = chacha20_enc_tv_template,
2176 - .count = CHACHA20_ENC_TEST_VECTORS
2177 - },
2178 - .dec = {
2179 - .vecs = chacha20_enc_tv_template,
2180 - .count = CHACHA20_ENC_TEST_VECTORS
2181 - },
2182 + .enc = __VECS(chacha20_enc_tv_template),
2183 + .dec = __VECS(chacha20_enc_tv_template),
2184 }
2185 }
2186 }, {
2187 @@ -2611,20 +2795,14 @@ static const struct alg_test_desc alg_te
2188 .fips_allowed = 1,
2189 .test = alg_test_hash,
2190 .suite = {
2191 - .hash = {
2192 - .vecs = aes_cmac128_tv_template,
2193 - .count = CMAC_AES_TEST_VECTORS
2194 - }
2195 + .hash = __VECS(aes_cmac128_tv_template)
2196 }
2197 }, {
2198 .alg = "cmac(des3_ede)",
2199 .fips_allowed = 1,
2200 .test = alg_test_hash,
2201 .suite = {
2202 - .hash = {
2203 - .vecs = des3_ede_cmac64_tv_template,
2204 - .count = CMAC_DES3_EDE_TEST_VECTORS
2205 - }
2206 + .hash = __VECS(des3_ede_cmac64_tv_template)
2207 }
2208 }, {
2209 .alg = "compress_null",
2210 @@ -2633,94 +2811,30 @@ static const struct alg_test_desc alg_te
2211 .alg = "crc32",
2212 .test = alg_test_hash,
2213 .suite = {
2214 - .hash = {
2215 - .vecs = crc32_tv_template,
2216 - .count = CRC32_TEST_VECTORS
2217 - }
2218 + .hash = __VECS(crc32_tv_template)
2219 }
2220 }, {
2221 .alg = "crc32c",
2222 .test = alg_test_crc32c,
2223 .fips_allowed = 1,
2224 .suite = {
2225 - .hash = {
2226 - .vecs = crc32c_tv_template,
2227 - .count = CRC32C_TEST_VECTORS
2228 - }
2229 + .hash = __VECS(crc32c_tv_template)
2230 }
2231 }, {
2232 .alg = "crct10dif",
2233 .test = alg_test_hash,
2234 .fips_allowed = 1,
2235 .suite = {
2236 - .hash = {
2237 - .vecs = crct10dif_tv_template,
2238 - .count = CRCT10DIF_TEST_VECTORS
2239 - }
2240 + .hash = __VECS(crct10dif_tv_template)
2241 }
2242 }, {
2243 - .alg = "cryptd(__driver-cbc-aes-aesni)",
2244 - .test = alg_test_null,
2245 - .fips_allowed = 1,
2246 - }, {
2247 - .alg = "cryptd(__driver-cbc-camellia-aesni)",
2248 - .test = alg_test_null,
2249 - }, {
2250 - .alg = "cryptd(__driver-cbc-camellia-aesni-avx2)",
2251 - .test = alg_test_null,
2252 - }, {
2253 - .alg = "cryptd(__driver-cbc-serpent-avx2)",
2254 - .test = alg_test_null,
2255 - }, {
2256 - .alg = "cryptd(__driver-ecb-aes-aesni)",
2257 - .test = alg_test_null,
2258 - .fips_allowed = 1,
2259 - }, {
2260 - .alg = "cryptd(__driver-ecb-camellia-aesni)",
2261 - .test = alg_test_null,
2262 - }, {
2263 - .alg = "cryptd(__driver-ecb-camellia-aesni-avx2)",
2264 - .test = alg_test_null,
2265 - }, {
2266 - .alg = "cryptd(__driver-ecb-cast5-avx)",
2267 - .test = alg_test_null,
2268 - }, {
2269 - .alg = "cryptd(__driver-ecb-cast6-avx)",
2270 - .test = alg_test_null,
2271 - }, {
2272 - .alg = "cryptd(__driver-ecb-serpent-avx)",
2273 - .test = alg_test_null,
2274 - }, {
2275 - .alg = "cryptd(__driver-ecb-serpent-avx2)",
2276 - .test = alg_test_null,
2277 - }, {
2278 - .alg = "cryptd(__driver-ecb-serpent-sse2)",
2279 - .test = alg_test_null,
2280 - }, {
2281 - .alg = "cryptd(__driver-ecb-twofish-avx)",
2282 - .test = alg_test_null,
2283 - }, {
2284 - .alg = "cryptd(__driver-gcm-aes-aesni)",
2285 - .test = alg_test_null,
2286 - .fips_allowed = 1,
2287 - }, {
2288 - .alg = "cryptd(__ghash-pclmulqdqni)",
2289 - .test = alg_test_null,
2290 - .fips_allowed = 1,
2291 - }, {
2292 .alg = "ctr(aes)",
2293 .test = alg_test_skcipher,
2294 .fips_allowed = 1,
2295 .suite = {
2296 .cipher = {
2297 - .enc = {
2298 - .vecs = aes_ctr_enc_tv_template,
2299 - .count = AES_CTR_ENC_TEST_VECTORS
2300 - },
2301 - .dec = {
2302 - .vecs = aes_ctr_dec_tv_template,
2303 - .count = AES_CTR_DEC_TEST_VECTORS
2304 - }
2305 + .enc = __VECS(aes_ctr_enc_tv_template),
2306 + .dec = __VECS(aes_ctr_dec_tv_template)
2307 }
2308 }
2309 }, {
2310 @@ -2728,14 +2842,8 @@ static const struct alg_test_desc alg_te
2311 .test = alg_test_skcipher,
2312 .suite = {
2313 .cipher = {
2314 - .enc = {
2315 - .vecs = bf_ctr_enc_tv_template,
2316 - .count = BF_CTR_ENC_TEST_VECTORS
2317 - },
2318 - .dec = {
2319 - .vecs = bf_ctr_dec_tv_template,
2320 - .count = BF_CTR_DEC_TEST_VECTORS
2321 - }
2322 + .enc = __VECS(bf_ctr_enc_tv_template),
2323 + .dec = __VECS(bf_ctr_dec_tv_template)
2324 }
2325 }
2326 }, {
2327 @@ -2743,14 +2851,8 @@ static const struct alg_test_desc alg_te
2328 .test = alg_test_skcipher,
2329 .suite = {
2330 .cipher = {
2331 - .enc = {
2332 - .vecs = camellia_ctr_enc_tv_template,
2333 - .count = CAMELLIA_CTR_ENC_TEST_VECTORS
2334 - },
2335 - .dec = {
2336 - .vecs = camellia_ctr_dec_tv_template,
2337 - .count = CAMELLIA_CTR_DEC_TEST_VECTORS
2338 - }
2339 + .enc = __VECS(camellia_ctr_enc_tv_template),
2340 + .dec = __VECS(camellia_ctr_dec_tv_template)
2341 }
2342 }
2343 }, {
2344 @@ -2758,14 +2860,8 @@ static const struct alg_test_desc alg_te
2345 .test = alg_test_skcipher,
2346 .suite = {
2347 .cipher = {
2348 - .enc = {
2349 - .vecs = cast5_ctr_enc_tv_template,
2350 - .count = CAST5_CTR_ENC_TEST_VECTORS
2351 - },
2352 - .dec = {
2353 - .vecs = cast5_ctr_dec_tv_template,
2354 - .count = CAST5_CTR_DEC_TEST_VECTORS
2355 - }
2356 + .enc = __VECS(cast5_ctr_enc_tv_template),
2357 + .dec = __VECS(cast5_ctr_dec_tv_template)
2358 }
2359 }
2360 }, {
2361 @@ -2773,14 +2869,8 @@ static const struct alg_test_desc alg_te
2362 .test = alg_test_skcipher,
2363 .suite = {
2364 .cipher = {
2365 - .enc = {
2366 - .vecs = cast6_ctr_enc_tv_template,
2367 - .count = CAST6_CTR_ENC_TEST_VECTORS
2368 - },
2369 - .dec = {
2370 - .vecs = cast6_ctr_dec_tv_template,
2371 - .count = CAST6_CTR_DEC_TEST_VECTORS
2372 - }
2373 + .enc = __VECS(cast6_ctr_enc_tv_template),
2374 + .dec = __VECS(cast6_ctr_dec_tv_template)
2375 }
2376 }
2377 }, {
2378 @@ -2788,29 +2878,18 @@ static const struct alg_test_desc alg_te
2379 .test = alg_test_skcipher,
2380 .suite = {
2381 .cipher = {
2382 - .enc = {
2383 - .vecs = des_ctr_enc_tv_template,
2384 - .count = DES_CTR_ENC_TEST_VECTORS
2385 - },
2386 - .dec = {
2387 - .vecs = des_ctr_dec_tv_template,
2388 - .count = DES_CTR_DEC_TEST_VECTORS
2389 - }
2390 + .enc = __VECS(des_ctr_enc_tv_template),
2391 + .dec = __VECS(des_ctr_dec_tv_template)
2392 }
2393 }
2394 }, {
2395 .alg = "ctr(des3_ede)",
2396 .test = alg_test_skcipher,
2397 + .fips_allowed = 1,
2398 .suite = {
2399 .cipher = {
2400 - .enc = {
2401 - .vecs = des3_ede_ctr_enc_tv_template,
2402 - .count = DES3_EDE_CTR_ENC_TEST_VECTORS
2403 - },
2404 - .dec = {
2405 - .vecs = des3_ede_ctr_dec_tv_template,
2406 - .count = DES3_EDE_CTR_DEC_TEST_VECTORS
2407 - }
2408 + .enc = __VECS(des3_ede_ctr_enc_tv_template),
2409 + .dec = __VECS(des3_ede_ctr_dec_tv_template)
2410 }
2411 }
2412 }, {
2413 @@ -2818,14 +2897,8 @@ static const struct alg_test_desc alg_te
2414 .test = alg_test_skcipher,
2415 .suite = {
2416 .cipher = {
2417 - .enc = {
2418 - .vecs = serpent_ctr_enc_tv_template,
2419 - .count = SERPENT_CTR_ENC_TEST_VECTORS
2420 - },
2421 - .dec = {
2422 - .vecs = serpent_ctr_dec_tv_template,
2423 - .count = SERPENT_CTR_DEC_TEST_VECTORS
2424 - }
2425 + .enc = __VECS(serpent_ctr_enc_tv_template),
2426 + .dec = __VECS(serpent_ctr_dec_tv_template)
2427 }
2428 }
2429 }, {
2430 @@ -2833,14 +2906,8 @@ static const struct alg_test_desc alg_te
2431 .test = alg_test_skcipher,
2432 .suite = {
2433 .cipher = {
2434 - .enc = {
2435 - .vecs = tf_ctr_enc_tv_template,
2436 - .count = TF_CTR_ENC_TEST_VECTORS
2437 - },
2438 - .dec = {
2439 - .vecs = tf_ctr_dec_tv_template,
2440 - .count = TF_CTR_DEC_TEST_VECTORS
2441 - }
2442 + .enc = __VECS(tf_ctr_enc_tv_template),
2443 + .dec = __VECS(tf_ctr_dec_tv_template)
2444 }
2445 }
2446 }, {
2447 @@ -2848,14 +2915,8 @@ static const struct alg_test_desc alg_te
2448 .test = alg_test_skcipher,
2449 .suite = {
2450 .cipher = {
2451 - .enc = {
2452 - .vecs = cts_mode_enc_tv_template,
2453 - .count = CTS_MODE_ENC_TEST_VECTORS
2454 - },
2455 - .dec = {
2456 - .vecs = cts_mode_dec_tv_template,
2457 - .count = CTS_MODE_DEC_TEST_VECTORS
2458 - }
2459 + .enc = __VECS(cts_mode_enc_tv_template),
2460 + .dec = __VECS(cts_mode_dec_tv_template)
2461 }
2462 }
2463 }, {
2464 @@ -2864,14 +2925,8 @@ static const struct alg_test_desc alg_te
2465 .fips_allowed = 1,
2466 .suite = {
2467 .comp = {
2468 - .comp = {
2469 - .vecs = deflate_comp_tv_template,
2470 - .count = DEFLATE_COMP_TEST_VECTORS
2471 - },
2472 - .decomp = {
2473 - .vecs = deflate_decomp_tv_template,
2474 - .count = DEFLATE_DECOMP_TEST_VECTORS
2475 - }
2476 + .comp = __VECS(deflate_comp_tv_template),
2477 + .decomp = __VECS(deflate_decomp_tv_template)
2478 }
2479 }
2480 }, {
2481 @@ -2879,10 +2934,7 @@ static const struct alg_test_desc alg_te
2482 .test = alg_test_kpp,
2483 .fips_allowed = 1,
2484 .suite = {
2485 - .kpp = {
2486 - .vecs = dh_tv_template,
2487 - .count = DH_TEST_VECTORS
2488 - }
2489 + .kpp = __VECS(dh_tv_template)
2490 }
2491 }, {
2492 .alg = "digest_null",
2493 @@ -2892,30 +2944,21 @@ static const struct alg_test_desc alg_te
2494 .test = alg_test_drbg,
2495 .fips_allowed = 1,
2496 .suite = {
2497 - .drbg = {
2498 - .vecs = drbg_nopr_ctr_aes128_tv_template,
2499 - .count = ARRAY_SIZE(drbg_nopr_ctr_aes128_tv_template)
2500 - }
2501 + .drbg = __VECS(drbg_nopr_ctr_aes128_tv_template)
2502 }
2503 }, {
2504 .alg = "drbg_nopr_ctr_aes192",
2505 .test = alg_test_drbg,
2506 .fips_allowed = 1,
2507 .suite = {
2508 - .drbg = {
2509 - .vecs = drbg_nopr_ctr_aes192_tv_template,
2510 - .count = ARRAY_SIZE(drbg_nopr_ctr_aes192_tv_template)
2511 - }
2512 + .drbg = __VECS(drbg_nopr_ctr_aes192_tv_template)
2513 }
2514 }, {
2515 .alg = "drbg_nopr_ctr_aes256",
2516 .test = alg_test_drbg,
2517 .fips_allowed = 1,
2518 .suite = {
2519 - .drbg = {
2520 - .vecs = drbg_nopr_ctr_aes256_tv_template,
2521 - .count = ARRAY_SIZE(drbg_nopr_ctr_aes256_tv_template)
2522 - }
2523 + .drbg = __VECS(drbg_nopr_ctr_aes256_tv_template)
2524 }
2525 }, {
2526 /*
2527 @@ -2930,11 +2973,7 @@ static const struct alg_test_desc alg_te
2528 .test = alg_test_drbg,
2529 .fips_allowed = 1,
2530 .suite = {
2531 - .drbg = {
2532 - .vecs = drbg_nopr_hmac_sha256_tv_template,
2533 - .count =
2534 - ARRAY_SIZE(drbg_nopr_hmac_sha256_tv_template)
2535 - }
2536 + .drbg = __VECS(drbg_nopr_hmac_sha256_tv_template)
2537 }
2538 }, {
2539 /* covered by drbg_nopr_hmac_sha256 test */
2540 @@ -2954,10 +2993,7 @@ static const struct alg_test_desc alg_te
2541 .test = alg_test_drbg,
2542 .fips_allowed = 1,
2543 .suite = {
2544 - .drbg = {
2545 - .vecs = drbg_nopr_sha256_tv_template,
2546 - .count = ARRAY_SIZE(drbg_nopr_sha256_tv_template)
2547 - }
2548 + .drbg = __VECS(drbg_nopr_sha256_tv_template)
2549 }
2550 }, {
2551 /* covered by drbg_nopr_sha256 test */
2552 @@ -2973,10 +3009,7 @@ static const struct alg_test_desc alg_te
2553 .test = alg_test_drbg,
2554 .fips_allowed = 1,
2555 .suite = {
2556 - .drbg = {
2557 - .vecs = drbg_pr_ctr_aes128_tv_template,
2558 - .count = ARRAY_SIZE(drbg_pr_ctr_aes128_tv_template)
2559 - }
2560 + .drbg = __VECS(drbg_pr_ctr_aes128_tv_template)
2561 }
2562 }, {
2563 /* covered by drbg_pr_ctr_aes128 test */
2564 @@ -2996,10 +3029,7 @@ static const struct alg_test_desc alg_te
2565 .test = alg_test_drbg,
2566 .fips_allowed = 1,
2567 .suite = {
2568 - .drbg = {
2569 - .vecs = drbg_pr_hmac_sha256_tv_template,
2570 - .count = ARRAY_SIZE(drbg_pr_hmac_sha256_tv_template)
2571 - }
2572 + .drbg = __VECS(drbg_pr_hmac_sha256_tv_template)
2573 }
2574 }, {
2575 /* covered by drbg_pr_hmac_sha256 test */
2576 @@ -3019,10 +3049,7 @@ static const struct alg_test_desc alg_te
2577 .test = alg_test_drbg,
2578 .fips_allowed = 1,
2579 .suite = {
2580 - .drbg = {
2581 - .vecs = drbg_pr_sha256_tv_template,
2582 - .count = ARRAY_SIZE(drbg_pr_sha256_tv_template)
2583 - }
2584 + .drbg = __VECS(drbg_pr_sha256_tv_template)
2585 }
2586 }, {
2587 /* covered by drbg_pr_sha256 test */
2588 @@ -3034,23 +3061,13 @@ static const struct alg_test_desc alg_te
2589 .fips_allowed = 1,
2590 .test = alg_test_null,
2591 }, {
2592 - .alg = "ecb(__aes-aesni)",
2593 - .test = alg_test_null,
2594 - .fips_allowed = 1,
2595 - }, {
2596 .alg = "ecb(aes)",
2597 .test = alg_test_skcipher,
2598 .fips_allowed = 1,
2599 .suite = {
2600 .cipher = {
2601 - .enc = {
2602 - .vecs = aes_enc_tv_template,
2603 - .count = AES_ENC_TEST_VECTORS
2604 - },
2605 - .dec = {
2606 - .vecs = aes_dec_tv_template,
2607 - .count = AES_DEC_TEST_VECTORS
2608 - }
2609 + .enc = __VECS(aes_enc_tv_template),
2610 + .dec = __VECS(aes_dec_tv_template)
2611 }
2612 }
2613 }, {
2614 @@ -3058,14 +3075,8 @@ static const struct alg_test_desc alg_te
2615 .test = alg_test_skcipher,
2616 .suite = {
2617 .cipher = {
2618 - .enc = {
2619 - .vecs = anubis_enc_tv_template,
2620 - .count = ANUBIS_ENC_TEST_VECTORS
2621 - },
2622 - .dec = {
2623 - .vecs = anubis_dec_tv_template,
2624 - .count = ANUBIS_DEC_TEST_VECTORS
2625 - }
2626 + .enc = __VECS(anubis_enc_tv_template),
2627 + .dec = __VECS(anubis_dec_tv_template)
2628 }
2629 }
2630 }, {
2631 @@ -3073,14 +3084,8 @@ static const struct alg_test_desc alg_te
2632 .test = alg_test_skcipher,
2633 .suite = {
2634 .cipher = {
2635 - .enc = {
2636 - .vecs = arc4_enc_tv_template,
2637 - .count = ARC4_ENC_TEST_VECTORS
2638 - },
2639 - .dec = {
2640 - .vecs = arc4_dec_tv_template,
2641 - .count = ARC4_DEC_TEST_VECTORS
2642 - }
2643 + .enc = __VECS(arc4_enc_tv_template),
2644 + .dec = __VECS(arc4_dec_tv_template)
2645 }
2646 }
2647 }, {
2648 @@ -3088,14 +3093,8 @@ static const struct alg_test_desc alg_te
2649 .test = alg_test_skcipher,
2650 .suite = {
2651 .cipher = {
2652 - .enc = {
2653 - .vecs = bf_enc_tv_template,
2654 - .count = BF_ENC_TEST_VECTORS
2655 - },
2656 - .dec = {
2657 - .vecs = bf_dec_tv_template,
2658 - .count = BF_DEC_TEST_VECTORS
2659 - }
2660 + .enc = __VECS(bf_enc_tv_template),
2661 + .dec = __VECS(bf_dec_tv_template)
2662 }
2663 }
2664 }, {
2665 @@ -3103,14 +3102,8 @@ static const struct alg_test_desc alg_te
2666 .test = alg_test_skcipher,
2667 .suite = {
2668 .cipher = {
2669 - .enc = {
2670 - .vecs = camellia_enc_tv_template,
2671 - .count = CAMELLIA_ENC_TEST_VECTORS
2672 - },
2673 - .dec = {
2674 - .vecs = camellia_dec_tv_template,
2675 - .count = CAMELLIA_DEC_TEST_VECTORS
2676 - }
2677 + .enc = __VECS(camellia_enc_tv_template),
2678 + .dec = __VECS(camellia_dec_tv_template)
2679 }
2680 }
2681 }, {
2682 @@ -3118,14 +3111,8 @@ static const struct alg_test_desc alg_te
2683 .test = alg_test_skcipher,
2684 .suite = {
2685 .cipher = {
2686 - .enc = {
2687 - .vecs = cast5_enc_tv_template,
2688 - .count = CAST5_ENC_TEST_VECTORS
2689 - },
2690 - .dec = {
2691 - .vecs = cast5_dec_tv_template,
2692 - .count = CAST5_DEC_TEST_VECTORS
2693 - }
2694 + .enc = __VECS(cast5_enc_tv_template),
2695 + .dec = __VECS(cast5_dec_tv_template)
2696 }
2697 }
2698 }, {
2699 @@ -3133,14 +3120,8 @@ static const struct alg_test_desc alg_te
2700 .test = alg_test_skcipher,
2701 .suite = {
2702 .cipher = {
2703 - .enc = {
2704 - .vecs = cast6_enc_tv_template,
2705 - .count = CAST6_ENC_TEST_VECTORS
2706 - },
2707 - .dec = {
2708 - .vecs = cast6_dec_tv_template,
2709 - .count = CAST6_DEC_TEST_VECTORS
2710 - }
2711 + .enc = __VECS(cast6_enc_tv_template),
2712 + .dec = __VECS(cast6_dec_tv_template)
2713 }
2714 }
2715 }, {
2716 @@ -3151,14 +3132,8 @@ static const struct alg_test_desc alg_te
2717 .test = alg_test_skcipher,
2718 .suite = {
2719 .cipher = {
2720 - .enc = {
2721 - .vecs = des_enc_tv_template,
2722 - .count = DES_ENC_TEST_VECTORS
2723 - },
2724 - .dec = {
2725 - .vecs = des_dec_tv_template,
2726 - .count = DES_DEC_TEST_VECTORS
2727 - }
2728 + .enc = __VECS(des_enc_tv_template),
2729 + .dec = __VECS(des_dec_tv_template)
2730 }
2731 }
2732 }, {
2733 @@ -3167,14 +3142,8 @@ static const struct alg_test_desc alg_te
2734 .fips_allowed = 1,
2735 .suite = {
2736 .cipher = {
2737 - .enc = {
2738 - .vecs = des3_ede_enc_tv_template,
2739 - .count = DES3_EDE_ENC_TEST_VECTORS
2740 - },
2741 - .dec = {
2742 - .vecs = des3_ede_dec_tv_template,
2743 - .count = DES3_EDE_DEC_TEST_VECTORS
2744 - }
2745 + .enc = __VECS(des3_ede_enc_tv_template),
2746 + .dec = __VECS(des3_ede_dec_tv_template)
2747 }
2748 }
2749 }, {
2750 @@ -3197,14 +3166,8 @@ static const struct alg_test_desc alg_te
2751 .test = alg_test_skcipher,
2752 .suite = {
2753 .cipher = {
2754 - .enc = {
2755 - .vecs = khazad_enc_tv_template,
2756 - .count = KHAZAD_ENC_TEST_VECTORS
2757 - },
2758 - .dec = {
2759 - .vecs = khazad_dec_tv_template,
2760 - .count = KHAZAD_DEC_TEST_VECTORS
2761 - }
2762 + .enc = __VECS(khazad_enc_tv_template),
2763 + .dec = __VECS(khazad_dec_tv_template)
2764 }
2765 }
2766 }, {
2767 @@ -3212,14 +3175,8 @@ static const struct alg_test_desc alg_te
2768 .test = alg_test_skcipher,
2769 .suite = {
2770 .cipher = {
2771 - .enc = {
2772 - .vecs = seed_enc_tv_template,
2773 - .count = SEED_ENC_TEST_VECTORS
2774 - },
2775 - .dec = {
2776 - .vecs = seed_dec_tv_template,
2777 - .count = SEED_DEC_TEST_VECTORS
2778 - }
2779 + .enc = __VECS(seed_enc_tv_template),
2780 + .dec = __VECS(seed_dec_tv_template)
2781 }
2782 }
2783 }, {
2784 @@ -3227,14 +3184,8 @@ static const struct alg_test_desc alg_te
2785 .test = alg_test_skcipher,
2786 .suite = {
2787 .cipher = {
2788 - .enc = {
2789 - .vecs = serpent_enc_tv_template,
2790 - .count = SERPENT_ENC_TEST_VECTORS
2791 - },
2792 - .dec = {
2793 - .vecs = serpent_dec_tv_template,
2794 - .count = SERPENT_DEC_TEST_VECTORS
2795 - }
2796 + .enc = __VECS(serpent_enc_tv_template),
2797 + .dec = __VECS(serpent_dec_tv_template)
2798 }
2799 }
2800 }, {
2801 @@ -3242,14 +3193,8 @@ static const struct alg_test_desc alg_te
2802 .test = alg_test_skcipher,
2803 .suite = {
2804 .cipher = {
2805 - .enc = {
2806 - .vecs = tea_enc_tv_template,
2807 - .count = TEA_ENC_TEST_VECTORS
2808 - },
2809 - .dec = {
2810 - .vecs = tea_dec_tv_template,
2811 - .count = TEA_DEC_TEST_VECTORS
2812 - }
2813 + .enc = __VECS(tea_enc_tv_template),
2814 + .dec = __VECS(tea_dec_tv_template)
2815 }
2816 }
2817 }, {
2818 @@ -3257,14 +3202,8 @@ static const struct alg_test_desc alg_te
2819 .test = alg_test_skcipher,
2820 .suite = {
2821 .cipher = {
2822 - .enc = {
2823 - .vecs = tnepres_enc_tv_template,
2824 - .count = TNEPRES_ENC_TEST_VECTORS
2825 - },
2826 - .dec = {
2827 - .vecs = tnepres_dec_tv_template,
2828 - .count = TNEPRES_DEC_TEST_VECTORS
2829 - }
2830 + .enc = __VECS(tnepres_enc_tv_template),
2831 + .dec = __VECS(tnepres_dec_tv_template)
2832 }
2833 }
2834 }, {
2835 @@ -3272,14 +3211,8 @@ static const struct alg_test_desc alg_te
2836 .test = alg_test_skcipher,
2837 .suite = {
2838 .cipher = {
2839 - .enc = {
2840 - .vecs = tf_enc_tv_template,
2841 - .count = TF_ENC_TEST_VECTORS
2842 - },
2843 - .dec = {
2844 - .vecs = tf_dec_tv_template,
2845 - .count = TF_DEC_TEST_VECTORS
2846 - }
2847 + .enc = __VECS(tf_enc_tv_template),
2848 + .dec = __VECS(tf_dec_tv_template)
2849 }
2850 }
2851 }, {
2852 @@ -3287,14 +3220,8 @@ static const struct alg_test_desc alg_te
2853 .test = alg_test_skcipher,
2854 .suite = {
2855 .cipher = {
2856 - .enc = {
2857 - .vecs = xeta_enc_tv_template,
2858 - .count = XETA_ENC_TEST_VECTORS
2859 - },
2860 - .dec = {
2861 - .vecs = xeta_dec_tv_template,
2862 - .count = XETA_DEC_TEST_VECTORS
2863 - }
2864 + .enc = __VECS(xeta_enc_tv_template),
2865 + .dec = __VECS(xeta_dec_tv_template)
2866 }
2867 }
2868 }, {
2869 @@ -3302,14 +3229,8 @@ static const struct alg_test_desc alg_te
2870 .test = alg_test_skcipher,
2871 .suite = {
2872 .cipher = {
2873 - .enc = {
2874 - .vecs = xtea_enc_tv_template,
2875 - .count = XTEA_ENC_TEST_VECTORS
2876 - },
2877 - .dec = {
2878 - .vecs = xtea_dec_tv_template,
2879 - .count = XTEA_DEC_TEST_VECTORS
2880 - }
2881 + .enc = __VECS(xtea_enc_tv_template),
2882 + .dec = __VECS(xtea_dec_tv_template)
2883 }
2884 }
2885 }, {
2886 @@ -3317,10 +3238,7 @@ static const struct alg_test_desc alg_te
2887 .test = alg_test_kpp,
2888 .fips_allowed = 1,
2889 .suite = {
2890 - .kpp = {
2891 - .vecs = ecdh_tv_template,
2892 - .count = ECDH_TEST_VECTORS
2893 - }
2894 + .kpp = __VECS(ecdh_tv_template)
2895 }
2896 }, {
2897 .alg = "gcm(aes)",
2898 @@ -3328,14 +3246,8 @@ static const struct alg_test_desc alg_te
2899 .fips_allowed = 1,
2900 .suite = {
2901 .aead = {
2902 - .enc = {
2903 - .vecs = aes_gcm_enc_tv_template,
2904 - .count = AES_GCM_ENC_TEST_VECTORS
2905 - },
2906 - .dec = {
2907 - .vecs = aes_gcm_dec_tv_template,
2908 - .count = AES_GCM_DEC_TEST_VECTORS
2909 - }
2910 + .enc = __VECS(aes_gcm_enc_tv_template),
2911 + .dec = __VECS(aes_gcm_dec_tv_template)
2912 }
2913 }
2914 }, {
2915 @@ -3343,136 +3255,94 @@ static const struct alg_test_desc alg_te
2916 .test = alg_test_hash,
2917 .fips_allowed = 1,
2918 .suite = {
2919 - .hash = {
2920 - .vecs = ghash_tv_template,
2921 - .count = GHASH_TEST_VECTORS
2922 - }
2923 + .hash = __VECS(ghash_tv_template)
2924 }
2925 }, {
2926 .alg = "hmac(crc32)",
2927 .test = alg_test_hash,
2928 .suite = {
2929 - .hash = {
2930 - .vecs = bfin_crc_tv_template,
2931 - .count = BFIN_CRC_TEST_VECTORS
2932 - }
2933 + .hash = __VECS(bfin_crc_tv_template)
2934 }
2935 }, {
2936 .alg = "hmac(md5)",
2937 .test = alg_test_hash,
2938 .suite = {
2939 - .hash = {
2940 - .vecs = hmac_md5_tv_template,
2941 - .count = HMAC_MD5_TEST_VECTORS
2942 - }
2943 + .hash = __VECS(hmac_md5_tv_template)
2944 }
2945 }, {
2946 .alg = "hmac(rmd128)",
2947 .test = alg_test_hash,
2948 .suite = {
2949 - .hash = {
2950 - .vecs = hmac_rmd128_tv_template,
2951 - .count = HMAC_RMD128_TEST_VECTORS
2952 - }
2953 + .hash = __VECS(hmac_rmd128_tv_template)
2954 }
2955 }, {
2956 .alg = "hmac(rmd160)",
2957 .test = alg_test_hash,
2958 .suite = {
2959 - .hash = {
2960 - .vecs = hmac_rmd160_tv_template,
2961 - .count = HMAC_RMD160_TEST_VECTORS
2962 - }
2963 + .hash = __VECS(hmac_rmd160_tv_template)
2964 }
2965 }, {
2966 .alg = "hmac(sha1)",
2967 .test = alg_test_hash,
2968 .fips_allowed = 1,
2969 .suite = {
2970 - .hash = {
2971 - .vecs = hmac_sha1_tv_template,
2972 - .count = HMAC_SHA1_TEST_VECTORS
2973 - }
2974 + .hash = __VECS(hmac_sha1_tv_template)
2975 }
2976 }, {
2977 .alg = "hmac(sha224)",
2978 .test = alg_test_hash,
2979 .fips_allowed = 1,
2980 .suite = {
2981 - .hash = {
2982 - .vecs = hmac_sha224_tv_template,
2983 - .count = HMAC_SHA224_TEST_VECTORS
2984 - }
2985 + .hash = __VECS(hmac_sha224_tv_template)
2986 }
2987 }, {
2988 .alg = "hmac(sha256)",
2989 .test = alg_test_hash,
2990 .fips_allowed = 1,
2991 .suite = {
2992 - .hash = {
2993 - .vecs = hmac_sha256_tv_template,
2994 - .count = HMAC_SHA256_TEST_VECTORS
2995 - }
2996 + .hash = __VECS(hmac_sha256_tv_template)
2997 }
2998 }, {
2999 .alg = "hmac(sha3-224)",
3000 .test = alg_test_hash,
3001 .fips_allowed = 1,
3002 .suite = {
3003 - .hash = {
3004 - .vecs = hmac_sha3_224_tv_template,
3005 - .count = HMAC_SHA3_224_TEST_VECTORS
3006 - }
3007 + .hash = __VECS(hmac_sha3_224_tv_template)
3008 }
3009 }, {
3010 .alg = "hmac(sha3-256)",
3011 .test = alg_test_hash,
3012 .fips_allowed = 1,
3013 .suite = {
3014 - .hash = {
3015 - .vecs = hmac_sha3_256_tv_template,
3016 - .count = HMAC_SHA3_256_TEST_VECTORS
3017 - }
3018 + .hash = __VECS(hmac_sha3_256_tv_template)
3019 }
3020 }, {
3021 .alg = "hmac(sha3-384)",
3022 .test = alg_test_hash,
3023 .fips_allowed = 1,
3024 .suite = {
3025 - .hash = {
3026 - .vecs = hmac_sha3_384_tv_template,
3027 - .count = HMAC_SHA3_384_TEST_VECTORS
3028 - }
3029 + .hash = __VECS(hmac_sha3_384_tv_template)
3030 }
3031 }, {
3032 .alg = "hmac(sha3-512)",
3033 .test = alg_test_hash,
3034 .fips_allowed = 1,
3035 .suite = {
3036 - .hash = {
3037 - .vecs = hmac_sha3_512_tv_template,
3038 - .count = HMAC_SHA3_512_TEST_VECTORS
3039 - }
3040 + .hash = __VECS(hmac_sha3_512_tv_template)
3041 }
3042 }, {
3043 .alg = "hmac(sha384)",
3044 .test = alg_test_hash,
3045 .fips_allowed = 1,
3046 .suite = {
3047 - .hash = {
3048 - .vecs = hmac_sha384_tv_template,
3049 - .count = HMAC_SHA384_TEST_VECTORS
3050 - }
3051 + .hash = __VECS(hmac_sha384_tv_template)
3052 }
3053 }, {
3054 .alg = "hmac(sha512)",
3055 .test = alg_test_hash,
3056 .fips_allowed = 1,
3057 .suite = {
3058 - .hash = {
3059 - .vecs = hmac_sha512_tv_template,
3060 - .count = HMAC_SHA512_TEST_VECTORS
3061 - }
3062 + .hash = __VECS(hmac_sha512_tv_template)
3063 }
3064 }, {
3065 .alg = "jitterentropy_rng",
3066 @@ -3484,14 +3354,8 @@ static const struct alg_test_desc alg_te
3067 .fips_allowed = 1,
3068 .suite = {
3069 .cipher = {
3070 - .enc = {
3071 - .vecs = aes_kw_enc_tv_template,
3072 - .count = ARRAY_SIZE(aes_kw_enc_tv_template)
3073 - },
3074 - .dec = {
3075 - .vecs = aes_kw_dec_tv_template,
3076 - .count = ARRAY_SIZE(aes_kw_dec_tv_template)
3077 - }
3078 + .enc = __VECS(aes_kw_enc_tv_template),
3079 + .dec = __VECS(aes_kw_dec_tv_template)
3080 }
3081 }
3082 }, {
3083 @@ -3499,14 +3363,8 @@ static const struct alg_test_desc alg_te
3084 .test = alg_test_skcipher,
3085 .suite = {
3086 .cipher = {
3087 - .enc = {
3088 - .vecs = aes_lrw_enc_tv_template,
3089 - .count = AES_LRW_ENC_TEST_VECTORS
3090 - },
3091 - .dec = {
3092 - .vecs = aes_lrw_dec_tv_template,
3093 - .count = AES_LRW_DEC_TEST_VECTORS
3094 - }
3095 + .enc = __VECS(aes_lrw_enc_tv_template),
3096 + .dec = __VECS(aes_lrw_dec_tv_template)
3097 }
3098 }
3099 }, {
3100 @@ -3514,14 +3372,8 @@ static const struct alg_test_desc alg_te
3101 .test = alg_test_skcipher,
3102 .suite = {
3103 .cipher = {
3104 - .enc = {
3105 - .vecs = camellia_lrw_enc_tv_template,
3106 - .count = CAMELLIA_LRW_ENC_TEST_VECTORS
3107 - },
3108 - .dec = {
3109 - .vecs = camellia_lrw_dec_tv_template,
3110 - .count = CAMELLIA_LRW_DEC_TEST_VECTORS
3111 - }
3112 + .enc = __VECS(camellia_lrw_enc_tv_template),
3113 + .dec = __VECS(camellia_lrw_dec_tv_template)
3114 }
3115 }
3116 }, {
3117 @@ -3529,14 +3381,8 @@ static const struct alg_test_desc alg_te
3118 .test = alg_test_skcipher,
3119 .suite = {
3120 .cipher = {
3121 - .enc = {
3122 - .vecs = cast6_lrw_enc_tv_template,
3123 - .count = CAST6_LRW_ENC_TEST_VECTORS
3124 - },
3125 - .dec = {
3126 - .vecs = cast6_lrw_dec_tv_template,
3127 - .count = CAST6_LRW_DEC_TEST_VECTORS
3128 - }
3129 + .enc = __VECS(cast6_lrw_enc_tv_template),
3130 + .dec = __VECS(cast6_lrw_dec_tv_template)
3131 }
3132 }
3133 }, {
3134 @@ -3544,14 +3390,8 @@ static const struct alg_test_desc alg_te
3135 .test = alg_test_skcipher,
3136 .suite = {
3137 .cipher = {
3138 - .enc = {
3139 - .vecs = serpent_lrw_enc_tv_template,
3140 - .count = SERPENT_LRW_ENC_TEST_VECTORS
3141 - },
3142 - .dec = {
3143 - .vecs = serpent_lrw_dec_tv_template,
3144 - .count = SERPENT_LRW_DEC_TEST_VECTORS
3145 - }
3146 + .enc = __VECS(serpent_lrw_enc_tv_template),
3147 + .dec = __VECS(serpent_lrw_dec_tv_template)
3148 }
3149 }
3150 }, {
3151 @@ -3559,14 +3399,8 @@ static const struct alg_test_desc alg_te
3152 .test = alg_test_skcipher,
3153 .suite = {
3154 .cipher = {
3155 - .enc = {
3156 - .vecs = tf_lrw_enc_tv_template,
3157 - .count = TF_LRW_ENC_TEST_VECTORS
3158 - },
3159 - .dec = {
3160 - .vecs = tf_lrw_dec_tv_template,
3161 - .count = TF_LRW_DEC_TEST_VECTORS
3162 - }
3163 + .enc = __VECS(tf_lrw_enc_tv_template),
3164 + .dec = __VECS(tf_lrw_dec_tv_template)
3165 }
3166 }
3167 }, {
3168 @@ -3575,14 +3409,8 @@ static const struct alg_test_desc alg_te
3169 .fips_allowed = 1,
3170 .suite = {
3171 .comp = {
3172 - .comp = {
3173 - .vecs = lz4_comp_tv_template,
3174 - .count = LZ4_COMP_TEST_VECTORS
3175 - },
3176 - .decomp = {
3177 - .vecs = lz4_decomp_tv_template,
3178 - .count = LZ4_DECOMP_TEST_VECTORS
3179 - }
3180 + .comp = __VECS(lz4_comp_tv_template),
3181 + .decomp = __VECS(lz4_decomp_tv_template)
3182 }
3183 }
3184 }, {
3185 @@ -3591,14 +3419,8 @@ static const struct alg_test_desc alg_te
3186 .fips_allowed = 1,
3187 .suite = {
3188 .comp = {
3189 - .comp = {
3190 - .vecs = lz4hc_comp_tv_template,
3191 - .count = LZ4HC_COMP_TEST_VECTORS
3192 - },
3193 - .decomp = {
3194 - .vecs = lz4hc_decomp_tv_template,
3195 - .count = LZ4HC_DECOMP_TEST_VECTORS
3196 - }
3197 + .comp = __VECS(lz4hc_comp_tv_template),
3198 + .decomp = __VECS(lz4hc_decomp_tv_template)
3199 }
3200 }
3201 }, {
3202 @@ -3607,42 +3429,27 @@ static const struct alg_test_desc alg_te
3203 .fips_allowed = 1,
3204 .suite = {
3205 .comp = {
3206 - .comp = {
3207 - .vecs = lzo_comp_tv_template,
3208 - .count = LZO_COMP_TEST_VECTORS
3209 - },
3210 - .decomp = {
3211 - .vecs = lzo_decomp_tv_template,
3212 - .count = LZO_DECOMP_TEST_VECTORS
3213 - }
3214 + .comp = __VECS(lzo_comp_tv_template),
3215 + .decomp = __VECS(lzo_decomp_tv_template)
3216 }
3217 }
3218 }, {
3219 .alg = "md4",
3220 .test = alg_test_hash,
3221 .suite = {
3222 - .hash = {
3223 - .vecs = md4_tv_template,
3224 - .count = MD4_TEST_VECTORS
3225 - }
3226 + .hash = __VECS(md4_tv_template)
3227 }
3228 }, {
3229 .alg = "md5",
3230 .test = alg_test_hash,
3231 .suite = {
3232 - .hash = {
3233 - .vecs = md5_tv_template,
3234 - .count = MD5_TEST_VECTORS
3235 - }
3236 + .hash = __VECS(md5_tv_template)
3237 }
3238 }, {
3239 .alg = "michael_mic",
3240 .test = alg_test_hash,
3241 .suite = {
3242 - .hash = {
3243 - .vecs = michael_mic_tv_template,
3244 - .count = MICHAEL_MIC_TEST_VECTORS
3245 - }
3246 + .hash = __VECS(michael_mic_tv_template)
3247 }
3248 }, {
3249 .alg = "ofb(aes)",
3250 @@ -3650,14 +3457,8 @@ static const struct alg_test_desc alg_te
3251 .fips_allowed = 1,
3252 .suite = {
3253 .cipher = {
3254 - .enc = {
3255 - .vecs = aes_ofb_enc_tv_template,
3256 - .count = AES_OFB_ENC_TEST_VECTORS
3257 - },
3258 - .dec = {
3259 - .vecs = aes_ofb_dec_tv_template,
3260 - .count = AES_OFB_DEC_TEST_VECTORS
3261 - }
3262 + .enc = __VECS(aes_ofb_enc_tv_template),
3263 + .dec = __VECS(aes_ofb_dec_tv_template)
3264 }
3265 }
3266 }, {
3267 @@ -3665,24 +3466,15 @@ static const struct alg_test_desc alg_te
3268 .test = alg_test_skcipher,
3269 .suite = {
3270 .cipher = {
3271 - .enc = {
3272 - .vecs = fcrypt_pcbc_enc_tv_template,
3273 - .count = FCRYPT_ENC_TEST_VECTORS
3274 - },
3275 - .dec = {
3276 - .vecs = fcrypt_pcbc_dec_tv_template,
3277 - .count = FCRYPT_DEC_TEST_VECTORS
3278 - }
3279 + .enc = __VECS(fcrypt_pcbc_enc_tv_template),
3280 + .dec = __VECS(fcrypt_pcbc_dec_tv_template)
3281 }
3282 }
3283 }, {
3284 .alg = "poly1305",
3285 .test = alg_test_hash,
3286 .suite = {
3287 - .hash = {
3288 - .vecs = poly1305_tv_template,
3289 - .count = POLY1305_TEST_VECTORS
3290 - }
3291 + .hash = __VECS(poly1305_tv_template)
3292 }
3293 }, {
3294 .alg = "rfc3686(ctr(aes))",
3295 @@ -3690,14 +3482,8 @@ static const struct alg_test_desc alg_te
3296 .fips_allowed = 1,
3297 .suite = {
3298 .cipher = {
3299 - .enc = {
3300 - .vecs = aes_ctr_rfc3686_enc_tv_template,
3301 - .count = AES_CTR_3686_ENC_TEST_VECTORS
3302 - },
3303 - .dec = {
3304 - .vecs = aes_ctr_rfc3686_dec_tv_template,
3305 - .count = AES_CTR_3686_DEC_TEST_VECTORS
3306 - }
3307 + .enc = __VECS(aes_ctr_rfc3686_enc_tv_template),
3308 + .dec = __VECS(aes_ctr_rfc3686_dec_tv_template)
3309 }
3310 }
3311 }, {
3312 @@ -3706,14 +3492,8 @@ static const struct alg_test_desc alg_te
3313 .fips_allowed = 1,
3314 .suite = {
3315 .aead = {
3316 - .enc = {
3317 - .vecs = aes_gcm_rfc4106_enc_tv_template,
3318 - .count = AES_GCM_4106_ENC_TEST_VECTORS
3319 - },
3320 - .dec = {
3321 - .vecs = aes_gcm_rfc4106_dec_tv_template,
3322 - .count = AES_GCM_4106_DEC_TEST_VECTORS
3323 - }
3324 + .enc = __VECS(aes_gcm_rfc4106_enc_tv_template),
3325 + .dec = __VECS(aes_gcm_rfc4106_dec_tv_template)
3326 }
3327 }
3328 }, {
3329 @@ -3722,14 +3502,8 @@ static const struct alg_test_desc alg_te
3330 .fips_allowed = 1,
3331 .suite = {
3332 .aead = {
3333 - .enc = {
3334 - .vecs = aes_ccm_rfc4309_enc_tv_template,
3335 - .count = AES_CCM_4309_ENC_TEST_VECTORS
3336 - },
3337 - .dec = {
3338 - .vecs = aes_ccm_rfc4309_dec_tv_template,
3339 - .count = AES_CCM_4309_DEC_TEST_VECTORS
3340 - }
3341 + .enc = __VECS(aes_ccm_rfc4309_enc_tv_template),
3342 + .dec = __VECS(aes_ccm_rfc4309_dec_tv_template)
3343 }
3344 }
3345 }, {
3346 @@ -3737,14 +3511,8 @@ static const struct alg_test_desc alg_te
3347 .test = alg_test_aead,
3348 .suite = {
3349 .aead = {
3350 - .enc = {
3351 - .vecs = aes_gcm_rfc4543_enc_tv_template,
3352 - .count = AES_GCM_4543_ENC_TEST_VECTORS
3353 - },
3354 - .dec = {
3355 - .vecs = aes_gcm_rfc4543_dec_tv_template,
3356 - .count = AES_GCM_4543_DEC_TEST_VECTORS
3357 - },
3358 + .enc = __VECS(aes_gcm_rfc4543_enc_tv_template),
3359 + .dec = __VECS(aes_gcm_rfc4543_dec_tv_template),
3360 }
3361 }
3362 }, {
3363 @@ -3752,14 +3520,8 @@ static const struct alg_test_desc alg_te
3364 .test = alg_test_aead,
3365 .suite = {
3366 .aead = {
3367 - .enc = {
3368 - .vecs = rfc7539_enc_tv_template,
3369 - .count = RFC7539_ENC_TEST_VECTORS
3370 - },
3371 - .dec = {
3372 - .vecs = rfc7539_dec_tv_template,
3373 - .count = RFC7539_DEC_TEST_VECTORS
3374 - },
3375 + .enc = __VECS(rfc7539_enc_tv_template),
3376 + .dec = __VECS(rfc7539_dec_tv_template),
3377 }
3378 }
3379 }, {
3380 @@ -3767,71 +3529,47 @@ static const struct alg_test_desc alg_te
3381 .test = alg_test_aead,
3382 .suite = {
3383 .aead = {
3384 - .enc = {
3385 - .vecs = rfc7539esp_enc_tv_template,
3386 - .count = RFC7539ESP_ENC_TEST_VECTORS
3387 - },
3388 - .dec = {
3389 - .vecs = rfc7539esp_dec_tv_template,
3390 - .count = RFC7539ESP_DEC_TEST_VECTORS
3391 - },
3392 + .enc = __VECS(rfc7539esp_enc_tv_template),
3393 + .dec = __VECS(rfc7539esp_dec_tv_template),
3394 }
3395 }
3396 }, {
3397 .alg = "rmd128",
3398 .test = alg_test_hash,
3399 .suite = {
3400 - .hash = {
3401 - .vecs = rmd128_tv_template,
3402 - .count = RMD128_TEST_VECTORS
3403 - }
3404 + .hash = __VECS(rmd128_tv_template)
3405 }
3406 }, {
3407 .alg = "rmd160",
3408 .test = alg_test_hash,
3409 .suite = {
3410 - .hash = {