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
2050 .test
= alg_test_hash
,
2054 .vecs
= crct10dif_tv_template
,
2055 .count
= CRCT10DIF_TEST_VECTORS
2059 .alg
= "cryptd(__driver-cbc-aes-aesni)",
2060 .test
= alg_test_null
,
2063 .alg
= "cryptd(__driver-cbc-camellia-aesni)",
2064 .test
= alg_test_null
,
2066 .alg
= "cryptd(__driver-cbc-camellia-aesni-avx2)",
2067 .test
= alg_test_null
,
2069 .alg
= "cryptd(__driver-cbc-serpent-avx2)",
2070 .test
= alg_test_null
,
2072 .alg
= "cryptd(__driver-ecb-aes-aesni)",
2073 .test
= alg_test_null
,
2076 .alg
= "cryptd(__driver-ecb-camellia-aesni)",
2077 .test
= alg_test_null
,
2079 .alg
= "cryptd(__driver-ecb-camellia-aesni-avx2)",
2080 .test
= alg_test_null
,
2082 .alg
= "cryptd(__driver-ecb-cast5-avx)",
2083 .test
= alg_test_null
,
2085 .alg
= "cryptd(__driver-ecb-cast6-avx)",
2086 .test
= alg_test_null
,
2088 .alg
= "cryptd(__driver-ecb-serpent-avx)",
2089 .test
= alg_test_null
,
2091 .alg
= "cryptd(__driver-ecb-serpent-avx2)",
2092 .test
= alg_test_null
,
2094 .alg
= "cryptd(__driver-ecb-serpent-sse2)",
2095 .test
= alg_test_null
,
2097 .alg
= "cryptd(__driver-ecb-twofish-avx)",
2098 .test
= alg_test_null
,
2100 .alg
= "cryptd(__driver-gcm-aes-aesni)",
2101 .test
= alg_test_null
,
2104 .alg
= "cryptd(__ghash-pclmulqdqni)",
2105 .test
= alg_test_null
,
2109 .test
= alg_test_skcipher
,
2114 .vecs
= aes_ctr_enc_tv_template
,
2115 .count
= AES_CTR_ENC_TEST_VECTORS
2118 .vecs
= aes_ctr_dec_tv_template
,
2119 .count
= AES_CTR_DEC_TEST_VECTORS
2124 .alg
= "ctr(blowfish)",
2125 .test
= alg_test_skcipher
,
2129 .vecs
= bf_ctr_enc_tv_template
,
2130 .count
= BF_CTR_ENC_TEST_VECTORS
2133 .vecs
= bf_ctr_dec_tv_template
,
2134 .count
= BF_CTR_DEC_TEST_VECTORS
2139 .alg
= "ctr(camellia)",
2140 .test
= alg_test_skcipher
,
2144 .vecs
= camellia_ctr_enc_tv_template
,
2145 .count
= CAMELLIA_CTR_ENC_TEST_VECTORS
2148 .vecs
= camellia_ctr_dec_tv_template
,
2149 .count
= CAMELLIA_CTR_DEC_TEST_VECTORS
2154 .alg
= "ctr(cast5)",
2155 .test
= alg_test_skcipher
,
2159 .vecs
= cast5_ctr_enc_tv_template
,
2160 .count
= CAST5_CTR_ENC_TEST_VECTORS
2163 .vecs
= cast5_ctr_dec_tv_template
,
2164 .count
= CAST5_CTR_DEC_TEST_VECTORS
2169 .alg
= "ctr(cast6)",
2170 .test
= alg_test_skcipher
,
2174 .vecs
= cast6_ctr_enc_tv_template
,
2175 .count
= CAST6_CTR_ENC_TEST_VECTORS
2178 .vecs
= cast6_ctr_dec_tv_template
,
2179 .count
= CAST6_CTR_DEC_TEST_VECTORS
2185 .test
= alg_test_skcipher
,
2189 .vecs
= des_ctr_enc_tv_template
,
2190 .count
= DES_CTR_ENC_TEST_VECTORS
2193 .vecs
= des_ctr_dec_tv_template
,
2194 .count
= DES_CTR_DEC_TEST_VECTORS
2199 .alg
= "ctr(des3_ede)",
2200 .test
= alg_test_skcipher
,
2204 .vecs
= des3_ede_ctr_enc_tv_template
,
2205 .count
= DES3_EDE_CTR_ENC_TEST_VECTORS
2208 .vecs
= des3_ede_ctr_dec_tv_template
,
2209 .count
= DES3_EDE_CTR_DEC_TEST_VECTORS
2214 .alg
= "ctr(serpent)",
2215 .test
= alg_test_skcipher
,
2219 .vecs
= serpent_ctr_enc_tv_template
,
2220 .count
= SERPENT_CTR_ENC_TEST_VECTORS
2223 .vecs
= serpent_ctr_dec_tv_template
,
2224 .count
= SERPENT_CTR_DEC_TEST_VECTORS
2229 .alg
= "ctr(twofish)",
2230 .test
= alg_test_skcipher
,
2234 .vecs
= tf_ctr_enc_tv_template
,
2235 .count
= TF_CTR_ENC_TEST_VECTORS
2238 .vecs
= tf_ctr_dec_tv_template
,
2239 .count
= TF_CTR_DEC_TEST_VECTORS
2244 .alg
= "cts(cbc(aes))",
2245 .test
= alg_test_skcipher
,
2249 .vecs
= cts_mode_enc_tv_template
,
2250 .count
= CTS_MODE_ENC_TEST_VECTORS
2253 .vecs
= cts_mode_dec_tv_template
,
2254 .count
= CTS_MODE_DEC_TEST_VECTORS
2260 .test
= alg_test_comp
,
2265 .vecs
= deflate_comp_tv_template
,
2266 .count
= DEFLATE_COMP_TEST_VECTORS
2269 .vecs
= deflate_decomp_tv_template
,
2270 .count
= DEFLATE_DECOMP_TEST_VECTORS
2275 .alg
= "digest_null",
2276 .test
= alg_test_null
,
2278 .alg
= "ecb(__aes-aesni)",
2279 .test
= alg_test_null
,
2283 .test
= alg_test_skcipher
,
2288 .vecs
= aes_enc_tv_template
,
2289 .count
= AES_ENC_TEST_VECTORS
2292 .vecs
= aes_dec_tv_template
,
2293 .count
= AES_DEC_TEST_VECTORS
2298 .alg
= "ecb(anubis)",
2299 .test
= alg_test_skcipher
,
2303 .vecs
= anubis_enc_tv_template
,
2304 .count
= ANUBIS_ENC_TEST_VECTORS
2307 .vecs
= anubis_dec_tv_template
,
2308 .count
= ANUBIS_DEC_TEST_VECTORS
2314 .test
= alg_test_skcipher
,
2318 .vecs
= arc4_enc_tv_template
,
2319 .count
= ARC4_ENC_TEST_VECTORS
2322 .vecs
= arc4_dec_tv_template
,
2323 .count
= ARC4_DEC_TEST_VECTORS
2328 .alg
= "ecb(blowfish)",
2329 .test
= alg_test_skcipher
,
2333 .vecs
= bf_enc_tv_template
,
2334 .count
= BF_ENC_TEST_VECTORS
2337 .vecs
= bf_dec_tv_template
,
2338 .count
= BF_DEC_TEST_VECTORS
2343 .alg
= "ecb(camellia)",
2344 .test
= alg_test_skcipher
,
2348 .vecs
= camellia_enc_tv_template
,
2349 .count
= CAMELLIA_ENC_TEST_VECTORS
2352 .vecs
= camellia_dec_tv_template
,
2353 .count
= CAMELLIA_DEC_TEST_VECTORS
2358 .alg
= "ecb(cast5)",
2359 .test
= alg_test_skcipher
,
2363 .vecs
= cast5_enc_tv_template
,
2364 .count
= CAST5_ENC_TEST_VECTORS
2367 .vecs
= cast5_dec_tv_template
,
2368 .count
= CAST5_DEC_TEST_VECTORS
2373 .alg
= "ecb(cast6)",
2374 .test
= alg_test_skcipher
,
2378 .vecs
= cast6_enc_tv_template
,
2379 .count
= CAST6_ENC_TEST_VECTORS
2382 .vecs
= cast6_dec_tv_template
,
2383 .count
= CAST6_DEC_TEST_VECTORS
2388 .alg
= "ecb(cipher_null)",
2389 .test
= alg_test_null
,
2392 .test
= alg_test_skcipher
,
2397 .vecs
= des_enc_tv_template
,
2398 .count
= DES_ENC_TEST_VECTORS
2401 .vecs
= des_dec_tv_template
,
2402 .count
= DES_DEC_TEST_VECTORS
2407 .alg
= "ecb(des3_ede)",
2408 .test
= alg_test_skcipher
,
2413 .vecs
= des3_ede_enc_tv_template
,
2414 .count
= DES3_EDE_ENC_TEST_VECTORS
2417 .vecs
= des3_ede_dec_tv_template
,
2418 .count
= DES3_EDE_DEC_TEST_VECTORS
2423 .alg
= "ecb(fcrypt)",
2424 .test
= alg_test_skcipher
,
2428 .vecs
= fcrypt_pcbc_enc_tv_template
,
2432 .vecs
= fcrypt_pcbc_dec_tv_template
,
2438 .alg
= "ecb(khazad)",
2439 .test
= alg_test_skcipher
,
2443 .vecs
= khazad_enc_tv_template
,
2444 .count
= KHAZAD_ENC_TEST_VECTORS
2447 .vecs
= khazad_dec_tv_template
,
2448 .count
= KHAZAD_DEC_TEST_VECTORS
2454 .test
= alg_test_skcipher
,
2458 .vecs
= seed_enc_tv_template
,
2459 .count
= SEED_ENC_TEST_VECTORS
2462 .vecs
= seed_dec_tv_template
,
2463 .count
= SEED_DEC_TEST_VECTORS
2468 .alg
= "ecb(serpent)",
2469 .test
= alg_test_skcipher
,
2473 .vecs
= serpent_enc_tv_template
,
2474 .count
= SERPENT_ENC_TEST_VECTORS
2477 .vecs
= serpent_dec_tv_template
,
2478 .count
= SERPENT_DEC_TEST_VECTORS
2484 .test
= alg_test_skcipher
,
2488 .vecs
= tea_enc_tv_template
,
2489 .count
= TEA_ENC_TEST_VECTORS
2492 .vecs
= tea_dec_tv_template
,
2493 .count
= TEA_DEC_TEST_VECTORS
2498 .alg
= "ecb(tnepres)",
2499 .test
= alg_test_skcipher
,
2503 .vecs
= tnepres_enc_tv_template
,
2504 .count
= TNEPRES_ENC_TEST_VECTORS
2507 .vecs
= tnepres_dec_tv_template
,
2508 .count
= TNEPRES_DEC_TEST_VECTORS
2513 .alg
= "ecb(twofish)",
2514 .test
= alg_test_skcipher
,
2518 .vecs
= tf_enc_tv_template
,
2519 .count
= TF_ENC_TEST_VECTORS
2522 .vecs
= tf_dec_tv_template
,
2523 .count
= TF_DEC_TEST_VECTORS
2529 .test
= alg_test_skcipher
,
2533 .vecs
= xeta_enc_tv_template
,
2534 .count
= XETA_ENC_TEST_VECTORS
2537 .vecs
= xeta_dec_tv_template
,
2538 .count
= XETA_DEC_TEST_VECTORS
2544 .test
= alg_test_skcipher
,
2548 .vecs
= xtea_enc_tv_template
,
2549 .count
= XTEA_ENC_TEST_VECTORS
2552 .vecs
= xtea_dec_tv_template
,
2553 .count
= XTEA_DEC_TEST_VECTORS
2559 .test
= alg_test_aead
,
2564 .vecs
= aes_gcm_enc_tv_template
,
2565 .count
= AES_GCM_ENC_TEST_VECTORS
2568 .vecs
= aes_gcm_dec_tv_template
,
2569 .count
= AES_GCM_DEC_TEST_VECTORS
2575 .test
= alg_test_hash
,
2579 .vecs
= ghash_tv_template
,
2580 .count
= GHASH_TEST_VECTORS
2584 .alg
= "hmac(crc32)",
2585 .test
= alg_test_hash
,
2588 .vecs
= bfin_crc_tv_template
,
2589 .count
= BFIN_CRC_TEST_VECTORS
2594 .test
= alg_test_hash
,
2597 .vecs
= hmac_md5_tv_template
,
2598 .count
= HMAC_MD5_TEST_VECTORS
2602 .alg
= "hmac(rmd128)",
2603 .test
= alg_test_hash
,
2606 .vecs
= hmac_rmd128_tv_template
,
2607 .count
= HMAC_RMD128_TEST_VECTORS
2611 .alg
= "hmac(rmd160)",
2612 .test
= alg_test_hash
,
2615 .vecs
= hmac_rmd160_tv_template
,
2616 .count
= HMAC_RMD160_TEST_VECTORS
2620 .alg
= "hmac(sha1)",
2621 .test
= alg_test_hash
,
2625 .vecs
= hmac_sha1_tv_template
,
2626 .count
= HMAC_SHA1_TEST_VECTORS
2630 .alg
= "hmac(sha224)",
2631 .test
= alg_test_hash
,
2635 .vecs
= hmac_sha224_tv_template
,
2636 .count
= HMAC_SHA224_TEST_VECTORS
2640 .alg
= "hmac(sha256)",
2641 .test
= alg_test_hash
,
2645 .vecs
= hmac_sha256_tv_template
,
2646 .count
= HMAC_SHA256_TEST_VECTORS
2650 .alg
= "hmac(sha384)",
2651 .test
= alg_test_hash
,
2655 .vecs
= hmac_sha384_tv_template
,
2656 .count
= HMAC_SHA384_TEST_VECTORS
2660 .alg
= "hmac(sha512)",
2661 .test
= alg_test_hash
,
2665 .vecs
= hmac_sha512_tv_template
,
2666 .count
= HMAC_SHA512_TEST_VECTORS
2671 .test
= alg_test_skcipher
,
2675 .vecs
= aes_lrw_enc_tv_template
,
2676 .count
= AES_LRW_ENC_TEST_VECTORS
2679 .vecs
= aes_lrw_dec_tv_template
,
2680 .count
= AES_LRW_DEC_TEST_VECTORS
2685 .alg
= "lrw(camellia)",
2686 .test
= alg_test_skcipher
,
2690 .vecs
= camellia_lrw_enc_tv_template
,
2691 .count
= CAMELLIA_LRW_ENC_TEST_VECTORS
2694 .vecs
= camellia_lrw_dec_tv_template
,
2695 .count
= CAMELLIA_LRW_DEC_TEST_VECTORS
2700 .alg
= "lrw(cast6)",
2701 .test
= alg_test_skcipher
,
2705 .vecs
= cast6_lrw_enc_tv_template
,
2706 .count
= CAST6_LRW_ENC_TEST_VECTORS
2709 .vecs
= cast6_lrw_dec_tv_template
,
2710 .count
= CAST6_LRW_DEC_TEST_VECTORS
2715 .alg
= "lrw(serpent)",
2716 .test
= alg_test_skcipher
,
2720 .vecs
= serpent_lrw_enc_tv_template
,
2721 .count
= SERPENT_LRW_ENC_TEST_VECTORS
2724 .vecs
= serpent_lrw_dec_tv_template
,
2725 .count
= SERPENT_LRW_DEC_TEST_VECTORS
2730 .alg
= "lrw(twofish)",
2731 .test
= alg_test_skcipher
,
2735 .vecs
= tf_lrw_enc_tv_template
,
2736 .count
= TF_LRW_ENC_TEST_VECTORS
2739 .vecs
= tf_lrw_dec_tv_template
,
2740 .count
= TF_LRW_DEC_TEST_VECTORS
2746 .test
= alg_test_comp
,
2751 .vecs
= lzo_comp_tv_template
,
2752 .count
= LZO_COMP_TEST_VECTORS
2755 .vecs
= lzo_decomp_tv_template
,
2756 .count
= LZO_DECOMP_TEST_VECTORS
2762 .test
= alg_test_hash
,
2765 .vecs
= md4_tv_template
,
2766 .count
= MD4_TEST_VECTORS
2771 .test
= alg_test_hash
,
2774 .vecs
= md5_tv_template
,
2775 .count
= MD5_TEST_VECTORS
2779 .alg
= "michael_mic",
2780 .test
= alg_test_hash
,
2783 .vecs
= michael_mic_tv_template
,
2784 .count
= MICHAEL_MIC_TEST_VECTORS
2789 .test
= alg_test_skcipher
,
2794 .vecs
= aes_ofb_enc_tv_template
,
2795 .count
= AES_OFB_ENC_TEST_VECTORS
2798 .vecs
= aes_ofb_dec_tv_template
,
2799 .count
= AES_OFB_DEC_TEST_VECTORS
2804 .alg
= "pcbc(fcrypt)",
2805 .test
= alg_test_skcipher
,
2809 .vecs
= fcrypt_pcbc_enc_tv_template
,
2810 .count
= FCRYPT_ENC_TEST_VECTORS
2813 .vecs
= fcrypt_pcbc_dec_tv_template
,
2814 .count
= FCRYPT_DEC_TEST_VECTORS
2819 .alg
= "rfc3686(ctr(aes))",
2820 .test
= alg_test_skcipher
,
2825 .vecs
= aes_ctr_rfc3686_enc_tv_template
,
2826 .count
= AES_CTR_3686_ENC_TEST_VECTORS
2829 .vecs
= aes_ctr_rfc3686_dec_tv_template
,
2830 .count
= AES_CTR_3686_DEC_TEST_VECTORS
2835 .alg
= "rfc4106(gcm(aes))",
2836 .test
= alg_test_aead
,
2840 .vecs
= aes_gcm_rfc4106_enc_tv_template
,
2841 .count
= AES_GCM_4106_ENC_TEST_VECTORS
2844 .vecs
= aes_gcm_rfc4106_dec_tv_template
,
2845 .count
= AES_GCM_4106_DEC_TEST_VECTORS
2850 .alg
= "rfc4309(ccm(aes))",
2851 .test
= alg_test_aead
,
2856 .vecs
= aes_ccm_rfc4309_enc_tv_template
,
2857 .count
= AES_CCM_4309_ENC_TEST_VECTORS
2860 .vecs
= aes_ccm_rfc4309_dec_tv_template
,
2861 .count
= AES_CCM_4309_DEC_TEST_VECTORS
2866 .alg
= "rfc4543(gcm(aes))",
2867 .test
= alg_test_aead
,
2871 .vecs
= aes_gcm_rfc4543_enc_tv_template
,
2872 .count
= AES_GCM_4543_ENC_TEST_VECTORS
2875 .vecs
= aes_gcm_rfc4543_dec_tv_template
,
2876 .count
= AES_GCM_4543_DEC_TEST_VECTORS
2882 .test
= alg_test_hash
,
2885 .vecs
= rmd128_tv_template
,
2886 .count
= RMD128_TEST_VECTORS
2891 .test
= alg_test_hash
,
2894 .vecs
= rmd160_tv_template
,
2895 .count
= RMD160_TEST_VECTORS
2900 .test
= alg_test_hash
,
2903 .vecs
= rmd256_tv_template
,
2904 .count
= RMD256_TEST_VECTORS
2909 .test
= alg_test_hash
,
2912 .vecs
= rmd320_tv_template
,
2913 .count
= RMD320_TEST_VECTORS
2918 .test
= alg_test_skcipher
,
2922 .vecs
= salsa20_stream_enc_tv_template
,
2923 .count
= SALSA20_STREAM_ENC_TEST_VECTORS
2929 .test
= alg_test_hash
,
2933 .vecs
= sha1_tv_template
,
2934 .count
= SHA1_TEST_VECTORS
2939 .test
= alg_test_hash
,
2943 .vecs
= sha224_tv_template
,
2944 .count
= SHA224_TEST_VECTORS
2949 .test
= alg_test_hash
,
2953 .vecs
= sha256_tv_template
,
2954 .count
= SHA256_TEST_VECTORS
2959 .test
= alg_test_hash
,
2963 .vecs
= sha384_tv_template
,
2964 .count
= SHA384_TEST_VECTORS
2969 .test
= alg_test_hash
,
2973 .vecs
= sha512_tv_template
,
2974 .count
= SHA512_TEST_VECTORS
2979 .test
= alg_test_hash
,
2982 .vecs
= tgr128_tv_template
,
2983 .count
= TGR128_TEST_VECTORS
2988 .test
= alg_test_hash
,
2991 .vecs
= tgr160_tv_template
,
2992 .count
= TGR160_TEST_VECTORS
2997 .test
= alg_test_hash
,
3000 .vecs
= tgr192_tv_template
,
3001 .count
= TGR192_TEST_VECTORS
3006 .test
= alg_test_hash
,
3009 .vecs
= aes_vmac128_tv_template
,
3010 .count
= VMAC_AES_TEST_VECTORS
3015 .test
= alg_test_hash
,
3018 .vecs
= wp256_tv_template
,
3019 .count
= WP256_TEST_VECTORS
3024 .test
= alg_test_hash
,
3027 .vecs
= wp384_tv_template
,
3028 .count
= WP384_TEST_VECTORS
3033 .test
= alg_test_hash
,
3036 .vecs
= wp512_tv_template
,
3037 .count
= WP512_TEST_VECTORS
3042 .test
= alg_test_hash
,
3045 .vecs
= aes_xcbc128_tv_template
,
3046 .count
= XCBC_AES_TEST_VECTORS
3051 .test
= alg_test_skcipher
,
3056 .vecs
= aes_xts_enc_tv_template
,
3057 .count
= AES_XTS_ENC_TEST_VECTORS
3060 .vecs
= aes_xts_dec_tv_template
,
3061 .count
= AES_XTS_DEC_TEST_VECTORS
3066 .alg
= "xts(camellia)",
3067 .test
= alg_test_skcipher
,
3071 .vecs
= camellia_xts_enc_tv_template
,
3072 .count
= CAMELLIA_XTS_ENC_TEST_VECTORS
3075 .vecs
= camellia_xts_dec_tv_template
,
3076 .count
= CAMELLIA_XTS_DEC_TEST_VECTORS
3081 .alg
= "xts(cast6)",
3082 .test
= alg_test_skcipher
,
3086 .vecs
= cast6_xts_enc_tv_template
,
3087 .count
= CAST6_XTS_ENC_TEST_VECTORS
3090 .vecs
= cast6_xts_dec_tv_template
,
3091 .count
= CAST6_XTS_DEC_TEST_VECTORS
3096 .alg
= "xts(serpent)",
3097 .test
= alg_test_skcipher
,
3101 .vecs
= serpent_xts_enc_tv_template
,
3102 .count
= SERPENT_XTS_ENC_TEST_VECTORS
3105 .vecs
= serpent_xts_dec_tv_template
,
3106 .count
= SERPENT_XTS_DEC_TEST_VECTORS
3111 .alg
= "xts(twofish)",
3112 .test
= alg_test_skcipher
,
3116 .vecs
= tf_xts_enc_tv_template
,
3117 .count
= TF_XTS_ENC_TEST_VECTORS
3120 .vecs
= tf_xts_dec_tv_template
,
3121 .count
= TF_XTS_DEC_TEST_VECTORS
3127 .test
= alg_test_pcomp
,
3132 .vecs
= zlib_comp_tv_template
,
3133 .count
= ZLIB_COMP_TEST_VECTORS
3136 .vecs
= zlib_decomp_tv_template
,
3137 .count
= ZLIB_DECOMP_TEST_VECTORS
3144 static bool alg_test_descs_checked
;
3146 static void alg_test_descs_check_order(void)
3150 /* only check once */
3151 if (alg_test_descs_checked
)
3154 alg_test_descs_checked
= true;
3156 for (i
= 1; i
< ARRAY_SIZE(alg_test_descs
); i
++) {
3157 int diff
= strcmp(alg_test_descs
[i
- 1].alg
,
3158 alg_test_descs
[i
].alg
);
3160 if (WARN_ON(diff
> 0)) {
3161 pr_warn("testmgr: alg_test_descs entries in wrong order: '%s' before '%s'\n",
3162 alg_test_descs
[i
- 1].alg
,
3163 alg_test_descs
[i
].alg
);
3166 if (WARN_ON(diff
== 0)) {
3167 pr_warn("testmgr: duplicate alg_test_descs entry: '%s'\n",
3168 alg_test_descs
[i
].alg
);
3173 static int alg_find_test(const char *alg
)
3176 int end
= ARRAY_SIZE(alg_test_descs
);
3178 while (start
< end
) {
3179 int i
= (start
+ end
) / 2;
3180 int diff
= strcmp(alg_test_descs
[i
].alg
, alg
);
3198 int alg_test(const char *driver
, const char *alg
, u32 type
, u32 mask
)
3204 alg_test_descs_check_order();
3206 if ((type
& CRYPTO_ALG_TYPE_MASK
) == CRYPTO_ALG_TYPE_CIPHER
) {
3207 char nalg
[CRYPTO_MAX_ALG_NAME
];
3209 if (snprintf(nalg
, sizeof(nalg
), "ecb(%s)", alg
) >=
3211 return -ENAMETOOLONG
;
3213 i
= alg_find_test(nalg
);
3217 if (fips_enabled
&& !alg_test_descs
[i
].fips_allowed
)
3220 rc
= alg_test_cipher(alg_test_descs
+ i
, driver
, type
, mask
);
3224 i
= alg_find_test(alg
);
3225 j
= alg_find_test(driver
);
3229 if (fips_enabled
&& ((i
>= 0 && !alg_test_descs
[i
].fips_allowed
) ||
3230 (j
>= 0 && !alg_test_descs
[j
].fips_allowed
)))
3235 rc
|= alg_test_descs
[i
].test(alg_test_descs
+ i
, driver
,
3237 if (j
>= 0 && j
!= i
)
3238 rc
|= alg_test_descs
[j
].test(alg_test_descs
+ j
, driver
,
3242 if (fips_enabled
&& rc
)
3243 panic("%s: %s alg self test failed in fips mode!\n", driver
, alg
);
3245 if (fips_enabled
&& !rc
)
3246 printk(KERN_INFO
"alg: self-tests for %s (%s) passed\n",
3252 printk(KERN_INFO
"alg: No test for %s (%s)\n", alg
, driver
);
3258 #endif /* CONFIG_CRYPTO_MANAGER_DISABLE_TESTS */
3260 EXPORT_SYMBOL_GPL(alg_test
);