2 * Algorithm testing framework and tests.
4 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
5 * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
6 * Copyright (c) 2007 Nokia Siemens Networks
7 * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
9 * Updated RFC4106 AES-GCM testing.
10 * Authors: Aidan O'Mahony (aidan.o.mahony@intel.com)
11 * Adrian Hoban <adrian.hoban@intel.com>
12 * Gabriele Paoloni <gabriele.paoloni@intel.com>
13 * Tadeusz Struk (tadeusz.struk@intel.com)
14 * Copyright (c) 2010, Intel Corporation.
16 * This program is free software; you can redistribute it and/or modify it
17 * under the terms of the GNU General Public License as published by the Free
18 * Software Foundation; either version 2 of the License, or (at your option)
23 #include <crypto/aead.h>
24 #include <crypto/hash.h>
25 #include <crypto/skcipher.h>
26 #include <linux/err.h>
27 #include <linux/fips.h>
28 #include <linux/module.h>
29 #include <linux/scatterlist.h>
30 #include <linux/slab.h>
31 #include <linux/string.h>
32 #include <crypto/rng.h>
33 #include <crypto/drbg.h>
34 #include <crypto/akcipher.h>
38 #ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
41 int alg_test(const char *driver
, const char *alg
, u32 type
, u32 mask
)
51 * Need slab memory for testing (size in number of pages).
56 * Indexes into the xbuf to simulate cross-page access.
68 * Used by test_cipher()
73 struct tcrypt_result
{
74 struct completion completion
;
78 struct aead_test_suite
{
80 struct aead_testvec
*vecs
;
85 struct cipher_test_suite
{
87 struct cipher_testvec
*vecs
;
92 struct comp_test_suite
{
94 struct comp_testvec
*vecs
;
99 struct pcomp_test_suite
{
101 struct pcomp_testvec
*vecs
;
106 struct hash_test_suite
{
107 struct hash_testvec
*vecs
;
111 struct cprng_test_suite
{
112 struct cprng_testvec
*vecs
;
116 struct drbg_test_suite
{
117 struct drbg_testvec
*vecs
;
121 struct akcipher_test_suite
{
122 struct akcipher_testvec
*vecs
;
126 struct alg_test_desc
{
128 int (*test
)(const struct alg_test_desc
*desc
, const char *driver
,
130 int fips_allowed
; /* set if alg is allowed in fips mode */
133 struct aead_test_suite aead
;
134 struct cipher_test_suite cipher
;
135 struct comp_test_suite comp
;
136 struct pcomp_test_suite pcomp
;
137 struct hash_test_suite hash
;
138 struct cprng_test_suite cprng
;
139 struct drbg_test_suite drbg
;
140 struct akcipher_test_suite akcipher
;
144 static unsigned int IDX
[8] = { IDX1
, IDX2
, IDX3
, IDX4
, IDX5
, IDX6
, IDX7
, IDX8
};
146 static void hexdump(unsigned char *buf
, unsigned int len
)
148 print_hex_dump(KERN_CONT
, "", DUMP_PREFIX_OFFSET
,
153 static void tcrypt_complete(struct crypto_async_request
*req
, int err
)
155 struct tcrypt_result
*res
= req
->data
;
157 if (err
== -EINPROGRESS
)
161 complete(&res
->completion
);
164 static int testmgr_alloc_buf(char *buf
[XBUFSIZE
])
168 for (i
= 0; i
< XBUFSIZE
; i
++) {
169 buf
[i
] = (void *)__get_free_page(GFP_KERNEL
);
178 free_page((unsigned long)buf
[i
]);
183 static void testmgr_free_buf(char *buf
[XBUFSIZE
])
187 for (i
= 0; i
< XBUFSIZE
; i
++)
188 free_page((unsigned long)buf
[i
]);
191 static int wait_async_op(struct tcrypt_result
*tr
, int ret
)
193 if (ret
== -EINPROGRESS
|| ret
== -EBUSY
) {
194 wait_for_completion(&tr
->completion
);
195 reinit_completion(&tr
->completion
);
201 static int __test_hash(struct crypto_ahash
*tfm
, struct hash_testvec
*template,
202 unsigned int tcount
, bool use_digest
,
203 const int align_offset
)
205 const char *algo
= crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm
));
206 unsigned int i
, j
, k
, temp
;
207 struct scatterlist sg
[8];
210 struct ahash_request
*req
;
211 struct tcrypt_result tresult
;
213 char *xbuf
[XBUFSIZE
];
216 result
= kmalloc(MAX_DIGEST_SIZE
, GFP_KERNEL
);
219 key
= kmalloc(MAX_KEYLEN
, GFP_KERNEL
);
222 if (testmgr_alloc_buf(xbuf
))
225 init_completion(&tresult
.completion
);
227 req
= ahash_request_alloc(tfm
, GFP_KERNEL
);
229 printk(KERN_ERR
"alg: hash: Failed to allocate request for "
233 ahash_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
234 tcrypt_complete
, &tresult
);
237 for (i
= 0; i
< tcount
; i
++) {
242 if (WARN_ON(align_offset
+ template[i
].psize
> PAGE_SIZE
))
246 memset(result
, 0, MAX_DIGEST_SIZE
);
249 hash_buff
+= align_offset
;
251 memcpy(hash_buff
, template[i
].plaintext
, template[i
].psize
);
252 sg_init_one(&sg
[0], hash_buff
, template[i
].psize
);
254 if (template[i
].ksize
) {
255 crypto_ahash_clear_flags(tfm
, ~0);
256 if (template[i
].ksize
> MAX_KEYLEN
) {
257 pr_err("alg: hash: setkey failed on test %d for %s: key size %d > %d\n",
258 j
, algo
, template[i
].ksize
, MAX_KEYLEN
);
262 memcpy(key
, template[i
].key
, template[i
].ksize
);
263 ret
= crypto_ahash_setkey(tfm
, key
, template[i
].ksize
);
265 printk(KERN_ERR
"alg: hash: setkey failed on "
266 "test %d for %s: ret=%d\n", j
, algo
,
272 ahash_request_set_crypt(req
, sg
, result
, template[i
].psize
);
274 ret
= wait_async_op(&tresult
, crypto_ahash_digest(req
));
276 pr_err("alg: hash: digest failed on test %d "
277 "for %s: ret=%d\n", j
, algo
, -ret
);
281 ret
= wait_async_op(&tresult
, crypto_ahash_init(req
));
283 pr_err("alt: hash: init failed on test %d "
284 "for %s: ret=%d\n", j
, algo
, -ret
);
287 ret
= wait_async_op(&tresult
, crypto_ahash_update(req
));
289 pr_err("alt: hash: update failed on test %d "
290 "for %s: ret=%d\n", j
, algo
, -ret
);
293 ret
= wait_async_op(&tresult
, crypto_ahash_final(req
));
295 pr_err("alt: hash: final failed on test %d "
296 "for %s: ret=%d\n", j
, algo
, -ret
);
301 if (memcmp(result
, template[i
].digest
,
302 crypto_ahash_digestsize(tfm
))) {
303 printk(KERN_ERR
"alg: hash: Test %d failed for %s\n",
305 hexdump(result
, crypto_ahash_digestsize(tfm
));
312 for (i
= 0; i
< tcount
; i
++) {
313 /* alignment tests are only done with continuous buffers */
314 if (align_offset
!= 0)
321 memset(result
, 0, MAX_DIGEST_SIZE
);
324 sg_init_table(sg
, template[i
].np
);
326 for (k
= 0; k
< template[i
].np
; k
++) {
327 if (WARN_ON(offset_in_page(IDX
[k
]) +
328 template[i
].tap
[k
] > PAGE_SIZE
))
331 memcpy(xbuf
[IDX
[k
] >> PAGE_SHIFT
] +
332 offset_in_page(IDX
[k
]),
333 template[i
].plaintext
+ temp
,
336 temp
+= template[i
].tap
[k
];
339 if (template[i
].ksize
) {
340 if (template[i
].ksize
> MAX_KEYLEN
) {
341 pr_err("alg: hash: setkey failed on test %d for %s: key size %d > %d\n",
342 j
, algo
, template[i
].ksize
, MAX_KEYLEN
);
346 crypto_ahash_clear_flags(tfm
, ~0);
347 memcpy(key
, template[i
].key
, template[i
].ksize
);
348 ret
= crypto_ahash_setkey(tfm
, key
, template[i
].ksize
);
351 printk(KERN_ERR
"alg: hash: setkey "
352 "failed on chunking test %d "
353 "for %s: ret=%d\n", j
, algo
, -ret
);
358 ahash_request_set_crypt(req
, sg
, result
, template[i
].psize
);
359 ret
= crypto_ahash_digest(req
);
365 wait_for_completion(&tresult
.completion
);
366 reinit_completion(&tresult
.completion
);
372 printk(KERN_ERR
"alg: hash: digest failed "
373 "on chunking test %d for %s: "
374 "ret=%d\n", j
, algo
, -ret
);
378 if (memcmp(result
, template[i
].digest
,
379 crypto_ahash_digestsize(tfm
))) {
380 printk(KERN_ERR
"alg: hash: Chunking test %d "
381 "failed for %s\n", j
, algo
);
382 hexdump(result
, crypto_ahash_digestsize(tfm
));
391 ahash_request_free(req
);
393 testmgr_free_buf(xbuf
);
400 static int test_hash(struct crypto_ahash
*tfm
, struct hash_testvec
*template,
401 unsigned int tcount
, bool use_digest
)
403 unsigned int alignmask
;
406 ret
= __test_hash(tfm
, template, tcount
, use_digest
, 0);
410 /* test unaligned buffers, check with one byte offset */
411 ret
= __test_hash(tfm
, template, tcount
, use_digest
, 1);
415 alignmask
= crypto_tfm_alg_alignmask(&tfm
->base
);
417 /* Check if alignment mask for tfm is correctly set. */
418 ret
= __test_hash(tfm
, template, tcount
, use_digest
,
427 static int __test_aead(struct crypto_aead
*tfm
, int enc
,
428 struct aead_testvec
*template, unsigned int tcount
,
429 const bool diff_dst
, const int align_offset
)
431 const char *algo
= crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm
));
432 unsigned int i
, j
, k
, n
, temp
;
436 struct aead_request
*req
;
437 struct scatterlist
*sg
;
438 struct scatterlist
*sgout
;
440 struct tcrypt_result result
;
441 unsigned int authsize
, iv_len
;
446 char *xbuf
[XBUFSIZE
];
447 char *xoutbuf
[XBUFSIZE
];
448 char *axbuf
[XBUFSIZE
];
450 iv
= kzalloc(MAX_IVLEN
, GFP_KERNEL
);
453 key
= kmalloc(MAX_KEYLEN
, GFP_KERNEL
);
456 if (testmgr_alloc_buf(xbuf
))
458 if (testmgr_alloc_buf(axbuf
))
460 if (diff_dst
&& testmgr_alloc_buf(xoutbuf
))
463 /* avoid "the frame size is larger than 1024 bytes" compiler warning */
464 sg
= kmalloc(sizeof(*sg
) * 8 * (diff_dst
? 4 : 2), GFP_KERNEL
);
479 init_completion(&result
.completion
);
481 req
= aead_request_alloc(tfm
, GFP_KERNEL
);
483 pr_err("alg: aead%s: Failed to allocate request for %s\n",
488 aead_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
489 tcrypt_complete
, &result
);
491 for (i
= 0, j
= 0; i
< tcount
; i
++) {
497 /* some templates have no input data but they will
501 input
+= align_offset
;
505 if (WARN_ON(align_offset
+ template[i
].ilen
>
506 PAGE_SIZE
|| template[i
].alen
> PAGE_SIZE
))
509 memcpy(input
, template[i
].input
, template[i
].ilen
);
510 memcpy(assoc
, template[i
].assoc
, template[i
].alen
);
511 iv_len
= crypto_aead_ivsize(tfm
);
513 memcpy(iv
, template[i
].iv
, iv_len
);
515 memset(iv
, 0, iv_len
);
517 crypto_aead_clear_flags(tfm
, ~0);
519 crypto_aead_set_flags(tfm
, CRYPTO_TFM_REQ_WEAK_KEY
);
521 if (template[i
].klen
> MAX_KEYLEN
) {
522 pr_err("alg: aead%s: setkey failed on test %d for %s: key size %d > %d\n",
523 d
, j
, algo
, template[i
].klen
,
528 memcpy(key
, template[i
].key
, template[i
].klen
);
530 ret
= crypto_aead_setkey(tfm
, key
, template[i
].klen
);
531 if (!ret
== template[i
].fail
) {
532 pr_err("alg: aead%s: setkey failed on test %d for %s: flags=%x\n",
533 d
, j
, algo
, crypto_aead_get_flags(tfm
));
538 authsize
= abs(template[i
].rlen
- template[i
].ilen
);
539 ret
= crypto_aead_setauthsize(tfm
, authsize
);
541 pr_err("alg: aead%s: Failed to set authsize to %u on test %d for %s\n",
542 d
, authsize
, j
, algo
);
546 k
= !!template[i
].alen
;
547 sg_init_table(sg
, k
+ 1);
548 sg_set_buf(&sg
[0], assoc
, template[i
].alen
);
549 sg_set_buf(&sg
[k
], input
,
550 template[i
].ilen
+ (enc
? authsize
: 0));
554 sg_init_table(sgout
, k
+ 1);
555 sg_set_buf(&sgout
[0], assoc
, template[i
].alen
);
558 output
+= align_offset
;
559 sg_set_buf(&sgout
[k
], output
,
560 template[i
].rlen
+ (enc
? 0 : authsize
));
563 aead_request_set_crypt(req
, sg
, (diff_dst
) ? sgout
: sg
,
564 template[i
].ilen
, iv
);
566 aead_request_set_ad(req
, template[i
].alen
);
568 ret
= enc
? crypto_aead_encrypt(req
) : crypto_aead_decrypt(req
);
572 if (template[i
].novrfy
) {
573 /* verification was supposed to fail */
574 pr_err("alg: aead%s: %s failed on test %d for %s: ret was 0, expected -EBADMSG\n",
576 /* so really, we got a bad message */
583 wait_for_completion(&result
.completion
);
584 reinit_completion(&result
.completion
);
589 if (template[i
].novrfy
)
590 /* verification failure was expected */
594 pr_err("alg: aead%s: %s failed on test %d for %s: ret=%d\n",
595 d
, e
, j
, algo
, -ret
);
600 if (memcmp(q
, template[i
].result
, template[i
].rlen
)) {
601 pr_err("alg: aead%s: Test %d failed on %s for %s\n",
603 hexdump(q
, template[i
].rlen
);
609 for (i
= 0, j
= 0; i
< tcount
; i
++) {
610 /* alignment tests are only done with continuous buffers */
611 if (align_offset
!= 0)
620 memcpy(iv
, template[i
].iv
, MAX_IVLEN
);
622 memset(iv
, 0, MAX_IVLEN
);
624 crypto_aead_clear_flags(tfm
, ~0);
626 crypto_aead_set_flags(tfm
, CRYPTO_TFM_REQ_WEAK_KEY
);
627 if (template[i
].klen
> MAX_KEYLEN
) {
628 pr_err("alg: aead%s: setkey failed on test %d for %s: key size %d > %d\n",
629 d
, j
, algo
, template[i
].klen
, MAX_KEYLEN
);
633 memcpy(key
, template[i
].key
, template[i
].klen
);
635 ret
= crypto_aead_setkey(tfm
, key
, template[i
].klen
);
636 if (!ret
== template[i
].fail
) {
637 pr_err("alg: aead%s: setkey failed on chunk test %d for %s: flags=%x\n",
638 d
, j
, algo
, crypto_aead_get_flags(tfm
));
643 authsize
= abs(template[i
].rlen
- template[i
].ilen
);
646 sg_init_table(sg
, template[i
].anp
+ template[i
].np
);
648 sg_init_table(sgout
, template[i
].anp
+ template[i
].np
);
651 for (k
= 0, temp
= 0; k
< template[i
].anp
; k
++) {
652 if (WARN_ON(offset_in_page(IDX
[k
]) +
653 template[i
].atap
[k
] > PAGE_SIZE
))
656 memcpy(axbuf
[IDX
[k
] >> PAGE_SHIFT
] +
657 offset_in_page(IDX
[k
]),
658 template[i
].assoc
+ temp
,
659 template[i
].atap
[k
]),
660 template[i
].atap
[k
]);
662 sg_set_buf(&sgout
[k
],
663 axbuf
[IDX
[k
] >> PAGE_SHIFT
] +
664 offset_in_page(IDX
[k
]),
665 template[i
].atap
[k
]);
666 temp
+= template[i
].atap
[k
];
669 for (k
= 0, temp
= 0; k
< template[i
].np
; k
++) {
670 if (WARN_ON(offset_in_page(IDX
[k
]) +
671 template[i
].tap
[k
] > PAGE_SIZE
))
674 q
= xbuf
[IDX
[k
] >> PAGE_SHIFT
] + offset_in_page(IDX
[k
]);
675 memcpy(q
, template[i
].input
+ temp
, template[i
].tap
[k
]);
676 sg_set_buf(&sg
[template[i
].anp
+ k
],
677 q
, template[i
].tap
[k
]);
680 q
= xoutbuf
[IDX
[k
] >> PAGE_SHIFT
] +
681 offset_in_page(IDX
[k
]);
683 memset(q
, 0, template[i
].tap
[k
]);
685 sg_set_buf(&sgout
[template[i
].anp
+ k
],
686 q
, template[i
].tap
[k
]);
689 n
= template[i
].tap
[k
];
690 if (k
== template[i
].np
- 1 && enc
)
692 if (offset_in_page(q
) + n
< PAGE_SIZE
)
695 temp
+= template[i
].tap
[k
];
698 ret
= crypto_aead_setauthsize(tfm
, authsize
);
700 pr_err("alg: aead%s: Failed to set authsize to %u on chunk test %d for %s\n",
701 d
, authsize
, j
, algo
);
706 if (WARN_ON(sg
[template[i
].anp
+ k
- 1].offset
+
707 sg
[template[i
].anp
+ k
- 1].length
+
708 authsize
> PAGE_SIZE
)) {
714 sgout
[template[i
].anp
+ k
- 1].length
+=
716 sg
[template[i
].anp
+ k
- 1].length
+= authsize
;
719 aead_request_set_crypt(req
, sg
, (diff_dst
) ? sgout
: sg
,
723 aead_request_set_ad(req
, template[i
].alen
);
725 ret
= enc
? crypto_aead_encrypt(req
) : crypto_aead_decrypt(req
);
729 if (template[i
].novrfy
) {
730 /* verification was supposed to fail */
731 pr_err("alg: aead%s: %s failed on chunk test %d for %s: ret was 0, expected -EBADMSG\n",
733 /* so really, we got a bad message */
740 wait_for_completion(&result
.completion
);
741 reinit_completion(&result
.completion
);
746 if (template[i
].novrfy
)
747 /* verification failure was expected */
751 pr_err("alg: aead%s: %s failed on chunk test %d for %s: ret=%d\n",
752 d
, e
, j
, algo
, -ret
);
757 for (k
= 0, temp
= 0; k
< template[i
].np
; k
++) {
759 q
= xoutbuf
[IDX
[k
] >> PAGE_SHIFT
] +
760 offset_in_page(IDX
[k
]);
762 q
= xbuf
[IDX
[k
] >> PAGE_SHIFT
] +
763 offset_in_page(IDX
[k
]);
765 n
= template[i
].tap
[k
];
766 if (k
== template[i
].np
- 1)
767 n
+= enc
? authsize
: -authsize
;
769 if (memcmp(q
, template[i
].result
+ temp
, n
)) {
770 pr_err("alg: aead%s: Chunk test %d failed on %s at page %u for %s\n",
777 if (k
== template[i
].np
- 1 && !enc
) {
779 memcmp(q
, template[i
].input
+
785 for (n
= 0; offset_in_page(q
+ n
) && q
[n
]; n
++)
789 pr_err("alg: aead%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n",
790 d
, j
, e
, k
, algo
, n
);
795 temp
+= template[i
].tap
[k
];
802 aead_request_free(req
);
806 testmgr_free_buf(xoutbuf
);
808 testmgr_free_buf(axbuf
);
810 testmgr_free_buf(xbuf
);
817 static int test_aead(struct crypto_aead
*tfm
, int enc
,
818 struct aead_testvec
*template, unsigned int tcount
)
820 unsigned int alignmask
;
823 /* test 'dst == src' case */
824 ret
= __test_aead(tfm
, enc
, template, tcount
, false, 0);
828 /* test 'dst != src' case */
829 ret
= __test_aead(tfm
, enc
, template, tcount
, true, 0);
833 /* test unaligned buffers, check with one byte offset */
834 ret
= __test_aead(tfm
, enc
, template, tcount
, true, 1);
838 alignmask
= crypto_tfm_alg_alignmask(&tfm
->base
);
840 /* Check if alignment mask for tfm is correctly set. */
841 ret
= __test_aead(tfm
, enc
, template, tcount
, true,
850 static int test_cipher(struct crypto_cipher
*tfm
, int enc
,
851 struct cipher_testvec
*template, unsigned int tcount
)
853 const char *algo
= crypto_tfm_alg_driver_name(crypto_cipher_tfm(tfm
));
854 unsigned int i
, j
, k
;
858 char *xbuf
[XBUFSIZE
];
861 if (testmgr_alloc_buf(xbuf
))
870 for (i
= 0; i
< tcount
; i
++) {
877 if (WARN_ON(template[i
].ilen
> PAGE_SIZE
))
881 memcpy(data
, template[i
].input
, template[i
].ilen
);
883 crypto_cipher_clear_flags(tfm
, ~0);
885 crypto_cipher_set_flags(tfm
, CRYPTO_TFM_REQ_WEAK_KEY
);
887 ret
= crypto_cipher_setkey(tfm
, template[i
].key
,
889 if (!ret
== template[i
].fail
) {
890 printk(KERN_ERR
"alg: cipher: setkey failed "
891 "on test %d for %s: flags=%x\n", j
,
892 algo
, crypto_cipher_get_flags(tfm
));
897 for (k
= 0; k
< template[i
].ilen
;
898 k
+= crypto_cipher_blocksize(tfm
)) {
900 crypto_cipher_encrypt_one(tfm
, data
+ k
,
903 crypto_cipher_decrypt_one(tfm
, data
+ k
,
908 if (memcmp(q
, template[i
].result
, template[i
].rlen
)) {
909 printk(KERN_ERR
"alg: cipher: Test %d failed "
910 "on %s for %s\n", j
, e
, algo
);
911 hexdump(q
, template[i
].rlen
);
920 testmgr_free_buf(xbuf
);
925 static int __test_skcipher(struct crypto_skcipher
*tfm
, int enc
,
926 struct cipher_testvec
*template, unsigned int tcount
,
927 const bool diff_dst
, const int align_offset
)
930 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm
));
931 unsigned int i
, j
, k
, n
, temp
;
933 struct skcipher_request
*req
;
934 struct scatterlist sg
[8];
935 struct scatterlist sgout
[8];
937 struct tcrypt_result result
;
940 char *xbuf
[XBUFSIZE
];
941 char *xoutbuf
[XBUFSIZE
];
944 if (testmgr_alloc_buf(xbuf
))
947 if (diff_dst
&& testmgr_alloc_buf(xoutbuf
))
960 init_completion(&result
.completion
);
962 req
= skcipher_request_alloc(tfm
, GFP_KERNEL
);
964 pr_err("alg: skcipher%s: Failed to allocate request for %s\n",
969 skcipher_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
970 tcrypt_complete
, &result
);
973 for (i
= 0; i
< tcount
; i
++) {
974 if (template[i
].np
&& !template[i
].also_non_np
)
978 memcpy(iv
, template[i
].iv
, MAX_IVLEN
);
980 memset(iv
, 0, MAX_IVLEN
);
984 if (WARN_ON(align_offset
+ template[i
].ilen
> PAGE_SIZE
))
988 data
+= align_offset
;
989 memcpy(data
, template[i
].input
, template[i
].ilen
);
991 crypto_skcipher_clear_flags(tfm
, ~0);
993 crypto_skcipher_set_flags(tfm
,
994 CRYPTO_TFM_REQ_WEAK_KEY
);
996 ret
= crypto_skcipher_setkey(tfm
, template[i
].key
,
998 if (!ret
== template[i
].fail
) {
999 pr_err("alg: skcipher%s: setkey failed on test %d for %s: flags=%x\n",
1000 d
, j
, algo
, crypto_skcipher_get_flags(tfm
));
1005 sg_init_one(&sg
[0], data
, template[i
].ilen
);
1008 data
+= align_offset
;
1009 sg_init_one(&sgout
[0], data
, template[i
].ilen
);
1012 skcipher_request_set_crypt(req
, sg
, (diff_dst
) ? sgout
: sg
,
1013 template[i
].ilen
, iv
);
1014 ret
= enc
? crypto_skcipher_encrypt(req
) :
1015 crypto_skcipher_decrypt(req
);
1022 wait_for_completion(&result
.completion
);
1023 reinit_completion(&result
.completion
);
1029 pr_err("alg: skcipher%s: %s failed on test %d for %s: ret=%d\n",
1030 d
, e
, j
, algo
, -ret
);
1035 if (memcmp(q
, template[i
].result
, template[i
].rlen
)) {
1036 pr_err("alg: skcipher%s: Test %d failed on %s for %s\n",
1038 hexdump(q
, template[i
].rlen
);
1045 for (i
= 0; i
< tcount
; i
++) {
1046 /* alignment tests are only done with continuous buffers */
1047 if (align_offset
!= 0)
1050 if (!template[i
].np
)
1054 memcpy(iv
, template[i
].iv
, MAX_IVLEN
);
1056 memset(iv
, 0, MAX_IVLEN
);
1059 crypto_skcipher_clear_flags(tfm
, ~0);
1061 crypto_skcipher_set_flags(tfm
,
1062 CRYPTO_TFM_REQ_WEAK_KEY
);
1064 ret
= crypto_skcipher_setkey(tfm
, template[i
].key
,
1066 if (!ret
== template[i
].fail
) {
1067 pr_err("alg: skcipher%s: setkey failed on chunk test %d for %s: flags=%x\n",
1068 d
, j
, algo
, crypto_skcipher_get_flags(tfm
));
1075 sg_init_table(sg
, template[i
].np
);
1077 sg_init_table(sgout
, template[i
].np
);
1078 for (k
= 0; k
< template[i
].np
; k
++) {
1079 if (WARN_ON(offset_in_page(IDX
[k
]) +
1080 template[i
].tap
[k
] > PAGE_SIZE
))
1083 q
= xbuf
[IDX
[k
] >> PAGE_SHIFT
] + offset_in_page(IDX
[k
]);
1085 memcpy(q
, template[i
].input
+ temp
, template[i
].tap
[k
]);
1087 if (offset_in_page(q
) + template[i
].tap
[k
] < PAGE_SIZE
)
1088 q
[template[i
].tap
[k
]] = 0;
1090 sg_set_buf(&sg
[k
], q
, template[i
].tap
[k
]);
1092 q
= xoutbuf
[IDX
[k
] >> PAGE_SHIFT
] +
1093 offset_in_page(IDX
[k
]);
1095 sg_set_buf(&sgout
[k
], q
, template[i
].tap
[k
]);
1097 memset(q
, 0, template[i
].tap
[k
]);
1098 if (offset_in_page(q
) +
1099 template[i
].tap
[k
] < PAGE_SIZE
)
1100 q
[template[i
].tap
[k
]] = 0;
1103 temp
+= template[i
].tap
[k
];
1106 skcipher_request_set_crypt(req
, sg
, (diff_dst
) ? sgout
: sg
,
1107 template[i
].ilen
, iv
);
1109 ret
= enc
? crypto_skcipher_encrypt(req
) :
1110 crypto_skcipher_decrypt(req
);
1117 wait_for_completion(&result
.completion
);
1118 reinit_completion(&result
.completion
);
1124 pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n",
1125 d
, e
, j
, algo
, -ret
);
1131 for (k
= 0; k
< template[i
].np
; k
++) {
1133 q
= xoutbuf
[IDX
[k
] >> PAGE_SHIFT
] +
1134 offset_in_page(IDX
[k
]);
1136 q
= xbuf
[IDX
[k
] >> PAGE_SHIFT
] +
1137 offset_in_page(IDX
[k
]);
1139 if (memcmp(q
, template[i
].result
+ temp
,
1140 template[i
].tap
[k
])) {
1141 pr_err("alg: skcipher%s: Chunk test %d failed on %s at page %u for %s\n",
1143 hexdump(q
, template[i
].tap
[k
]);
1147 q
+= template[i
].tap
[k
];
1148 for (n
= 0; offset_in_page(q
+ n
) && q
[n
]; n
++)
1151 pr_err("alg: skcipher%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n",
1152 d
, j
, e
, k
, algo
, n
);
1156 temp
+= template[i
].tap
[k
];
1163 skcipher_request_free(req
);
1165 testmgr_free_buf(xoutbuf
);
1167 testmgr_free_buf(xbuf
);
1172 static int test_skcipher(struct crypto_skcipher
*tfm
, int enc
,
1173 struct cipher_testvec
*template, unsigned int tcount
)
1175 unsigned int alignmask
;
1178 /* test 'dst == src' case */
1179 ret
= __test_skcipher(tfm
, enc
, template, tcount
, false, 0);
1183 /* test 'dst != src' case */
1184 ret
= __test_skcipher(tfm
, enc
, template, tcount
, true, 0);
1188 /* test unaligned buffers, check with one byte offset */
1189 ret
= __test_skcipher(tfm
, enc
, template, tcount
, true, 1);
1193 alignmask
= crypto_tfm_alg_alignmask(&tfm
->base
);
1195 /* Check if alignment mask for tfm is correctly set. */
1196 ret
= __test_skcipher(tfm
, enc
, template, tcount
, true,
1205 static int test_comp(struct crypto_comp
*tfm
, struct comp_testvec
*ctemplate
,
1206 struct comp_testvec
*dtemplate
, int ctcount
, int dtcount
)
1208 const char *algo
= crypto_tfm_alg_driver_name(crypto_comp_tfm(tfm
));
1210 char result
[COMP_BUF_SIZE
];
1213 for (i
= 0; i
< ctcount
; i
++) {
1215 unsigned int dlen
= COMP_BUF_SIZE
;
1217 memset(result
, 0, sizeof (result
));
1219 ilen
= ctemplate
[i
].inlen
;
1220 ret
= crypto_comp_compress(tfm
, ctemplate
[i
].input
,
1221 ilen
, result
, &dlen
);
1223 printk(KERN_ERR
"alg: comp: compression failed "
1224 "on test %d for %s: ret=%d\n", i
+ 1, algo
,
1229 if (dlen
!= ctemplate
[i
].outlen
) {
1230 printk(KERN_ERR
"alg: comp: Compression test %d "
1231 "failed for %s: output len = %d\n", i
+ 1, algo
,
1237 if (memcmp(result
, ctemplate
[i
].output
, dlen
)) {
1238 printk(KERN_ERR
"alg: comp: Compression test %d "
1239 "failed for %s\n", i
+ 1, algo
);
1240 hexdump(result
, dlen
);
1246 for (i
= 0; i
< dtcount
; i
++) {
1248 unsigned int dlen
= COMP_BUF_SIZE
;
1250 memset(result
, 0, sizeof (result
));
1252 ilen
= dtemplate
[i
].inlen
;
1253 ret
= crypto_comp_decompress(tfm
, dtemplate
[i
].input
,
1254 ilen
, result
, &dlen
);
1256 printk(KERN_ERR
"alg: comp: decompression failed "
1257 "on test %d for %s: ret=%d\n", i
+ 1, algo
,
1262 if (dlen
!= dtemplate
[i
].outlen
) {
1263 printk(KERN_ERR
"alg: comp: Decompression test %d "
1264 "failed for %s: output len = %d\n", i
+ 1, algo
,
1270 if (memcmp(result
, dtemplate
[i
].output
, dlen
)) {
1271 printk(KERN_ERR
"alg: comp: Decompression test %d "
1272 "failed for %s\n", i
+ 1, algo
);
1273 hexdump(result
, dlen
);
1285 static int test_pcomp(struct crypto_pcomp
*tfm
,
1286 struct pcomp_testvec
*ctemplate
,
1287 struct pcomp_testvec
*dtemplate
, int ctcount
,
1290 const char *algo
= crypto_tfm_alg_driver_name(crypto_pcomp_tfm(tfm
));
1292 char result
[COMP_BUF_SIZE
];
1295 for (i
= 0; i
< ctcount
; i
++) {
1296 struct comp_request req
;
1297 unsigned int produced
= 0;
1299 res
= crypto_compress_setup(tfm
, ctemplate
[i
].params
,
1300 ctemplate
[i
].paramsize
);
1302 pr_err("alg: pcomp: compression setup failed on test "
1303 "%d for %s: error=%d\n", i
+ 1, algo
, res
);
1307 res
= crypto_compress_init(tfm
);
1309 pr_err("alg: pcomp: compression init failed on test "
1310 "%d for %s: error=%d\n", i
+ 1, algo
, res
);
1314 memset(result
, 0, sizeof(result
));
1316 req
.next_in
= ctemplate
[i
].input
;
1317 req
.avail_in
= ctemplate
[i
].inlen
/ 2;
1318 req
.next_out
= result
;
1319 req
.avail_out
= ctemplate
[i
].outlen
/ 2;
1321 res
= crypto_compress_update(tfm
, &req
);
1322 if (res
< 0 && (res
!= -EAGAIN
|| req
.avail_in
)) {
1323 pr_err("alg: pcomp: compression update failed on test "
1324 "%d for %s: error=%d\n", i
+ 1, algo
, res
);
1330 /* Add remaining input data */
1331 req
.avail_in
+= (ctemplate
[i
].inlen
+ 1) / 2;
1333 res
= crypto_compress_update(tfm
, &req
);
1334 if (res
< 0 && (res
!= -EAGAIN
|| req
.avail_in
)) {
1335 pr_err("alg: pcomp: compression update failed on test "
1336 "%d for %s: error=%d\n", i
+ 1, algo
, res
);
1342 /* Provide remaining output space */
1343 req
.avail_out
+= COMP_BUF_SIZE
- ctemplate
[i
].outlen
/ 2;
1345 res
= crypto_compress_final(tfm
, &req
);
1347 pr_err("alg: pcomp: compression final failed on test "
1348 "%d for %s: error=%d\n", i
+ 1, algo
, res
);
1353 if (COMP_BUF_SIZE
- req
.avail_out
!= ctemplate
[i
].outlen
) {
1354 pr_err("alg: comp: Compression test %d failed for %s: "
1355 "output len = %d (expected %d)\n", i
+ 1, algo
,
1356 COMP_BUF_SIZE
- req
.avail_out
,
1357 ctemplate
[i
].outlen
);
1361 if (produced
!= ctemplate
[i
].outlen
) {
1362 pr_err("alg: comp: Compression test %d failed for %s: "
1363 "returned len = %u (expected %d)\n", i
+ 1,
1364 algo
, produced
, ctemplate
[i
].outlen
);
1368 if (memcmp(result
, ctemplate
[i
].output
, ctemplate
[i
].outlen
)) {
1369 pr_err("alg: pcomp: Compression test %d failed for "
1370 "%s\n", i
+ 1, algo
);
1371 hexdump(result
, ctemplate
[i
].outlen
);
1376 for (i
= 0; i
< dtcount
; i
++) {
1377 struct comp_request req
;
1378 unsigned int produced
= 0;
1380 res
= crypto_decompress_setup(tfm
, dtemplate
[i
].params
,
1381 dtemplate
[i
].paramsize
);
1383 pr_err("alg: pcomp: decompression setup failed on "
1384 "test %d for %s: error=%d\n", i
+ 1, algo
, res
);
1388 res
= crypto_decompress_init(tfm
);
1390 pr_err("alg: pcomp: decompression init failed on test "
1391 "%d for %s: error=%d\n", i
+ 1, algo
, res
);
1395 memset(result
, 0, sizeof(result
));
1397 req
.next_in
= dtemplate
[i
].input
;
1398 req
.avail_in
= dtemplate
[i
].inlen
/ 2;
1399 req
.next_out
= result
;
1400 req
.avail_out
= dtemplate
[i
].outlen
/ 2;
1402 res
= crypto_decompress_update(tfm
, &req
);
1403 if (res
< 0 && (res
!= -EAGAIN
|| req
.avail_in
)) {
1404 pr_err("alg: pcomp: decompression update failed on "
1405 "test %d for %s: error=%d\n", i
+ 1, algo
, res
);
1411 /* Add remaining input data */
1412 req
.avail_in
+= (dtemplate
[i
].inlen
+ 1) / 2;
1414 res
= crypto_decompress_update(tfm
, &req
);
1415 if (res
< 0 && (res
!= -EAGAIN
|| req
.avail_in
)) {
1416 pr_err("alg: pcomp: decompression update failed on "
1417 "test %d for %s: error=%d\n", i
+ 1, algo
, res
);
1423 /* Provide remaining output space */
1424 req
.avail_out
+= COMP_BUF_SIZE
- dtemplate
[i
].outlen
/ 2;
1426 res
= crypto_decompress_final(tfm
, &req
);
1427 if (res
< 0 && (res
!= -EAGAIN
|| req
.avail_in
)) {
1428 pr_err("alg: pcomp: decompression final failed on "
1429 "test %d for %s: error=%d\n", i
+ 1, algo
, res
);
1435 if (COMP_BUF_SIZE
- req
.avail_out
!= dtemplate
[i
].outlen
) {
1436 pr_err("alg: comp: Decompression test %d failed for "
1437 "%s: output len = %d (expected %d)\n", i
+ 1,
1438 algo
, COMP_BUF_SIZE
- req
.avail_out
,
1439 dtemplate
[i
].outlen
);
1443 if (produced
!= dtemplate
[i
].outlen
) {
1444 pr_err("alg: comp: Decompression test %d failed for "
1445 "%s: returned len = %u (expected %d)\n", i
+ 1,
1446 algo
, produced
, dtemplate
[i
].outlen
);
1450 if (memcmp(result
, dtemplate
[i
].output
, dtemplate
[i
].outlen
)) {
1451 pr_err("alg: pcomp: Decompression test %d failed for "
1452 "%s\n", i
+ 1, algo
);
1453 hexdump(result
, dtemplate
[i
].outlen
);
1462 static int test_cprng(struct crypto_rng
*tfm
, struct cprng_testvec
*template,
1463 unsigned int tcount
)
1465 const char *algo
= crypto_tfm_alg_driver_name(crypto_rng_tfm(tfm
));
1466 int err
= 0, i
, j
, seedsize
;
1470 seedsize
= crypto_rng_seedsize(tfm
);
1472 seed
= kmalloc(seedsize
, GFP_KERNEL
);
1474 printk(KERN_ERR
"alg: cprng: Failed to allocate seed space "
1479 for (i
= 0; i
< tcount
; i
++) {
1480 memset(result
, 0, 32);
1482 memcpy(seed
, template[i
].v
, template[i
].vlen
);
1483 memcpy(seed
+ template[i
].vlen
, template[i
].key
,
1485 memcpy(seed
+ template[i
].vlen
+ template[i
].klen
,
1486 template[i
].dt
, template[i
].dtlen
);
1488 err
= crypto_rng_reset(tfm
, seed
, seedsize
);
1490 printk(KERN_ERR
"alg: cprng: Failed to reset rng "
1495 for (j
= 0; j
< template[i
].loops
; j
++) {
1496 err
= crypto_rng_get_bytes(tfm
, result
,
1499 printk(KERN_ERR
"alg: cprng: Failed to obtain "
1500 "the correct amount of random data for "
1501 "%s (requested %d)\n", algo
,
1507 err
= memcmp(result
, template[i
].result
,
1510 printk(KERN_ERR
"alg: cprng: Test %d failed for %s\n",
1512 hexdump(result
, template[i
].rlen
);
1523 static int alg_test_aead(const struct alg_test_desc
*desc
, const char *driver
,
1526 struct crypto_aead
*tfm
;
1529 tfm
= crypto_alloc_aead(driver
, type
| CRYPTO_ALG_INTERNAL
, mask
);
1531 printk(KERN_ERR
"alg: aead: Failed to load transform for %s: "
1532 "%ld\n", driver
, PTR_ERR(tfm
));
1533 return PTR_ERR(tfm
);
1536 if (desc
->suite
.aead
.enc
.vecs
) {
1537 err
= test_aead(tfm
, ENCRYPT
, desc
->suite
.aead
.enc
.vecs
,
1538 desc
->suite
.aead
.enc
.count
);
1543 if (!err
&& desc
->suite
.aead
.dec
.vecs
)
1544 err
= test_aead(tfm
, DECRYPT
, desc
->suite
.aead
.dec
.vecs
,
1545 desc
->suite
.aead
.dec
.count
);
1548 crypto_free_aead(tfm
);
1552 static int alg_test_cipher(const struct alg_test_desc
*desc
,
1553 const char *driver
, u32 type
, u32 mask
)
1555 struct crypto_cipher
*tfm
;
1558 tfm
= crypto_alloc_cipher(driver
, type
| CRYPTO_ALG_INTERNAL
, mask
);
1560 printk(KERN_ERR
"alg: cipher: Failed to load transform for "
1561 "%s: %ld\n", driver
, PTR_ERR(tfm
));
1562 return PTR_ERR(tfm
);
1565 if (desc
->suite
.cipher
.enc
.vecs
) {
1566 err
= test_cipher(tfm
, ENCRYPT
, desc
->suite
.cipher
.enc
.vecs
,
1567 desc
->suite
.cipher
.enc
.count
);
1572 if (desc
->suite
.cipher
.dec
.vecs
)
1573 err
= test_cipher(tfm
, DECRYPT
, desc
->suite
.cipher
.dec
.vecs
,
1574 desc
->suite
.cipher
.dec
.count
);
1577 crypto_free_cipher(tfm
);
1581 static int alg_test_skcipher(const struct alg_test_desc
*desc
,
1582 const char *driver
, u32 type
, u32 mask
)
1584 struct crypto_skcipher
*tfm
;
1587 tfm
= crypto_alloc_skcipher(driver
, type
| CRYPTO_ALG_INTERNAL
, mask
);
1589 printk(KERN_ERR
"alg: skcipher: Failed to load transform for "
1590 "%s: %ld\n", driver
, PTR_ERR(tfm
));
1591 return PTR_ERR(tfm
);
1594 if (desc
->suite
.cipher
.enc
.vecs
) {
1595 err
= test_skcipher(tfm
, ENCRYPT
, desc
->suite
.cipher
.enc
.vecs
,
1596 desc
->suite
.cipher
.enc
.count
);
1601 if (desc
->suite
.cipher
.dec
.vecs
)
1602 err
= test_skcipher(tfm
, DECRYPT
, desc
->suite
.cipher
.dec
.vecs
,
1603 desc
->suite
.cipher
.dec
.count
);
1606 crypto_free_skcipher(tfm
);
1610 static int alg_test_comp(const struct alg_test_desc
*desc
, const char *driver
,
1613 struct crypto_comp
*tfm
;
1616 tfm
= crypto_alloc_comp(driver
, type
, mask
);
1618 printk(KERN_ERR
"alg: comp: Failed to load transform for %s: "
1619 "%ld\n", driver
, PTR_ERR(tfm
));
1620 return PTR_ERR(tfm
);
1623 err
= test_comp(tfm
, desc
->suite
.comp
.comp
.vecs
,
1624 desc
->suite
.comp
.decomp
.vecs
,
1625 desc
->suite
.comp
.comp
.count
,
1626 desc
->suite
.comp
.decomp
.count
);
1628 crypto_free_comp(tfm
);
1632 static int alg_test_pcomp(const struct alg_test_desc
*desc
, const char *driver
,
1635 struct crypto_pcomp
*tfm
;
1638 tfm
= crypto_alloc_pcomp(driver
, type
, mask
);
1640 pr_err("alg: pcomp: Failed to load transform for %s: %ld\n",
1641 driver
, PTR_ERR(tfm
));
1642 return PTR_ERR(tfm
);
1645 err
= test_pcomp(tfm
, desc
->suite
.pcomp
.comp
.vecs
,
1646 desc
->suite
.pcomp
.decomp
.vecs
,
1647 desc
->suite
.pcomp
.comp
.count
,
1648 desc
->suite
.pcomp
.decomp
.count
);
1650 crypto_free_pcomp(tfm
);
1654 static int alg_test_hash(const struct alg_test_desc
*desc
, const char *driver
,
1657 struct crypto_ahash
*tfm
;
1660 tfm
= crypto_alloc_ahash(driver
, type
| CRYPTO_ALG_INTERNAL
, mask
);
1662 printk(KERN_ERR
"alg: hash: Failed to load transform for %s: "
1663 "%ld\n", driver
, PTR_ERR(tfm
));
1664 return PTR_ERR(tfm
);
1667 err
= test_hash(tfm
, desc
->suite
.hash
.vecs
,
1668 desc
->suite
.hash
.count
, true);
1670 err
= test_hash(tfm
, desc
->suite
.hash
.vecs
,
1671 desc
->suite
.hash
.count
, false);
1673 crypto_free_ahash(tfm
);
1677 static int alg_test_crc32c(const struct alg_test_desc
*desc
,
1678 const char *driver
, u32 type
, u32 mask
)
1680 struct crypto_shash
*tfm
;
1684 err
= alg_test_hash(desc
, driver
, type
, mask
);
1688 tfm
= crypto_alloc_shash(driver
, type
| CRYPTO_ALG_INTERNAL
, mask
);
1690 printk(KERN_ERR
"alg: crc32c: Failed to load transform for %s: "
1691 "%ld\n", driver
, PTR_ERR(tfm
));
1697 SHASH_DESC_ON_STACK(shash
, tfm
);
1698 u32
*ctx
= (u32
*)shash_desc_ctx(shash
);
1703 *ctx
= le32_to_cpu(420553207);
1704 err
= crypto_shash_final(shash
, (u8
*)&val
);
1706 printk(KERN_ERR
"alg: crc32c: Operation failed for "
1707 "%s: %d\n", driver
, err
);
1711 if (val
!= ~420553207) {
1712 printk(KERN_ERR
"alg: crc32c: Test failed for %s: "
1713 "%d\n", driver
, val
);
1718 crypto_free_shash(tfm
);
1724 static int alg_test_cprng(const struct alg_test_desc
*desc
, const char *driver
,
1727 struct crypto_rng
*rng
;
1730 rng
= crypto_alloc_rng(driver
, type
| CRYPTO_ALG_INTERNAL
, mask
);
1732 printk(KERN_ERR
"alg: cprng: Failed to load transform for %s: "
1733 "%ld\n", driver
, PTR_ERR(rng
));
1734 return PTR_ERR(rng
);
1737 err
= test_cprng(rng
, desc
->suite
.cprng
.vecs
, desc
->suite
.cprng
.count
);
1739 crypto_free_rng(rng
);
1745 static int drbg_cavs_test(struct drbg_testvec
*test
, int pr
,
1746 const char *driver
, u32 type
, u32 mask
)
1749 struct crypto_rng
*drng
;
1750 struct drbg_test_data test_data
;
1751 struct drbg_string addtl
, pers
, testentropy
;
1752 unsigned char *buf
= kzalloc(test
->expectedlen
, GFP_KERNEL
);
1757 drng
= crypto_alloc_rng(driver
, type
| CRYPTO_ALG_INTERNAL
, mask
);
1759 printk(KERN_ERR
"alg: drbg: could not allocate DRNG handle for "
1765 test_data
.testentropy
= &testentropy
;
1766 drbg_string_fill(&testentropy
, test
->entropy
, test
->entropylen
);
1767 drbg_string_fill(&pers
, test
->pers
, test
->perslen
);
1768 ret
= crypto_drbg_reset_test(drng
, &pers
, &test_data
);
1770 printk(KERN_ERR
"alg: drbg: Failed to reset rng\n");
1774 drbg_string_fill(&addtl
, test
->addtla
, test
->addtllen
);
1776 drbg_string_fill(&testentropy
, test
->entpra
, test
->entprlen
);
1777 ret
= crypto_drbg_get_bytes_addtl_test(drng
,
1778 buf
, test
->expectedlen
, &addtl
, &test_data
);
1780 ret
= crypto_drbg_get_bytes_addtl(drng
,
1781 buf
, test
->expectedlen
, &addtl
);
1784 printk(KERN_ERR
"alg: drbg: could not obtain random data for "
1785 "driver %s\n", driver
);
1789 drbg_string_fill(&addtl
, test
->addtlb
, test
->addtllen
);
1791 drbg_string_fill(&testentropy
, test
->entprb
, test
->entprlen
);
1792 ret
= crypto_drbg_get_bytes_addtl_test(drng
,
1793 buf
, test
->expectedlen
, &addtl
, &test_data
);
1795 ret
= crypto_drbg_get_bytes_addtl(drng
,
1796 buf
, test
->expectedlen
, &addtl
);
1799 printk(KERN_ERR
"alg: drbg: could not obtain random data for "
1800 "driver %s\n", driver
);
1804 ret
= memcmp(test
->expected
, buf
, test
->expectedlen
);
1807 crypto_free_rng(drng
);
1813 static int alg_test_drbg(const struct alg_test_desc
*desc
, const char *driver
,
1819 struct drbg_testvec
*template = desc
->suite
.drbg
.vecs
;
1820 unsigned int tcount
= desc
->suite
.drbg
.count
;
1822 if (0 == memcmp(driver
, "drbg_pr_", 8))
1825 for (i
= 0; i
< tcount
; i
++) {
1826 err
= drbg_cavs_test(&template[i
], pr
, driver
, type
, mask
);
1828 printk(KERN_ERR
"alg: drbg: Test %d failed for %s\n",
1838 static int do_test_rsa(struct crypto_akcipher
*tfm
,
1839 struct akcipher_testvec
*vecs
)
1841 struct akcipher_request
*req
;
1842 void *outbuf_enc
= NULL
;
1843 void *outbuf_dec
= NULL
;
1844 struct tcrypt_result result
;
1845 unsigned int out_len_max
, out_len
= 0;
1848 req
= akcipher_request_alloc(tfm
, GFP_KERNEL
);
1852 init_completion(&result
.completion
);
1853 err
= crypto_akcipher_setkey(tfm
, vecs
->key
, vecs
->key_len
);
1857 akcipher_request_set_crypt(req
, vecs
->m
, outbuf_enc
, vecs
->m_size
,
1859 /* expect this to fail, and update the required buf len */
1860 crypto_akcipher_encrypt(req
);
1861 out_len
= req
->dst_len
;
1867 out_len_max
= out_len
;
1869 outbuf_enc
= kzalloc(out_len_max
, GFP_KERNEL
);
1873 akcipher_request_set_crypt(req
, vecs
->m
, outbuf_enc
, vecs
->m_size
,
1875 akcipher_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
1876 tcrypt_complete
, &result
);
1878 /* Run RSA encrypt - c = m^e mod n;*/
1879 err
= wait_async_op(&result
, crypto_akcipher_encrypt(req
));
1881 pr_err("alg: rsa: encrypt test failed. err %d\n", err
);
1884 if (out_len
!= vecs
->c_size
) {
1885 pr_err("alg: rsa: encrypt test failed. Invalid output len\n");
1889 /* verify that encrypted message is equal to expected */
1890 if (memcmp(vecs
->c
, outbuf_enc
, vecs
->c_size
)) {
1891 pr_err("alg: rsa: encrypt test failed. Invalid output\n");
1895 /* Don't invoke decrypt for vectors with public key */
1896 if (vecs
->public_key_vec
) {
1900 outbuf_dec
= kzalloc(out_len_max
, GFP_KERNEL
);
1905 init_completion(&result
.completion
);
1906 akcipher_request_set_crypt(req
, outbuf_enc
, outbuf_dec
, vecs
->c_size
,
1909 /* Run RSA decrypt - m = c^d mod n;*/
1910 err
= wait_async_op(&result
, crypto_akcipher_decrypt(req
));
1912 pr_err("alg: rsa: decrypt test failed. err %d\n", err
);
1915 out_len
= req
->dst_len
;
1916 if (out_len
!= vecs
->m_size
) {
1917 pr_err("alg: rsa: decrypt test failed. Invalid output len\n");
1921 /* verify that decrypted message is equal to the original msg */
1922 if (memcmp(vecs
->m
, outbuf_dec
, vecs
->m_size
)) {
1923 pr_err("alg: rsa: decrypt test failed. Invalid output\n");
1930 akcipher_request_free(req
);
1934 static int test_rsa(struct crypto_akcipher
*tfm
, struct akcipher_testvec
*vecs
,
1935 unsigned int tcount
)
1939 for (i
= 0; i
< tcount
; i
++) {
1940 ret
= do_test_rsa(tfm
, vecs
++);
1942 pr_err("alg: rsa: test failed on vector %d, err=%d\n",
1950 static int test_akcipher(struct crypto_akcipher
*tfm
, const char *alg
,
1951 struct akcipher_testvec
*vecs
, unsigned int tcount
)
1953 if (strncmp(alg
, "rsa", 3) == 0)
1954 return test_rsa(tfm
, vecs
, tcount
);
1959 static int alg_test_akcipher(const struct alg_test_desc
*desc
,
1960 const char *driver
, u32 type
, u32 mask
)
1962 struct crypto_akcipher
*tfm
;
1965 tfm
= crypto_alloc_akcipher(driver
, type
| CRYPTO_ALG_INTERNAL
, mask
);
1967 pr_err("alg: akcipher: Failed to load tfm for %s: %ld\n",
1968 driver
, PTR_ERR(tfm
));
1969 return PTR_ERR(tfm
);
1971 if (desc
->suite
.akcipher
.vecs
)
1972 err
= test_akcipher(tfm
, desc
->alg
, desc
->suite
.akcipher
.vecs
,
1973 desc
->suite
.akcipher
.count
);
1975 crypto_free_akcipher(tfm
);
1979 static int alg_test_null(const struct alg_test_desc
*desc
,
1980 const char *driver
, u32 type
, u32 mask
)
1985 /* Please keep this list sorted by algorithm name. */
1986 static const struct alg_test_desc alg_test_descs
[] = {
1988 .alg
= "__cbc-cast5-avx",
1989 .test
= alg_test_null
,
1991 .alg
= "__cbc-cast6-avx",
1992 .test
= alg_test_null
,
1994 .alg
= "__cbc-serpent-avx",
1995 .test
= alg_test_null
,
1997 .alg
= "__cbc-serpent-avx2",
1998 .test
= alg_test_null
,
2000 .alg
= "__cbc-serpent-sse2",
2001 .test
= alg_test_null
,
2003 .alg
= "__cbc-twofish-avx",
2004 .test
= alg_test_null
,
2006 .alg
= "__driver-cbc-aes-aesni",
2007 .test
= alg_test_null
,
2010 .alg
= "__driver-cbc-camellia-aesni",
2011 .test
= alg_test_null
,
2013 .alg
= "__driver-cbc-camellia-aesni-avx2",
2014 .test
= alg_test_null
,
2016 .alg
= "__driver-cbc-cast5-avx",
2017 .test
= alg_test_null
,
2019 .alg
= "__driver-cbc-cast6-avx",
2020 .test
= alg_test_null
,
2022 .alg
= "__driver-cbc-serpent-avx",
2023 .test
= alg_test_null
,
2025 .alg
= "__driver-cbc-serpent-avx2",
2026 .test
= alg_test_null
,
2028 .alg
= "__driver-cbc-serpent-sse2",
2029 .test
= alg_test_null
,
2031 .alg
= "__driver-cbc-twofish-avx",
2032 .test
= alg_test_null
,
2034 .alg
= "__driver-ecb-aes-aesni",
2035 .test
= alg_test_null
,
2038 .alg
= "__driver-ecb-camellia-aesni",
2039 .test
= alg_test_null
,
2041 .alg
= "__driver-ecb-camellia-aesni-avx2",
2042 .test
= alg_test_null
,
2044 .alg
= "__driver-ecb-cast5-avx",
2045 .test
= alg_test_null
,
2047 .alg
= "__driver-ecb-cast6-avx",
2048 .test
= alg_test_null
,
2050 .alg
= "__driver-ecb-serpent-avx",
2051 .test
= alg_test_null
,
2053 .alg
= "__driver-ecb-serpent-avx2",
2054 .test
= alg_test_null
,
2056 .alg
= "__driver-ecb-serpent-sse2",
2057 .test
= alg_test_null
,
2059 .alg
= "__driver-ecb-twofish-avx",
2060 .test
= alg_test_null
,
2062 .alg
= "__driver-gcm-aes-aesni",
2063 .test
= alg_test_null
,
2066 .alg
= "__ghash-pclmulqdqni",
2067 .test
= alg_test_null
,
2070 .alg
= "ansi_cprng",
2071 .test
= alg_test_cprng
,
2075 .vecs
= ansi_cprng_aes_tv_template
,
2076 .count
= ANSI_CPRNG_AES_TEST_VECTORS
2080 .alg
= "authenc(hmac(md5),ecb(cipher_null))",
2081 .test
= alg_test_aead
,
2086 .vecs
= hmac_md5_ecb_cipher_null_enc_tv_template
,
2087 .count
= HMAC_MD5_ECB_CIPHER_NULL_ENC_TEST_VECTORS
2090 .vecs
= hmac_md5_ecb_cipher_null_dec_tv_template
,
2091 .count
= HMAC_MD5_ECB_CIPHER_NULL_DEC_TEST_VECTORS
2096 .alg
= "authenc(hmac(sha1),cbc(aes))",
2097 .test
= alg_test_aead
,
2103 hmac_sha1_aes_cbc_enc_tv_temp
,
2105 HMAC_SHA1_AES_CBC_ENC_TEST_VEC
2110 .alg
= "authenc(hmac(sha1),cbc(des))",
2111 .test
= alg_test_aead
,
2117 hmac_sha1_des_cbc_enc_tv_temp
,
2119 HMAC_SHA1_DES_CBC_ENC_TEST_VEC
2124 .alg
= "authenc(hmac(sha1),cbc(des3_ede))",
2125 .test
= alg_test_aead
,
2131 hmac_sha1_des3_ede_cbc_enc_tv_temp
,
2133 HMAC_SHA1_DES3_EDE_CBC_ENC_TEST_VEC
2138 .alg
= "authenc(hmac(sha1),ecb(cipher_null))",
2139 .test
= alg_test_aead
,
2145 hmac_sha1_ecb_cipher_null_enc_tv_temp
,
2147 HMAC_SHA1_ECB_CIPHER_NULL_ENC_TEST_VEC
2151 hmac_sha1_ecb_cipher_null_dec_tv_temp
,
2153 HMAC_SHA1_ECB_CIPHER_NULL_DEC_TEST_VEC
2158 .alg
= "authenc(hmac(sha224),cbc(des))",
2159 .test
= alg_test_aead
,
2165 hmac_sha224_des_cbc_enc_tv_temp
,
2167 HMAC_SHA224_DES_CBC_ENC_TEST_VEC
2172 .alg
= "authenc(hmac(sha224),cbc(des3_ede))",
2173 .test
= alg_test_aead
,
2179 hmac_sha224_des3_ede_cbc_enc_tv_temp
,
2181 HMAC_SHA224_DES3_EDE_CBC_ENC_TEST_VEC
2186 .alg
= "authenc(hmac(sha256),cbc(aes))",
2187 .test
= alg_test_aead
,
2193 hmac_sha256_aes_cbc_enc_tv_temp
,
2195 HMAC_SHA256_AES_CBC_ENC_TEST_VEC
2200 .alg
= "authenc(hmac(sha256),cbc(des))",
2201 .test
= alg_test_aead
,
2207 hmac_sha256_des_cbc_enc_tv_temp
,
2209 HMAC_SHA256_DES_CBC_ENC_TEST_VEC
2214 .alg
= "authenc(hmac(sha256),cbc(des3_ede))",
2215 .test
= alg_test_aead
,
2221 hmac_sha256_des3_ede_cbc_enc_tv_temp
,
2223 HMAC_SHA256_DES3_EDE_CBC_ENC_TEST_VEC
2228 .alg
= "authenc(hmac(sha384),cbc(des))",
2229 .test
= alg_test_aead
,
2235 hmac_sha384_des_cbc_enc_tv_temp
,
2237 HMAC_SHA384_DES_CBC_ENC_TEST_VEC
2242 .alg
= "authenc(hmac(sha384),cbc(des3_ede))",
2243 .test
= alg_test_aead
,
2249 hmac_sha384_des3_ede_cbc_enc_tv_temp
,
2251 HMAC_SHA384_DES3_EDE_CBC_ENC_TEST_VEC
2256 .alg
= "authenc(hmac(sha512),cbc(aes))",
2257 .test
= alg_test_aead
,
2263 hmac_sha512_aes_cbc_enc_tv_temp
,
2265 HMAC_SHA512_AES_CBC_ENC_TEST_VEC
2270 .alg
= "authenc(hmac(sha512),cbc(des))",
2271 .test
= alg_test_aead
,
2277 hmac_sha512_des_cbc_enc_tv_temp
,
2279 HMAC_SHA512_DES_CBC_ENC_TEST_VEC
2284 .alg
= "authenc(hmac(sha512),cbc(des3_ede))",
2285 .test
= alg_test_aead
,
2291 hmac_sha512_des3_ede_cbc_enc_tv_temp
,
2293 HMAC_SHA512_DES3_EDE_CBC_ENC_TEST_VEC
2299 .test
= alg_test_skcipher
,
2304 .vecs
= aes_cbc_enc_tv_template
,
2305 .count
= AES_CBC_ENC_TEST_VECTORS
2308 .vecs
= aes_cbc_dec_tv_template
,
2309 .count
= AES_CBC_DEC_TEST_VECTORS
2314 .alg
= "cbc(anubis)",
2315 .test
= alg_test_skcipher
,
2319 .vecs
= anubis_cbc_enc_tv_template
,
2320 .count
= ANUBIS_CBC_ENC_TEST_VECTORS
2323 .vecs
= anubis_cbc_dec_tv_template
,
2324 .count
= ANUBIS_CBC_DEC_TEST_VECTORS
2329 .alg
= "cbc(blowfish)",
2330 .test
= alg_test_skcipher
,
2334 .vecs
= bf_cbc_enc_tv_template
,
2335 .count
= BF_CBC_ENC_TEST_VECTORS
2338 .vecs
= bf_cbc_dec_tv_template
,
2339 .count
= BF_CBC_DEC_TEST_VECTORS
2344 .alg
= "cbc(camellia)",
2345 .test
= alg_test_skcipher
,
2349 .vecs
= camellia_cbc_enc_tv_template
,
2350 .count
= CAMELLIA_CBC_ENC_TEST_VECTORS
2353 .vecs
= camellia_cbc_dec_tv_template
,
2354 .count
= CAMELLIA_CBC_DEC_TEST_VECTORS
2359 .alg
= "cbc(cast5)",
2360 .test
= alg_test_skcipher
,
2364 .vecs
= cast5_cbc_enc_tv_template
,
2365 .count
= CAST5_CBC_ENC_TEST_VECTORS
2368 .vecs
= cast5_cbc_dec_tv_template
,
2369 .count
= CAST5_CBC_DEC_TEST_VECTORS
2374 .alg
= "cbc(cast6)",
2375 .test
= alg_test_skcipher
,
2379 .vecs
= cast6_cbc_enc_tv_template
,
2380 .count
= CAST6_CBC_ENC_TEST_VECTORS
2383 .vecs
= cast6_cbc_dec_tv_template
,
2384 .count
= CAST6_CBC_DEC_TEST_VECTORS
2390 .test
= alg_test_skcipher
,
2394 .vecs
= des_cbc_enc_tv_template
,
2395 .count
= DES_CBC_ENC_TEST_VECTORS
2398 .vecs
= des_cbc_dec_tv_template
,
2399 .count
= DES_CBC_DEC_TEST_VECTORS
2404 .alg
= "cbc(des3_ede)",
2405 .test
= alg_test_skcipher
,
2410 .vecs
= des3_ede_cbc_enc_tv_template
,
2411 .count
= DES3_EDE_CBC_ENC_TEST_VECTORS
2414 .vecs
= des3_ede_cbc_dec_tv_template
,
2415 .count
= DES3_EDE_CBC_DEC_TEST_VECTORS
2420 .alg
= "cbc(serpent)",
2421 .test
= alg_test_skcipher
,
2425 .vecs
= serpent_cbc_enc_tv_template
,
2426 .count
= SERPENT_CBC_ENC_TEST_VECTORS
2429 .vecs
= serpent_cbc_dec_tv_template
,
2430 .count
= SERPENT_CBC_DEC_TEST_VECTORS
2435 .alg
= "cbc(twofish)",
2436 .test
= alg_test_skcipher
,
2440 .vecs
= tf_cbc_enc_tv_template
,
2441 .count
= TF_CBC_ENC_TEST_VECTORS
2444 .vecs
= tf_cbc_dec_tv_template
,
2445 .count
= TF_CBC_DEC_TEST_VECTORS
2451 .test
= alg_test_aead
,
2456 .vecs
= aes_ccm_enc_tv_template
,
2457 .count
= AES_CCM_ENC_TEST_VECTORS
2460 .vecs
= aes_ccm_dec_tv_template
,
2461 .count
= AES_CCM_DEC_TEST_VECTORS
2467 .test
= alg_test_skcipher
,
2471 .vecs
= chacha20_enc_tv_template
,
2472 .count
= CHACHA20_ENC_TEST_VECTORS
2475 .vecs
= chacha20_enc_tv_template
,
2476 .count
= CHACHA20_ENC_TEST_VECTORS
2483 .test
= alg_test_hash
,
2486 .vecs
= aes_cmac128_tv_template
,
2487 .count
= CMAC_AES_TEST_VECTORS
2491 .alg
= "cmac(des3_ede)",
2493 .test
= alg_test_hash
,
2496 .vecs
= des3_ede_cmac64_tv_template
,
2497 .count
= CMAC_DES3_EDE_TEST_VECTORS
2501 .alg
= "compress_null",
2502 .test
= alg_test_null
,
2505 .test
= alg_test_hash
,
2508 .vecs
= crc32_tv_template
,
2509 .count
= CRC32_TEST_VECTORS
2514 .test
= alg_test_crc32c
,
2518 .vecs
= crc32c_tv_template
,
2519 .count
= CRC32C_TEST_VECTORS
2524 .test
= alg_test_hash
,
2528 .vecs
= crct10dif_tv_template
,
2529 .count
= CRCT10DIF_TEST_VECTORS
2533 .alg
= "cryptd(__driver-cbc-aes-aesni)",
2534 .test
= alg_test_null
,
2537 .alg
= "cryptd(__driver-cbc-camellia-aesni)",
2538 .test
= alg_test_null
,
2540 .alg
= "cryptd(__driver-cbc-camellia-aesni-avx2)",
2541 .test
= alg_test_null
,
2543 .alg
= "cryptd(__driver-cbc-serpent-avx2)",
2544 .test
= alg_test_null
,
2546 .alg
= "cryptd(__driver-ecb-aes-aesni)",
2547 .test
= alg_test_null
,
2550 .alg
= "cryptd(__driver-ecb-camellia-aesni)",
2551 .test
= alg_test_null
,
2553 .alg
= "cryptd(__driver-ecb-camellia-aesni-avx2)",
2554 .test
= alg_test_null
,
2556 .alg
= "cryptd(__driver-ecb-cast5-avx)",
2557 .test
= alg_test_null
,
2559 .alg
= "cryptd(__driver-ecb-cast6-avx)",
2560 .test
= alg_test_null
,
2562 .alg
= "cryptd(__driver-ecb-serpent-avx)",
2563 .test
= alg_test_null
,
2565 .alg
= "cryptd(__driver-ecb-serpent-avx2)",
2566 .test
= alg_test_null
,
2568 .alg
= "cryptd(__driver-ecb-serpent-sse2)",
2569 .test
= alg_test_null
,
2571 .alg
= "cryptd(__driver-ecb-twofish-avx)",
2572 .test
= alg_test_null
,
2574 .alg
= "cryptd(__driver-gcm-aes-aesni)",
2575 .test
= alg_test_null
,
2578 .alg
= "cryptd(__ghash-pclmulqdqni)",
2579 .test
= alg_test_null
,
2583 .test
= alg_test_skcipher
,
2588 .vecs
= aes_ctr_enc_tv_template
,
2589 .count
= AES_CTR_ENC_TEST_VECTORS
2592 .vecs
= aes_ctr_dec_tv_template
,
2593 .count
= AES_CTR_DEC_TEST_VECTORS
2598 .alg
= "ctr(blowfish)",
2599 .test
= alg_test_skcipher
,
2603 .vecs
= bf_ctr_enc_tv_template
,
2604 .count
= BF_CTR_ENC_TEST_VECTORS
2607 .vecs
= bf_ctr_dec_tv_template
,
2608 .count
= BF_CTR_DEC_TEST_VECTORS
2613 .alg
= "ctr(camellia)",
2614 .test
= alg_test_skcipher
,
2618 .vecs
= camellia_ctr_enc_tv_template
,
2619 .count
= CAMELLIA_CTR_ENC_TEST_VECTORS
2622 .vecs
= camellia_ctr_dec_tv_template
,
2623 .count
= CAMELLIA_CTR_DEC_TEST_VECTORS
2628 .alg
= "ctr(cast5)",
2629 .test
= alg_test_skcipher
,
2633 .vecs
= cast5_ctr_enc_tv_template
,
2634 .count
= CAST5_CTR_ENC_TEST_VECTORS
2637 .vecs
= cast5_ctr_dec_tv_template
,
2638 .count
= CAST5_CTR_DEC_TEST_VECTORS
2643 .alg
= "ctr(cast6)",
2644 .test
= alg_test_skcipher
,
2648 .vecs
= cast6_ctr_enc_tv_template
,
2649 .count
= CAST6_CTR_ENC_TEST_VECTORS
2652 .vecs
= cast6_ctr_dec_tv_template
,
2653 .count
= CAST6_CTR_DEC_TEST_VECTORS
2659 .test
= alg_test_skcipher
,
2663 .vecs
= des_ctr_enc_tv_template
,
2664 .count
= DES_CTR_ENC_TEST_VECTORS
2667 .vecs
= des_ctr_dec_tv_template
,
2668 .count
= DES_CTR_DEC_TEST_VECTORS
2673 .alg
= "ctr(des3_ede)",
2674 .test
= alg_test_skcipher
,
2678 .vecs
= des3_ede_ctr_enc_tv_template
,
2679 .count
= DES3_EDE_CTR_ENC_TEST_VECTORS
2682 .vecs
= des3_ede_ctr_dec_tv_template
,
2683 .count
= DES3_EDE_CTR_DEC_TEST_VECTORS
2688 .alg
= "ctr(serpent)",
2689 .test
= alg_test_skcipher
,
2693 .vecs
= serpent_ctr_enc_tv_template
,
2694 .count
= SERPENT_CTR_ENC_TEST_VECTORS
2697 .vecs
= serpent_ctr_dec_tv_template
,
2698 .count
= SERPENT_CTR_DEC_TEST_VECTORS
2703 .alg
= "ctr(twofish)",
2704 .test
= alg_test_skcipher
,
2708 .vecs
= tf_ctr_enc_tv_template
,
2709 .count
= TF_CTR_ENC_TEST_VECTORS
2712 .vecs
= tf_ctr_dec_tv_template
,
2713 .count
= TF_CTR_DEC_TEST_VECTORS
2718 .alg
= "cts(cbc(aes))",
2719 .test
= alg_test_skcipher
,
2723 .vecs
= cts_mode_enc_tv_template
,
2724 .count
= CTS_MODE_ENC_TEST_VECTORS
2727 .vecs
= cts_mode_dec_tv_template
,
2728 .count
= CTS_MODE_DEC_TEST_VECTORS
2734 .test
= alg_test_comp
,
2739 .vecs
= deflate_comp_tv_template
,
2740 .count
= DEFLATE_COMP_TEST_VECTORS
2743 .vecs
= deflate_decomp_tv_template
,
2744 .count
= DEFLATE_DECOMP_TEST_VECTORS
2749 .alg
= "digest_null",
2750 .test
= alg_test_null
,
2752 .alg
= "drbg_nopr_ctr_aes128",
2753 .test
= alg_test_drbg
,
2757 .vecs
= drbg_nopr_ctr_aes128_tv_template
,
2758 .count
= ARRAY_SIZE(drbg_nopr_ctr_aes128_tv_template
)
2762 .alg
= "drbg_nopr_ctr_aes192",
2763 .test
= alg_test_drbg
,
2767 .vecs
= drbg_nopr_ctr_aes192_tv_template
,
2768 .count
= ARRAY_SIZE(drbg_nopr_ctr_aes192_tv_template
)
2772 .alg
= "drbg_nopr_ctr_aes256",
2773 .test
= alg_test_drbg
,
2777 .vecs
= drbg_nopr_ctr_aes256_tv_template
,
2778 .count
= ARRAY_SIZE(drbg_nopr_ctr_aes256_tv_template
)
2783 * There is no need to specifically test the DRBG with every
2784 * backend cipher -- covered by drbg_nopr_hmac_sha256 test
2786 .alg
= "drbg_nopr_hmac_sha1",
2788 .test
= alg_test_null
,
2790 .alg
= "drbg_nopr_hmac_sha256",
2791 .test
= alg_test_drbg
,
2795 .vecs
= drbg_nopr_hmac_sha256_tv_template
,
2797 ARRAY_SIZE(drbg_nopr_hmac_sha256_tv_template
)
2801 /* covered by drbg_nopr_hmac_sha256 test */
2802 .alg
= "drbg_nopr_hmac_sha384",
2804 .test
= alg_test_null
,
2806 .alg
= "drbg_nopr_hmac_sha512",
2807 .test
= alg_test_null
,
2810 .alg
= "drbg_nopr_sha1",
2812 .test
= alg_test_null
,
2814 .alg
= "drbg_nopr_sha256",
2815 .test
= alg_test_drbg
,
2819 .vecs
= drbg_nopr_sha256_tv_template
,
2820 .count
= ARRAY_SIZE(drbg_nopr_sha256_tv_template
)
2824 /* covered by drbg_nopr_sha256 test */
2825 .alg
= "drbg_nopr_sha384",
2827 .test
= alg_test_null
,
2829 .alg
= "drbg_nopr_sha512",
2831 .test
= alg_test_null
,
2833 .alg
= "drbg_pr_ctr_aes128",
2834 .test
= alg_test_drbg
,
2838 .vecs
= drbg_pr_ctr_aes128_tv_template
,
2839 .count
= ARRAY_SIZE(drbg_pr_ctr_aes128_tv_template
)
2843 /* covered by drbg_pr_ctr_aes128 test */
2844 .alg
= "drbg_pr_ctr_aes192",
2846 .test
= alg_test_null
,
2848 .alg
= "drbg_pr_ctr_aes256",
2850 .test
= alg_test_null
,
2852 .alg
= "drbg_pr_hmac_sha1",
2854 .test
= alg_test_null
,
2856 .alg
= "drbg_pr_hmac_sha256",
2857 .test
= alg_test_drbg
,
2861 .vecs
= drbg_pr_hmac_sha256_tv_template
,
2862 .count
= ARRAY_SIZE(drbg_pr_hmac_sha256_tv_template
)
2866 /* covered by drbg_pr_hmac_sha256 test */
2867 .alg
= "drbg_pr_hmac_sha384",
2869 .test
= alg_test_null
,
2871 .alg
= "drbg_pr_hmac_sha512",
2872 .test
= alg_test_null
,
2875 .alg
= "drbg_pr_sha1",
2877 .test
= alg_test_null
,
2879 .alg
= "drbg_pr_sha256",
2880 .test
= alg_test_drbg
,
2884 .vecs
= drbg_pr_sha256_tv_template
,
2885 .count
= ARRAY_SIZE(drbg_pr_sha256_tv_template
)
2889 /* covered by drbg_pr_sha256 test */
2890 .alg
= "drbg_pr_sha384",
2892 .test
= alg_test_null
,
2894 .alg
= "drbg_pr_sha512",
2896 .test
= alg_test_null
,
2898 .alg
= "ecb(__aes-aesni)",
2899 .test
= alg_test_null
,
2903 .test
= alg_test_skcipher
,
2908 .vecs
= aes_enc_tv_template
,
2909 .count
= AES_ENC_TEST_VECTORS
2912 .vecs
= aes_dec_tv_template
,
2913 .count
= AES_DEC_TEST_VECTORS
2918 .alg
= "ecb(anubis)",
2919 .test
= alg_test_skcipher
,
2923 .vecs
= anubis_enc_tv_template
,
2924 .count
= ANUBIS_ENC_TEST_VECTORS
2927 .vecs
= anubis_dec_tv_template
,
2928 .count
= ANUBIS_DEC_TEST_VECTORS
2934 .test
= alg_test_skcipher
,
2938 .vecs
= arc4_enc_tv_template
,
2939 .count
= ARC4_ENC_TEST_VECTORS
2942 .vecs
= arc4_dec_tv_template
,
2943 .count
= ARC4_DEC_TEST_VECTORS
2948 .alg
= "ecb(blowfish)",
2949 .test
= alg_test_skcipher
,
2953 .vecs
= bf_enc_tv_template
,
2954 .count
= BF_ENC_TEST_VECTORS
2957 .vecs
= bf_dec_tv_template
,
2958 .count
= BF_DEC_TEST_VECTORS
2963 .alg
= "ecb(camellia)",
2964 .test
= alg_test_skcipher
,
2968 .vecs
= camellia_enc_tv_template
,
2969 .count
= CAMELLIA_ENC_TEST_VECTORS
2972 .vecs
= camellia_dec_tv_template
,
2973 .count
= CAMELLIA_DEC_TEST_VECTORS
2978 .alg
= "ecb(cast5)",
2979 .test
= alg_test_skcipher
,
2983 .vecs
= cast5_enc_tv_template
,
2984 .count
= CAST5_ENC_TEST_VECTORS
2987 .vecs
= cast5_dec_tv_template
,
2988 .count
= CAST5_DEC_TEST_VECTORS
2993 .alg
= "ecb(cast6)",
2994 .test
= alg_test_skcipher
,
2998 .vecs
= cast6_enc_tv_template
,
2999 .count
= CAST6_ENC_TEST_VECTORS
3002 .vecs
= cast6_dec_tv_template
,
3003 .count
= CAST6_DEC_TEST_VECTORS
3008 .alg
= "ecb(cipher_null)",
3009 .test
= alg_test_null
,
3012 .test
= alg_test_skcipher
,
3017 .vecs
= des_enc_tv_template
,
3018 .count
= DES_ENC_TEST_VECTORS
3021 .vecs
= des_dec_tv_template
,
3022 .count
= DES_DEC_TEST_VECTORS
3027 .alg
= "ecb(des3_ede)",
3028 .test
= alg_test_skcipher
,
3033 .vecs
= des3_ede_enc_tv_template
,
3034 .count
= DES3_EDE_ENC_TEST_VECTORS
3037 .vecs
= des3_ede_dec_tv_template
,
3038 .count
= DES3_EDE_DEC_TEST_VECTORS
3043 .alg
= "ecb(fcrypt)",
3044 .test
= alg_test_skcipher
,
3048 .vecs
= fcrypt_pcbc_enc_tv_template
,
3052 .vecs
= fcrypt_pcbc_dec_tv_template
,
3058 .alg
= "ecb(khazad)",
3059 .test
= alg_test_skcipher
,
3063 .vecs
= khazad_enc_tv_template
,
3064 .count
= KHAZAD_ENC_TEST_VECTORS
3067 .vecs
= khazad_dec_tv_template
,
3068 .count
= KHAZAD_DEC_TEST_VECTORS
3074 .test
= alg_test_skcipher
,
3078 .vecs
= seed_enc_tv_template
,
3079 .count
= SEED_ENC_TEST_VECTORS
3082 .vecs
= seed_dec_tv_template
,
3083 .count
= SEED_DEC_TEST_VECTORS
3088 .alg
= "ecb(serpent)",
3089 .test
= alg_test_skcipher
,
3093 .vecs
= serpent_enc_tv_template
,
3094 .count
= SERPENT_ENC_TEST_VECTORS
3097 .vecs
= serpent_dec_tv_template
,
3098 .count
= SERPENT_DEC_TEST_VECTORS
3104 .test
= alg_test_skcipher
,
3108 .vecs
= tea_enc_tv_template
,
3109 .count
= TEA_ENC_TEST_VECTORS
3112 .vecs
= tea_dec_tv_template
,
3113 .count
= TEA_DEC_TEST_VECTORS
3118 .alg
= "ecb(tnepres)",
3119 .test
= alg_test_skcipher
,
3123 .vecs
= tnepres_enc_tv_template
,
3124 .count
= TNEPRES_ENC_TEST_VECTORS
3127 .vecs
= tnepres_dec_tv_template
,
3128 .count
= TNEPRES_DEC_TEST_VECTORS
3133 .alg
= "ecb(twofish)",
3134 .test
= alg_test_skcipher
,
3138 .vecs
= tf_enc_tv_template
,
3139 .count
= TF_ENC_TEST_VECTORS
3142 .vecs
= tf_dec_tv_template
,
3143 .count
= TF_DEC_TEST_VECTORS
3149 .test
= alg_test_skcipher
,
3153 .vecs
= xeta_enc_tv_template
,
3154 .count
= XETA_ENC_TEST_VECTORS
3157 .vecs
= xeta_dec_tv_template
,
3158 .count
= XETA_DEC_TEST_VECTORS
3164 .test
= alg_test_skcipher
,
3168 .vecs
= xtea_enc_tv_template
,
3169 .count
= XTEA_ENC_TEST_VECTORS
3172 .vecs
= xtea_dec_tv_template
,
3173 .count
= XTEA_DEC_TEST_VECTORS
3179 .test
= alg_test_aead
,
3184 .vecs
= aes_gcm_enc_tv_template
,
3185 .count
= AES_GCM_ENC_TEST_VECTORS
3188 .vecs
= aes_gcm_dec_tv_template
,
3189 .count
= AES_GCM_DEC_TEST_VECTORS
3195 .test
= alg_test_hash
,
3199 .vecs
= ghash_tv_template
,
3200 .count
= GHASH_TEST_VECTORS
3204 .alg
= "hmac(crc32)",
3205 .test
= alg_test_hash
,
3208 .vecs
= bfin_crc_tv_template
,
3209 .count
= BFIN_CRC_TEST_VECTORS
3214 .test
= alg_test_hash
,
3217 .vecs
= hmac_md5_tv_template
,
3218 .count
= HMAC_MD5_TEST_VECTORS
3222 .alg
= "hmac(rmd128)",
3223 .test
= alg_test_hash
,
3226 .vecs
= hmac_rmd128_tv_template
,
3227 .count
= HMAC_RMD128_TEST_VECTORS
3231 .alg
= "hmac(rmd160)",
3232 .test
= alg_test_hash
,
3235 .vecs
= hmac_rmd160_tv_template
,
3236 .count
= HMAC_RMD160_TEST_VECTORS
3240 .alg
= "hmac(sha1)",
3241 .test
= alg_test_hash
,
3245 .vecs
= hmac_sha1_tv_template
,
3246 .count
= HMAC_SHA1_TEST_VECTORS
3250 .alg
= "hmac(sha224)",
3251 .test
= alg_test_hash
,
3255 .vecs
= hmac_sha224_tv_template
,
3256 .count
= HMAC_SHA224_TEST_VECTORS
3260 .alg
= "hmac(sha256)",
3261 .test
= alg_test_hash
,
3265 .vecs
= hmac_sha256_tv_template
,
3266 .count
= HMAC_SHA256_TEST_VECTORS
3270 .alg
= "hmac(sha384)",
3271 .test
= alg_test_hash
,
3275 .vecs
= hmac_sha384_tv_template
,
3276 .count
= HMAC_SHA384_TEST_VECTORS
3280 .alg
= "hmac(sha512)",
3281 .test
= alg_test_hash
,
3285 .vecs
= hmac_sha512_tv_template
,
3286 .count
= HMAC_SHA512_TEST_VECTORS
3290 .alg
= "jitterentropy_rng",
3292 .test
= alg_test_null
,
3295 .test
= alg_test_skcipher
,
3299 .vecs
= aes_lrw_enc_tv_template
,
3300 .count
= AES_LRW_ENC_TEST_VECTORS
3303 .vecs
= aes_lrw_dec_tv_template
,
3304 .count
= AES_LRW_DEC_TEST_VECTORS
3309 .alg
= "lrw(camellia)",
3310 .test
= alg_test_skcipher
,
3314 .vecs
= camellia_lrw_enc_tv_template
,
3315 .count
= CAMELLIA_LRW_ENC_TEST_VECTORS
3318 .vecs
= camellia_lrw_dec_tv_template
,
3319 .count
= CAMELLIA_LRW_DEC_TEST_VECTORS
3324 .alg
= "lrw(cast6)",
3325 .test
= alg_test_skcipher
,
3329 .vecs
= cast6_lrw_enc_tv_template
,
3330 .count
= CAST6_LRW_ENC_TEST_VECTORS
3333 .vecs
= cast6_lrw_dec_tv_template
,
3334 .count
= CAST6_LRW_DEC_TEST_VECTORS
3339 .alg
= "lrw(serpent)",
3340 .test
= alg_test_skcipher
,
3344 .vecs
= serpent_lrw_enc_tv_template
,
3345 .count
= SERPENT_LRW_ENC_TEST_VECTORS
3348 .vecs
= serpent_lrw_dec_tv_template
,
3349 .count
= SERPENT_LRW_DEC_TEST_VECTORS
3354 .alg
= "lrw(twofish)",
3355 .test
= alg_test_skcipher
,
3359 .vecs
= tf_lrw_enc_tv_template
,
3360 .count
= TF_LRW_ENC_TEST_VECTORS
3363 .vecs
= tf_lrw_dec_tv_template
,
3364 .count
= TF_LRW_DEC_TEST_VECTORS
3370 .test
= alg_test_comp
,
3375 .vecs
= lz4_comp_tv_template
,
3376 .count
= LZ4_COMP_TEST_VECTORS
3379 .vecs
= lz4_decomp_tv_template
,
3380 .count
= LZ4_DECOMP_TEST_VECTORS
3386 .test
= alg_test_comp
,
3391 .vecs
= lz4hc_comp_tv_template
,
3392 .count
= LZ4HC_COMP_TEST_VECTORS
3395 .vecs
= lz4hc_decomp_tv_template
,
3396 .count
= LZ4HC_DECOMP_TEST_VECTORS
3402 .test
= alg_test_comp
,
3407 .vecs
= lzo_comp_tv_template
,
3408 .count
= LZO_COMP_TEST_VECTORS
3411 .vecs
= lzo_decomp_tv_template
,
3412 .count
= LZO_DECOMP_TEST_VECTORS
3418 .test
= alg_test_hash
,
3421 .vecs
= md4_tv_template
,
3422 .count
= MD4_TEST_VECTORS
3427 .test
= alg_test_hash
,
3430 .vecs
= md5_tv_template
,
3431 .count
= MD5_TEST_VECTORS
3435 .alg
= "michael_mic",
3436 .test
= alg_test_hash
,
3439 .vecs
= michael_mic_tv_template
,
3440 .count
= MICHAEL_MIC_TEST_VECTORS
3445 .test
= alg_test_skcipher
,
3450 .vecs
= aes_ofb_enc_tv_template
,
3451 .count
= AES_OFB_ENC_TEST_VECTORS
3454 .vecs
= aes_ofb_dec_tv_template
,
3455 .count
= AES_OFB_DEC_TEST_VECTORS
3460 .alg
= "pcbc(fcrypt)",
3461 .test
= alg_test_skcipher
,
3465 .vecs
= fcrypt_pcbc_enc_tv_template
,
3466 .count
= FCRYPT_ENC_TEST_VECTORS
3469 .vecs
= fcrypt_pcbc_dec_tv_template
,
3470 .count
= FCRYPT_DEC_TEST_VECTORS
3476 .test
= alg_test_hash
,
3479 .vecs
= poly1305_tv_template
,
3480 .count
= POLY1305_TEST_VECTORS
3484 .alg
= "rfc3686(ctr(aes))",
3485 .test
= alg_test_skcipher
,
3490 .vecs
= aes_ctr_rfc3686_enc_tv_template
,
3491 .count
= AES_CTR_3686_ENC_TEST_VECTORS
3494 .vecs
= aes_ctr_rfc3686_dec_tv_template
,
3495 .count
= AES_CTR_3686_DEC_TEST_VECTORS
3500 .alg
= "rfc4106(gcm(aes))",
3501 .test
= alg_test_aead
,
3506 .vecs
= aes_gcm_rfc4106_enc_tv_template
,
3507 .count
= AES_GCM_4106_ENC_TEST_VECTORS
3510 .vecs
= aes_gcm_rfc4106_dec_tv_template
,
3511 .count
= AES_GCM_4106_DEC_TEST_VECTORS
3516 .alg
= "rfc4309(ccm(aes))",
3517 .test
= alg_test_aead
,
3522 .vecs
= aes_ccm_rfc4309_enc_tv_template
,
3523 .count
= AES_CCM_4309_ENC_TEST_VECTORS
3526 .vecs
= aes_ccm_rfc4309_dec_tv_template
,
3527 .count
= AES_CCM_4309_DEC_TEST_VECTORS
3532 .alg
= "rfc4543(gcm(aes))",
3533 .test
= alg_test_aead
,
3537 .vecs
= aes_gcm_rfc4543_enc_tv_template
,
3538 .count
= AES_GCM_4543_ENC_TEST_VECTORS
3541 .vecs
= aes_gcm_rfc4543_dec_tv_template
,
3542 .count
= AES_GCM_4543_DEC_TEST_VECTORS
3547 .alg
= "rfc7539(chacha20,poly1305)",
3548 .test
= alg_test_aead
,
3552 .vecs
= rfc7539_enc_tv_template
,
3553 .count
= RFC7539_ENC_TEST_VECTORS
3556 .vecs
= rfc7539_dec_tv_template
,
3557 .count
= RFC7539_DEC_TEST_VECTORS
3562 .alg
= "rfc7539esp(chacha20,poly1305)",
3563 .test
= alg_test_aead
,
3567 .vecs
= rfc7539esp_enc_tv_template
,
3568 .count
= RFC7539ESP_ENC_TEST_VECTORS
3571 .vecs
= rfc7539esp_dec_tv_template
,
3572 .count
= RFC7539ESP_DEC_TEST_VECTORS
3578 .test
= alg_test_hash
,
3581 .vecs
= rmd128_tv_template
,
3582 .count
= RMD128_TEST_VECTORS
3587 .test
= alg_test_hash
,
3590 .vecs
= rmd160_tv_template
,
3591 .count
= RMD160_TEST_VECTORS
3596 .test
= alg_test_hash
,
3599 .vecs
= rmd256_tv_template
,
3600 .count
= RMD256_TEST_VECTORS
3605 .test
= alg_test_hash
,
3608 .vecs
= rmd320_tv_template
,
3609 .count
= RMD320_TEST_VECTORS
3614 .test
= alg_test_akcipher
,
3618 .vecs
= rsa_tv_template
,
3619 .count
= RSA_TEST_VECTORS
3624 .test
= alg_test_skcipher
,
3628 .vecs
= salsa20_stream_enc_tv_template
,
3629 .count
= SALSA20_STREAM_ENC_TEST_VECTORS
3635 .test
= alg_test_hash
,
3639 .vecs
= sha1_tv_template
,
3640 .count
= SHA1_TEST_VECTORS
3645 .test
= alg_test_hash
,
3649 .vecs
= sha224_tv_template
,
3650 .count
= SHA224_TEST_VECTORS
3655 .test
= alg_test_hash
,
3659 .vecs
= sha256_tv_template
,
3660 .count
= SHA256_TEST_VECTORS
3665 .test
= alg_test_hash
,
3669 .vecs
= sha384_tv_template
,
3670 .count
= SHA384_TEST_VECTORS
3675 .test
= alg_test_hash
,
3679 .vecs
= sha512_tv_template
,
3680 .count
= SHA512_TEST_VECTORS
3685 .test
= alg_test_hash
,
3688 .vecs
= tgr128_tv_template
,
3689 .count
= TGR128_TEST_VECTORS
3694 .test
= alg_test_hash
,
3697 .vecs
= tgr160_tv_template
,
3698 .count
= TGR160_TEST_VECTORS
3703 .test
= alg_test_hash
,
3706 .vecs
= tgr192_tv_template
,
3707 .count
= TGR192_TEST_VECTORS
3712 .test
= alg_test_hash
,
3715 .vecs
= aes_vmac128_tv_template
,
3716 .count
= VMAC_AES_TEST_VECTORS
3721 .test
= alg_test_hash
,
3724 .vecs
= wp256_tv_template
,
3725 .count
= WP256_TEST_VECTORS
3730 .test
= alg_test_hash
,
3733 .vecs
= wp384_tv_template
,
3734 .count
= WP384_TEST_VECTORS
3739 .test
= alg_test_hash
,
3742 .vecs
= wp512_tv_template
,
3743 .count
= WP512_TEST_VECTORS
3748 .test
= alg_test_hash
,
3751 .vecs
= aes_xcbc128_tv_template
,
3752 .count
= XCBC_AES_TEST_VECTORS
3757 .test
= alg_test_skcipher
,
3762 .vecs
= aes_xts_enc_tv_template
,
3763 .count
= AES_XTS_ENC_TEST_VECTORS
3766 .vecs
= aes_xts_dec_tv_template
,
3767 .count
= AES_XTS_DEC_TEST_VECTORS
3772 .alg
= "xts(camellia)",
3773 .test
= alg_test_skcipher
,
3777 .vecs
= camellia_xts_enc_tv_template
,
3778 .count
= CAMELLIA_XTS_ENC_TEST_VECTORS
3781 .vecs
= camellia_xts_dec_tv_template
,
3782 .count
= CAMELLIA_XTS_DEC_TEST_VECTORS
3787 .alg
= "xts(cast6)",
3788 .test
= alg_test_skcipher
,
3792 .vecs
= cast6_xts_enc_tv_template
,
3793 .count
= CAST6_XTS_ENC_TEST_VECTORS
3796 .vecs
= cast6_xts_dec_tv_template
,
3797 .count
= CAST6_XTS_DEC_TEST_VECTORS
3802 .alg
= "xts(serpent)",
3803 .test
= alg_test_skcipher
,
3807 .vecs
= serpent_xts_enc_tv_template
,
3808 .count
= SERPENT_XTS_ENC_TEST_VECTORS
3811 .vecs
= serpent_xts_dec_tv_template
,
3812 .count
= SERPENT_XTS_DEC_TEST_VECTORS
3817 .alg
= "xts(twofish)",
3818 .test
= alg_test_skcipher
,
3822 .vecs
= tf_xts_enc_tv_template
,
3823 .count
= TF_XTS_ENC_TEST_VECTORS
3826 .vecs
= tf_xts_dec_tv_template
,
3827 .count
= TF_XTS_DEC_TEST_VECTORS
3833 .test
= alg_test_pcomp
,
3838 .vecs
= zlib_comp_tv_template
,
3839 .count
= ZLIB_COMP_TEST_VECTORS
3842 .vecs
= zlib_decomp_tv_template
,
3843 .count
= ZLIB_DECOMP_TEST_VECTORS
3850 static bool alg_test_descs_checked
;
3852 static void alg_test_descs_check_order(void)
3856 /* only check once */
3857 if (alg_test_descs_checked
)
3860 alg_test_descs_checked
= true;
3862 for (i
= 1; i
< ARRAY_SIZE(alg_test_descs
); i
++) {
3863 int diff
= strcmp(alg_test_descs
[i
- 1].alg
,
3864 alg_test_descs
[i
].alg
);
3866 if (WARN_ON(diff
> 0)) {
3867 pr_warn("testmgr: alg_test_descs entries in wrong order: '%s' before '%s'\n",
3868 alg_test_descs
[i
- 1].alg
,
3869 alg_test_descs
[i
].alg
);
3872 if (WARN_ON(diff
== 0)) {
3873 pr_warn("testmgr: duplicate alg_test_descs entry: '%s'\n",
3874 alg_test_descs
[i
].alg
);
3879 static int alg_find_test(const char *alg
)
3882 int end
= ARRAY_SIZE(alg_test_descs
);
3884 while (start
< end
) {
3885 int i
= (start
+ end
) / 2;
3886 int diff
= strcmp(alg_test_descs
[i
].alg
, alg
);
3904 int alg_test(const char *driver
, const char *alg
, u32 type
, u32 mask
)
3910 alg_test_descs_check_order();
3912 if ((type
& CRYPTO_ALG_TYPE_MASK
) == CRYPTO_ALG_TYPE_CIPHER
) {
3913 char nalg
[CRYPTO_MAX_ALG_NAME
];
3915 if (snprintf(nalg
, sizeof(nalg
), "ecb(%s)", alg
) >=
3917 return -ENAMETOOLONG
;
3919 i
= alg_find_test(nalg
);
3923 if (fips_enabled
&& !alg_test_descs
[i
].fips_allowed
)
3926 rc
= alg_test_cipher(alg_test_descs
+ i
, driver
, type
, mask
);
3930 i
= alg_find_test(alg
);
3931 j
= alg_find_test(driver
);
3935 if (fips_enabled
&& ((i
>= 0 && !alg_test_descs
[i
].fips_allowed
) ||
3936 (j
>= 0 && !alg_test_descs
[j
].fips_allowed
)))
3941 rc
|= alg_test_descs
[i
].test(alg_test_descs
+ i
, driver
,
3943 if (j
>= 0 && j
!= i
)
3944 rc
|= alg_test_descs
[j
].test(alg_test_descs
+ j
, driver
,
3948 if (fips_enabled
&& rc
)
3949 panic("%s: %s alg self test failed in fips mode!\n", driver
, alg
);
3951 if (fips_enabled
&& !rc
)
3952 pr_info("alg: self-tests for %s (%s) passed\n", driver
, alg
);
3957 printk(KERN_INFO
"alg: No test for %s (%s)\n", alg
, driver
);
3963 #endif /* CONFIG_CRYPTO_MANAGER_DISABLE_TESTS */
3965 EXPORT_SYMBOL_GPL(alg_test
);