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>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
16 * Rewritten by Kartikey Mahendra Bhatt
19 #include <linux/init.h>
20 #include <linux/module.h>
22 #include <linux/slab.h>
23 #include <asm/scatterlist.h>
24 #include <linux/string.h>
25 #include <linux/crypto.h>
26 #include <linux/highmem.h>
29 #define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
32 * Need to kmalloc() memory for testing kmap().
34 #define TVMEMSIZE 4096
35 #define XBUFSIZE 32768
38 * Indexes into the xbuf to simulate cross-page access.
50 * Used by test_cipher()
57 static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 };
63 static char *check[] = {
64 "des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish",
65 "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6",
66 "arc4", "michael_mic", "deflate", "tea", "xtea", "khazad",
67 "wp512", "wp384", "wp256", "tnepres", "anubis", "xeta", NULL
71 hexdump(unsigned char *buf, unsigned int len)
74 printk("%02x", *buf++);
80 test_hash (char * algo, struct hash_testvec * template, unsigned int tcount)
83 unsigned int i, j, k, temp;
84 struct scatterlist sg[8];
86 struct crypto_tfm *tfm;
87 struct hash_testvec *hash_tv;
90 printk("\ntesting %s\n", algo);
92 tsize = sizeof (struct hash_testvec);
95 if (tsize > TVMEMSIZE) {
96 printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE);
100 memcpy(tvmem, template, tsize);
101 hash_tv = (void *) tvmem;
102 tfm = crypto_alloc_tfm(algo, 0);
104 printk("failed to load transform for %s\n", algo);
108 for (i = 0; i < tcount; i++) {
109 printk ("test %u:\n", i + 1);
110 memset (result, 0, 64);
112 p = hash_tv[i].plaintext;
113 sg[0].page = virt_to_page (p);
114 sg[0].offset = offset_in_page (p);
115 sg[0].length = hash_tv[i].psize;
117 crypto_digest_init (tfm);
118 if (tfm->crt_u.digest.dit_setkey) {
119 crypto_digest_setkey (tfm, hash_tv[i].key,
122 crypto_digest_update (tfm, sg, 1);
123 crypto_digest_final (tfm, result);
125 hexdump (result, crypto_tfm_alg_digestsize (tfm));
127 memcmp(result, hash_tv[i].digest,
128 crypto_tfm_alg_digestsize(tfm)) ? "fail" :
132 printk ("testing %s across pages\n", algo);
134 /* setup the dummy buffer first */
135 memset(xbuf, 0, XBUFSIZE);
138 for (i = 0; i < tcount; i++) {
141 printk ("test %u:\n", j);
142 memset (result, 0, 64);
145 for (k = 0; k < hash_tv[i].np; k++) {
146 memcpy (&xbuf[IDX[k]], hash_tv[i].plaintext + temp,
148 temp += hash_tv[i].tap[k];
150 sg[k].page = virt_to_page (p);
151 sg[k].offset = offset_in_page (p);
152 sg[k].length = hash_tv[i].tap[k];
155 crypto_digest_digest (tfm, sg, hash_tv[i].np, result);
157 hexdump (result, crypto_tfm_alg_digestsize (tfm));
159 memcmp(result, hash_tv[i].digest,
160 crypto_tfm_alg_digestsize(tfm)) ? "fail" :
165 crypto_free_tfm (tfm);
169 #ifdef CONFIG_CRYPTO_HMAC
172 test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount)
175 unsigned int i, j, k, temp;
176 struct scatterlist sg[8];
178 struct crypto_tfm *tfm;
179 struct hmac_testvec *hmac_tv;
180 unsigned int tsize, klen;
182 tfm = crypto_alloc_tfm(algo, 0);
184 printk("failed to load transform for %s\n", algo);
188 printk("\ntesting hmac_%s\n", algo);
190 tsize = sizeof (struct hmac_testvec);
192 if (tsize > TVMEMSIZE) {
193 printk("template (%u) too big for tvmem (%u)\n", tsize,
198 memcpy(tvmem, template, tsize);
199 hmac_tv = (void *) tvmem;
201 for (i = 0; i < tcount; i++) {
202 printk("test %u:\n", i + 1);
203 memset(result, 0, sizeof (result));
205 p = hmac_tv[i].plaintext;
206 klen = hmac_tv[i].ksize;
207 sg[0].page = virt_to_page(p);
208 sg[0].offset = offset_in_page(p);
209 sg[0].length = hmac_tv[i].psize;
211 crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, 1, result);
213 hexdump(result, crypto_tfm_alg_digestsize(tfm));
215 memcmp(result, hmac_tv[i].digest,
216 crypto_tfm_alg_digestsize(tfm)) ? "fail" :
220 printk("\ntesting hmac_%s across pages\n", algo);
222 memset(xbuf, 0, XBUFSIZE);
225 for (i = 0; i < tcount; i++) {
228 printk ("test %u:\n",j);
229 memset (result, 0, 64);
232 klen = hmac_tv[i].ksize;
233 for (k = 0; k < hmac_tv[i].np; k++) {
234 memcpy (&xbuf[IDX[k]], hmac_tv[i].plaintext + temp,
236 temp += hmac_tv[i].tap[k];
238 sg[k].page = virt_to_page (p);
239 sg[k].offset = offset_in_page (p);
240 sg[k].length = hmac_tv[i].tap[k];
243 crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, hmac_tv[i].np,
245 hexdump(result, crypto_tfm_alg_digestsize(tfm));
248 memcmp(result, hmac_tv[i].digest,
249 crypto_tfm_alg_digestsize(tfm)) ? "fail" :
254 crypto_free_tfm(tfm);
257 #endif /* CONFIG_CRYPTO_HMAC */
260 test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, unsigned int tcount)
262 unsigned int ret, i, j, k, temp;
265 struct crypto_tfm *tfm;
267 struct cipher_testvec *cipher_tv;
268 struct scatterlist sg[8];
272 strncpy(e, "encryption", 11);
274 strncpy(e, "decryption", 11);
275 if (mode == MODE_ECB)
276 strncpy(m, "ECB", 4);
278 strncpy(m, "CBC", 4);
280 printk("\ntesting %s %s %s \n", algo, m, e);
282 tsize = sizeof (struct cipher_testvec);
285 if (tsize > TVMEMSIZE) {
286 printk("template (%u) too big for tvmem (%u)\n", tsize,
291 memcpy(tvmem, template, tsize);
292 cipher_tv = (void *) tvmem;
295 tfm = crypto_alloc_tfm (algo, 0);
297 tfm = crypto_alloc_tfm (algo, CRYPTO_TFM_MODE_CBC);
300 printk("failed to load transform for %s %s\n", algo, m);
305 for (i = 0; i < tcount; i++) {
306 if (!(cipher_tv[i].np)) {
308 printk("test %u (%d bit key):\n",
309 j, cipher_tv[i].klen * 8);
313 tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY;
314 key = cipher_tv[i].key;
316 ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen);
318 printk("setkey() failed flags=%x\n", tfm->crt_flags);
320 if (!cipher_tv[i].fail)
324 p = cipher_tv[i].input;
325 sg[0].page = virt_to_page(p);
326 sg[0].offset = offset_in_page(p);
327 sg[0].length = cipher_tv[i].ilen;
330 crypto_cipher_set_iv(tfm, cipher_tv[i].iv,
331 crypto_tfm_alg_ivsize (tfm));
335 ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen);
337 ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen);
341 printk("%s () failed flags=%x\n", e, tfm->crt_flags);
345 q = kmap(sg[0].page) + sg[0].offset;
346 hexdump(q, cipher_tv[i].rlen);
349 memcmp(q, cipher_tv[i].result, cipher_tv[i].rlen) ? "fail" :
354 printk("\ntesting %s %s %s across pages (chunking) \n", algo, m, e);
355 memset(xbuf, 0, XBUFSIZE);
358 for (i = 0; i < tcount; i++) {
359 if (cipher_tv[i].np) {
361 printk("test %u (%d bit key):\n",
362 j, cipher_tv[i].klen * 8);
366 tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY;
367 key = cipher_tv[i].key;
369 ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen);
371 printk("setkey() failed flags=%x\n", tfm->crt_flags);
373 if (!cipher_tv[i].fail)
378 for (k = 0; k < cipher_tv[i].np; k++) {
379 memcpy (&xbuf[IDX[k]], cipher_tv[i].input + temp,
380 cipher_tv[i].tap[k]);
381 temp += cipher_tv[i].tap[k];
383 sg[k].page = virt_to_page (p);
384 sg[k].offset = offset_in_page (p);
385 sg[k].length = cipher_tv[i].tap[k];
389 crypto_cipher_set_iv(tfm, cipher_tv[i].iv,
390 crypto_tfm_alg_ivsize (tfm));
394 ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen);
396 ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen);
399 printk("%s () failed flags=%x\n", e, tfm->crt_flags);
404 for (k = 0; k < cipher_tv[i].np; k++) {
405 printk("page %u\n", k);
406 q = kmap(sg[k].page) + sg[k].offset;
407 hexdump(q, cipher_tv[i].tap[k]);
409 memcmp(q, cipher_tv[i].result + temp,
410 cipher_tv[i].tap[k]) ? "fail" :
412 temp += cipher_tv[i].tap[k];
418 crypto_free_tfm(tfm);
425 char result[COMP_BUF_SIZE];
426 struct crypto_tfm *tfm;
427 struct comp_testvec *tv;
430 printk("\ntesting deflate compression\n");
432 tsize = sizeof (deflate_comp_tv_template);
433 if (tsize > TVMEMSIZE) {
434 printk("template (%u) too big for tvmem (%u)\n", tsize,
439 memcpy(tvmem, deflate_comp_tv_template, tsize);
442 tfm = crypto_alloc_tfm("deflate", 0);
444 printk("failed to load transform for deflate\n");
448 for (i = 0; i < DEFLATE_COMP_TEST_VECTORS; i++) {
449 int ilen, ret, dlen = COMP_BUF_SIZE;
451 printk("test %u:\n", i + 1);
452 memset(result, 0, sizeof (result));
455 ret = crypto_comp_compress(tfm, tv[i].input,
456 ilen, result, &dlen);
458 printk("fail: ret=%d\n", ret);
461 hexdump(result, dlen);
462 printk("%s (ratio %d:%d)\n",
463 memcmp(result, tv[i].output, dlen) ? "fail" : "pass",
467 printk("\ntesting deflate decompression\n");
469 tsize = sizeof (deflate_decomp_tv_template);
470 if (tsize > TVMEMSIZE) {
471 printk("template (%u) too big for tvmem (%u)\n", tsize,
476 memcpy(tvmem, deflate_decomp_tv_template, tsize);
479 for (i = 0; i < DEFLATE_DECOMP_TEST_VECTORS; i++) {
480 int ilen, ret, dlen = COMP_BUF_SIZE;
482 printk("test %u:\n", i + 1);
483 memset(result, 0, sizeof (result));
486 ret = crypto_comp_decompress(tfm, tv[i].input,
487 ilen, result, &dlen);
489 printk("fail: ret=%d\n", ret);
492 hexdump(result, dlen);
493 printk("%s (ratio %d:%d)\n",
494 memcmp(result, tv[i].output, dlen) ? "fail" : "pass",
498 crypto_free_tfm(tfm);
507 printk("alg %s ", *name);
508 printk((crypto_alg_available(*name, 0)) ?
509 "found\n" : "not found\n");
520 test_hash("md5", md5_tv_template, MD5_TEST_VECTORS);
522 test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS);
525 test_cipher ("des", MODE_ECB, ENCRYPT, des_enc_tv_template, DES_ENC_TEST_VECTORS);
526 test_cipher ("des", MODE_ECB, DECRYPT, des_dec_tv_template, DES_DEC_TEST_VECTORS);
527 test_cipher ("des", MODE_CBC, ENCRYPT, des_cbc_enc_tv_template, DES_CBC_ENC_TEST_VECTORS);
528 test_cipher ("des", MODE_CBC, DECRYPT, des_cbc_dec_tv_template, DES_CBC_DEC_TEST_VECTORS);
531 test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS);
532 test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS);
534 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS);
536 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS);
539 test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS);
540 test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS);
541 test_cipher ("blowfish", MODE_CBC, ENCRYPT, bf_cbc_enc_tv_template, BF_CBC_ENC_TEST_VECTORS);
542 test_cipher ("blowfish", MODE_CBC, DECRYPT, bf_cbc_dec_tv_template, BF_CBC_DEC_TEST_VECTORS);
545 test_cipher ("twofish", MODE_ECB, ENCRYPT, tf_enc_tv_template, TF_ENC_TEST_VECTORS);
546 test_cipher ("twofish", MODE_ECB, DECRYPT, tf_dec_tv_template, TF_DEC_TEST_VECTORS);
547 test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS);
548 test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS);
551 test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS);
552 test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS);
555 test_cipher ("tnepres", MODE_ECB, ENCRYPT, tnepres_enc_tv_template, TNEPRES_ENC_TEST_VECTORS);
556 test_cipher ("tnepres", MODE_ECB, DECRYPT, tnepres_dec_tv_template, TNEPRES_DEC_TEST_VECTORS);
559 test_cipher ("aes", MODE_ECB, ENCRYPT, aes_enc_tv_template, AES_ENC_TEST_VECTORS);
560 test_cipher ("aes", MODE_ECB, DECRYPT, aes_dec_tv_template, AES_DEC_TEST_VECTORS);
563 test_cipher ("cast5", MODE_ECB, ENCRYPT, cast5_enc_tv_template, CAST5_ENC_TEST_VECTORS);
564 test_cipher ("cast5", MODE_ECB, DECRYPT, cast5_dec_tv_template, CAST5_DEC_TEST_VECTORS);
567 test_cipher ("cast6", MODE_ECB, ENCRYPT, cast6_enc_tv_template, CAST6_ENC_TEST_VECTORS);
568 test_cipher ("cast6", MODE_ECB, DECRYPT, cast6_dec_tv_template, CAST6_DEC_TEST_VECTORS);
571 test_cipher ("arc4", MODE_ECB, ENCRYPT, arc4_enc_tv_template, ARC4_ENC_TEST_VECTORS);
572 test_cipher ("arc4", MODE_ECB, DECRYPT, arc4_dec_tv_template, ARC4_DEC_TEST_VECTORS);
575 test_cipher ("tea", MODE_ECB, ENCRYPT, tea_enc_tv_template, TEA_ENC_TEST_VECTORS);
576 test_cipher ("tea", MODE_ECB, DECRYPT, tea_dec_tv_template, TEA_DEC_TEST_VECTORS);
580 test_cipher ("xtea", MODE_ECB, ENCRYPT, xtea_enc_tv_template, XTEA_ENC_TEST_VECTORS);
581 test_cipher ("xtea", MODE_ECB, DECRYPT, xtea_dec_tv_template, XTEA_DEC_TEST_VECTORS);
584 test_cipher ("khazad", MODE_ECB, ENCRYPT, khazad_enc_tv_template, KHAZAD_ENC_TEST_VECTORS);
585 test_cipher ("khazad", MODE_ECB, DECRYPT, khazad_dec_tv_template, KHAZAD_DEC_TEST_VECTORS);
588 test_cipher ("anubis", MODE_ECB, ENCRYPT, anubis_enc_tv_template, ANUBIS_ENC_TEST_VECTORS);
589 test_cipher ("anubis", MODE_ECB, DECRYPT, anubis_dec_tv_template, ANUBIS_DEC_TEST_VECTORS);
590 test_cipher ("anubis", MODE_CBC, ENCRYPT, anubis_cbc_enc_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
591 test_cipher ("anubis", MODE_CBC, DECRYPT, anubis_cbc_dec_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
594 test_cipher ("xeta", MODE_ECB, ENCRYPT, xeta_enc_tv_template, XETA_ENC_TEST_VECTORS);
595 test_cipher ("xeta", MODE_ECB, DECRYPT, xeta_dec_tv_template, XETA_DEC_TEST_VECTORS);
597 test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
598 test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
599 test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS);
600 test_hash("wp384", wp384_tv_template, WP384_TEST_VECTORS);
601 test_hash("wp256", wp256_tv_template, WP256_TEST_VECTORS);
603 #ifdef CONFIG_CRYPTO_HMAC
604 test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS);
605 test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS);
606 test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS);
609 test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS);
613 test_hash("md5", md5_tv_template, MD5_TEST_VECTORS);
617 test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS);
621 test_cipher ("des", MODE_ECB, ENCRYPT, des_enc_tv_template, DES_ENC_TEST_VECTORS);
622 test_cipher ("des", MODE_ECB, DECRYPT, des_dec_tv_template, DES_DEC_TEST_VECTORS);
623 test_cipher ("des", MODE_CBC, ENCRYPT, des_cbc_enc_tv_template, DES_CBC_ENC_TEST_VECTORS);
624 test_cipher ("des", MODE_CBC, DECRYPT, des_cbc_dec_tv_template, DES_CBC_DEC_TEST_VECTORS);
628 test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS);
629 test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS);
633 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS);
637 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS);
641 test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS);
642 test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS);
643 test_cipher ("blowfish", MODE_CBC, ENCRYPT, bf_cbc_enc_tv_template, BF_CBC_ENC_TEST_VECTORS);
644 test_cipher ("blowfish", MODE_CBC, DECRYPT, bf_cbc_dec_tv_template, BF_CBC_DEC_TEST_VECTORS);
648 test_cipher ("twofish", MODE_ECB, ENCRYPT, tf_enc_tv_template, TF_ENC_TEST_VECTORS);
649 test_cipher ("twofish", MODE_ECB, DECRYPT, tf_dec_tv_template, TF_DEC_TEST_VECTORS);
650 test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS);
651 test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS);
655 test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS);
656 test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS);
660 test_cipher ("aes", MODE_ECB, ENCRYPT, aes_enc_tv_template, AES_ENC_TEST_VECTORS);
661 test_cipher ("aes", MODE_ECB, DECRYPT, aes_dec_tv_template, AES_DEC_TEST_VECTORS);
665 test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
669 test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
677 test_cipher ("cast5", MODE_ECB, ENCRYPT, cast5_enc_tv_template, CAST5_ENC_TEST_VECTORS);
678 test_cipher ("cast5", MODE_ECB, DECRYPT, cast5_dec_tv_template, CAST5_DEC_TEST_VECTORS);
682 test_cipher ("cast6", MODE_ECB, ENCRYPT, cast6_enc_tv_template, CAST6_ENC_TEST_VECTORS);
683 test_cipher ("cast6", MODE_ECB, DECRYPT, cast6_dec_tv_template, CAST6_DEC_TEST_VECTORS);
687 test_cipher ("arc4", MODE_ECB, ENCRYPT, arc4_enc_tv_template, ARC4_ENC_TEST_VECTORS);
688 test_cipher ("arc4", MODE_ECB, DECRYPT, arc4_dec_tv_template, ARC4_DEC_TEST_VECTORS);
692 test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS);
696 test_cipher ("tea", MODE_ECB, ENCRYPT, tea_enc_tv_template, TEA_ENC_TEST_VECTORS);
697 test_cipher ("tea", MODE_ECB, DECRYPT, tea_dec_tv_template, TEA_DEC_TEST_VECTORS);
701 test_cipher ("xtea", MODE_ECB, ENCRYPT, xtea_enc_tv_template, XTEA_ENC_TEST_VECTORS);
702 test_cipher ("xtea", MODE_ECB, DECRYPT, xtea_dec_tv_template, XTEA_DEC_TEST_VECTORS);
706 test_cipher ("khazad", MODE_ECB, ENCRYPT, khazad_enc_tv_template, KHAZAD_ENC_TEST_VECTORS);
707 test_cipher ("khazad", MODE_ECB, DECRYPT, khazad_dec_tv_template, KHAZAD_DEC_TEST_VECTORS);
709 test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS);
713 test_hash("wp384", wp384_tv_template, WP384_TEST_VECTORS);
717 test_hash("wp256", wp256_tv_template, WP256_TEST_VECTORS);
721 test_cipher ("tnepres", MODE_ECB, ENCRYPT, tnepres_enc_tv_template, TNEPRES_ENC_TEST_VECTORS);
722 test_cipher ("tnepres", MODE_ECB, DECRYPT, tnepres_dec_tv_template, TNEPRES_DEC_TEST_VECTORS);
726 test_cipher ("anubis", MODE_ECB, ENCRYPT, anubis_enc_tv_template, ANUBIS_ENC_TEST_VECTORS);
727 test_cipher ("anubis", MODE_ECB, DECRYPT, anubis_dec_tv_template, ANUBIS_DEC_TEST_VECTORS);
728 test_cipher ("anubis", MODE_CBC, ENCRYPT, anubis_cbc_enc_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
729 test_cipher ("anubis", MODE_CBC, DECRYPT, anubis_cbc_dec_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
733 test_cipher ("xeta", MODE_ECB, ENCRYPT, xeta_enc_tv_template, XETA_ENC_TEST_VECTORS);
734 test_cipher ("xeta", MODE_ECB, DECRYPT, xeta_dec_tv_template, XETA_DEC_TEST_VECTORS);
737 #ifdef CONFIG_CRYPTO_HMAC
739 test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS);
743 test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS);
747 test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS);
757 /* useful for debugging */
758 printk("not testing anything\n");
766 tvmem = kmalloc(TVMEMSIZE, GFP_KERNEL);
770 xbuf = kmalloc(XBUFSIZE, GFP_KERNEL);
784 * If an init function is provided, an exit function must also be provided
785 * to allow module unload.
787 static void __exit fini(void) { }
792 MODULE_PARM(mode, "i");
794 MODULE_LICENSE("GPL");
795 MODULE_DESCRIPTION("Quick & dirty crypto testing module");
796 MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");