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/hash.h>
24 #include <linux/err.h>
25 #include <linux/module.h>
26 #include <linux/scatterlist.h>
27 #include <linux/slab.h>
28 #include <linux/string.h>
29 #include <crypto/rng.h>
33 #ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
36 int alg_test(const char *driver
, const char *alg
, u32 type
, u32 mask
)
46 * Need slab memory for testing (size in number of pages).
51 * Indexes into the xbuf to simulate cross-page access.
63 * Used by test_cipher()
68 struct tcrypt_result
{
69 struct completion completion
;
73 struct aead_test_suite
{
75 struct aead_testvec
*vecs
;
80 struct cipher_test_suite
{
82 struct cipher_testvec
*vecs
;
87 struct comp_test_suite
{
89 struct comp_testvec
*vecs
;
94 struct pcomp_test_suite
{
96 struct pcomp_testvec
*vecs
;
101 struct hash_test_suite
{
102 struct hash_testvec
*vecs
;
106 struct cprng_test_suite
{
107 struct cprng_testvec
*vecs
;
111 struct alg_test_desc
{
113 int (*test
)(const struct alg_test_desc
*desc
, const char *driver
,
115 int fips_allowed
; /* set if alg is allowed in fips mode */
118 struct aead_test_suite aead
;
119 struct cipher_test_suite cipher
;
120 struct comp_test_suite comp
;
121 struct pcomp_test_suite pcomp
;
122 struct hash_test_suite hash
;
123 struct cprng_test_suite cprng
;
127 static unsigned int IDX
[8] = { IDX1
, IDX2
, IDX3
, IDX4
, IDX5
, IDX6
, IDX7
, IDX8
};
129 static void hexdump(unsigned char *buf
, unsigned int len
)
131 print_hex_dump(KERN_CONT
, "", DUMP_PREFIX_OFFSET
,
136 static void tcrypt_complete(struct crypto_async_request
*req
, int err
)
138 struct tcrypt_result
*res
= req
->data
;
140 if (err
== -EINPROGRESS
)
144 complete(&res
->completion
);
147 static int testmgr_alloc_buf(char *buf
[XBUFSIZE
])
151 for (i
= 0; i
< XBUFSIZE
; i
++) {
152 buf
[i
] = (void *)__get_free_page(GFP_KERNEL
);
161 free_page((unsigned long)buf
[i
]);
166 static void testmgr_free_buf(char *buf
[XBUFSIZE
])
170 for (i
= 0; i
< XBUFSIZE
; i
++)
171 free_page((unsigned long)buf
[i
]);
174 static int do_one_async_hash_op(struct ahash_request
*req
,
175 struct tcrypt_result
*tr
,
178 if (ret
== -EINPROGRESS
|| ret
== -EBUSY
) {
179 ret
= wait_for_completion_interruptible(&tr
->completion
);
182 INIT_COMPLETION(tr
->completion
);
187 static int __test_hash(struct crypto_ahash
*tfm
, struct hash_testvec
*template,
188 unsigned int tcount
, bool use_digest
,
189 const int align_offset
)
191 const char *algo
= crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm
));
192 unsigned int i
, j
, k
, temp
;
193 struct scatterlist sg
[8];
195 struct ahash_request
*req
;
196 struct tcrypt_result tresult
;
198 char *xbuf
[XBUFSIZE
];
201 if (testmgr_alloc_buf(xbuf
))
204 init_completion(&tresult
.completion
);
206 req
= ahash_request_alloc(tfm
, GFP_KERNEL
);
208 printk(KERN_ERR
"alg: hash: Failed to allocate request for "
212 ahash_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
213 tcrypt_complete
, &tresult
);
216 for (i
= 0; i
< tcount
; i
++) {
221 if (WARN_ON(align_offset
+ template[i
].psize
> PAGE_SIZE
))
225 memset(result
, 0, 64);
228 hash_buff
+= align_offset
;
230 memcpy(hash_buff
, template[i
].plaintext
, template[i
].psize
);
231 sg_init_one(&sg
[0], hash_buff
, template[i
].psize
);
233 if (template[i
].ksize
) {
234 crypto_ahash_clear_flags(tfm
, ~0);
235 ret
= crypto_ahash_setkey(tfm
, template[i
].key
,
238 printk(KERN_ERR
"alg: hash: setkey failed on "
239 "test %d for %s: ret=%d\n", j
, algo
,
245 ahash_request_set_crypt(req
, sg
, result
, template[i
].psize
);
247 ret
= do_one_async_hash_op(req
, &tresult
,
248 crypto_ahash_digest(req
));
250 pr_err("alg: hash: digest failed on test %d "
251 "for %s: ret=%d\n", j
, algo
, -ret
);
255 ret
= do_one_async_hash_op(req
, &tresult
,
256 crypto_ahash_init(req
));
258 pr_err("alt: hash: init failed on test %d "
259 "for %s: ret=%d\n", j
, algo
, -ret
);
262 ret
= do_one_async_hash_op(req
, &tresult
,
263 crypto_ahash_update(req
));
265 pr_err("alt: hash: update failed on test %d "
266 "for %s: ret=%d\n", j
, algo
, -ret
);
269 ret
= do_one_async_hash_op(req
, &tresult
,
270 crypto_ahash_final(req
));
272 pr_err("alt: hash: final failed on test %d "
273 "for %s: ret=%d\n", j
, algo
, -ret
);
278 if (memcmp(result
, template[i
].digest
,
279 crypto_ahash_digestsize(tfm
))) {
280 printk(KERN_ERR
"alg: hash: Test %d failed for %s\n",
282 hexdump(result
, crypto_ahash_digestsize(tfm
));
289 for (i
= 0; i
< tcount
; i
++) {
290 /* alignment tests are only done with continuous buffers */
291 if (align_offset
!= 0)
294 if (template[i
].np
) {
296 memset(result
, 0, 64);
299 sg_init_table(sg
, template[i
].np
);
301 for (k
= 0; k
< template[i
].np
; k
++) {
302 if (WARN_ON(offset_in_page(IDX
[k
]) +
303 template[i
].tap
[k
] > PAGE_SIZE
))
306 memcpy(xbuf
[IDX
[k
] >> PAGE_SHIFT
] +
307 offset_in_page(IDX
[k
]),
308 template[i
].plaintext
+ temp
,
311 temp
+= template[i
].tap
[k
];
314 if (template[i
].ksize
) {
315 crypto_ahash_clear_flags(tfm
, ~0);
316 ret
= crypto_ahash_setkey(tfm
, template[i
].key
,
320 printk(KERN_ERR
"alg: hash: setkey "
321 "failed on chunking test %d "
322 "for %s: ret=%d\n", j
, algo
,
328 ahash_request_set_crypt(req
, sg
, result
,
330 ret
= crypto_ahash_digest(req
);
336 ret
= wait_for_completion_interruptible(
337 &tresult
.completion
);
338 if (!ret
&& !(ret
= tresult
.err
)) {
339 INIT_COMPLETION(tresult
.completion
);
344 printk(KERN_ERR
"alg: hash: digest failed "
345 "on chunking test %d for %s: "
346 "ret=%d\n", j
, algo
, -ret
);
350 if (memcmp(result
, template[i
].digest
,
351 crypto_ahash_digestsize(tfm
))) {
352 printk(KERN_ERR
"alg: hash: Chunking test %d "
353 "failed for %s\n", j
, algo
);
354 hexdump(result
, crypto_ahash_digestsize(tfm
));
364 ahash_request_free(req
);
366 testmgr_free_buf(xbuf
);
371 static int test_hash(struct crypto_ahash
*tfm
, struct hash_testvec
*template,
372 unsigned int tcount
, bool use_digest
)
374 unsigned int alignmask
;
377 ret
= __test_hash(tfm
, template, tcount
, use_digest
, 0);
381 /* test unaligned buffers, check with one byte offset */
382 ret
= __test_hash(tfm
, template, tcount
, use_digest
, 1);
386 alignmask
= crypto_tfm_alg_alignmask(&tfm
->base
);
388 /* Check if alignment mask for tfm is correctly set. */
389 ret
= __test_hash(tfm
, template, tcount
, use_digest
,
398 static int __test_aead(struct crypto_aead
*tfm
, int enc
,
399 struct aead_testvec
*template, unsigned int tcount
,
400 const bool diff_dst
, const int align_offset
)
402 const char *algo
= crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm
));
403 unsigned int i
, j
, k
, n
, temp
;
407 struct aead_request
*req
;
408 struct scatterlist
*sg
;
409 struct scatterlist
*asg
;
410 struct scatterlist
*sgout
;
412 struct tcrypt_result result
;
413 unsigned int authsize
;
418 char *xbuf
[XBUFSIZE
];
419 char *xoutbuf
[XBUFSIZE
];
420 char *axbuf
[XBUFSIZE
];
422 if (testmgr_alloc_buf(xbuf
))
424 if (testmgr_alloc_buf(axbuf
))
427 if (diff_dst
&& testmgr_alloc_buf(xoutbuf
))
430 /* avoid "the frame size is larger than 1024 bytes" compiler warning */
431 sg
= kmalloc(sizeof(*sg
) * 8 * (diff_dst
? 3 : 2), GFP_KERNEL
);
447 init_completion(&result
.completion
);
449 req
= aead_request_alloc(tfm
, GFP_KERNEL
);
451 pr_err("alg: aead%s: Failed to allocate request for %s\n",
456 aead_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
457 tcrypt_complete
, &result
);
459 for (i
= 0, j
= 0; i
< tcount
; i
++) {
460 if (!template[i
].np
) {
463 /* some templates have no input data but they will
467 input
+= align_offset
;
471 if (WARN_ON(align_offset
+ template[i
].ilen
>
472 PAGE_SIZE
|| template[i
].alen
> PAGE_SIZE
))
475 memcpy(input
, template[i
].input
, template[i
].ilen
);
476 memcpy(assoc
, template[i
].assoc
, template[i
].alen
);
478 memcpy(iv
, template[i
].iv
, MAX_IVLEN
);
480 memset(iv
, 0, MAX_IVLEN
);
482 crypto_aead_clear_flags(tfm
, ~0);
484 crypto_aead_set_flags(
485 tfm
, CRYPTO_TFM_REQ_WEAK_KEY
);
487 key
= template[i
].key
;
489 ret
= crypto_aead_setkey(tfm
, key
,
491 if (!ret
== template[i
].fail
) {
492 pr_err("alg: aead%s: setkey failed on test %d for %s: flags=%x\n",
493 d
, j
, algo
, crypto_aead_get_flags(tfm
));
498 authsize
= abs(template[i
].rlen
- template[i
].ilen
);
499 ret
= crypto_aead_setauthsize(tfm
, authsize
);
501 pr_err("alg: aead%s: Failed to set authsize to %u on test %d for %s\n",
502 d
, authsize
, j
, algo
);
506 sg_init_one(&sg
[0], input
,
507 template[i
].ilen
+ (enc
? authsize
: 0));
511 output
+= align_offset
;
512 sg_init_one(&sgout
[0], output
,
514 (enc
? authsize
: 0));
519 sg_init_one(&asg
[0], assoc
, template[i
].alen
);
521 aead_request_set_crypt(req
, sg
, (diff_dst
) ? sgout
: sg
,
522 template[i
].ilen
, iv
);
524 aead_request_set_assoc(req
, asg
, template[i
].alen
);
527 crypto_aead_encrypt(req
) :
528 crypto_aead_decrypt(req
);
532 if (template[i
].novrfy
) {
533 /* verification was supposed to fail */
534 pr_err("alg: aead%s: %s failed on test %d for %s: ret was 0, expected -EBADMSG\n",
536 /* so really, we got a bad message */
543 ret
= wait_for_completion_interruptible(
545 if (!ret
&& !(ret
= result
.err
)) {
546 INIT_COMPLETION(result
.completion
);
550 if (template[i
].novrfy
)
551 /* verification failure was expected */
555 pr_err("alg: aead%s: %s failed on test %d for %s: ret=%d\n",
556 d
, e
, j
, algo
, -ret
);
561 if (memcmp(q
, template[i
].result
, template[i
].rlen
)) {
562 pr_err("alg: aead%s: Test %d failed on %s for %s\n",
564 hexdump(q
, template[i
].rlen
);
571 for (i
= 0, j
= 0; i
< tcount
; i
++) {
572 /* alignment tests are only done with continuous buffers */
573 if (align_offset
!= 0)
576 if (template[i
].np
) {
580 memcpy(iv
, template[i
].iv
, MAX_IVLEN
);
582 memset(iv
, 0, MAX_IVLEN
);
584 crypto_aead_clear_flags(tfm
, ~0);
586 crypto_aead_set_flags(
587 tfm
, CRYPTO_TFM_REQ_WEAK_KEY
);
588 key
= template[i
].key
;
590 ret
= crypto_aead_setkey(tfm
, key
, template[i
].klen
);
591 if (!ret
== template[i
].fail
) {
592 pr_err("alg: aead%s: setkey failed on chunk test %d for %s: flags=%x\n",
593 d
, j
, algo
, crypto_aead_get_flags(tfm
));
598 authsize
= abs(template[i
].rlen
- template[i
].ilen
);
601 sg_init_table(sg
, template[i
].np
);
603 sg_init_table(sgout
, template[i
].np
);
604 for (k
= 0, temp
= 0; k
< template[i
].np
; k
++) {
605 if (WARN_ON(offset_in_page(IDX
[k
]) +
606 template[i
].tap
[k
] > PAGE_SIZE
))
609 q
= xbuf
[IDX
[k
] >> PAGE_SHIFT
] +
610 offset_in_page(IDX
[k
]);
612 memcpy(q
, template[i
].input
+ temp
,
615 n
= template[i
].tap
[k
];
616 if (k
== template[i
].np
- 1 && enc
)
618 if (offset_in_page(q
) + n
< PAGE_SIZE
)
621 sg_set_buf(&sg
[k
], q
, template[i
].tap
[k
]);
624 q
= xoutbuf
[IDX
[k
] >> PAGE_SHIFT
] +
625 offset_in_page(IDX
[k
]);
627 memset(q
, 0, template[i
].tap
[k
]);
628 if (offset_in_page(q
) + n
< PAGE_SIZE
)
631 sg_set_buf(&sgout
[k
], q
,
635 temp
+= template[i
].tap
[k
];
638 ret
= crypto_aead_setauthsize(tfm
, authsize
);
640 pr_err("alg: aead%s: Failed to set authsize to %u on chunk test %d for %s\n",
641 d
, authsize
, j
, algo
);
646 if (WARN_ON(sg
[k
- 1].offset
+
647 sg
[k
- 1].length
+ authsize
>
653 sg
[k
- 1].length
+= authsize
;
656 sgout
[k
- 1].length
+= authsize
;
659 sg_init_table(asg
, template[i
].anp
);
661 for (k
= 0, temp
= 0; k
< template[i
].anp
; k
++) {
662 if (WARN_ON(offset_in_page(IDX
[k
]) +
663 template[i
].atap
[k
] > PAGE_SIZE
))
666 memcpy(axbuf
[IDX
[k
] >> PAGE_SHIFT
] +
667 offset_in_page(IDX
[k
]),
668 template[i
].assoc
+ temp
,
669 template[i
].atap
[k
]),
670 template[i
].atap
[k
]);
671 temp
+= template[i
].atap
[k
];
674 aead_request_set_crypt(req
, sg
, (diff_dst
) ? sgout
: sg
,
678 aead_request_set_assoc(req
, asg
, template[i
].alen
);
681 crypto_aead_encrypt(req
) :
682 crypto_aead_decrypt(req
);
686 if (template[i
].novrfy
) {
687 /* verification was supposed to fail */
688 pr_err("alg: aead%s: %s failed on chunk test %d for %s: ret was 0, expected -EBADMSG\n",
690 /* so really, we got a bad message */
697 ret
= wait_for_completion_interruptible(
699 if (!ret
&& !(ret
= result
.err
)) {
700 INIT_COMPLETION(result
.completion
);
704 if (template[i
].novrfy
)
705 /* verification failure was expected */
709 pr_err("alg: aead%s: %s failed on chunk test %d for %s: ret=%d\n",
710 d
, e
, j
, algo
, -ret
);
715 for (k
= 0, temp
= 0; k
< template[i
].np
; k
++) {
717 q
= xoutbuf
[IDX
[k
] >> PAGE_SHIFT
] +
718 offset_in_page(IDX
[k
]);
720 q
= xbuf
[IDX
[k
] >> PAGE_SHIFT
] +
721 offset_in_page(IDX
[k
]);
723 n
= template[i
].tap
[k
];
724 if (k
== template[i
].np
- 1)
725 n
+= enc
? authsize
: -authsize
;
727 if (memcmp(q
, template[i
].result
+ temp
, n
)) {
728 pr_err("alg: aead%s: Chunk test %d failed on %s at page %u for %s\n",
735 if (k
== template[i
].np
- 1 && !enc
) {
737 memcmp(q
, template[i
].input
+
743 for (n
= 0; offset_in_page(q
+ n
) &&
748 pr_err("alg: aead%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n",
749 d
, j
, e
, k
, algo
, n
);
754 temp
+= template[i
].tap
[k
];
762 aead_request_free(req
);
766 testmgr_free_buf(xoutbuf
);
768 testmgr_free_buf(axbuf
);
770 testmgr_free_buf(xbuf
);
775 static int test_aead(struct crypto_aead
*tfm
, int enc
,
776 struct aead_testvec
*template, unsigned int tcount
)
778 unsigned int alignmask
;
781 /* test 'dst == src' case */
782 ret
= __test_aead(tfm
, enc
, template, tcount
, false, 0);
786 /* test 'dst != src' case */
787 ret
= __test_aead(tfm
, enc
, template, tcount
, true, 0);
791 /* test unaligned buffers, check with one byte offset */
792 ret
= __test_aead(tfm
, enc
, template, tcount
, true, 1);
796 alignmask
= crypto_tfm_alg_alignmask(&tfm
->base
);
798 /* Check if alignment mask for tfm is correctly set. */
799 ret
= __test_aead(tfm
, enc
, template, tcount
, true,
808 static int test_cipher(struct crypto_cipher
*tfm
, int enc
,
809 struct cipher_testvec
*template, unsigned int tcount
)
811 const char *algo
= crypto_tfm_alg_driver_name(crypto_cipher_tfm(tfm
));
812 unsigned int i
, j
, k
;
816 char *xbuf
[XBUFSIZE
];
819 if (testmgr_alloc_buf(xbuf
))
828 for (i
= 0; i
< tcount
; i
++) {
835 if (WARN_ON(template[i
].ilen
> PAGE_SIZE
))
839 memcpy(data
, template[i
].input
, template[i
].ilen
);
841 crypto_cipher_clear_flags(tfm
, ~0);
843 crypto_cipher_set_flags(tfm
, CRYPTO_TFM_REQ_WEAK_KEY
);
845 ret
= crypto_cipher_setkey(tfm
, template[i
].key
,
847 if (!ret
== template[i
].fail
) {
848 printk(KERN_ERR
"alg: cipher: setkey failed "
849 "on test %d for %s: flags=%x\n", j
,
850 algo
, crypto_cipher_get_flags(tfm
));
855 for (k
= 0; k
< template[i
].ilen
;
856 k
+= crypto_cipher_blocksize(tfm
)) {
858 crypto_cipher_encrypt_one(tfm
, data
+ k
,
861 crypto_cipher_decrypt_one(tfm
, data
+ k
,
866 if (memcmp(q
, template[i
].result
, template[i
].rlen
)) {
867 printk(KERN_ERR
"alg: cipher: Test %d failed "
868 "on %s for %s\n", j
, e
, algo
);
869 hexdump(q
, template[i
].rlen
);
878 testmgr_free_buf(xbuf
);
883 static int __test_skcipher(struct crypto_ablkcipher
*tfm
, int enc
,
884 struct cipher_testvec
*template, unsigned int tcount
,
885 const bool diff_dst
, const int align_offset
)
888 crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm
));
889 unsigned int i
, j
, k
, n
, temp
;
891 struct ablkcipher_request
*req
;
892 struct scatterlist sg
[8];
893 struct scatterlist sgout
[8];
895 struct tcrypt_result result
;
898 char *xbuf
[XBUFSIZE
];
899 char *xoutbuf
[XBUFSIZE
];
902 if (testmgr_alloc_buf(xbuf
))
905 if (diff_dst
&& testmgr_alloc_buf(xoutbuf
))
918 init_completion(&result
.completion
);
920 req
= ablkcipher_request_alloc(tfm
, GFP_KERNEL
);
922 pr_err("alg: skcipher%s: Failed to allocate request for %s\n",
927 ablkcipher_request_set_callback(req
, CRYPTO_TFM_REQ_MAY_BACKLOG
,
928 tcrypt_complete
, &result
);
931 for (i
= 0; i
< tcount
; i
++) {
933 memcpy(iv
, template[i
].iv
, MAX_IVLEN
);
935 memset(iv
, 0, MAX_IVLEN
);
937 if (!(template[i
].np
) || (template[i
].also_non_np
)) {
941 if (WARN_ON(align_offset
+ template[i
].ilen
>
946 data
+= align_offset
;
947 memcpy(data
, template[i
].input
, template[i
].ilen
);
949 crypto_ablkcipher_clear_flags(tfm
, ~0);
951 crypto_ablkcipher_set_flags(
952 tfm
, CRYPTO_TFM_REQ_WEAK_KEY
);
954 ret
= crypto_ablkcipher_setkey(tfm
, template[i
].key
,
956 if (!ret
== template[i
].fail
) {
957 pr_err("alg: skcipher%s: setkey failed on test %d for %s: flags=%x\n",
959 crypto_ablkcipher_get_flags(tfm
));
964 sg_init_one(&sg
[0], data
, template[i
].ilen
);
967 data
+= align_offset
;
968 sg_init_one(&sgout
[0], data
, template[i
].ilen
);
971 ablkcipher_request_set_crypt(req
, sg
,
972 (diff_dst
) ? sgout
: sg
,
973 template[i
].ilen
, iv
);
975 crypto_ablkcipher_encrypt(req
) :
976 crypto_ablkcipher_decrypt(req
);
983 ret
= wait_for_completion_interruptible(
985 if (!ret
&& !((ret
= result
.err
))) {
986 INIT_COMPLETION(result
.completion
);
991 pr_err("alg: skcipher%s: %s failed on test %d for %s: ret=%d\n",
992 d
, e
, j
, algo
, -ret
);
997 if (memcmp(q
, template[i
].result
, template[i
].rlen
)) {
998 pr_err("alg: skcipher%s: Test %d failed on %s for %s\n",
1000 hexdump(q
, template[i
].rlen
);
1008 for (i
= 0; i
< tcount
; i
++) {
1009 /* alignment tests are only done with continuous buffers */
1010 if (align_offset
!= 0)
1014 memcpy(iv
, template[i
].iv
, MAX_IVLEN
);
1016 memset(iv
, 0, MAX_IVLEN
);
1018 if (template[i
].np
) {
1021 crypto_ablkcipher_clear_flags(tfm
, ~0);
1023 crypto_ablkcipher_set_flags(
1024 tfm
, CRYPTO_TFM_REQ_WEAK_KEY
);
1026 ret
= crypto_ablkcipher_setkey(tfm
, template[i
].key
,
1028 if (!ret
== template[i
].fail
) {
1029 pr_err("alg: skcipher%s: setkey failed on chunk test %d for %s: flags=%x\n",
1031 crypto_ablkcipher_get_flags(tfm
));
1038 sg_init_table(sg
, template[i
].np
);
1040 sg_init_table(sgout
, template[i
].np
);
1041 for (k
= 0; k
< template[i
].np
; k
++) {
1042 if (WARN_ON(offset_in_page(IDX
[k
]) +
1043 template[i
].tap
[k
] > PAGE_SIZE
))
1046 q
= xbuf
[IDX
[k
] >> PAGE_SHIFT
] +
1047 offset_in_page(IDX
[k
]);
1049 memcpy(q
, template[i
].input
+ temp
,
1050 template[i
].tap
[k
]);
1052 if (offset_in_page(q
) + template[i
].tap
[k
] <
1054 q
[template[i
].tap
[k
]] = 0;
1056 sg_set_buf(&sg
[k
], q
, template[i
].tap
[k
]);
1058 q
= xoutbuf
[IDX
[k
] >> PAGE_SHIFT
] +
1059 offset_in_page(IDX
[k
]);
1061 sg_set_buf(&sgout
[k
], q
,
1062 template[i
].tap
[k
]);
1064 memset(q
, 0, template[i
].tap
[k
]);
1065 if (offset_in_page(q
) +
1066 template[i
].tap
[k
] < PAGE_SIZE
)
1067 q
[template[i
].tap
[k
]] = 0;
1070 temp
+= template[i
].tap
[k
];
1073 ablkcipher_request_set_crypt(req
, sg
,
1074 (diff_dst
) ? sgout
: sg
,
1075 template[i
].ilen
, iv
);
1078 crypto_ablkcipher_encrypt(req
) :
1079 crypto_ablkcipher_decrypt(req
);
1086 ret
= wait_for_completion_interruptible(
1087 &result
.completion
);
1088 if (!ret
&& !((ret
= result
.err
))) {
1089 INIT_COMPLETION(result
.completion
);
1094 pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n",
1095 d
, e
, j
, algo
, -ret
);
1101 for (k
= 0; k
< template[i
].np
; k
++) {
1103 q
= xoutbuf
[IDX
[k
] >> PAGE_SHIFT
] +
1104 offset_in_page(IDX
[k
]);
1106 q
= xbuf
[IDX
[k
] >> PAGE_SHIFT
] +
1107 offset_in_page(IDX
[k
]);
1109 if (memcmp(q
, template[i
].result
+ temp
,
1110 template[i
].tap
[k
])) {
1111 pr_err("alg: skcipher%s: Chunk test %d failed on %s at page %u for %s\n",
1113 hexdump(q
, template[i
].tap
[k
]);
1117 q
+= template[i
].tap
[k
];
1118 for (n
= 0; offset_in_page(q
+ n
) && q
[n
]; n
++)
1121 pr_err("alg: skcipher%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n",
1122 d
, j
, e
, k
, algo
, n
);
1126 temp
+= template[i
].tap
[k
];
1134 ablkcipher_request_free(req
);
1136 testmgr_free_buf(xoutbuf
);
1138 testmgr_free_buf(xbuf
);
1143 static int test_skcipher(struct crypto_ablkcipher
*tfm
, int enc
,
1144 struct cipher_testvec
*template, unsigned int tcount
)
1146 unsigned int alignmask
;
1149 /* test 'dst == src' case */
1150 ret
= __test_skcipher(tfm
, enc
, template, tcount
, false, 0);
1154 /* test 'dst != src' case */
1155 ret
= __test_skcipher(tfm
, enc
, template, tcount
, true, 0);
1159 /* test unaligned buffers, check with one byte offset */
1160 ret
= __test_skcipher(tfm
, enc
, template, tcount
, true, 1);
1164 alignmask
= crypto_tfm_alg_alignmask(&tfm
->base
);
1166 /* Check if alignment mask for tfm is correctly set. */
1167 ret
= __test_skcipher(tfm
, enc
, template, tcount
, true,
1176 static int test_comp(struct crypto_comp
*tfm
, struct comp_testvec
*ctemplate
,
1177 struct comp_testvec
*dtemplate
, int ctcount
, int dtcount
)
1179 const char *algo
= crypto_tfm_alg_driver_name(crypto_comp_tfm(tfm
));
1181 char result
[COMP_BUF_SIZE
];
1184 for (i
= 0; i
< ctcount
; i
++) {
1186 unsigned int dlen
= COMP_BUF_SIZE
;
1188 memset(result
, 0, sizeof (result
));
1190 ilen
= ctemplate
[i
].inlen
;
1191 ret
= crypto_comp_compress(tfm
, ctemplate
[i
].input
,
1192 ilen
, result
, &dlen
);
1194 printk(KERN_ERR
"alg: comp: compression failed "
1195 "on test %d for %s: ret=%d\n", i
+ 1, algo
,
1200 if (dlen
!= ctemplate
[i
].outlen
) {
1201 printk(KERN_ERR
"alg: comp: Compression test %d "
1202 "failed for %s: output len = %d\n", i
+ 1, algo
,
1208 if (memcmp(result
, ctemplate
[i
].output
, dlen
)) {
1209 printk(KERN_ERR
"alg: comp: Compression test %d "
1210 "failed for %s\n", i
+ 1, algo
);
1211 hexdump(result
, dlen
);
1217 for (i
= 0; i
< dtcount
; i
++) {
1219 unsigned int dlen
= COMP_BUF_SIZE
;
1221 memset(result
, 0, sizeof (result
));
1223 ilen
= dtemplate
[i
].inlen
;
1224 ret
= crypto_comp_decompress(tfm
, dtemplate
[i
].input
,
1225 ilen
, result
, &dlen
);
1227 printk(KERN_ERR
"alg: comp: decompression failed "
1228 "on test %d for %s: ret=%d\n", i
+ 1, algo
,
1233 if (dlen
!= dtemplate
[i
].outlen
) {
1234 printk(KERN_ERR
"alg: comp: Decompression test %d "
1235 "failed for %s: output len = %d\n", i
+ 1, algo
,
1241 if (memcmp(result
, dtemplate
[i
].output
, dlen
)) {
1242 printk(KERN_ERR
"alg: comp: Decompression test %d "
1243 "failed for %s\n", i
+ 1, algo
);
1244 hexdump(result
, dlen
);
1256 static int test_pcomp(struct crypto_pcomp
*tfm
,
1257 struct pcomp_testvec
*ctemplate
,
1258 struct pcomp_testvec
*dtemplate
, int ctcount
,
1261 const char *algo
= crypto_tfm_alg_driver_name(crypto_pcomp_tfm(tfm
));
1263 char result
[COMP_BUF_SIZE
];
1266 for (i
= 0; i
< ctcount
; i
++) {
1267 struct comp_request req
;
1268 unsigned int produced
= 0;
1270 res
= crypto_compress_setup(tfm
, ctemplate
[i
].params
,
1271 ctemplate
[i
].paramsize
);
1273 pr_err("alg: pcomp: compression setup failed on test "
1274 "%d for %s: error=%d\n", i
+ 1, algo
, res
);
1278 res
= crypto_compress_init(tfm
);
1280 pr_err("alg: pcomp: compression init failed on test "
1281 "%d for %s: error=%d\n", i
+ 1, algo
, res
);
1285 memset(result
, 0, sizeof(result
));
1287 req
.next_in
= ctemplate
[i
].input
;
1288 req
.avail_in
= ctemplate
[i
].inlen
/ 2;
1289 req
.next_out
= result
;
1290 req
.avail_out
= ctemplate
[i
].outlen
/ 2;
1292 res
= crypto_compress_update(tfm
, &req
);
1293 if (res
< 0 && (res
!= -EAGAIN
|| req
.avail_in
)) {
1294 pr_err("alg: pcomp: compression update failed on test "
1295 "%d for %s: error=%d\n", i
+ 1, algo
, res
);
1301 /* Add remaining input data */
1302 req
.avail_in
+= (ctemplate
[i
].inlen
+ 1) / 2;
1304 res
= crypto_compress_update(tfm
, &req
);
1305 if (res
< 0 && (res
!= -EAGAIN
|| req
.avail_in
)) {
1306 pr_err("alg: pcomp: compression update failed on test "
1307 "%d for %s: error=%d\n", i
+ 1, algo
, res
);
1313 /* Provide remaining output space */
1314 req
.avail_out
+= COMP_BUF_SIZE
- ctemplate
[i
].outlen
/ 2;
1316 res
= crypto_compress_final(tfm
, &req
);
1318 pr_err("alg: pcomp: compression final failed on test "
1319 "%d for %s: error=%d\n", i
+ 1, algo
, res
);
1324 if (COMP_BUF_SIZE
- req
.avail_out
!= ctemplate
[i
].outlen
) {
1325 pr_err("alg: comp: Compression test %d failed for %s: "
1326 "output len = %d (expected %d)\n", i
+ 1, algo
,
1327 COMP_BUF_SIZE
- req
.avail_out
,
1328 ctemplate
[i
].outlen
);
1332 if (produced
!= ctemplate
[i
].outlen
) {
1333 pr_err("alg: comp: Compression test %d failed for %s: "
1334 "returned len = %u (expected %d)\n", i
+ 1,
1335 algo
, produced
, ctemplate
[i
].outlen
);
1339 if (memcmp(result
, ctemplate
[i
].output
, ctemplate
[i
].outlen
)) {
1340 pr_err("alg: pcomp: Compression test %d failed for "
1341 "%s\n", i
+ 1, algo
);
1342 hexdump(result
, ctemplate
[i
].outlen
);
1347 for (i
= 0; i
< dtcount
; i
++) {
1348 struct comp_request req
;
1349 unsigned int produced
= 0;
1351 res
= crypto_decompress_setup(tfm
, dtemplate
[i
].params
,
1352 dtemplate
[i
].paramsize
);
1354 pr_err("alg: pcomp: decompression setup failed on "
1355 "test %d for %s: error=%d\n", i
+ 1, algo
, res
);
1359 res
= crypto_decompress_init(tfm
);
1361 pr_err("alg: pcomp: decompression init failed on test "
1362 "%d for %s: error=%d\n", i
+ 1, algo
, res
);
1366 memset(result
, 0, sizeof(result
));
1368 req
.next_in
= dtemplate
[i
].input
;
1369 req
.avail_in
= dtemplate
[i
].inlen
/ 2;
1370 req
.next_out
= result
;
1371 req
.avail_out
= dtemplate
[i
].outlen
/ 2;
1373 res
= crypto_decompress_update(tfm
, &req
);
1374 if (res
< 0 && (res
!= -EAGAIN
|| req
.avail_in
)) {
1375 pr_err("alg: pcomp: decompression update failed on "
1376 "test %d for %s: error=%d\n", i
+ 1, algo
, res
);
1382 /* Add remaining input data */
1383 req
.avail_in
+= (dtemplate
[i
].inlen
+ 1) / 2;
1385 res
= crypto_decompress_update(tfm
, &req
);
1386 if (res
< 0 && (res
!= -EAGAIN
|| req
.avail_in
)) {
1387 pr_err("alg: pcomp: decompression update failed on "
1388 "test %d for %s: error=%d\n", i
+ 1, algo
, res
);
1394 /* Provide remaining output space */
1395 req
.avail_out
+= COMP_BUF_SIZE
- dtemplate
[i
].outlen
/ 2;
1397 res
= crypto_decompress_final(tfm
, &req
);
1398 if (res
< 0 && (res
!= -EAGAIN
|| req
.avail_in
)) {
1399 pr_err("alg: pcomp: decompression final failed on "
1400 "test %d for %s: error=%d\n", i
+ 1, algo
, res
);
1406 if (COMP_BUF_SIZE
- req
.avail_out
!= dtemplate
[i
].outlen
) {
1407 pr_err("alg: comp: Decompression test %d failed for "
1408 "%s: output len = %d (expected %d)\n", i
+ 1,
1409 algo
, COMP_BUF_SIZE
- req
.avail_out
,
1410 dtemplate
[i
].outlen
);
1414 if (produced
!= dtemplate
[i
].outlen
) {
1415 pr_err("alg: comp: Decompression test %d failed for "
1416 "%s: returned len = %u (expected %d)\n", i
+ 1,
1417 algo
, produced
, dtemplate
[i
].outlen
);
1421 if (memcmp(result
, dtemplate
[i
].output
, dtemplate
[i
].outlen
)) {
1422 pr_err("alg: pcomp: Decompression test %d failed for "
1423 "%s\n", i
+ 1, algo
);
1424 hexdump(result
, dtemplate
[i
].outlen
);
1433 static int test_cprng(struct crypto_rng
*tfm
, struct cprng_testvec
*template,
1434 unsigned int tcount
)
1436 const char *algo
= crypto_tfm_alg_driver_name(crypto_rng_tfm(tfm
));
1437 int err
= 0, i
, j
, seedsize
;
1441 seedsize
= crypto_rng_seedsize(tfm
);
1443 seed
= kmalloc(seedsize
, GFP_KERNEL
);
1445 printk(KERN_ERR
"alg: cprng: Failed to allocate seed space "
1450 for (i
= 0; i
< tcount
; i
++) {
1451 memset(result
, 0, 32);
1453 memcpy(seed
, template[i
].v
, template[i
].vlen
);
1454 memcpy(seed
+ template[i
].vlen
, template[i
].key
,
1456 memcpy(seed
+ template[i
].vlen
+ template[i
].klen
,
1457 template[i
].dt
, template[i
].dtlen
);
1459 err
= crypto_rng_reset(tfm
, seed
, seedsize
);
1461 printk(KERN_ERR
"alg: cprng: Failed to reset rng "
1466 for (j
= 0; j
< template[i
].loops
; j
++) {
1467 err
= crypto_rng_get_bytes(tfm
, result
,
1469 if (err
!= template[i
].rlen
) {
1470 printk(KERN_ERR
"alg: cprng: Failed to obtain "
1471 "the correct amount of random data for "
1472 "%s (requested %d, got %d)\n", algo
,
1473 template[i
].rlen
, err
);
1478 err
= memcmp(result
, template[i
].result
,
1481 printk(KERN_ERR
"alg: cprng: Test %d failed for %s\n",
1483 hexdump(result
, template[i
].rlen
);
1494 static int alg_test_aead(const struct alg_test_desc
*desc
, const char *driver
,
1497 struct crypto_aead
*tfm
;
1500 tfm
= crypto_alloc_aead(driver
, type
, mask
);
1502 printk(KERN_ERR
"alg: aead: Failed to load transform for %s: "
1503 "%ld\n", driver
, PTR_ERR(tfm
));
1504 return PTR_ERR(tfm
);
1507 if (desc
->suite
.aead
.enc
.vecs
) {
1508 err
= test_aead(tfm
, ENCRYPT
, desc
->suite
.aead
.enc
.vecs
,
1509 desc
->suite
.aead
.enc
.count
);
1514 if (!err
&& desc
->suite
.aead
.dec
.vecs
)
1515 err
= test_aead(tfm
, DECRYPT
, desc
->suite
.aead
.dec
.vecs
,
1516 desc
->suite
.aead
.dec
.count
);
1519 crypto_free_aead(tfm
);
1523 static int alg_test_cipher(const struct alg_test_desc
*desc
,
1524 const char *driver
, u32 type
, u32 mask
)
1526 struct crypto_cipher
*tfm
;
1529 tfm
= crypto_alloc_cipher(driver
, type
, mask
);
1531 printk(KERN_ERR
"alg: cipher: Failed to load transform for "
1532 "%s: %ld\n", driver
, PTR_ERR(tfm
));
1533 return PTR_ERR(tfm
);
1536 if (desc
->suite
.cipher
.enc
.vecs
) {
1537 err
= test_cipher(tfm
, ENCRYPT
, desc
->suite
.cipher
.enc
.vecs
,
1538 desc
->suite
.cipher
.enc
.count
);
1543 if (desc
->suite
.cipher
.dec
.vecs
)
1544 err
= test_cipher(tfm
, DECRYPT
, desc
->suite
.cipher
.dec
.vecs
,
1545 desc
->suite
.cipher
.dec
.count
);
1548 crypto_free_cipher(tfm
);
1552 static int alg_test_skcipher(const struct alg_test_desc
*desc
,
1553 const char *driver
, u32 type
, u32 mask
)
1555 struct crypto_ablkcipher
*tfm
;
1558 tfm
= crypto_alloc_ablkcipher(driver
, type
, mask
);
1560 printk(KERN_ERR
"alg: skcipher: 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_skcipher(tfm
, ENCRYPT
, desc
->suite
.cipher
.enc
.vecs
,
1567 desc
->suite
.cipher
.enc
.count
);
1572 if (desc
->suite
.cipher
.dec
.vecs
)
1573 err
= test_skcipher(tfm
, DECRYPT
, desc
->suite
.cipher
.dec
.vecs
,
1574 desc
->suite
.cipher
.dec
.count
);
1577 crypto_free_ablkcipher(tfm
);
1581 static int alg_test_comp(const struct alg_test_desc
*desc
, const char *driver
,
1584 struct crypto_comp
*tfm
;
1587 tfm
= crypto_alloc_comp(driver
, type
, mask
);
1589 printk(KERN_ERR
"alg: comp: Failed to load transform for %s: "
1590 "%ld\n", driver
, PTR_ERR(tfm
));
1591 return PTR_ERR(tfm
);
1594 err
= test_comp(tfm
, desc
->suite
.comp
.comp
.vecs
,
1595 desc
->suite
.comp
.decomp
.vecs
,
1596 desc
->suite
.comp
.comp
.count
,
1597 desc
->suite
.comp
.decomp
.count
);
1599 crypto_free_comp(tfm
);
1603 static int alg_test_pcomp(const struct alg_test_desc
*desc
, const char *driver
,
1606 struct crypto_pcomp
*tfm
;
1609 tfm
= crypto_alloc_pcomp(driver
, type
, mask
);
1611 pr_err("alg: pcomp: Failed to load transform for %s: %ld\n",
1612 driver
, PTR_ERR(tfm
));
1613 return PTR_ERR(tfm
);
1616 err
= test_pcomp(tfm
, desc
->suite
.pcomp
.comp
.vecs
,
1617 desc
->suite
.pcomp
.decomp
.vecs
,
1618 desc
->suite
.pcomp
.comp
.count
,
1619 desc
->suite
.pcomp
.decomp
.count
);
1621 crypto_free_pcomp(tfm
);
1625 static int alg_test_hash(const struct alg_test_desc
*desc
, const char *driver
,
1628 struct crypto_ahash
*tfm
;
1631 tfm
= crypto_alloc_ahash(driver
, type
, mask
);
1633 printk(KERN_ERR
"alg: hash: Failed to load transform for %s: "
1634 "%ld\n", driver
, PTR_ERR(tfm
));
1635 return PTR_ERR(tfm
);
1638 err
= test_hash(tfm
, desc
->suite
.hash
.vecs
,
1639 desc
->suite
.hash
.count
, true);
1641 err
= test_hash(tfm
, desc
->suite
.hash
.vecs
,
1642 desc
->suite
.hash
.count
, false);
1644 crypto_free_ahash(tfm
);
1648 static int alg_test_crc32c(const struct alg_test_desc
*desc
,
1649 const char *driver
, u32 type
, u32 mask
)
1651 struct crypto_shash
*tfm
;
1655 err
= alg_test_hash(desc
, driver
, type
, mask
);
1659 tfm
= crypto_alloc_shash(driver
, type
, mask
);
1661 printk(KERN_ERR
"alg: crc32c: Failed to load transform for %s: "
1662 "%ld\n", driver
, PTR_ERR(tfm
));
1669 struct shash_desc shash
;
1670 char ctx
[crypto_shash_descsize(tfm
)];
1673 sdesc
.shash
.tfm
= tfm
;
1674 sdesc
.shash
.flags
= 0;
1676 *(u32
*)sdesc
.ctx
= le32_to_cpu(420553207);
1677 err
= crypto_shash_final(&sdesc
.shash
, (u8
*)&val
);
1679 printk(KERN_ERR
"alg: crc32c: Operation failed for "
1680 "%s: %d\n", driver
, err
);
1684 if (val
!= ~420553207) {
1685 printk(KERN_ERR
"alg: crc32c: Test failed for %s: "
1686 "%d\n", driver
, val
);
1691 crypto_free_shash(tfm
);
1697 static int alg_test_cprng(const struct alg_test_desc
*desc
, const char *driver
,
1700 struct crypto_rng
*rng
;
1703 rng
= crypto_alloc_rng(driver
, type
, mask
);
1705 printk(KERN_ERR
"alg: cprng: Failed to load transform for %s: "
1706 "%ld\n", driver
, PTR_ERR(rng
));
1707 return PTR_ERR(rng
);
1710 err
= test_cprng(rng
, desc
->suite
.cprng
.vecs
, desc
->suite
.cprng
.count
);
1712 crypto_free_rng(rng
);
1717 static int alg_test_null(const struct alg_test_desc
*desc
,
1718 const char *driver
, u32 type
, u32 mask
)
1723 /* Please keep this list sorted by algorithm name. */
1724 static const struct alg_test_desc alg_test_descs
[] = {
1726 .alg
= "__cbc-cast5-avx",
1727 .test
= alg_test_null
,
1729 .alg
= "__cbc-cast6-avx",
1730 .test
= alg_test_null
,
1732 .alg
= "__cbc-serpent-avx",
1733 .test
= alg_test_null
,
1735 .alg
= "__cbc-serpent-avx2",
1736 .test
= alg_test_null
,
1738 .alg
= "__cbc-serpent-sse2",
1739 .test
= alg_test_null
,
1741 .alg
= "__cbc-twofish-avx",
1742 .test
= alg_test_null
,
1744 .alg
= "__driver-cbc-aes-aesni",
1745 .test
= alg_test_null
,
1748 .alg
= "__driver-cbc-camellia-aesni",
1749 .test
= alg_test_null
,
1751 .alg
= "__driver-cbc-camellia-aesni-avx2",
1752 .test
= alg_test_null
,
1754 .alg
= "__driver-cbc-cast5-avx",
1755 .test
= alg_test_null
,
1757 .alg
= "__driver-cbc-cast6-avx",
1758 .test
= alg_test_null
,
1760 .alg
= "__driver-cbc-serpent-avx",
1761 .test
= alg_test_null
,
1763 .alg
= "__driver-cbc-serpent-avx2",
1764 .test
= alg_test_null
,
1766 .alg
= "__driver-cbc-serpent-sse2",
1767 .test
= alg_test_null
,
1769 .alg
= "__driver-cbc-twofish-avx",
1770 .test
= alg_test_null
,
1772 .alg
= "__driver-ecb-aes-aesni",
1773 .test
= alg_test_null
,
1776 .alg
= "__driver-ecb-camellia-aesni",
1777 .test
= alg_test_null
,
1779 .alg
= "__driver-ecb-camellia-aesni-avx2",
1780 .test
= alg_test_null
,
1782 .alg
= "__driver-ecb-cast5-avx",
1783 .test
= alg_test_null
,
1785 .alg
= "__driver-ecb-cast6-avx",
1786 .test
= alg_test_null
,
1788 .alg
= "__driver-ecb-serpent-avx",
1789 .test
= alg_test_null
,
1791 .alg
= "__driver-ecb-serpent-avx2",
1792 .test
= alg_test_null
,
1794 .alg
= "__driver-ecb-serpent-sse2",
1795 .test
= alg_test_null
,
1797 .alg
= "__driver-ecb-twofish-avx",
1798 .test
= alg_test_null
,
1800 .alg
= "__ghash-pclmulqdqni",
1801 .test
= alg_test_null
,
1804 .alg
= "ansi_cprng",
1805 .test
= alg_test_cprng
,
1809 .vecs
= ansi_cprng_aes_tv_template
,
1810 .count
= ANSI_CPRNG_AES_TEST_VECTORS
1814 .alg
= "authenc(hmac(sha1),cbc(aes))",
1815 .test
= alg_test_aead
,
1820 .vecs
= hmac_sha1_aes_cbc_enc_tv_template
,
1821 .count
= HMAC_SHA1_AES_CBC_ENC_TEST_VECTORS
1826 .alg
= "authenc(hmac(sha256),cbc(aes))",
1827 .test
= alg_test_aead
,
1832 .vecs
= hmac_sha256_aes_cbc_enc_tv_template
,
1833 .count
= HMAC_SHA256_AES_CBC_ENC_TEST_VECTORS
1838 .alg
= "authenc(hmac(sha512),cbc(aes))",
1839 .test
= alg_test_aead
,
1844 .vecs
= hmac_sha512_aes_cbc_enc_tv_template
,
1845 .count
= HMAC_SHA512_AES_CBC_ENC_TEST_VECTORS
1851 .test
= alg_test_skcipher
,
1856 .vecs
= aes_cbc_enc_tv_template
,
1857 .count
= AES_CBC_ENC_TEST_VECTORS
1860 .vecs
= aes_cbc_dec_tv_template
,
1861 .count
= AES_CBC_DEC_TEST_VECTORS
1866 .alg
= "cbc(anubis)",
1867 .test
= alg_test_skcipher
,
1871 .vecs
= anubis_cbc_enc_tv_template
,
1872 .count
= ANUBIS_CBC_ENC_TEST_VECTORS
1875 .vecs
= anubis_cbc_dec_tv_template
,
1876 .count
= ANUBIS_CBC_DEC_TEST_VECTORS
1881 .alg
= "cbc(blowfish)",
1882 .test
= alg_test_skcipher
,
1886 .vecs
= bf_cbc_enc_tv_template
,
1887 .count
= BF_CBC_ENC_TEST_VECTORS
1890 .vecs
= bf_cbc_dec_tv_template
,
1891 .count
= BF_CBC_DEC_TEST_VECTORS
1896 .alg
= "cbc(camellia)",
1897 .test
= alg_test_skcipher
,
1901 .vecs
= camellia_cbc_enc_tv_template
,
1902 .count
= CAMELLIA_CBC_ENC_TEST_VECTORS
1905 .vecs
= camellia_cbc_dec_tv_template
,
1906 .count
= CAMELLIA_CBC_DEC_TEST_VECTORS
1911 .alg
= "cbc(cast5)",
1912 .test
= alg_test_skcipher
,
1916 .vecs
= cast5_cbc_enc_tv_template
,
1917 .count
= CAST5_CBC_ENC_TEST_VECTORS
1920 .vecs
= cast5_cbc_dec_tv_template
,
1921 .count
= CAST5_CBC_DEC_TEST_VECTORS
1926 .alg
= "cbc(cast6)",
1927 .test
= alg_test_skcipher
,
1931 .vecs
= cast6_cbc_enc_tv_template
,
1932 .count
= CAST6_CBC_ENC_TEST_VECTORS
1935 .vecs
= cast6_cbc_dec_tv_template
,
1936 .count
= CAST6_CBC_DEC_TEST_VECTORS
1942 .test
= alg_test_skcipher
,
1946 .vecs
= des_cbc_enc_tv_template
,
1947 .count
= DES_CBC_ENC_TEST_VECTORS
1950 .vecs
= des_cbc_dec_tv_template
,
1951 .count
= DES_CBC_DEC_TEST_VECTORS
1956 .alg
= "cbc(des3_ede)",
1957 .test
= alg_test_skcipher
,
1962 .vecs
= des3_ede_cbc_enc_tv_template
,
1963 .count
= DES3_EDE_CBC_ENC_TEST_VECTORS
1966 .vecs
= des3_ede_cbc_dec_tv_template
,
1967 .count
= DES3_EDE_CBC_DEC_TEST_VECTORS
1972 .alg
= "cbc(serpent)",
1973 .test
= alg_test_skcipher
,
1977 .vecs
= serpent_cbc_enc_tv_template
,
1978 .count
= SERPENT_CBC_ENC_TEST_VECTORS
1981 .vecs
= serpent_cbc_dec_tv_template
,
1982 .count
= SERPENT_CBC_DEC_TEST_VECTORS
1987 .alg
= "cbc(twofish)",
1988 .test
= alg_test_skcipher
,
1992 .vecs
= tf_cbc_enc_tv_template
,
1993 .count
= TF_CBC_ENC_TEST_VECTORS
1996 .vecs
= tf_cbc_dec_tv_template
,
1997 .count
= TF_CBC_DEC_TEST_VECTORS
2003 .test
= alg_test_aead
,
2008 .vecs
= aes_ccm_enc_tv_template
,
2009 .count
= AES_CCM_ENC_TEST_VECTORS
2012 .vecs
= aes_ccm_dec_tv_template
,
2013 .count
= AES_CCM_DEC_TEST_VECTORS
2019 .test
= alg_test_hash
,
2022 .vecs
= aes_cmac128_tv_template
,
2023 .count
= CMAC_AES_TEST_VECTORS
2027 .alg
= "cmac(des3_ede)",
2028 .test
= alg_test_hash
,
2031 .vecs
= des3_ede_cmac64_tv_template
,
2032 .count
= CMAC_DES3_EDE_TEST_VECTORS
2036 .alg
= "compress_null",
2037 .test
= alg_test_null
,
2040 .test
= alg_test_crc32c
,
2044 .vecs
= crc32c_tv_template
,
2045 .count
= CRC32C_TEST_VECTORS
2049 .alg
= "cryptd(__driver-cbc-aes-aesni)",
2050 .test
= alg_test_null
,
2053 .alg
= "cryptd(__driver-cbc-camellia-aesni)",
2054 .test
= alg_test_null
,
2056 .alg
= "cryptd(__driver-cbc-camellia-aesni-avx2)",
2057 .test
= alg_test_null
,
2059 .alg
= "cryptd(__driver-cbc-serpent-avx2)",
2060 .test
= alg_test_null
,
2062 .alg
= "cryptd(__driver-ecb-aes-aesni)",
2063 .test
= alg_test_null
,
2066 .alg
= "cryptd(__driver-ecb-camellia-aesni)",
2067 .test
= alg_test_null
,
2069 .alg
= "cryptd(__driver-ecb-camellia-aesni-avx2)",
2070 .test
= alg_test_null
,
2072 .alg
= "cryptd(__driver-ecb-cast5-avx)",
2073 .test
= alg_test_null
,
2075 .alg
= "cryptd(__driver-ecb-cast6-avx)",
2076 .test
= alg_test_null
,
2078 .alg
= "cryptd(__driver-ecb-serpent-avx)",
2079 .test
= alg_test_null
,
2081 .alg
= "cryptd(__driver-ecb-serpent-avx2)",
2082 .test
= alg_test_null
,
2084 .alg
= "cryptd(__driver-ecb-serpent-sse2)",
2085 .test
= alg_test_null
,
2087 .alg
= "cryptd(__driver-ecb-twofish-avx)",
2088 .test
= alg_test_null
,
2090 .alg
= "cryptd(__driver-gcm-aes-aesni)",
2091 .test
= alg_test_null
,
2094 .alg
= "cryptd(__ghash-pclmulqdqni)",
2095 .test
= alg_test_null
,
2099 .test
= alg_test_skcipher
,
2104 .vecs
= aes_ctr_enc_tv_template
,
2105 .count
= AES_CTR_ENC_TEST_VECTORS
2108 .vecs
= aes_ctr_dec_tv_template
,
2109 .count
= AES_CTR_DEC_TEST_VECTORS
2114 .alg
= "ctr(blowfish)",
2115 .test
= alg_test_skcipher
,
2119 .vecs
= bf_ctr_enc_tv_template
,
2120 .count
= BF_CTR_ENC_TEST_VECTORS
2123 .vecs
= bf_ctr_dec_tv_template
,
2124 .count
= BF_CTR_DEC_TEST_VECTORS
2129 .alg
= "ctr(camellia)",
2130 .test
= alg_test_skcipher
,
2134 .vecs
= camellia_ctr_enc_tv_template
,
2135 .count
= CAMELLIA_CTR_ENC_TEST_VECTORS
2138 .vecs
= camellia_ctr_dec_tv_template
,
2139 .count
= CAMELLIA_CTR_DEC_TEST_VECTORS
2144 .alg
= "ctr(cast5)",
2145 .test
= alg_test_skcipher
,
2149 .vecs
= cast5_ctr_enc_tv_template
,
2150 .count
= CAST5_CTR_ENC_TEST_VECTORS
2153 .vecs
= cast5_ctr_dec_tv_template
,
2154 .count
= CAST5_CTR_DEC_TEST_VECTORS
2159 .alg
= "ctr(cast6)",
2160 .test
= alg_test_skcipher
,
2164 .vecs
= cast6_ctr_enc_tv_template
,
2165 .count
= CAST6_CTR_ENC_TEST_VECTORS
2168 .vecs
= cast6_ctr_dec_tv_template
,
2169 .count
= CAST6_CTR_DEC_TEST_VECTORS
2175 .test
= alg_test_skcipher
,
2179 .vecs
= des_ctr_enc_tv_template
,
2180 .count
= DES_CTR_ENC_TEST_VECTORS
2183 .vecs
= des_ctr_dec_tv_template
,
2184 .count
= DES_CTR_DEC_TEST_VECTORS
2189 .alg
= "ctr(des3_ede)",
2190 .test
= alg_test_skcipher
,
2194 .vecs
= des3_ede_ctr_enc_tv_template
,
2195 .count
= DES3_EDE_CTR_ENC_TEST_VECTORS
2198 .vecs
= des3_ede_ctr_dec_tv_template
,
2199 .count
= DES3_EDE_CTR_DEC_TEST_VECTORS
2204 .alg
= "ctr(serpent)",
2205 .test
= alg_test_skcipher
,
2209 .vecs
= serpent_ctr_enc_tv_template
,
2210 .count
= SERPENT_CTR_ENC_TEST_VECTORS
2213 .vecs
= serpent_ctr_dec_tv_template
,
2214 .count
= SERPENT_CTR_DEC_TEST_VECTORS
2219 .alg
= "ctr(twofish)",
2220 .test
= alg_test_skcipher
,
2224 .vecs
= tf_ctr_enc_tv_template
,
2225 .count
= TF_CTR_ENC_TEST_VECTORS
2228 .vecs
= tf_ctr_dec_tv_template
,
2229 .count
= TF_CTR_DEC_TEST_VECTORS
2234 .alg
= "cts(cbc(aes))",
2235 .test
= alg_test_skcipher
,
2239 .vecs
= cts_mode_enc_tv_template
,
2240 .count
= CTS_MODE_ENC_TEST_VECTORS
2243 .vecs
= cts_mode_dec_tv_template
,
2244 .count
= CTS_MODE_DEC_TEST_VECTORS
2250 .test
= alg_test_comp
,
2255 .vecs
= deflate_comp_tv_template
,
2256 .count
= DEFLATE_COMP_TEST_VECTORS
2259 .vecs
= deflate_decomp_tv_template
,
2260 .count
= DEFLATE_DECOMP_TEST_VECTORS
2265 .alg
= "digest_null",
2266 .test
= alg_test_null
,
2268 .alg
= "ecb(__aes-aesni)",
2269 .test
= alg_test_null
,
2273 .test
= alg_test_skcipher
,
2278 .vecs
= aes_enc_tv_template
,
2279 .count
= AES_ENC_TEST_VECTORS
2282 .vecs
= aes_dec_tv_template
,
2283 .count
= AES_DEC_TEST_VECTORS
2288 .alg
= "ecb(anubis)",
2289 .test
= alg_test_skcipher
,
2293 .vecs
= anubis_enc_tv_template
,
2294 .count
= ANUBIS_ENC_TEST_VECTORS
2297 .vecs
= anubis_dec_tv_template
,
2298 .count
= ANUBIS_DEC_TEST_VECTORS
2304 .test
= alg_test_skcipher
,
2308 .vecs
= arc4_enc_tv_template
,
2309 .count
= ARC4_ENC_TEST_VECTORS
2312 .vecs
= arc4_dec_tv_template
,
2313 .count
= ARC4_DEC_TEST_VECTORS
2318 .alg
= "ecb(blowfish)",
2319 .test
= alg_test_skcipher
,
2323 .vecs
= bf_enc_tv_template
,
2324 .count
= BF_ENC_TEST_VECTORS
2327 .vecs
= bf_dec_tv_template
,
2328 .count
= BF_DEC_TEST_VECTORS
2333 .alg
= "ecb(camellia)",
2334 .test
= alg_test_skcipher
,
2338 .vecs
= camellia_enc_tv_template
,
2339 .count
= CAMELLIA_ENC_TEST_VECTORS
2342 .vecs
= camellia_dec_tv_template
,
2343 .count
= CAMELLIA_DEC_TEST_VECTORS
2348 .alg
= "ecb(cast5)",
2349 .test
= alg_test_skcipher
,
2353 .vecs
= cast5_enc_tv_template
,
2354 .count
= CAST5_ENC_TEST_VECTORS
2357 .vecs
= cast5_dec_tv_template
,
2358 .count
= CAST5_DEC_TEST_VECTORS
2363 .alg
= "ecb(cast6)",
2364 .test
= alg_test_skcipher
,
2368 .vecs
= cast6_enc_tv_template
,
2369 .count
= CAST6_ENC_TEST_VECTORS
2372 .vecs
= cast6_dec_tv_template
,
2373 .count
= CAST6_DEC_TEST_VECTORS
2378 .alg
= "ecb(cipher_null)",
2379 .test
= alg_test_null
,
2382 .test
= alg_test_skcipher
,
2387 .vecs
= des_enc_tv_template
,
2388 .count
= DES_ENC_TEST_VECTORS
2391 .vecs
= des_dec_tv_template
,
2392 .count
= DES_DEC_TEST_VECTORS
2397 .alg
= "ecb(des3_ede)",
2398 .test
= alg_test_skcipher
,
2403 .vecs
= des3_ede_enc_tv_template
,
2404 .count
= DES3_EDE_ENC_TEST_VECTORS
2407 .vecs
= des3_ede_dec_tv_template
,
2408 .count
= DES3_EDE_DEC_TEST_VECTORS
2413 .alg
= "ecb(fcrypt)",
2414 .test
= alg_test_skcipher
,
2418 .vecs
= fcrypt_pcbc_enc_tv_template
,
2422 .vecs
= fcrypt_pcbc_dec_tv_template
,
2428 .alg
= "ecb(khazad)",
2429 .test
= alg_test_skcipher
,
2433 .vecs
= khazad_enc_tv_template
,
2434 .count
= KHAZAD_ENC_TEST_VECTORS
2437 .vecs
= khazad_dec_tv_template
,
2438 .count
= KHAZAD_DEC_TEST_VECTORS
2444 .test
= alg_test_skcipher
,
2448 .vecs
= seed_enc_tv_template
,
2449 .count
= SEED_ENC_TEST_VECTORS
2452 .vecs
= seed_dec_tv_template
,
2453 .count
= SEED_DEC_TEST_VECTORS
2458 .alg
= "ecb(serpent)",
2459 .test
= alg_test_skcipher
,
2463 .vecs
= serpent_enc_tv_template
,
2464 .count
= SERPENT_ENC_TEST_VECTORS
2467 .vecs
= serpent_dec_tv_template
,
2468 .count
= SERPENT_DEC_TEST_VECTORS
2474 .test
= alg_test_skcipher
,
2478 .vecs
= tea_enc_tv_template
,
2479 .count
= TEA_ENC_TEST_VECTORS
2482 .vecs
= tea_dec_tv_template
,
2483 .count
= TEA_DEC_TEST_VECTORS
2488 .alg
= "ecb(tnepres)",
2489 .test
= alg_test_skcipher
,
2493 .vecs
= tnepres_enc_tv_template
,
2494 .count
= TNEPRES_ENC_TEST_VECTORS
2497 .vecs
= tnepres_dec_tv_template
,
2498 .count
= TNEPRES_DEC_TEST_VECTORS
2503 .alg
= "ecb(twofish)",
2504 .test
= alg_test_skcipher
,
2508 .vecs
= tf_enc_tv_template
,
2509 .count
= TF_ENC_TEST_VECTORS
2512 .vecs
= tf_dec_tv_template
,
2513 .count
= TF_DEC_TEST_VECTORS
2519 .test
= alg_test_skcipher
,
2523 .vecs
= xeta_enc_tv_template
,
2524 .count
= XETA_ENC_TEST_VECTORS
2527 .vecs
= xeta_dec_tv_template
,
2528 .count
= XETA_DEC_TEST_VECTORS
2534 .test
= alg_test_skcipher
,
2538 .vecs
= xtea_enc_tv_template
,
2539 .count
= XTEA_ENC_TEST_VECTORS
2542 .vecs
= xtea_dec_tv_template
,
2543 .count
= XTEA_DEC_TEST_VECTORS
2549 .test
= alg_test_aead
,
2554 .vecs
= aes_gcm_enc_tv_template
,
2555 .count
= AES_GCM_ENC_TEST_VECTORS
2558 .vecs
= aes_gcm_dec_tv_template
,
2559 .count
= AES_GCM_DEC_TEST_VECTORS
2565 .test
= alg_test_hash
,
2569 .vecs
= ghash_tv_template
,
2570 .count
= GHASH_TEST_VECTORS
2574 .alg
= "hmac(crc32)",
2575 .test
= alg_test_hash
,
2578 .vecs
= bfin_crc_tv_template
,
2579 .count
= BFIN_CRC_TEST_VECTORS
2584 .test
= alg_test_hash
,
2587 .vecs
= hmac_md5_tv_template
,
2588 .count
= HMAC_MD5_TEST_VECTORS
2592 .alg
= "hmac(rmd128)",
2593 .test
= alg_test_hash
,
2596 .vecs
= hmac_rmd128_tv_template
,
2597 .count
= HMAC_RMD128_TEST_VECTORS
2601 .alg
= "hmac(rmd160)",
2602 .test
= alg_test_hash
,
2605 .vecs
= hmac_rmd160_tv_template
,
2606 .count
= HMAC_RMD160_TEST_VECTORS
2610 .alg
= "hmac(sha1)",
2611 .test
= alg_test_hash
,
2615 .vecs
= hmac_sha1_tv_template
,
2616 .count
= HMAC_SHA1_TEST_VECTORS
2620 .alg
= "hmac(sha224)",
2621 .test
= alg_test_hash
,
2625 .vecs
= hmac_sha224_tv_template
,
2626 .count
= HMAC_SHA224_TEST_VECTORS
2630 .alg
= "hmac(sha256)",
2631 .test
= alg_test_hash
,
2635 .vecs
= hmac_sha256_tv_template
,
2636 .count
= HMAC_SHA256_TEST_VECTORS
2640 .alg
= "hmac(sha384)",
2641 .test
= alg_test_hash
,
2645 .vecs
= hmac_sha384_tv_template
,
2646 .count
= HMAC_SHA384_TEST_VECTORS
2650 .alg
= "hmac(sha512)",
2651 .test
= alg_test_hash
,
2655 .vecs
= hmac_sha512_tv_template
,
2656 .count
= HMAC_SHA512_TEST_VECTORS
2661 .test
= alg_test_skcipher
,
2665 .vecs
= aes_lrw_enc_tv_template
,
2666 .count
= AES_LRW_ENC_TEST_VECTORS
2669 .vecs
= aes_lrw_dec_tv_template
,
2670 .count
= AES_LRW_DEC_TEST_VECTORS
2675 .alg
= "lrw(camellia)",
2676 .test
= alg_test_skcipher
,
2680 .vecs
= camellia_lrw_enc_tv_template
,
2681 .count
= CAMELLIA_LRW_ENC_TEST_VECTORS
2684 .vecs
= camellia_lrw_dec_tv_template
,
2685 .count
= CAMELLIA_LRW_DEC_TEST_VECTORS
2690 .alg
= "lrw(cast6)",
2691 .test
= alg_test_skcipher
,
2695 .vecs
= cast6_lrw_enc_tv_template
,
2696 .count
= CAST6_LRW_ENC_TEST_VECTORS
2699 .vecs
= cast6_lrw_dec_tv_template
,
2700 .count
= CAST6_LRW_DEC_TEST_VECTORS
2705 .alg
= "lrw(serpent)",
2706 .test
= alg_test_skcipher
,
2710 .vecs
= serpent_lrw_enc_tv_template
,
2711 .count
= SERPENT_LRW_ENC_TEST_VECTORS
2714 .vecs
= serpent_lrw_dec_tv_template
,
2715 .count
= SERPENT_LRW_DEC_TEST_VECTORS
2720 .alg
= "lrw(twofish)",
2721 .test
= alg_test_skcipher
,
2725 .vecs
= tf_lrw_enc_tv_template
,
2726 .count
= TF_LRW_ENC_TEST_VECTORS
2729 .vecs
= tf_lrw_dec_tv_template
,
2730 .count
= TF_LRW_DEC_TEST_VECTORS
2736 .test
= alg_test_comp
,
2741 .vecs
= lzo_comp_tv_template
,
2742 .count
= LZO_COMP_TEST_VECTORS
2745 .vecs
= lzo_decomp_tv_template
,
2746 .count
= LZO_DECOMP_TEST_VECTORS
2752 .test
= alg_test_hash
,
2755 .vecs
= md4_tv_template
,
2756 .count
= MD4_TEST_VECTORS
2761 .test
= alg_test_hash
,
2764 .vecs
= md5_tv_template
,
2765 .count
= MD5_TEST_VECTORS
2769 .alg
= "michael_mic",
2770 .test
= alg_test_hash
,
2773 .vecs
= michael_mic_tv_template
,
2774 .count
= MICHAEL_MIC_TEST_VECTORS
2779 .test
= alg_test_skcipher
,
2784 .vecs
= aes_ofb_enc_tv_template
,
2785 .count
= AES_OFB_ENC_TEST_VECTORS
2788 .vecs
= aes_ofb_dec_tv_template
,
2789 .count
= AES_OFB_DEC_TEST_VECTORS
2794 .alg
= "pcbc(fcrypt)",
2795 .test
= alg_test_skcipher
,
2799 .vecs
= fcrypt_pcbc_enc_tv_template
,
2800 .count
= FCRYPT_ENC_TEST_VECTORS
2803 .vecs
= fcrypt_pcbc_dec_tv_template
,
2804 .count
= FCRYPT_DEC_TEST_VECTORS
2809 .alg
= "rfc3686(ctr(aes))",
2810 .test
= alg_test_skcipher
,
2815 .vecs
= aes_ctr_rfc3686_enc_tv_template
,
2816 .count
= AES_CTR_3686_ENC_TEST_VECTORS
2819 .vecs
= aes_ctr_rfc3686_dec_tv_template
,
2820 .count
= AES_CTR_3686_DEC_TEST_VECTORS
2825 .alg
= "rfc4106(gcm(aes))",
2826 .test
= alg_test_aead
,
2830 .vecs
= aes_gcm_rfc4106_enc_tv_template
,
2831 .count
= AES_GCM_4106_ENC_TEST_VECTORS
2834 .vecs
= aes_gcm_rfc4106_dec_tv_template
,
2835 .count
= AES_GCM_4106_DEC_TEST_VECTORS
2840 .alg
= "rfc4309(ccm(aes))",
2841 .test
= alg_test_aead
,
2846 .vecs
= aes_ccm_rfc4309_enc_tv_template
,
2847 .count
= AES_CCM_4309_ENC_TEST_VECTORS
2850 .vecs
= aes_ccm_rfc4309_dec_tv_template
,
2851 .count
= AES_CCM_4309_DEC_TEST_VECTORS
2856 .alg
= "rfc4543(gcm(aes))",
2857 .test
= alg_test_aead
,
2861 .vecs
= aes_gcm_rfc4543_enc_tv_template
,
2862 .count
= AES_GCM_4543_ENC_TEST_VECTORS
2865 .vecs
= aes_gcm_rfc4543_dec_tv_template
,
2866 .count
= AES_GCM_4543_DEC_TEST_VECTORS
2872 .test
= alg_test_hash
,
2875 .vecs
= rmd128_tv_template
,
2876 .count
= RMD128_TEST_VECTORS
2881 .test
= alg_test_hash
,
2884 .vecs
= rmd160_tv_template
,
2885 .count
= RMD160_TEST_VECTORS
2890 .test
= alg_test_hash
,
2893 .vecs
= rmd256_tv_template
,
2894 .count
= RMD256_TEST_VECTORS
2899 .test
= alg_test_hash
,
2902 .vecs
= rmd320_tv_template
,
2903 .count
= RMD320_TEST_VECTORS
2908 .test
= alg_test_skcipher
,
2912 .vecs
= salsa20_stream_enc_tv_template
,
2913 .count
= SALSA20_STREAM_ENC_TEST_VECTORS
2919 .test
= alg_test_hash
,
2923 .vecs
= sha1_tv_template
,
2924 .count
= SHA1_TEST_VECTORS
2929 .test
= alg_test_hash
,
2933 .vecs
= sha224_tv_template
,
2934 .count
= SHA224_TEST_VECTORS
2939 .test
= alg_test_hash
,
2943 .vecs
= sha256_tv_template
,
2944 .count
= SHA256_TEST_VECTORS
2949 .test
= alg_test_hash
,
2953 .vecs
= sha384_tv_template
,
2954 .count
= SHA384_TEST_VECTORS
2959 .test
= alg_test_hash
,
2963 .vecs
= sha512_tv_template
,
2964 .count
= SHA512_TEST_VECTORS
2969 .test
= alg_test_hash
,
2972 .vecs
= tgr128_tv_template
,
2973 .count
= TGR128_TEST_VECTORS
2978 .test
= alg_test_hash
,
2981 .vecs
= tgr160_tv_template
,
2982 .count
= TGR160_TEST_VECTORS
2987 .test
= alg_test_hash
,
2990 .vecs
= tgr192_tv_template
,
2991 .count
= TGR192_TEST_VECTORS
2996 .test
= alg_test_hash
,
2999 .vecs
= aes_vmac128_tv_template
,
3000 .count
= VMAC_AES_TEST_VECTORS
3005 .test
= alg_test_hash
,
3008 .vecs
= wp256_tv_template
,
3009 .count
= WP256_TEST_VECTORS
3014 .test
= alg_test_hash
,
3017 .vecs
= wp384_tv_template
,
3018 .count
= WP384_TEST_VECTORS
3023 .test
= alg_test_hash
,
3026 .vecs
= wp512_tv_template
,
3027 .count
= WP512_TEST_VECTORS
3032 .test
= alg_test_hash
,
3035 .vecs
= aes_xcbc128_tv_template
,
3036 .count
= XCBC_AES_TEST_VECTORS
3041 .test
= alg_test_skcipher
,
3046 .vecs
= aes_xts_enc_tv_template
,
3047 .count
= AES_XTS_ENC_TEST_VECTORS
3050 .vecs
= aes_xts_dec_tv_template
,
3051 .count
= AES_XTS_DEC_TEST_VECTORS
3056 .alg
= "xts(camellia)",
3057 .test
= alg_test_skcipher
,
3061 .vecs
= camellia_xts_enc_tv_template
,
3062 .count
= CAMELLIA_XTS_ENC_TEST_VECTORS
3065 .vecs
= camellia_xts_dec_tv_template
,
3066 .count
= CAMELLIA_XTS_DEC_TEST_VECTORS
3071 .alg
= "xts(cast6)",
3072 .test
= alg_test_skcipher
,
3076 .vecs
= cast6_xts_enc_tv_template
,
3077 .count
= CAST6_XTS_ENC_TEST_VECTORS
3080 .vecs
= cast6_xts_dec_tv_template
,
3081 .count
= CAST6_XTS_DEC_TEST_VECTORS
3086 .alg
= "xts(serpent)",
3087 .test
= alg_test_skcipher
,
3091 .vecs
= serpent_xts_enc_tv_template
,
3092 .count
= SERPENT_XTS_ENC_TEST_VECTORS
3095 .vecs
= serpent_xts_dec_tv_template
,
3096 .count
= SERPENT_XTS_DEC_TEST_VECTORS
3101 .alg
= "xts(twofish)",
3102 .test
= alg_test_skcipher
,
3106 .vecs
= tf_xts_enc_tv_template
,
3107 .count
= TF_XTS_ENC_TEST_VECTORS
3110 .vecs
= tf_xts_dec_tv_template
,
3111 .count
= TF_XTS_DEC_TEST_VECTORS
3117 .test
= alg_test_pcomp
,
3122 .vecs
= zlib_comp_tv_template
,
3123 .count
= ZLIB_COMP_TEST_VECTORS
3126 .vecs
= zlib_decomp_tv_template
,
3127 .count
= ZLIB_DECOMP_TEST_VECTORS
3134 static bool alg_test_descs_checked
;
3136 static void alg_test_descs_check_order(void)
3140 /* only check once */
3141 if (alg_test_descs_checked
)
3144 alg_test_descs_checked
= true;
3146 for (i
= 1; i
< ARRAY_SIZE(alg_test_descs
); i
++) {
3147 int diff
= strcmp(alg_test_descs
[i
- 1].alg
,
3148 alg_test_descs
[i
].alg
);
3150 if (WARN_ON(diff
> 0)) {
3151 pr_warn("testmgr: alg_test_descs entries in wrong order: '%s' before '%s'\n",
3152 alg_test_descs
[i
- 1].alg
,
3153 alg_test_descs
[i
].alg
);
3156 if (WARN_ON(diff
== 0)) {
3157 pr_warn("testmgr: duplicate alg_test_descs entry: '%s'\n",
3158 alg_test_descs
[i
].alg
);
3163 static int alg_find_test(const char *alg
)
3166 int end
= ARRAY_SIZE(alg_test_descs
);
3168 while (start
< end
) {
3169 int i
= (start
+ end
) / 2;
3170 int diff
= strcmp(alg_test_descs
[i
].alg
, alg
);
3188 int alg_test(const char *driver
, const char *alg
, u32 type
, u32 mask
)
3194 alg_test_descs_check_order();
3196 if ((type
& CRYPTO_ALG_TYPE_MASK
) == CRYPTO_ALG_TYPE_CIPHER
) {
3197 char nalg
[CRYPTO_MAX_ALG_NAME
];
3199 if (snprintf(nalg
, sizeof(nalg
), "ecb(%s)", alg
) >=
3201 return -ENAMETOOLONG
;
3203 i
= alg_find_test(nalg
);
3207 if (fips_enabled
&& !alg_test_descs
[i
].fips_allowed
)
3210 rc
= alg_test_cipher(alg_test_descs
+ i
, driver
, type
, mask
);
3214 i
= alg_find_test(alg
);
3215 j
= alg_find_test(driver
);
3219 if (fips_enabled
&& ((i
>= 0 && !alg_test_descs
[i
].fips_allowed
) ||
3220 (j
>= 0 && !alg_test_descs
[j
].fips_allowed
)))
3225 rc
|= alg_test_descs
[i
].test(alg_test_descs
+ i
, driver
,
3228 rc
|= alg_test_descs
[j
].test(alg_test_descs
+ j
, driver
,
3232 if (fips_enabled
&& rc
)
3233 panic("%s: %s alg self test failed in fips mode!\n", driver
, alg
);
3235 if (fips_enabled
&& !rc
)
3236 printk(KERN_INFO
"alg: self-tests for %s (%s) passed\n",
3242 printk(KERN_INFO
"alg: No test for %s (%s)\n", alg
, driver
);
3248 #endif /* CONFIG_CRYPTO_MANAGER_DISABLE_TESTS */
3250 EXPORT_SYMBOL_GPL(alg_test
);