2 * Quick & dirty crypto testing module.
4 * This will only exist until we have a better testing mechanism
5 * (e.g. a char device).
7 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
8 * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
9 * Copyright (c) 2007 Nokia Siemens Networks
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the Free
13 * Software Foundation; either version 2 of the License, or (at your option)
18 #include <linux/err.h>
19 #include <linux/init.h>
20 #include <linux/module.h>
22 #include <linux/slab.h>
23 #include <linux/scatterlist.h>
24 #include <linux/string.h>
25 #include <linux/crypto.h>
26 #include <linux/highmem.h>
27 #include <linux/moduleparam.h>
28 #include <linux/jiffies.h>
29 #include <linux/timex.h>
30 #include <linux/interrupt.h>
34 * Need to kmalloc() memory for testing kmap().
36 #define TVMEMSIZE 16384
37 #define XBUFSIZE 32768
40 * Indexes into the xbuf to simulate cross-page access.
52 * Used by test_cipher()
57 struct tcrypt_result {
58 struct completion completion;
62 static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 };
65 * Used by test_cipher_speed()
67 static unsigned int sec;
74 static char *check[] = {
75 "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256",
76 "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
77 "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
78 "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
79 "camellia", "seed", "salsa20", "rmd128", "rmd160", "lzo", "cts", NULL
82 static void hexdump(unsigned char *buf, unsigned int len)
84 print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
89 static void tcrypt_complete(struct crypto_async_request *req, int err)
91 struct tcrypt_result *res = req->data;
93 if (err == -EINPROGRESS)
97 complete(&res->completion);
100 static void test_hash(char *algo, struct hash_testvec *template,
103 unsigned int i, j, k, temp;
104 struct scatterlist sg[8];
106 struct crypto_hash *tfm;
107 struct hash_desc desc;
111 printk("\ntesting %s\n", algo);
113 tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC);
115 printk("failed to load transform for %s: %ld\n", algo,
123 for (i = 0; i < tcount; i++) {
124 printk("test %u:\n", i + 1);
125 memset(result, 0, 64);
127 hash_buff = kzalloc(template[i].psize, GFP_KERNEL);
131 memcpy(hash_buff, template[i].plaintext, template[i].psize);
132 sg_init_one(&sg[0], hash_buff, template[i].psize);
134 if (template[i].ksize) {
135 ret = crypto_hash_setkey(tfm, template[i].key,
138 printk("setkey() failed ret=%d\n", ret);
144 ret = crypto_hash_digest(&desc, sg, template[i].psize, result);
146 printk("digest () failed ret=%d\n", ret);
151 hexdump(result, crypto_hash_digestsize(tfm));
153 memcmp(result, template[i].digest,
154 crypto_hash_digestsize(tfm)) ?
159 printk("testing %s across pages\n", algo);
161 /* setup the dummy buffer first */
162 memset(xbuf, 0, XBUFSIZE);
165 for (i = 0; i < tcount; i++) {
166 if (template[i].np) {
168 printk("test %u:\n", j);
169 memset(result, 0, 64);
172 sg_init_table(sg, template[i].np);
173 for (k = 0; k < template[i].np; k++) {
174 memcpy(&xbuf[IDX[k]],
175 template[i].plaintext + temp,
177 temp += template[i].tap[k];
178 sg_set_buf(&sg[k], &xbuf[IDX[k]],
182 if (template[i].ksize) {
183 ret = crypto_hash_setkey(tfm, template[i].key,
187 printk("setkey() failed ret=%d\n", ret);
192 ret = crypto_hash_digest(&desc, sg, template[i].psize,
195 printk("digest () failed ret=%d\n", ret);
199 hexdump(result, crypto_hash_digestsize(tfm));
201 memcmp(result, template[i].digest,
202 crypto_hash_digestsize(tfm)) ?
208 crypto_free_hash(tfm);
211 static void test_aead(char *algo, int enc, struct aead_testvec *template,
214 unsigned int ret, i, j, k, temp;
216 struct crypto_aead *tfm;
218 struct aead_request *req;
219 struct scatterlist sg[8];
220 struct scatterlist asg[8];
222 struct tcrypt_result result;
223 unsigned int authsize;
233 printk(KERN_INFO "\ntesting %s %s\n", algo, e);
235 init_completion(&result.completion);
237 tfm = crypto_alloc_aead(algo, 0, 0);
240 printk(KERN_INFO "failed to load transform for %s: %ld\n",
245 req = aead_request_alloc(tfm, GFP_KERNEL);
247 printk(KERN_INFO "failed to allocate request for %s\n", algo);
251 aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
252 tcrypt_complete, &result);
254 for (i = 0, j = 0; i < tcount; i++) {
255 if (!template[i].np) {
256 printk(KERN_INFO "test %u (%d bit key):\n",
257 ++j, template[i].klen * 8);
259 /* some tepmplates have no input data but they will
262 input = kzalloc(template[i].ilen + template[i].rlen, GFP_KERNEL);
266 assoc = kzalloc(template[i].alen, GFP_KERNEL);
272 memcpy(input, template[i].input, template[i].ilen);
273 memcpy(assoc, template[i].assoc, template[i].alen);
275 memcpy(iv, template[i].iv, MAX_IVLEN);
277 memset(iv, 0, MAX_IVLEN);
279 crypto_aead_clear_flags(tfm, ~0);
281 crypto_aead_set_flags(
282 tfm, CRYPTO_TFM_REQ_WEAK_KEY);
285 key = template[i].key;
287 key = kzalloc(template[i].klen, GFP_KERNEL);
289 ret = crypto_aead_setkey(tfm, key,
292 printk(KERN_INFO "setkey() failed flags=%x\n",
293 crypto_aead_get_flags(tfm));
295 if (!template[i].fail)
299 authsize = abs(template[i].rlen - template[i].ilen);
300 ret = crypto_aead_setauthsize(tfm, authsize);
303 "failed to set authsize = %u\n",
308 sg_init_one(&sg[0], input,
309 template[i].ilen + (enc ? authsize : 0));
311 sg_init_one(&asg[0], assoc, template[i].alen);
313 aead_request_set_crypt(req, sg, sg,
314 template[i].ilen, iv);
316 aead_request_set_assoc(req, asg, template[i].alen);
319 crypto_aead_encrypt(req) :
320 crypto_aead_decrypt(req);
327 ret = wait_for_completion_interruptible(
329 if (!ret && !(ret = result.err)) {
330 INIT_COMPLETION(result.completion);
335 printk(KERN_INFO "%s () failed err=%d\n",
340 q = kmap(sg_page(&sg[0])) + sg[0].offset;
341 hexdump(q, template[i].rlen);
343 printk(KERN_INFO "enc/dec: %s\n",
344 memcmp(q, template[i].result,
345 template[i].rlen) ? "fail" : "pass");
346 kunmap(sg_page(&sg[0]));
348 if (!template[i].key)
355 printk(KERN_INFO "\ntesting %s %s across pages (chunking)\n", algo, e);
356 memset(xbuf, 0, XBUFSIZE);
357 memset(axbuf, 0, XBUFSIZE);
359 for (i = 0, j = 0; i < tcount; i++) {
360 if (template[i].np) {
361 printk(KERN_INFO "test %u (%d bit key):\n",
362 ++j, template[i].klen * 8);
365 memcpy(iv, template[i].iv, MAX_IVLEN);
367 memset(iv, 0, MAX_IVLEN);
369 crypto_aead_clear_flags(tfm, ~0);
371 crypto_aead_set_flags(
372 tfm, CRYPTO_TFM_REQ_WEAK_KEY);
373 key = template[i].key;
375 ret = crypto_aead_setkey(tfm, key, template[i].klen);
377 printk(KERN_INFO "setkey() failed flags=%x\n",
378 crypto_aead_get_flags(tfm));
380 if (!template[i].fail)
384 sg_init_table(sg, template[i].np);
385 for (k = 0, temp = 0; k < template[i].np; k++) {
386 memcpy(&xbuf[IDX[k]],
387 template[i].input + temp,
389 temp += template[i].tap[k];
390 sg_set_buf(&sg[k], &xbuf[IDX[k]],
394 authsize = abs(template[i].rlen - template[i].ilen);
395 ret = crypto_aead_setauthsize(tfm, authsize);
398 "failed to set authsize = %u\n",
404 sg[k - 1].length += authsize;
406 sg_init_table(asg, template[i].anp);
407 for (k = 0, temp = 0; k < template[i].anp; k++) {
408 memcpy(&axbuf[IDX[k]],
409 template[i].assoc + temp,
410 template[i].atap[k]);
411 temp += template[i].atap[k];
412 sg_set_buf(&asg[k], &axbuf[IDX[k]],
413 template[i].atap[k]);
416 aead_request_set_crypt(req, sg, sg,
420 aead_request_set_assoc(req, asg, template[i].alen);
423 crypto_aead_encrypt(req) :
424 crypto_aead_decrypt(req);
431 ret = wait_for_completion_interruptible(
433 if (!ret && !(ret = result.err)) {
434 INIT_COMPLETION(result.completion);
439 printk(KERN_INFO "%s () failed err=%d\n",
444 for (k = 0, temp = 0; k < template[i].np; k++) {
445 printk(KERN_INFO "page %u\n", k);
446 q = kmap(sg_page(&sg[k])) + sg[k].offset;
447 hexdump(q, template[i].tap[k]);
448 printk(KERN_INFO "%s\n",
449 memcmp(q, template[i].result + temp,
451 (k < template[i].np - 1 || enc ?
455 temp += template[i].tap[k];
456 kunmap(sg_page(&sg[k]));
462 crypto_free_aead(tfm);
463 aead_request_free(req);
466 static void test_cipher(char *algo, int enc,
467 struct cipher_testvec *template, unsigned int tcount)
469 unsigned int ret, i, j, k, temp;
471 struct crypto_ablkcipher *tfm;
472 struct ablkcipher_request *req;
473 struct scatterlist sg[8];
475 struct tcrypt_result result;
484 printk("\ntesting %s %s\n", algo, e);
486 init_completion(&result.completion);
487 tfm = crypto_alloc_ablkcipher(algo, 0, 0);
490 printk("failed to load transform for %s: %ld\n", algo,
495 req = ablkcipher_request_alloc(tfm, GFP_KERNEL);
497 printk("failed to allocate request for %s\n", algo);
501 ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
502 tcrypt_complete, &result);
505 for (i = 0; i < tcount; i++) {
507 data = kzalloc(template[i].ilen, GFP_KERNEL);
511 memcpy(data, template[i].input, template[i].ilen);
513 memcpy(iv, template[i].iv, MAX_IVLEN);
515 memset(iv, 0, MAX_IVLEN);
517 if (!(template[i].np)) {
519 printk("test %u (%d bit key):\n",
520 j, template[i].klen * 8);
522 crypto_ablkcipher_clear_flags(tfm, ~0);
524 crypto_ablkcipher_set_flags(
525 tfm, CRYPTO_TFM_REQ_WEAK_KEY);
527 ret = crypto_ablkcipher_setkey(tfm, template[i].key,
530 printk("setkey() failed flags=%x\n",
531 crypto_ablkcipher_get_flags(tfm));
533 if (!template[i].fail) {
539 sg_init_one(&sg[0], data, template[i].ilen);
541 ablkcipher_request_set_crypt(req, sg, sg,
542 template[i].ilen, iv);
544 crypto_ablkcipher_encrypt(req) :
545 crypto_ablkcipher_decrypt(req);
552 ret = wait_for_completion_interruptible(
554 if (!ret && !((ret = result.err))) {
555 INIT_COMPLETION(result.completion);
560 printk("%s () failed err=%d\n", e, -ret);
565 q = kmap(sg_page(&sg[0])) + sg[0].offset;
566 hexdump(q, template[i].rlen);
569 memcmp(q, template[i].result,
570 template[i].rlen) ? "fail" : "pass");
571 kunmap(sg_page(&sg[0]));
576 printk("\ntesting %s %s across pages (chunking)\n", algo, e);
577 memset(xbuf, 0, XBUFSIZE);
580 for (i = 0; i < tcount; i++) {
583 memcpy(iv, template[i].iv, MAX_IVLEN);
585 memset(iv, 0, MAX_IVLEN);
587 if (template[i].np) {
589 printk("test %u (%d bit key):\n",
590 j, template[i].klen * 8);
592 crypto_ablkcipher_clear_flags(tfm, ~0);
594 crypto_ablkcipher_set_flags(
595 tfm, CRYPTO_TFM_REQ_WEAK_KEY);
597 ret = crypto_ablkcipher_setkey(tfm, template[i].key,
600 printk("setkey() failed flags=%x\n",
601 crypto_ablkcipher_get_flags(tfm));
603 if (!template[i].fail)
608 sg_init_table(sg, template[i].np);
609 for (k = 0; k < template[i].np; k++) {
610 memcpy(&xbuf[IDX[k]],
611 template[i].input + temp,
613 temp += template[i].tap[k];
614 sg_set_buf(&sg[k], &xbuf[IDX[k]],
618 ablkcipher_request_set_crypt(req, sg, sg,
619 template[i].ilen, iv);
622 crypto_ablkcipher_encrypt(req) :
623 crypto_ablkcipher_decrypt(req);
630 ret = wait_for_completion_interruptible(
632 if (!ret && !((ret = result.err))) {
633 INIT_COMPLETION(result.completion);
638 printk("%s () failed err=%d\n", e, -ret);
643 for (k = 0; k < template[i].np; k++) {
644 printk("page %u\n", k);
645 q = kmap(sg_page(&sg[k])) + sg[k].offset;
646 hexdump(q, template[i].tap[k]);
648 memcmp(q, template[i].result + temp,
649 template[i].tap[k]) ? "fail" :
651 temp += template[i].tap[k];
652 kunmap(sg_page(&sg[k]));
657 crypto_free_ablkcipher(tfm);
658 ablkcipher_request_free(req);
661 static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc, char *p,
664 struct scatterlist sg[1];
665 unsigned long start, end;
669 sg_init_one(sg, p, blen);
671 for (start = jiffies, end = start + sec * HZ, bcount = 0;
672 time_before(jiffies, end); bcount++) {
674 ret = crypto_blkcipher_encrypt(desc, sg, sg, blen);
676 ret = crypto_blkcipher_decrypt(desc, sg, sg, blen);
682 printk("%d operations in %d seconds (%ld bytes)\n",
683 bcount, sec, (long)bcount * blen);
687 static int test_cipher_cycles(struct blkcipher_desc *desc, int enc, char *p,
690 struct scatterlist sg[1];
691 unsigned long cycles = 0;
695 sg_init_one(sg, p, blen);
701 for (i = 0; i < 4; i++) {
703 ret = crypto_blkcipher_encrypt(desc, sg, sg, blen);
705 ret = crypto_blkcipher_decrypt(desc, sg, sg, blen);
711 /* The real thing. */
712 for (i = 0; i < 8; i++) {
715 start = get_cycles();
717 ret = crypto_blkcipher_encrypt(desc, sg, sg, blen);
719 ret = crypto_blkcipher_decrypt(desc, sg, sg, blen);
725 cycles += end - start;
733 printk("1 operation in %lu cycles (%d bytes)\n",
734 (cycles + 4) / 8, blen);
739 static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 };
741 static void test_cipher_speed(char *algo, int enc, unsigned int sec,
742 struct cipher_testvec *template,
743 unsigned int tcount, u8 *keysize)
745 unsigned int ret, i, j, iv_len;
746 unsigned char *key, *p, iv[128];
747 struct crypto_blkcipher *tfm;
748 struct blkcipher_desc desc;
757 printk("\ntesting speed of %s %s\n", algo, e);
759 tfm = crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC);
762 printk("failed to load transform for %s: %ld\n", algo,
772 b_size = block_sizes;
775 if ((*keysize + *b_size) > TVMEMSIZE) {
776 printk("template (%u) too big for tvmem (%u)\n",
777 *keysize + *b_size, TVMEMSIZE);
781 printk("test %u (%d bit key, %d byte blocks): ", i,
782 *keysize * 8, *b_size);
784 memset(tvmem, 0xff, *keysize + *b_size);
786 /* set key, plain text and IV */
787 key = (unsigned char *)tvmem;
788 for (j = 0; j < tcount; j++) {
789 if (template[j].klen == *keysize) {
790 key = template[j].key;
794 p = (unsigned char *)tvmem + *keysize;
796 ret = crypto_blkcipher_setkey(tfm, key, *keysize);
798 printk("setkey() failed flags=%x\n",
799 crypto_blkcipher_get_flags(tfm));
803 iv_len = crypto_blkcipher_ivsize(tfm);
805 memset(&iv, 0xff, iv_len);
806 crypto_blkcipher_set_iv(tfm, iv, iv_len);
810 ret = test_cipher_jiffies(&desc, enc, p, *b_size, sec);
812 ret = test_cipher_cycles(&desc, enc, p, *b_size);
815 printk("%s() failed flags=%x\n", e, desc.flags);
825 crypto_free_blkcipher(tfm);
828 static int test_hash_jiffies_digest(struct hash_desc *desc, char *p, int blen,
831 struct scatterlist sg[1];
832 unsigned long start, end;
836 sg_init_table(sg, 1);
838 for (start = jiffies, end = start + sec * HZ, bcount = 0;
839 time_before(jiffies, end); bcount++) {
840 sg_set_buf(sg, p, blen);
841 ret = crypto_hash_digest(desc, sg, blen, out);
846 printk("%6u opers/sec, %9lu bytes/sec\n",
847 bcount / sec, ((long)bcount * blen) / sec);
852 static int test_hash_jiffies(struct hash_desc *desc, char *p, int blen,
853 int plen, char *out, int sec)
855 struct scatterlist sg[1];
856 unsigned long start, end;
861 return test_hash_jiffies_digest(desc, p, blen, out, sec);
863 sg_init_table(sg, 1);
865 for (start = jiffies, end = start + sec * HZ, bcount = 0;
866 time_before(jiffies, end); bcount++) {
867 ret = crypto_hash_init(desc);
870 for (pcount = 0; pcount < blen; pcount += plen) {
871 sg_set_buf(sg, p + pcount, plen);
872 ret = crypto_hash_update(desc, sg, plen);
876 /* we assume there is enough space in 'out' for the result */
877 ret = crypto_hash_final(desc, out);
882 printk("%6u opers/sec, %9lu bytes/sec\n",
883 bcount / sec, ((long)bcount * blen) / sec);
888 static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen,
891 struct scatterlist sg[1];
892 unsigned long cycles = 0;
896 sg_init_table(sg, 1);
902 for (i = 0; i < 4; i++) {
903 sg_set_buf(sg, p, blen);
904 ret = crypto_hash_digest(desc, sg, blen, out);
909 /* The real thing. */
910 for (i = 0; i < 8; i++) {
913 start = get_cycles();
915 sg_set_buf(sg, p, blen);
916 ret = crypto_hash_digest(desc, sg, blen, out);
922 cycles += end - start;
932 printk("%6lu cycles/operation, %4lu cycles/byte\n",
933 cycles / 8, cycles / (8 * blen));
938 static int test_hash_cycles(struct hash_desc *desc, char *p, int blen,
941 struct scatterlist sg[1];
942 unsigned long cycles = 0;
947 return test_hash_cycles_digest(desc, p, blen, out);
949 sg_init_table(sg, 1);
955 for (i = 0; i < 4; i++) {
956 ret = crypto_hash_init(desc);
959 for (pcount = 0; pcount < blen; pcount += plen) {
960 sg_set_buf(sg, p + pcount, plen);
961 ret = crypto_hash_update(desc, sg, plen);
965 ret = crypto_hash_final(desc, out);
970 /* The real thing. */
971 for (i = 0; i < 8; i++) {
974 start = get_cycles();
976 ret = crypto_hash_init(desc);
979 for (pcount = 0; pcount < blen; pcount += plen) {
980 sg_set_buf(sg, p + pcount, plen);
981 ret = crypto_hash_update(desc, sg, plen);
985 ret = crypto_hash_final(desc, out);
991 cycles += end - start;
1001 printk("%6lu cycles/operation, %4lu cycles/byte\n",
1002 cycles / 8, cycles / (8 * blen));
1007 static void test_hash_speed(char *algo, unsigned int sec,
1008 struct hash_speed *speed)
1010 struct crypto_hash *tfm;
1011 struct hash_desc desc;
1016 printk("\ntesting speed of %s\n", algo);
1018 tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC);
1021 printk("failed to load transform for %s: %ld\n", algo,
1029 if (crypto_hash_digestsize(tfm) > sizeof(output)) {
1030 printk("digestsize(%u) > outputbuffer(%zu)\n",
1031 crypto_hash_digestsize(tfm), sizeof(output));
1035 for (i = 0; speed[i].blen != 0; i++) {
1036 if (speed[i].blen > TVMEMSIZE) {
1037 printk("template (%u) too big for tvmem (%u)\n",
1038 speed[i].blen, TVMEMSIZE);
1042 printk("test%3u (%5u byte blocks,%5u bytes per update,%4u updates): ",
1043 i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
1045 memset(tvmem, 0xff, speed[i].blen);
1048 ret = test_hash_jiffies(&desc, tvmem, speed[i].blen,
1049 speed[i].plen, output, sec);
1051 ret = test_hash_cycles(&desc, tvmem, speed[i].blen,
1052 speed[i].plen, output);
1055 printk("hashing failed ret=%d\n", ret);
1061 crypto_free_hash(tfm);
1064 static void test_comp(char *algo, struct comp_testvec *ctemplate,
1065 struct comp_testvec *dtemplate, int ctcount, int dtcount)
1068 char result[COMP_BUF_SIZE];
1069 struct crypto_comp *tfm;
1072 printk("\ntesting %s compression\n", algo);
1074 tfm = crypto_alloc_comp(algo, 0, CRYPTO_ALG_ASYNC);
1076 printk("failed to load transform for %s\n", algo);
1080 for (i = 0; i < ctcount; i++) {
1081 int ilen, ret, dlen = COMP_BUF_SIZE;
1083 printk("test %u:\n", i + 1);
1084 memset(result, 0, sizeof (result));
1086 ilen = ctemplate[i].inlen;
1087 ret = crypto_comp_compress(tfm, ctemplate[i].input,
1088 ilen, result, &dlen);
1090 printk("fail: ret=%d\n", ret);
1093 hexdump(result, dlen);
1094 printk("%s (ratio %d:%d)\n",
1095 memcmp(result, ctemplate[i].output, dlen) ? "fail" : "pass",
1099 printk("\ntesting %s decompression\n", algo);
1101 tsize = sizeof(struct comp_testvec);
1103 if (tsize > TVMEMSIZE) {
1104 printk("template (%u) too big for tvmem (%u)\n", tsize,
1109 for (i = 0; i < dtcount; i++) {
1110 int ilen, ret, dlen = COMP_BUF_SIZE;
1112 printk("test %u:\n", i + 1);
1113 memset(result, 0, sizeof (result));
1115 ilen = dtemplate[i].inlen;
1116 ret = crypto_comp_decompress(tfm, dtemplate[i].input,
1117 ilen, result, &dlen);
1119 printk("fail: ret=%d\n", ret);
1122 hexdump(result, dlen);
1123 printk("%s (ratio %d:%d)\n",
1124 memcmp(result, dtemplate[i].output, dlen) ? "fail" : "pass",
1128 crypto_free_comp(tfm);
1131 static void test_available(void)
1133 char **name = check;
1136 printk("alg %s ", *name);
1137 printk(crypto_has_alg(*name, 0, 0) ?
1138 "found\n" : "not found\n");
1143 static void do_test(void)
1148 test_hash("md5", md5_tv_template, MD5_TEST_VECTORS);
1150 test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS);
1153 test_cipher("ecb(des)", ENCRYPT, des_enc_tv_template,
1154 DES_ENC_TEST_VECTORS);
1155 test_cipher("ecb(des)", DECRYPT, des_dec_tv_template,
1156 DES_DEC_TEST_VECTORS);
1157 test_cipher("cbc(des)", ENCRYPT, des_cbc_enc_tv_template,
1158 DES_CBC_ENC_TEST_VECTORS);
1159 test_cipher("cbc(des)", DECRYPT, des_cbc_dec_tv_template,
1160 DES_CBC_DEC_TEST_VECTORS);
1163 test_cipher("ecb(des3_ede)", ENCRYPT, des3_ede_enc_tv_template,
1164 DES3_EDE_ENC_TEST_VECTORS);
1165 test_cipher("ecb(des3_ede)", DECRYPT, des3_ede_dec_tv_template,
1166 DES3_EDE_DEC_TEST_VECTORS);
1168 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS);
1170 test_hash("sha224", sha224_tv_template, SHA224_TEST_VECTORS);
1172 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS);
1175 test_cipher("ecb(blowfish)", ENCRYPT, bf_enc_tv_template,
1176 BF_ENC_TEST_VECTORS);
1177 test_cipher("ecb(blowfish)", DECRYPT, bf_dec_tv_template,
1178 BF_DEC_TEST_VECTORS);
1179 test_cipher("cbc(blowfish)", ENCRYPT, bf_cbc_enc_tv_template,
1180 BF_CBC_ENC_TEST_VECTORS);
1181 test_cipher("cbc(blowfish)", DECRYPT, bf_cbc_dec_tv_template,
1182 BF_CBC_DEC_TEST_VECTORS);
1185 test_cipher("ecb(twofish)", ENCRYPT, tf_enc_tv_template,
1186 TF_ENC_TEST_VECTORS);
1187 test_cipher("ecb(twofish)", DECRYPT, tf_dec_tv_template,
1188 TF_DEC_TEST_VECTORS);
1189 test_cipher("cbc(twofish)", ENCRYPT, tf_cbc_enc_tv_template,
1190 TF_CBC_ENC_TEST_VECTORS);
1191 test_cipher("cbc(twofish)", DECRYPT, tf_cbc_dec_tv_template,
1192 TF_CBC_DEC_TEST_VECTORS);
1195 test_cipher("ecb(serpent)", ENCRYPT, serpent_enc_tv_template,
1196 SERPENT_ENC_TEST_VECTORS);
1197 test_cipher("ecb(serpent)", DECRYPT, serpent_dec_tv_template,
1198 SERPENT_DEC_TEST_VECTORS);
1201 test_cipher("ecb(tnepres)", ENCRYPT, tnepres_enc_tv_template,
1202 TNEPRES_ENC_TEST_VECTORS);
1203 test_cipher("ecb(tnepres)", DECRYPT, tnepres_dec_tv_template,
1204 TNEPRES_DEC_TEST_VECTORS);
1207 test_cipher("ecb(aes)", ENCRYPT, aes_enc_tv_template,
1208 AES_ENC_TEST_VECTORS);
1209 test_cipher("ecb(aes)", DECRYPT, aes_dec_tv_template,
1210 AES_DEC_TEST_VECTORS);
1211 test_cipher("cbc(aes)", ENCRYPT, aes_cbc_enc_tv_template,
1212 AES_CBC_ENC_TEST_VECTORS);
1213 test_cipher("cbc(aes)", DECRYPT, aes_cbc_dec_tv_template,
1214 AES_CBC_DEC_TEST_VECTORS);
1215 test_cipher("lrw(aes)", ENCRYPT, aes_lrw_enc_tv_template,
1216 AES_LRW_ENC_TEST_VECTORS);
1217 test_cipher("lrw(aes)", DECRYPT, aes_lrw_dec_tv_template,
1218 AES_LRW_DEC_TEST_VECTORS);
1219 test_cipher("xts(aes)", ENCRYPT, aes_xts_enc_tv_template,
1220 AES_XTS_ENC_TEST_VECTORS);
1221 test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template,
1222 AES_XTS_DEC_TEST_VECTORS);
1223 test_cipher("rfc3686(ctr(aes))", ENCRYPT, aes_ctr_enc_tv_template,
1224 AES_CTR_ENC_TEST_VECTORS);
1225 test_cipher("rfc3686(ctr(aes))", DECRYPT, aes_ctr_dec_tv_template,
1226 AES_CTR_DEC_TEST_VECTORS);
1227 test_aead("gcm(aes)", ENCRYPT, aes_gcm_enc_tv_template,
1228 AES_GCM_ENC_TEST_VECTORS);
1229 test_aead("gcm(aes)", DECRYPT, aes_gcm_dec_tv_template,
1230 AES_GCM_DEC_TEST_VECTORS);
1231 test_aead("ccm(aes)", ENCRYPT, aes_ccm_enc_tv_template,
1232 AES_CCM_ENC_TEST_VECTORS);
1233 test_aead("ccm(aes)", DECRYPT, aes_ccm_dec_tv_template,
1234 AES_CCM_DEC_TEST_VECTORS);
1237 test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template,
1238 CAST5_ENC_TEST_VECTORS);
1239 test_cipher("ecb(cast5)", DECRYPT, cast5_dec_tv_template,
1240 CAST5_DEC_TEST_VECTORS);
1243 test_cipher("ecb(cast6)", ENCRYPT, cast6_enc_tv_template,
1244 CAST6_ENC_TEST_VECTORS);
1245 test_cipher("ecb(cast6)", DECRYPT, cast6_dec_tv_template,
1246 CAST6_DEC_TEST_VECTORS);
1249 test_cipher("ecb(arc4)", ENCRYPT, arc4_enc_tv_template,
1250 ARC4_ENC_TEST_VECTORS);
1251 test_cipher("ecb(arc4)", DECRYPT, arc4_dec_tv_template,
1252 ARC4_DEC_TEST_VECTORS);
1255 test_cipher("ecb(tea)", ENCRYPT, tea_enc_tv_template,
1256 TEA_ENC_TEST_VECTORS);
1257 test_cipher("ecb(tea)", DECRYPT, tea_dec_tv_template,
1258 TEA_DEC_TEST_VECTORS);
1262 test_cipher("ecb(xtea)", ENCRYPT, xtea_enc_tv_template,
1263 XTEA_ENC_TEST_VECTORS);
1264 test_cipher("ecb(xtea)", DECRYPT, xtea_dec_tv_template,
1265 XTEA_DEC_TEST_VECTORS);
1268 test_cipher("ecb(khazad)", ENCRYPT, khazad_enc_tv_template,
1269 KHAZAD_ENC_TEST_VECTORS);
1270 test_cipher("ecb(khazad)", DECRYPT, khazad_dec_tv_template,
1271 KHAZAD_DEC_TEST_VECTORS);
1274 test_cipher("ecb(anubis)", ENCRYPT, anubis_enc_tv_template,
1275 ANUBIS_ENC_TEST_VECTORS);
1276 test_cipher("ecb(anubis)", DECRYPT, anubis_dec_tv_template,
1277 ANUBIS_DEC_TEST_VECTORS);
1278 test_cipher("cbc(anubis)", ENCRYPT, anubis_cbc_enc_tv_template,
1279 ANUBIS_CBC_ENC_TEST_VECTORS);
1280 test_cipher("cbc(anubis)", DECRYPT, anubis_cbc_dec_tv_template,
1281 ANUBIS_CBC_ENC_TEST_VECTORS);
1284 test_cipher("ecb(xeta)", ENCRYPT, xeta_enc_tv_template,
1285 XETA_ENC_TEST_VECTORS);
1286 test_cipher("ecb(xeta)", DECRYPT, xeta_dec_tv_template,
1287 XETA_DEC_TEST_VECTORS);
1290 test_cipher("pcbc(fcrypt)", ENCRYPT, fcrypt_pcbc_enc_tv_template,
1291 FCRYPT_ENC_TEST_VECTORS);
1292 test_cipher("pcbc(fcrypt)", DECRYPT, fcrypt_pcbc_dec_tv_template,
1293 FCRYPT_DEC_TEST_VECTORS);
1296 test_cipher("ecb(camellia)", ENCRYPT,
1297 camellia_enc_tv_template,
1298 CAMELLIA_ENC_TEST_VECTORS);
1299 test_cipher("ecb(camellia)", DECRYPT,
1300 camellia_dec_tv_template,
1301 CAMELLIA_DEC_TEST_VECTORS);
1302 test_cipher("cbc(camellia)", ENCRYPT,
1303 camellia_cbc_enc_tv_template,
1304 CAMELLIA_CBC_ENC_TEST_VECTORS);
1305 test_cipher("cbc(camellia)", DECRYPT,
1306 camellia_cbc_dec_tv_template,
1307 CAMELLIA_CBC_DEC_TEST_VECTORS);
1310 test_cipher("ecb(seed)", ENCRYPT, seed_enc_tv_template,
1311 SEED_ENC_TEST_VECTORS);
1312 test_cipher("ecb(seed)", DECRYPT, seed_dec_tv_template,
1313 SEED_DEC_TEST_VECTORS);
1316 test_cipher("cts(cbc(aes))", ENCRYPT, cts_mode_enc_tv_template,
1317 CTS_MODE_ENC_TEST_VECTORS);
1318 test_cipher("cts(cbc(aes))", DECRYPT, cts_mode_dec_tv_template,
1319 CTS_MODE_DEC_TEST_VECTORS);
1321 test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
1322 test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
1323 test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS);
1324 test_hash("wp384", wp384_tv_template, WP384_TEST_VECTORS);
1325 test_hash("wp256", wp256_tv_template, WP256_TEST_VECTORS);
1326 test_hash("tgr192", tgr192_tv_template, TGR192_TEST_VECTORS);
1327 test_hash("tgr160", tgr160_tv_template, TGR160_TEST_VECTORS);
1328 test_hash("tgr128", tgr128_tv_template, TGR128_TEST_VECTORS);
1329 test_comp("deflate", deflate_comp_tv_template,
1330 deflate_decomp_tv_template, DEFLATE_COMP_TEST_VECTORS,
1331 DEFLATE_DECOMP_TEST_VECTORS);
1332 test_comp("lzo", lzo_comp_tv_template, lzo_decomp_tv_template,
1333 LZO_COMP_TEST_VECTORS, LZO_DECOMP_TEST_VECTORS);
1334 test_hash("crc32c", crc32c_tv_template, CRC32C_TEST_VECTORS);
1335 test_hash("hmac(md5)", hmac_md5_tv_template,
1336 HMAC_MD5_TEST_VECTORS);
1337 test_hash("hmac(sha1)", hmac_sha1_tv_template,
1338 HMAC_SHA1_TEST_VECTORS);
1339 test_hash("hmac(sha224)", hmac_sha224_tv_template,
1340 HMAC_SHA224_TEST_VECTORS);
1341 test_hash("hmac(sha256)", hmac_sha256_tv_template,
1342 HMAC_SHA256_TEST_VECTORS);
1343 test_hash("hmac(sha384)", hmac_sha384_tv_template,
1344 HMAC_SHA384_TEST_VECTORS);
1345 test_hash("hmac(sha512)", hmac_sha512_tv_template,
1346 HMAC_SHA512_TEST_VECTORS);
1348 test_hash("xcbc(aes)", aes_xcbc128_tv_template,
1349 XCBC_AES_TEST_VECTORS);
1351 test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS);
1355 test_hash("md5", md5_tv_template, MD5_TEST_VECTORS);
1359 test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS);
1363 test_cipher("ecb(des)", ENCRYPT, des_enc_tv_template,
1364 DES_ENC_TEST_VECTORS);
1365 test_cipher("ecb(des)", DECRYPT, des_dec_tv_template,
1366 DES_DEC_TEST_VECTORS);
1367 test_cipher("cbc(des)", ENCRYPT, des_cbc_enc_tv_template,
1368 DES_CBC_ENC_TEST_VECTORS);
1369 test_cipher("cbc(des)", DECRYPT, des_cbc_dec_tv_template,
1370 DES_CBC_DEC_TEST_VECTORS);
1374 test_cipher("ecb(des3_ede)", ENCRYPT, des3_ede_enc_tv_template,
1375 DES3_EDE_ENC_TEST_VECTORS);
1376 test_cipher("ecb(des3_ede)", DECRYPT, des3_ede_dec_tv_template,
1377 DES3_EDE_DEC_TEST_VECTORS);
1381 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS);
1385 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS);
1389 test_cipher("ecb(blowfish)", ENCRYPT, bf_enc_tv_template,
1390 BF_ENC_TEST_VECTORS);
1391 test_cipher("ecb(blowfish)", DECRYPT, bf_dec_tv_template,
1392 BF_DEC_TEST_VECTORS);
1393 test_cipher("cbc(blowfish)", ENCRYPT, bf_cbc_enc_tv_template,
1394 BF_CBC_ENC_TEST_VECTORS);
1395 test_cipher("cbc(blowfish)", DECRYPT, bf_cbc_dec_tv_template,
1396 BF_CBC_DEC_TEST_VECTORS);
1400 test_cipher("ecb(twofish)", ENCRYPT, tf_enc_tv_template,
1401 TF_ENC_TEST_VECTORS);
1402 test_cipher("ecb(twofish)", DECRYPT, tf_dec_tv_template,
1403 TF_DEC_TEST_VECTORS);
1404 test_cipher("cbc(twofish)", ENCRYPT, tf_cbc_enc_tv_template,
1405 TF_CBC_ENC_TEST_VECTORS);
1406 test_cipher("cbc(twofish)", DECRYPT, tf_cbc_dec_tv_template,
1407 TF_CBC_DEC_TEST_VECTORS);
1411 test_cipher("ecb(serpent)", ENCRYPT, serpent_enc_tv_template,
1412 SERPENT_ENC_TEST_VECTORS);
1413 test_cipher("ecb(serpent)", DECRYPT, serpent_dec_tv_template,
1414 SERPENT_DEC_TEST_VECTORS);
1418 test_cipher("ecb(aes)", ENCRYPT, aes_enc_tv_template,
1419 AES_ENC_TEST_VECTORS);
1420 test_cipher("ecb(aes)", DECRYPT, aes_dec_tv_template,
1421 AES_DEC_TEST_VECTORS);
1422 test_cipher("cbc(aes)", ENCRYPT, aes_cbc_enc_tv_template,
1423 AES_CBC_ENC_TEST_VECTORS);
1424 test_cipher("cbc(aes)", DECRYPT, aes_cbc_dec_tv_template,
1425 AES_CBC_DEC_TEST_VECTORS);
1426 test_cipher("lrw(aes)", ENCRYPT, aes_lrw_enc_tv_template,
1427 AES_LRW_ENC_TEST_VECTORS);
1428 test_cipher("lrw(aes)", DECRYPT, aes_lrw_dec_tv_template,
1429 AES_LRW_DEC_TEST_VECTORS);
1430 test_cipher("xts(aes)", ENCRYPT, aes_xts_enc_tv_template,
1431 AES_XTS_ENC_TEST_VECTORS);
1432 test_cipher("xts(aes)", DECRYPT, aes_xts_dec_tv_template,
1433 AES_XTS_DEC_TEST_VECTORS);
1434 test_cipher("rfc3686(ctr(aes))", ENCRYPT, aes_ctr_enc_tv_template,
1435 AES_CTR_ENC_TEST_VECTORS);
1436 test_cipher("rfc3686(ctr(aes))", DECRYPT, aes_ctr_dec_tv_template,
1437 AES_CTR_DEC_TEST_VECTORS);
1441 test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
1445 test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
1449 test_comp("deflate", deflate_comp_tv_template,
1450 deflate_decomp_tv_template, DEFLATE_COMP_TEST_VECTORS,
1451 DEFLATE_DECOMP_TEST_VECTORS);
1455 test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template,
1456 CAST5_ENC_TEST_VECTORS);
1457 test_cipher("ecb(cast5)", DECRYPT, cast5_dec_tv_template,
1458 CAST5_DEC_TEST_VECTORS);
1462 test_cipher("ecb(cast6)", ENCRYPT, cast6_enc_tv_template,
1463 CAST6_ENC_TEST_VECTORS);
1464 test_cipher("ecb(cast6)", DECRYPT, cast6_dec_tv_template,
1465 CAST6_DEC_TEST_VECTORS);
1469 test_cipher("ecb(arc4)", ENCRYPT, arc4_enc_tv_template,
1470 ARC4_ENC_TEST_VECTORS);
1471 test_cipher("ecb(arc4)", DECRYPT, arc4_dec_tv_template,
1472 ARC4_DEC_TEST_VECTORS);
1476 test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS);
1480 test_hash("crc32c", crc32c_tv_template, CRC32C_TEST_VECTORS);
1484 test_cipher("ecb(tea)", ENCRYPT, tea_enc_tv_template,
1485 TEA_ENC_TEST_VECTORS);
1486 test_cipher("ecb(tea)", DECRYPT, tea_dec_tv_template,
1487 TEA_DEC_TEST_VECTORS);
1491 test_cipher("ecb(xtea)", ENCRYPT, xtea_enc_tv_template,
1492 XTEA_ENC_TEST_VECTORS);
1493 test_cipher("ecb(xtea)", DECRYPT, xtea_dec_tv_template,
1494 XTEA_DEC_TEST_VECTORS);
1498 test_cipher("ecb(khazad)", ENCRYPT, khazad_enc_tv_template,
1499 KHAZAD_ENC_TEST_VECTORS);
1500 test_cipher("ecb(khazad)", DECRYPT, khazad_dec_tv_template,
1501 KHAZAD_DEC_TEST_VECTORS);
1505 test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS);
1509 test_hash("wp384", wp384_tv_template, WP384_TEST_VECTORS);
1513 test_hash("wp256", wp256_tv_template, WP256_TEST_VECTORS);
1517 test_cipher("ecb(tnepres)", ENCRYPT, tnepres_enc_tv_template,
1518 TNEPRES_ENC_TEST_VECTORS);
1519 test_cipher("ecb(tnepres)", DECRYPT, tnepres_dec_tv_template,
1520 TNEPRES_DEC_TEST_VECTORS);
1524 test_cipher("ecb(anubis)", ENCRYPT, anubis_enc_tv_template,
1525 ANUBIS_ENC_TEST_VECTORS);
1526 test_cipher("ecb(anubis)", DECRYPT, anubis_dec_tv_template,
1527 ANUBIS_DEC_TEST_VECTORS);
1528 test_cipher("cbc(anubis)", ENCRYPT, anubis_cbc_enc_tv_template,
1529 ANUBIS_CBC_ENC_TEST_VECTORS);
1530 test_cipher("cbc(anubis)", DECRYPT, anubis_cbc_dec_tv_template,
1531 ANUBIS_CBC_ENC_TEST_VECTORS);
1535 test_hash("tgr192", tgr192_tv_template, TGR192_TEST_VECTORS);
1540 test_hash("tgr160", tgr160_tv_template, TGR160_TEST_VECTORS);
1544 test_hash("tgr128", tgr128_tv_template, TGR128_TEST_VECTORS);
1548 test_cipher("ecb(xeta)", ENCRYPT, xeta_enc_tv_template,
1549 XETA_ENC_TEST_VECTORS);
1550 test_cipher("ecb(xeta)", DECRYPT, xeta_dec_tv_template,
1551 XETA_DEC_TEST_VECTORS);
1555 test_cipher("pcbc(fcrypt)", ENCRYPT, fcrypt_pcbc_enc_tv_template,
1556 FCRYPT_ENC_TEST_VECTORS);
1557 test_cipher("pcbc(fcrypt)", DECRYPT, fcrypt_pcbc_dec_tv_template,
1558 FCRYPT_DEC_TEST_VECTORS);
1562 test_cipher("ecb(camellia)", ENCRYPT,
1563 camellia_enc_tv_template,
1564 CAMELLIA_ENC_TEST_VECTORS);
1565 test_cipher("ecb(camellia)", DECRYPT,
1566 camellia_dec_tv_template,
1567 CAMELLIA_DEC_TEST_VECTORS);
1568 test_cipher("cbc(camellia)", ENCRYPT,
1569 camellia_cbc_enc_tv_template,
1570 CAMELLIA_CBC_ENC_TEST_VECTORS);
1571 test_cipher("cbc(camellia)", DECRYPT,
1572 camellia_cbc_dec_tv_template,
1573 CAMELLIA_CBC_DEC_TEST_VECTORS);
1576 test_hash("sha224", sha224_tv_template, SHA224_TEST_VECTORS);
1580 test_cipher("salsa20", ENCRYPT,
1581 salsa20_stream_enc_tv_template,
1582 SALSA20_STREAM_ENC_TEST_VECTORS);
1586 test_aead("gcm(aes)", ENCRYPT, aes_gcm_enc_tv_template,
1587 AES_GCM_ENC_TEST_VECTORS);
1588 test_aead("gcm(aes)", DECRYPT, aes_gcm_dec_tv_template,
1589 AES_GCM_DEC_TEST_VECTORS);
1593 test_comp("lzo", lzo_comp_tv_template, lzo_decomp_tv_template,
1594 LZO_COMP_TEST_VECTORS, LZO_DECOMP_TEST_VECTORS);
1598 test_aead("ccm(aes)", ENCRYPT, aes_ccm_enc_tv_template,
1599 AES_CCM_ENC_TEST_VECTORS);
1600 test_aead("ccm(aes)", DECRYPT, aes_ccm_dec_tv_template,
1601 AES_CCM_DEC_TEST_VECTORS);
1605 test_cipher("cts(cbc(aes))", ENCRYPT, cts_mode_enc_tv_template,
1606 CTS_MODE_ENC_TEST_VECTORS);
1607 test_cipher("cts(cbc(aes))", DECRYPT, cts_mode_dec_tv_template,
1608 CTS_MODE_DEC_TEST_VECTORS);
1612 test_hash("rmd128", rmd128_tv_template, RMD128_TEST_VECTORS);
1616 test_hash("rmd160", rmd160_tv_template, RMD160_TEST_VECTORS);
1620 test_hash("hmac(md5)", hmac_md5_tv_template,
1621 HMAC_MD5_TEST_VECTORS);
1625 test_hash("hmac(sha1)", hmac_sha1_tv_template,
1626 HMAC_SHA1_TEST_VECTORS);
1630 test_hash("hmac(sha256)", hmac_sha256_tv_template,
1631 HMAC_SHA256_TEST_VECTORS);
1635 test_hash("hmac(sha384)", hmac_sha384_tv_template,
1636 HMAC_SHA384_TEST_VECTORS);
1640 test_hash("hmac(sha512)", hmac_sha512_tv_template,
1641 HMAC_SHA512_TEST_VECTORS);
1645 test_hash("hmac(sha224)", hmac_sha224_tv_template,
1646 HMAC_SHA224_TEST_VECTORS);
1650 test_hash("xcbc(aes)", aes_xcbc128_tv_template,
1651 XCBC_AES_TEST_VECTORS);
1655 test_hash("hmac(rmd128)", hmac_rmd128_tv_template,
1656 HMAC_RMD128_TEST_VECTORS);
1660 test_hash("hmac(rmd160)", hmac_rmd160_tv_template,
1661 HMAC_RMD160_TEST_VECTORS);
1665 test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
1666 speed_template_16_24_32);
1667 test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
1668 speed_template_16_24_32);
1669 test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
1670 speed_template_16_24_32);
1671 test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
1672 speed_template_16_24_32);
1673 test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
1674 speed_template_32_40_48);
1675 test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
1676 speed_template_32_40_48);
1677 test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
1678 speed_template_32_48_64);
1679 test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
1680 speed_template_32_48_64);
1684 test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec,
1685 des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS,
1687 test_cipher_speed("ecb(des3_ede)", DECRYPT, sec,
1688 des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS,
1690 test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec,
1691 des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS,
1693 test_cipher_speed("cbc(des3_ede)", DECRYPT, sec,
1694 des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS,
1699 test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
1700 speed_template_16_24_32);
1701 test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
1702 speed_template_16_24_32);
1703 test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
1704 speed_template_16_24_32);
1705 test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
1706 speed_template_16_24_32);
1710 test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
1711 speed_template_8_32);
1712 test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
1713 speed_template_8_32);
1714 test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
1715 speed_template_8_32);
1716 test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
1717 speed_template_8_32);
1721 test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
1723 test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
1725 test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
1727 test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
1732 test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
1733 speed_template_16_24_32);
1734 test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
1735 speed_template_16_24_32);
1736 test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
1737 speed_template_16_24_32);
1738 test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
1739 speed_template_16_24_32);
1743 test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0,
1744 speed_template_16_32);
1751 test_hash_speed("md4", sec, generic_hash_speed_template);
1752 if (mode > 300 && mode < 400) break;
1755 test_hash_speed("md5", sec, generic_hash_speed_template);
1756 if (mode > 300 && mode < 400) break;
1759 test_hash_speed("sha1", sec, generic_hash_speed_template);
1760 if (mode > 300 && mode < 400) break;
1763 test_hash_speed("sha256", sec, generic_hash_speed_template);
1764 if (mode > 300 && mode < 400) break;
1767 test_hash_speed("sha384", sec, generic_hash_speed_template);
1768 if (mode > 300 && mode < 400) break;
1771 test_hash_speed("sha512", sec, generic_hash_speed_template);
1772 if (mode > 300 && mode < 400) break;
1775 test_hash_speed("wp256", sec, generic_hash_speed_template);
1776 if (mode > 300 && mode < 400) break;
1779 test_hash_speed("wp384", sec, generic_hash_speed_template);
1780 if (mode > 300 && mode < 400) break;
1783 test_hash_speed("wp512", sec, generic_hash_speed_template);
1784 if (mode > 300 && mode < 400) break;
1787 test_hash_speed("tgr128", sec, generic_hash_speed_template);
1788 if (mode > 300 && mode < 400) break;
1791 test_hash_speed("tgr160", sec, generic_hash_speed_template);
1792 if (mode > 300 && mode < 400) break;
1795 test_hash_speed("tgr192", sec, generic_hash_speed_template);
1796 if (mode > 300 && mode < 400) break;
1799 test_hash_speed("sha224", sec, generic_hash_speed_template);
1800 if (mode > 300 && mode < 400) break;
1803 test_hash_speed("rmd128", sec, generic_hash_speed_template);
1804 if (mode > 300 && mode < 400) break;
1807 test_hash_speed("rmd160", sec, generic_hash_speed_template);
1808 if (mode > 300 && mode < 400) break;
1818 /* useful for debugging */
1819 printk("not testing anything\n");
1824 static int __init tcrypt_mod_init(void)
1828 tvmem = kmalloc(TVMEMSIZE, GFP_KERNEL);
1832 xbuf = kmalloc(XBUFSIZE, GFP_KERNEL);
1836 axbuf = kmalloc(XBUFSIZE, GFP_KERNEL);
1842 /* We intentionaly return -EAGAIN to prevent keeping
1843 * the module. It does all its work from init()
1844 * and doesn't offer any runtime functionality
1845 * => we don't need it in the memory, do we?
1860 * If an init function is provided, an exit function must also be provided
1861 * to allow module unload.
1863 static void __exit tcrypt_mod_fini(void) { }
1865 module_init(tcrypt_mod_init);
1866 module_exit(tcrypt_mod_fini);
1868 module_param(mode, int, 0);
1869 module_param(sec, uint, 0);
1870 MODULE_PARM_DESC(sec, "Length in seconds of speed tests "
1871 "(defaults to zero which uses CPU cycles instead)");
1873 MODULE_LICENSE("GPL");
1874 MODULE_DESCRIPTION("Quick & dirty crypto testing module");
1875 MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");