blob: 7ae2130e1b002890900907fc415b1eb51094e8a7 [file] [log] [blame]
Herbert Xuef2736f2005-06-22 13:26:03 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Quick & dirty crypto testing module.
3 *
4 * This will only exist until we have a better testing mechanism
5 * (e.g. a char device).
6 *
7 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
8 * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
Mikko Herranene3a4ea42007-11-26 22:12:07 +08009 * Copyright (c) 2007 Nokia Siemens Networks
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
Adrian Hoban69435b92010-11-04 15:02:04 -040011 * Updated RFC4106 AES-GCM testing.
12 * Authors: Aidan O'Mahony (aidan.o.mahony@intel.com)
13 * Adrian Hoban <adrian.hoban@intel.com>
14 * Gabriele Paoloni <gabriele.paoloni@intel.com>
15 * Tadeusz Struk (tadeusz.struk@intel.com)
16 * Copyright (c) 2010, Intel Corporation.
17 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 * This program is free software; you can redistribute it and/or modify it
19 * under the terms of the GNU General Public License as published by the Free
Herbert Xuef2736f2005-06-22 13:26:03 -070020 * Software Foundation; either version 2 of the License, or (at your option)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021 * any later version.
22 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 */
24
Herbert Xu18e33e62008-07-10 16:01:22 +080025#include <crypto/hash.h>
Herbert Xucba83562006-08-13 08:26:09 +100026#include <linux/err.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/init.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090028#include <linux/gfp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/module.h>
David Hardeman378f0582005-09-17 17:55:31 +100030#include <linux/scatterlist.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/string.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/moduleparam.h>
Harald Welteebfd9bc2005-06-22 13:27:23 -070033#include <linux/jiffies.h>
Herbert Xu6a179442005-06-22 13:29:03 -070034#include <linux/timex.h>
35#include <linux/interrupt.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include "tcrypt.h"
Jarod Wilson4e033a62009-05-27 15:10:21 +100037#include "internal.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39/*
Herbert Xuf139cfa2008-07-31 12:23:53 +080040 * Need slab memory for testing (size in number of pages).
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 */
Herbert Xuf139cfa2008-07-31 12:23:53 +080042#define TVMEMSIZE 4
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
44/*
Herbert Xuda7f0332008-07-31 17:08:25 +080045* Used by test_cipher_speed()
Linus Torvalds1da177e2005-04-16 15:20:36 -070046*/
47#define ENCRYPT 1
48#define DECRYPT 0
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Harald Welteebfd9bc2005-06-22 13:27:23 -070050/*
51 * Used by test_cipher_speed()
52 */
Herbert Xu6a179442005-06-22 13:29:03 -070053static unsigned int sec;
Harald Welteebfd9bc2005-06-22 13:27:23 -070054
Steffen Klasserta873a5f2009-06-19 19:46:53 +080055static char *alg = NULL;
56static u32 type;
Herbert Xu7be380f2009-07-14 16:06:54 +080057static u32 mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058static int mode;
Herbert Xuf139cfa2008-07-31 12:23:53 +080059static char *tvmem[TVMEMSIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61static char *check[] = {
Jonathan Lynchcd12fb902007-11-10 20:08:25 +080062 "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256",
63 "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
64 "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
David Howells90831632006-12-16 12:13:14 +110065 "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
Adrian-Ken Rueegsegger2998db32008-05-09 21:29:35 +080066 "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320",
Geert Uytterhoeven0c01aed2009-03-04 15:42:15 +080067 "lzo", "cts", "zlib", NULL
Linus Torvalds1da177e2005-04-16 15:20:36 -070068};
69
Herbert Xuf139cfa2008-07-31 12:23:53 +080070static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc,
71 struct scatterlist *sg, int blen, int sec)
Herbert Xu6a179442005-06-22 13:29:03 -070072{
Herbert Xu6a179442005-06-22 13:29:03 -070073 unsigned long start, end;
74 int bcount;
75 int ret;
76
Herbert Xu6a179442005-06-22 13:29:03 -070077 for (start = jiffies, end = start + sec * HZ, bcount = 0;
78 time_before(jiffies, end); bcount++) {
79 if (enc)
Herbert Xucba83562006-08-13 08:26:09 +100080 ret = crypto_blkcipher_encrypt(desc, sg, sg, blen);
Herbert Xu6a179442005-06-22 13:29:03 -070081 else
Herbert Xucba83562006-08-13 08:26:09 +100082 ret = crypto_blkcipher_decrypt(desc, sg, sg, blen);
Herbert Xu6a179442005-06-22 13:29:03 -070083
84 if (ret)
85 return ret;
86 }
87
88 printk("%d operations in %d seconds (%ld bytes)\n",
89 bcount, sec, (long)bcount * blen);
90 return 0;
91}
92
Herbert Xuf139cfa2008-07-31 12:23:53 +080093static int test_cipher_cycles(struct blkcipher_desc *desc, int enc,
94 struct scatterlist *sg, int blen)
Herbert Xu6a179442005-06-22 13:29:03 -070095{
Herbert Xu6a179442005-06-22 13:29:03 -070096 unsigned long cycles = 0;
97 int ret = 0;
98 int i;
99
Herbert Xu6a179442005-06-22 13:29:03 -0700100 local_irq_disable();
101
102 /* Warm-up run. */
103 for (i = 0; i < 4; i++) {
104 if (enc)
Herbert Xucba83562006-08-13 08:26:09 +1000105 ret = crypto_blkcipher_encrypt(desc, sg, sg, blen);
Herbert Xu6a179442005-06-22 13:29:03 -0700106 else
Herbert Xucba83562006-08-13 08:26:09 +1000107 ret = crypto_blkcipher_decrypt(desc, sg, sg, blen);
Herbert Xu6a179442005-06-22 13:29:03 -0700108
109 if (ret)
110 goto out;
111 }
112
113 /* The real thing. */
114 for (i = 0; i < 8; i++) {
115 cycles_t start, end;
116
117 start = get_cycles();
118 if (enc)
Herbert Xucba83562006-08-13 08:26:09 +1000119 ret = crypto_blkcipher_encrypt(desc, sg, sg, blen);
Herbert Xu6a179442005-06-22 13:29:03 -0700120 else
Herbert Xucba83562006-08-13 08:26:09 +1000121 ret = crypto_blkcipher_decrypt(desc, sg, sg, blen);
Herbert Xu6a179442005-06-22 13:29:03 -0700122 end = get_cycles();
123
124 if (ret)
125 goto out;
126
127 cycles += end - start;
128 }
129
130out:
131 local_irq_enable();
Herbert Xu6a179442005-06-22 13:29:03 -0700132
133 if (ret == 0)
134 printk("1 operation in %lu cycles (%d bytes)\n",
135 (cycles + 4) / 8, blen);
136
137 return ret;
138}
139
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800140static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 };
141
Herbert Xu01b32322008-07-31 15:41:55 +0800142static void test_cipher_speed(const char *algo, int enc, unsigned int sec,
Herbert Xuda7f0332008-07-31 17:08:25 +0800143 struct cipher_speed_template *template,
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800144 unsigned int tcount, u8 *keysize)
Harald Welteebfd9bc2005-06-22 13:27:23 -0700145{
Herbert Xudce907c2005-06-22 13:27:51 -0700146 unsigned int ret, i, j, iv_len;
David Sterbaf07ef1d2011-03-04 15:28:52 +0800147 const char *key;
148 char iv[128];
Herbert Xucba83562006-08-13 08:26:09 +1000149 struct crypto_blkcipher *tfm;
150 struct blkcipher_desc desc;
151 const char *e;
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800152 u32 *b_size;
Harald Welteebfd9bc2005-06-22 13:27:23 -0700153
154 if (enc == ENCRYPT)
155 e = "encryption";
156 else
157 e = "decryption";
Harald Welteebfd9bc2005-06-22 13:27:23 -0700158
Herbert Xucba83562006-08-13 08:26:09 +1000159 printk("\ntesting speed of %s %s\n", algo, e);
Harald Welteebfd9bc2005-06-22 13:27:23 -0700160
Herbert Xucba83562006-08-13 08:26:09 +1000161 tfm = crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC);
Harald Welteebfd9bc2005-06-22 13:27:23 -0700162
Herbert Xucba83562006-08-13 08:26:09 +1000163 if (IS_ERR(tfm)) {
164 printk("failed to load transform for %s: %ld\n", algo,
165 PTR_ERR(tfm));
Harald Welteebfd9bc2005-06-22 13:27:23 -0700166 return;
167 }
Herbert Xucba83562006-08-13 08:26:09 +1000168 desc.tfm = tfm;
169 desc.flags = 0;
Harald Welteebfd9bc2005-06-22 13:27:23 -0700170
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800171 i = 0;
172 do {
Harald Welteebfd9bc2005-06-22 13:27:23 -0700173
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800174 b_size = block_sizes;
175 do {
Herbert Xuf139cfa2008-07-31 12:23:53 +0800176 struct scatterlist sg[TVMEMSIZE];
Harald Welteebfd9bc2005-06-22 13:27:23 -0700177
Herbert Xuf139cfa2008-07-31 12:23:53 +0800178 if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
179 printk("template (%u) too big for "
180 "tvmem (%lu)\n", *keysize + *b_size,
181 TVMEMSIZE * PAGE_SIZE);
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800182 goto out;
183 }
Harald Welteebfd9bc2005-06-22 13:27:23 -0700184
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800185 printk("test %u (%d bit key, %d byte blocks): ", i,
186 *keysize * 8, *b_size);
187
Herbert Xuf139cfa2008-07-31 12:23:53 +0800188 memset(tvmem[0], 0xff, PAGE_SIZE);
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800189
190 /* set key, plain text and IV */
Herbert Xuda7f0332008-07-31 17:08:25 +0800191 key = tvmem[0];
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800192 for (j = 0; j < tcount; j++) {
193 if (template[j].klen == *keysize) {
194 key = template[j].key;
195 break;
196 }
197 }
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800198
199 ret = crypto_blkcipher_setkey(tfm, key, *keysize);
200 if (ret) {
201 printk("setkey() failed flags=%x\n",
202 crypto_blkcipher_get_flags(tfm));
203 goto out;
204 }
205
Herbert Xuf139cfa2008-07-31 12:23:53 +0800206 sg_init_table(sg, TVMEMSIZE);
207 sg_set_buf(sg, tvmem[0] + *keysize,
208 PAGE_SIZE - *keysize);
209 for (j = 1; j < TVMEMSIZE; j++) {
210 sg_set_buf(sg + j, tvmem[j], PAGE_SIZE);
211 memset (tvmem[j], 0xff, PAGE_SIZE);
212 }
213
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800214 iv_len = crypto_blkcipher_ivsize(tfm);
215 if (iv_len) {
216 memset(&iv, 0xff, iv_len);
217 crypto_blkcipher_set_iv(tfm, iv, iv_len);
218 }
219
220 if (sec)
Herbert Xuf139cfa2008-07-31 12:23:53 +0800221 ret = test_cipher_jiffies(&desc, enc, sg,
222 *b_size, sec);
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800223 else
Herbert Xuf139cfa2008-07-31 12:23:53 +0800224 ret = test_cipher_cycles(&desc, enc, sg,
225 *b_size);
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800226
227 if (ret) {
228 printk("%s() failed flags=%x\n", e, desc.flags);
Herbert Xudce907c2005-06-22 13:27:51 -0700229 break;
230 }
Sebastian Siewiord5dc3922008-03-11 21:27:11 +0800231 b_size++;
232 i++;
233 } while (*b_size);
234 keysize++;
235 } while (*keysize);
Harald Welteebfd9bc2005-06-22 13:27:23 -0700236
237out:
Herbert Xucba83562006-08-13 08:26:09 +1000238 crypto_free_blkcipher(tfm);
Harald Welteebfd9bc2005-06-22 13:27:23 -0700239}
240
Herbert Xuf139cfa2008-07-31 12:23:53 +0800241static int test_hash_jiffies_digest(struct hash_desc *desc,
242 struct scatterlist *sg, int blen,
Herbert Xue9d41162006-08-19 21:38:49 +1000243 char *out, int sec)
Michal Ludvige8057922006-05-30 22:04:19 +1000244{
Michal Ludvige8057922006-05-30 22:04:19 +1000245 unsigned long start, end;
Herbert Xue9d41162006-08-19 21:38:49 +1000246 int bcount;
247 int ret;
Michal Ludvige8057922006-05-30 22:04:19 +1000248
249 for (start = jiffies, end = start + sec * HZ, bcount = 0;
250 time_before(jiffies, end); bcount++) {
Herbert Xue9d41162006-08-19 21:38:49 +1000251 ret = crypto_hash_digest(desc, sg, blen, out);
252 if (ret)
253 return ret;
Michal Ludvige8057922006-05-30 22:04:19 +1000254 }
255
256 printk("%6u opers/sec, %9lu bytes/sec\n",
257 bcount / sec, ((long)bcount * blen) / sec);
258
Herbert Xue9d41162006-08-19 21:38:49 +1000259 return 0;
Michal Ludvige8057922006-05-30 22:04:19 +1000260}
261
Herbert Xuf139cfa2008-07-31 12:23:53 +0800262static int test_hash_jiffies(struct hash_desc *desc, struct scatterlist *sg,
263 int blen, int plen, char *out, int sec)
Herbert Xue9d41162006-08-19 21:38:49 +1000264{
Herbert Xue9d41162006-08-19 21:38:49 +1000265 unsigned long start, end;
266 int bcount, pcount;
267 int ret;
268
269 if (plen == blen)
Herbert Xuf139cfa2008-07-31 12:23:53 +0800270 return test_hash_jiffies_digest(desc, sg, blen, out, sec);
Herbert Xua5a613a2007-10-27 00:51:21 -0700271
Herbert Xue9d41162006-08-19 21:38:49 +1000272 for (start = jiffies, end = start + sec * HZ, bcount = 0;
273 time_before(jiffies, end); bcount++) {
274 ret = crypto_hash_init(desc);
275 if (ret)
276 return ret;
277 for (pcount = 0; pcount < blen; pcount += plen) {
Herbert Xue9d41162006-08-19 21:38:49 +1000278 ret = crypto_hash_update(desc, sg, plen);
279 if (ret)
280 return ret;
281 }
282 /* we assume there is enough space in 'out' for the result */
283 ret = crypto_hash_final(desc, out);
284 if (ret)
285 return ret;
286 }
287
288 printk("%6u opers/sec, %9lu bytes/sec\n",
289 bcount / sec, ((long)bcount * blen) / sec);
290
291 return 0;
292}
293
Herbert Xuf139cfa2008-07-31 12:23:53 +0800294static int test_hash_cycles_digest(struct hash_desc *desc,
295 struct scatterlist *sg, int blen, char *out)
Michal Ludvige8057922006-05-30 22:04:19 +1000296{
Michal Ludvige8057922006-05-30 22:04:19 +1000297 unsigned long cycles = 0;
Herbert Xue9d41162006-08-19 21:38:49 +1000298 int i;
299 int ret;
Michal Ludvige8057922006-05-30 22:04:19 +1000300
Michal Ludvige8057922006-05-30 22:04:19 +1000301 local_irq_disable();
302
303 /* Warm-up run. */
304 for (i = 0; i < 4; i++) {
Herbert Xue9d41162006-08-19 21:38:49 +1000305 ret = crypto_hash_digest(desc, sg, blen, out);
306 if (ret)
307 goto out;
Michal Ludvige8057922006-05-30 22:04:19 +1000308 }
309
310 /* The real thing. */
311 for (i = 0; i < 8; i++) {
312 cycles_t start, end;
313
Michal Ludvige8057922006-05-30 22:04:19 +1000314 start = get_cycles();
315
Herbert Xue9d41162006-08-19 21:38:49 +1000316 ret = crypto_hash_digest(desc, sg, blen, out);
317 if (ret)
318 goto out;
Michal Ludvige8057922006-05-30 22:04:19 +1000319
320 end = get_cycles();
321
322 cycles += end - start;
323 }
324
Herbert Xue9d41162006-08-19 21:38:49 +1000325out:
Michal Ludvige8057922006-05-30 22:04:19 +1000326 local_irq_enable();
Michal Ludvige8057922006-05-30 22:04:19 +1000327
Herbert Xue9d41162006-08-19 21:38:49 +1000328 if (ret)
329 return ret;
330
Michal Ludvige8057922006-05-30 22:04:19 +1000331 printk("%6lu cycles/operation, %4lu cycles/byte\n",
332 cycles / 8, cycles / (8 * blen));
333
Herbert Xue9d41162006-08-19 21:38:49 +1000334 return 0;
Michal Ludvige8057922006-05-30 22:04:19 +1000335}
336
Herbert Xuf139cfa2008-07-31 12:23:53 +0800337static int test_hash_cycles(struct hash_desc *desc, struct scatterlist *sg,
338 int blen, int plen, char *out)
Michal Ludvige8057922006-05-30 22:04:19 +1000339{
Herbert Xue9d41162006-08-19 21:38:49 +1000340 unsigned long cycles = 0;
341 int i, pcount;
342 int ret;
343
344 if (plen == blen)
Herbert Xuf139cfa2008-07-31 12:23:53 +0800345 return test_hash_cycles_digest(desc, sg, blen, out);
Herbert Xua5a613a2007-10-27 00:51:21 -0700346
Herbert Xue9d41162006-08-19 21:38:49 +1000347 local_irq_disable();
348
349 /* Warm-up run. */
350 for (i = 0; i < 4; i++) {
351 ret = crypto_hash_init(desc);
352 if (ret)
353 goto out;
354 for (pcount = 0; pcount < blen; pcount += plen) {
Herbert Xue9d41162006-08-19 21:38:49 +1000355 ret = crypto_hash_update(desc, sg, plen);
356 if (ret)
357 goto out;
358 }
Herbert Xu29059d12007-05-18 16:25:19 +1000359 ret = crypto_hash_final(desc, out);
Herbert Xue9d41162006-08-19 21:38:49 +1000360 if (ret)
361 goto out;
362 }
363
364 /* The real thing. */
365 for (i = 0; i < 8; i++) {
366 cycles_t start, end;
367
368 start = get_cycles();
369
370 ret = crypto_hash_init(desc);
371 if (ret)
372 goto out;
373 for (pcount = 0; pcount < blen; pcount += plen) {
Herbert Xue9d41162006-08-19 21:38:49 +1000374 ret = crypto_hash_update(desc, sg, plen);
375 if (ret)
376 goto out;
377 }
378 ret = crypto_hash_final(desc, out);
379 if (ret)
380 goto out;
381
382 end = get_cycles();
383
384 cycles += end - start;
385 }
386
387out:
388 local_irq_enable();
Herbert Xue9d41162006-08-19 21:38:49 +1000389
390 if (ret)
391 return ret;
392
393 printk("%6lu cycles/operation, %4lu cycles/byte\n",
394 cycles / 8, cycles / (8 * blen));
395
396 return 0;
397}
398
David S. Millerbeb63da2010-05-19 14:11:21 +1000399static void test_hash_sg_init(struct scatterlist *sg)
400{
401 int i;
402
403 sg_init_table(sg, TVMEMSIZE);
404 for (i = 0; i < TVMEMSIZE; i++) {
405 sg_set_buf(sg + i, tvmem[i], PAGE_SIZE);
406 memset(tvmem[i], 0xff, PAGE_SIZE);
407 }
408}
409
Herbert Xu01b32322008-07-31 15:41:55 +0800410static void test_hash_speed(const char *algo, unsigned int sec,
411 struct hash_speed *speed)
Herbert Xue9d41162006-08-19 21:38:49 +1000412{
Herbert Xuf139cfa2008-07-31 12:23:53 +0800413 struct scatterlist sg[TVMEMSIZE];
Herbert Xue9d41162006-08-19 21:38:49 +1000414 struct crypto_hash *tfm;
415 struct hash_desc desc;
Frank Seidel376bacb2009-03-29 15:18:39 +0800416 static char output[1024];
Michal Ludvige8057922006-05-30 22:04:19 +1000417 int i;
Herbert Xue9d41162006-08-19 21:38:49 +1000418 int ret;
Michal Ludvige8057922006-05-30 22:04:19 +1000419
Frank Seidel376bacb2009-03-29 15:18:39 +0800420 printk(KERN_INFO "\ntesting speed of %s\n", algo);
Michal Ludvige8057922006-05-30 22:04:19 +1000421
Herbert Xue9d41162006-08-19 21:38:49 +1000422 tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC);
Michal Ludvige8057922006-05-30 22:04:19 +1000423
Herbert Xue9d41162006-08-19 21:38:49 +1000424 if (IS_ERR(tfm)) {
Frank Seidel376bacb2009-03-29 15:18:39 +0800425 printk(KERN_ERR "failed to load transform for %s: %ld\n", algo,
Herbert Xue9d41162006-08-19 21:38:49 +1000426 PTR_ERR(tfm));
Michal Ludvige8057922006-05-30 22:04:19 +1000427 return;
428 }
429
Herbert Xue9d41162006-08-19 21:38:49 +1000430 desc.tfm = tfm;
431 desc.flags = 0;
432
433 if (crypto_hash_digestsize(tfm) > sizeof(output)) {
Frank Seidel376bacb2009-03-29 15:18:39 +0800434 printk(KERN_ERR "digestsize(%u) > outputbuffer(%zu)\n",
Herbert Xue9d41162006-08-19 21:38:49 +1000435 crypto_hash_digestsize(tfm), sizeof(output));
Michal Ludvige8057922006-05-30 22:04:19 +1000436 goto out;
437 }
438
David S. Millerbeb63da2010-05-19 14:11:21 +1000439 test_hash_sg_init(sg);
Michal Ludvige8057922006-05-30 22:04:19 +1000440 for (i = 0; speed[i].blen != 0; i++) {
Herbert Xuf139cfa2008-07-31 12:23:53 +0800441 if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
Frank Seidel376bacb2009-03-29 15:18:39 +0800442 printk(KERN_ERR
443 "template (%u) too big for tvmem (%lu)\n",
Herbert Xuf139cfa2008-07-31 12:23:53 +0800444 speed[i].blen, TVMEMSIZE * PAGE_SIZE);
Michal Ludvige8057922006-05-30 22:04:19 +1000445 goto out;
446 }
447
Huang Ying18bcc912010-03-10 18:30:32 +0800448 if (speed[i].klen)
449 crypto_hash_setkey(tfm, tvmem[0], speed[i].klen);
450
Frank Seidel376bacb2009-03-29 15:18:39 +0800451 printk(KERN_INFO "test%3u "
452 "(%5u byte blocks,%5u bytes per update,%4u updates): ",
Michal Ludvige8057922006-05-30 22:04:19 +1000453 i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
454
Michal Ludvige8057922006-05-30 22:04:19 +1000455 if (sec)
Herbert Xuf139cfa2008-07-31 12:23:53 +0800456 ret = test_hash_jiffies(&desc, sg, speed[i].blen,
Herbert Xue9d41162006-08-19 21:38:49 +1000457 speed[i].plen, output, sec);
Michal Ludvige8057922006-05-30 22:04:19 +1000458 else
Herbert Xuf139cfa2008-07-31 12:23:53 +0800459 ret = test_hash_cycles(&desc, sg, speed[i].blen,
Herbert Xue9d41162006-08-19 21:38:49 +1000460 speed[i].plen, output);
461
462 if (ret) {
Frank Seidel376bacb2009-03-29 15:18:39 +0800463 printk(KERN_ERR "hashing failed ret=%d\n", ret);
Herbert Xue9d41162006-08-19 21:38:49 +1000464 break;
465 }
Michal Ludvige8057922006-05-30 22:04:19 +1000466 }
467
468out:
Herbert Xue9d41162006-08-19 21:38:49 +1000469 crypto_free_hash(tfm);
Michal Ludvige8057922006-05-30 22:04:19 +1000470}
471
David S. Millerbeb63da2010-05-19 14:11:21 +1000472struct tcrypt_result {
473 struct completion completion;
474 int err;
475};
476
477static void tcrypt_complete(struct crypto_async_request *req, int err)
478{
479 struct tcrypt_result *res = req->data;
480
481 if (err == -EINPROGRESS)
482 return;
483
484 res->err = err;
485 complete(&res->completion);
486}
487
488static inline int do_one_ahash_op(struct ahash_request *req, int ret)
489{
490 if (ret == -EINPROGRESS || ret == -EBUSY) {
491 struct tcrypt_result *tr = req->base.data;
492
493 ret = wait_for_completion_interruptible(&tr->completion);
494 if (!ret)
495 ret = tr->err;
496 INIT_COMPLETION(tr->completion);
497 }
498 return ret;
499}
500
501static int test_ahash_jiffies_digest(struct ahash_request *req, int blen,
502 char *out, int sec)
503{
504 unsigned long start, end;
505 int bcount;
506 int ret;
507
508 for (start = jiffies, end = start + sec * HZ, bcount = 0;
509 time_before(jiffies, end); bcount++) {
510 ret = do_one_ahash_op(req, crypto_ahash_digest(req));
511 if (ret)
512 return ret;
513 }
514
515 printk("%6u opers/sec, %9lu bytes/sec\n",
516 bcount / sec, ((long)bcount * blen) / sec);
517
518 return 0;
519}
520
521static int test_ahash_jiffies(struct ahash_request *req, int blen,
522 int plen, char *out, int sec)
523{
524 unsigned long start, end;
525 int bcount, pcount;
526 int ret;
527
528 if (plen == blen)
529 return test_ahash_jiffies_digest(req, blen, out, sec);
530
531 for (start = jiffies, end = start + sec * HZ, bcount = 0;
532 time_before(jiffies, end); bcount++) {
533 ret = crypto_ahash_init(req);
534 if (ret)
535 return ret;
536 for (pcount = 0; pcount < blen; pcount += plen) {
537 ret = do_one_ahash_op(req, crypto_ahash_update(req));
538 if (ret)
539 return ret;
540 }
541 /* we assume there is enough space in 'out' for the result */
542 ret = do_one_ahash_op(req, crypto_ahash_final(req));
543 if (ret)
544 return ret;
545 }
546
547 pr_cont("%6u opers/sec, %9lu bytes/sec\n",
548 bcount / sec, ((long)bcount * blen) / sec);
549
550 return 0;
551}
552
553static int test_ahash_cycles_digest(struct ahash_request *req, int blen,
554 char *out)
555{
556 unsigned long cycles = 0;
557 int ret, i;
558
559 /* Warm-up run. */
560 for (i = 0; i < 4; i++) {
561 ret = do_one_ahash_op(req, crypto_ahash_digest(req));
562 if (ret)
563 goto out;
564 }
565
566 /* The real thing. */
567 for (i = 0; i < 8; i++) {
568 cycles_t start, end;
569
570 start = get_cycles();
571
572 ret = do_one_ahash_op(req, crypto_ahash_digest(req));
573 if (ret)
574 goto out;
575
576 end = get_cycles();
577
578 cycles += end - start;
579 }
580
581out:
582 if (ret)
583 return ret;
584
585 pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
586 cycles / 8, cycles / (8 * blen));
587
588 return 0;
589}
590
591static int test_ahash_cycles(struct ahash_request *req, int blen,
592 int plen, char *out)
593{
594 unsigned long cycles = 0;
595 int i, pcount, ret;
596
597 if (plen == blen)
598 return test_ahash_cycles_digest(req, blen, out);
599
600 /* Warm-up run. */
601 for (i = 0; i < 4; i++) {
602 ret = crypto_ahash_init(req);
603 if (ret)
604 goto out;
605 for (pcount = 0; pcount < blen; pcount += plen) {
606 ret = do_one_ahash_op(req, crypto_ahash_update(req));
607 if (ret)
608 goto out;
609 }
610 ret = do_one_ahash_op(req, crypto_ahash_final(req));
611 if (ret)
612 goto out;
613 }
614
615 /* The real thing. */
616 for (i = 0; i < 8; i++) {
617 cycles_t start, end;
618
619 start = get_cycles();
620
621 ret = crypto_ahash_init(req);
622 if (ret)
623 goto out;
624 for (pcount = 0; pcount < blen; pcount += plen) {
625 ret = do_one_ahash_op(req, crypto_ahash_update(req));
626 if (ret)
627 goto out;
628 }
629 ret = do_one_ahash_op(req, crypto_ahash_final(req));
630 if (ret)
631 goto out;
632
633 end = get_cycles();
634
635 cycles += end - start;
636 }
637
638out:
639 if (ret)
640 return ret;
641
642 pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
643 cycles / 8, cycles / (8 * blen));
644
645 return 0;
646}
647
648static void test_ahash_speed(const char *algo, unsigned int sec,
649 struct hash_speed *speed)
650{
651 struct scatterlist sg[TVMEMSIZE];
652 struct tcrypt_result tresult;
653 struct ahash_request *req;
654 struct crypto_ahash *tfm;
655 static char output[1024];
656 int i, ret;
657
658 printk(KERN_INFO "\ntesting speed of async %s\n", algo);
659
660 tfm = crypto_alloc_ahash(algo, 0, 0);
661 if (IS_ERR(tfm)) {
662 pr_err("failed to load transform for %s: %ld\n",
663 algo, PTR_ERR(tfm));
664 return;
665 }
666
667 if (crypto_ahash_digestsize(tfm) > sizeof(output)) {
668 pr_err("digestsize(%u) > outputbuffer(%zu)\n",
669 crypto_ahash_digestsize(tfm), sizeof(output));
670 goto out;
671 }
672
673 test_hash_sg_init(sg);
674 req = ahash_request_alloc(tfm, GFP_KERNEL);
675 if (!req) {
676 pr_err("ahash request allocation failure\n");
677 goto out;
678 }
679
680 init_completion(&tresult.completion);
681 ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
682 tcrypt_complete, &tresult);
683
684 for (i = 0; speed[i].blen != 0; i++) {
685 if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
686 pr_err("template (%u) too big for tvmem (%lu)\n",
687 speed[i].blen, TVMEMSIZE * PAGE_SIZE);
688 break;
689 }
690
691 pr_info("test%3u "
692 "(%5u byte blocks,%5u bytes per update,%4u updates): ",
693 i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
694
695 ahash_request_set_crypt(req, sg, output, speed[i].plen);
696
697 if (sec)
698 ret = test_ahash_jiffies(req, speed[i].blen,
699 speed[i].plen, output, sec);
700 else
701 ret = test_ahash_cycles(req, speed[i].blen,
702 speed[i].plen, output);
703
704 if (ret) {
705 pr_err("hashing failed ret=%d\n", ret);
706 break;
707 }
708 }
709
710 ahash_request_free(req);
711
712out:
713 crypto_free_ahash(tfm);
714}
715
Jussi Kivilinna3f3baf32011-10-18 00:02:58 +0300716static inline int do_one_acipher_op(struct ablkcipher_request *req, int ret)
717{
718 if (ret == -EINPROGRESS || ret == -EBUSY) {
719 struct tcrypt_result *tr = req->base.data;
720
721 ret = wait_for_completion_interruptible(&tr->completion);
722 if (!ret)
723 ret = tr->err;
724 INIT_COMPLETION(tr->completion);
725 }
726
727 return ret;
728}
729
730static int test_acipher_jiffies(struct ablkcipher_request *req, int enc,
731 int blen, int sec)
732{
733 unsigned long start, end;
734 int bcount;
735 int ret;
736
737 for (start = jiffies, end = start + sec * HZ, bcount = 0;
738 time_before(jiffies, end); bcount++) {
739 if (enc)
740 ret = do_one_acipher_op(req,
741 crypto_ablkcipher_encrypt(req));
742 else
743 ret = do_one_acipher_op(req,
744 crypto_ablkcipher_decrypt(req));
745
746 if (ret)
747 return ret;
748 }
749
750 pr_cont("%d operations in %d seconds (%ld bytes)\n",
751 bcount, sec, (long)bcount * blen);
752 return 0;
753}
754
755static int test_acipher_cycles(struct ablkcipher_request *req, int enc,
756 int blen)
757{
758 unsigned long cycles = 0;
759 int ret = 0;
760 int i;
761
762 /* Warm-up run. */
763 for (i = 0; i < 4; i++) {
764 if (enc)
765 ret = do_one_acipher_op(req,
766 crypto_ablkcipher_encrypt(req));
767 else
768 ret = do_one_acipher_op(req,
769 crypto_ablkcipher_decrypt(req));
770
771 if (ret)
772 goto out;
773 }
774
775 /* The real thing. */
776 for (i = 0; i < 8; i++) {
777 cycles_t start, end;
778
779 start = get_cycles();
780 if (enc)
781 ret = do_one_acipher_op(req,
782 crypto_ablkcipher_encrypt(req));
783 else
784 ret = do_one_acipher_op(req,
785 crypto_ablkcipher_decrypt(req));
786 end = get_cycles();
787
788 if (ret)
789 goto out;
790
791 cycles += end - start;
792 }
793
794out:
795 if (ret == 0)
796 pr_cont("1 operation in %lu cycles (%d bytes)\n",
797 (cycles + 4) / 8, blen);
798
799 return ret;
800}
801
802static void test_acipher_speed(const char *algo, int enc, unsigned int sec,
803 struct cipher_speed_template *template,
804 unsigned int tcount, u8 *keysize)
805{
Nicolas Royerde1975332012-07-01 19:19:47 +0200806 unsigned int ret, i, j, k, iv_len;
Jussi Kivilinna3f3baf32011-10-18 00:02:58 +0300807 struct tcrypt_result tresult;
808 const char *key;
809 char iv[128];
810 struct ablkcipher_request *req;
811 struct crypto_ablkcipher *tfm;
812 const char *e;
813 u32 *b_size;
814
815 if (enc == ENCRYPT)
816 e = "encryption";
817 else
818 e = "decryption";
819
820 pr_info("\ntesting speed of async %s %s\n", algo, e);
821
822 init_completion(&tresult.completion);
823
824 tfm = crypto_alloc_ablkcipher(algo, 0, 0);
825
826 if (IS_ERR(tfm)) {
827 pr_err("failed to load transform for %s: %ld\n", algo,
828 PTR_ERR(tfm));
829 return;
830 }
831
832 req = ablkcipher_request_alloc(tfm, GFP_KERNEL);
833 if (!req) {
834 pr_err("tcrypt: skcipher: Failed to allocate request for %s\n",
835 algo);
836 goto out;
837 }
838
839 ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
840 tcrypt_complete, &tresult);
841
842 i = 0;
843 do {
844 b_size = block_sizes;
845
846 do {
847 struct scatterlist sg[TVMEMSIZE];
848
849 if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
850 pr_err("template (%u) too big for "
851 "tvmem (%lu)\n", *keysize + *b_size,
852 TVMEMSIZE * PAGE_SIZE);
853 goto out_free_req;
854 }
855
856 pr_info("test %u (%d bit key, %d byte blocks): ", i,
857 *keysize * 8, *b_size);
858
859 memset(tvmem[0], 0xff, PAGE_SIZE);
860
861 /* set key, plain text and IV */
862 key = tvmem[0];
863 for (j = 0; j < tcount; j++) {
864 if (template[j].klen == *keysize) {
865 key = template[j].key;
866 break;
867 }
868 }
869
870 crypto_ablkcipher_clear_flags(tfm, ~0);
871
872 ret = crypto_ablkcipher_setkey(tfm, key, *keysize);
873 if (ret) {
874 pr_err("setkey() failed flags=%x\n",
875 crypto_ablkcipher_get_flags(tfm));
876 goto out_free_req;
877 }
878
879 sg_init_table(sg, TVMEMSIZE);
Nicolas Royerde1975332012-07-01 19:19:47 +0200880
881 k = *keysize + *b_size;
882 if (k > PAGE_SIZE) {
883 sg_set_buf(sg, tvmem[0] + *keysize,
Jussi Kivilinna3f3baf32011-10-18 00:02:58 +0300884 PAGE_SIZE - *keysize);
Nicolas Royerde1975332012-07-01 19:19:47 +0200885 k -= PAGE_SIZE;
886 j = 1;
887 while (k > PAGE_SIZE) {
888 sg_set_buf(sg + j, tvmem[j], PAGE_SIZE);
889 memset(tvmem[j], 0xff, PAGE_SIZE);
890 j++;
891 k -= PAGE_SIZE;
892 }
893 sg_set_buf(sg + j, tvmem[j], k);
894 memset(tvmem[j], 0xff, k);
895 } else {
896 sg_set_buf(sg, tvmem[0] + *keysize, *b_size);
Jussi Kivilinna3f3baf32011-10-18 00:02:58 +0300897 }
898
899 iv_len = crypto_ablkcipher_ivsize(tfm);
900 if (iv_len)
901 memset(&iv, 0xff, iv_len);
902
903 ablkcipher_request_set_crypt(req, sg, sg, *b_size, iv);
904
905 if (sec)
906 ret = test_acipher_jiffies(req, enc,
907 *b_size, sec);
908 else
909 ret = test_acipher_cycles(req, enc,
910 *b_size);
911
912 if (ret) {
913 pr_err("%s() failed flags=%x\n", e,
914 crypto_ablkcipher_get_flags(tfm));
915 break;
916 }
917 b_size++;
918 i++;
919 } while (*b_size);
920 keysize++;
921 } while (*keysize);
922
923out_free_req:
924 ablkcipher_request_free(req);
925out:
926 crypto_free_ablkcipher(tfm);
927}
928
Herbert Xuef2736f2005-06-22 13:26:03 -0700929static void test_available(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930{
931 char **name = check;
Herbert Xuef2736f2005-06-22 13:26:03 -0700932
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933 while (*name) {
934 printk("alg %s ", *name);
Herbert Xu6158efc2007-04-04 17:41:07 +1000935 printk(crypto_has_alg(*name, 0, 0) ?
Herbert Xue4d5b792006-08-26 18:12:40 +1000936 "found\n" : "not found\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937 name++;
Herbert Xuef2736f2005-06-22 13:26:03 -0700938 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939}
940
Herbert Xu01b32322008-07-31 15:41:55 +0800941static inline int tcrypt_test(const char *alg)
942{
Jarod Wilson4e033a62009-05-27 15:10:21 +1000943 int ret;
944
945 ret = alg_test(alg, alg, 0, 0);
946 /* non-fips algs return -EINVAL in fips mode */
947 if (fips_enabled && ret == -EINVAL)
948 ret = 0;
949 return ret;
Herbert Xu01b32322008-07-31 15:41:55 +0800950}
951
Jarod Wilson4e033a62009-05-27 15:10:21 +1000952static int do_test(int m)
Herbert Xu01b32322008-07-31 15:41:55 +0800953{
954 int i;
Jarod Wilson4e033a62009-05-27 15:10:21 +1000955 int ret = 0;
Herbert Xu01b32322008-07-31 15:41:55 +0800956
957 switch (m) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958 case 0:
Herbert Xu01b32322008-07-31 15:41:55 +0800959 for (i = 1; i < 200; i++)
Jarod Wilson4e033a62009-05-27 15:10:21 +1000960 ret += do_test(i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961 break;
962
963 case 1:
Jarod Wilson4e033a62009-05-27 15:10:21 +1000964 ret += tcrypt_test("md5");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965 break;
966
967 case 2:
Jarod Wilson4e033a62009-05-27 15:10:21 +1000968 ret += tcrypt_test("sha1");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 break;
970
971 case 3:
Jarod Wilson4e033a62009-05-27 15:10:21 +1000972 ret += tcrypt_test("ecb(des)");
973 ret += tcrypt_test("cbc(des)");
Jussi Kivilinna8163fc32012-10-20 14:53:07 +0300974 ret += tcrypt_test("ctr(des)");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975 break;
976
977 case 4:
Jarod Wilson4e033a62009-05-27 15:10:21 +1000978 ret += tcrypt_test("ecb(des3_ede)");
979 ret += tcrypt_test("cbc(des3_ede)");
Jussi Kivilinnae080b172012-10-20 14:53:12 +0300980 ret += tcrypt_test("ctr(des3_ede)");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981 break;
982
983 case 5:
Jarod Wilson4e033a62009-05-27 15:10:21 +1000984 ret += tcrypt_test("md4");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985 break;
Herbert Xuef2736f2005-06-22 13:26:03 -0700986
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 case 6:
Jarod Wilson4e033a62009-05-27 15:10:21 +1000988 ret += tcrypt_test("sha256");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989 break;
Herbert Xuef2736f2005-06-22 13:26:03 -0700990
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991 case 7:
Jarod Wilson4e033a62009-05-27 15:10:21 +1000992 ret += tcrypt_test("ecb(blowfish)");
993 ret += tcrypt_test("cbc(blowfish)");
Jussi Kivilinna85b63e32011-10-10 23:03:03 +0300994 ret += tcrypt_test("ctr(blowfish)");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995 break;
996
997 case 8:
Jarod Wilson4e033a62009-05-27 15:10:21 +1000998 ret += tcrypt_test("ecb(twofish)");
999 ret += tcrypt_test("cbc(twofish)");
Jussi Kivilinna573da622011-10-10 23:03:12 +03001000 ret += tcrypt_test("ctr(twofish)");
Jussi Kivilinnabee3a902011-10-18 13:32:56 +03001001 ret += tcrypt_test("lrw(twofish)");
Jussi Kivilinna131f7542011-10-18 13:33:38 +03001002 ret += tcrypt_test("xts(twofish)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003 break;
Herbert Xuef2736f2005-06-22 13:26:03 -07001004
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005 case 9:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001006 ret += tcrypt_test("ecb(serpent)");
Jussi Kivilinna9d259172011-10-18 00:02:53 +03001007 ret += tcrypt_test("cbc(serpent)");
1008 ret += tcrypt_test("ctr(serpent)");
Jussi Kivilinna87aae4b2011-10-18 13:32:39 +03001009 ret += tcrypt_test("lrw(serpent)");
Jussi Kivilinna5209c072011-10-18 13:33:22 +03001010 ret += tcrypt_test("xts(serpent)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011 break;
1012
1013 case 10:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001014 ret += tcrypt_test("ecb(aes)");
1015 ret += tcrypt_test("cbc(aes)");
1016 ret += tcrypt_test("lrw(aes)");
1017 ret += tcrypt_test("xts(aes)");
1018 ret += tcrypt_test("ctr(aes)");
1019 ret += tcrypt_test("rfc3686(ctr(aes))");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020 break;
1021
1022 case 11:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001023 ret += tcrypt_test("sha384");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001024 break;
Herbert Xuef2736f2005-06-22 13:26:03 -07001025
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026 case 12:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001027 ret += tcrypt_test("sha512");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001028 break;
1029
1030 case 13:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001031 ret += tcrypt_test("deflate");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001032 break;
1033
1034 case 14:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001035 ret += tcrypt_test("ecb(cast5)");
Johannes Goetzfrieda2c58262012-07-11 19:37:21 +02001036 ret += tcrypt_test("cbc(cast5)");
1037 ret += tcrypt_test("ctr(cast5)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 break;
1039
1040 case 15:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001041 ret += tcrypt_test("ecb(cast6)");
Johannes Goetzfried9b8b0402012-07-11 19:38:29 +02001042 ret += tcrypt_test("cbc(cast6)");
1043 ret += tcrypt_test("ctr(cast6)");
1044 ret += tcrypt_test("lrw(cast6)");
1045 ret += tcrypt_test("xts(cast6)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046 break;
1047
1048 case 16:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001049 ret += tcrypt_test("ecb(arc4)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001050 break;
1051
1052 case 17:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001053 ret += tcrypt_test("michael_mic");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054 break;
1055
1056 case 18:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001057 ret += tcrypt_test("crc32c");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058 break;
1059
1060 case 19:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001061 ret += tcrypt_test("ecb(tea)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001062 break;
1063
1064 case 20:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001065 ret += tcrypt_test("ecb(xtea)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 break;
1067
1068 case 21:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001069 ret += tcrypt_test("ecb(khazad)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 break;
1071
1072 case 22:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001073 ret += tcrypt_test("wp512");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001074 break;
1075
1076 case 23:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001077 ret += tcrypt_test("wp384");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078 break;
1079
1080 case 24:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001081 ret += tcrypt_test("wp256");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082 break;
1083
1084 case 25:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001085 ret += tcrypt_test("ecb(tnepres)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001086 break;
1087
1088 case 26:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001089 ret += tcrypt_test("ecb(anubis)");
1090 ret += tcrypt_test("cbc(anubis)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091 break;
1092
1093 case 27:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001094 ret += tcrypt_test("tgr192");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 break;
1096
1097 case 28:
1098
Jarod Wilson4e033a62009-05-27 15:10:21 +10001099 ret += tcrypt_test("tgr160");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100 break;
1101
1102 case 29:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001103 ret += tcrypt_test("tgr128");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104 break;
Adrian-Ken Rueegsegger2998db32008-05-09 21:29:35 +08001105
Aaron Grothefb4f10e2005-09-01 17:42:46 -07001106 case 30:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001107 ret += tcrypt_test("ecb(xeta)");
Aaron Grothefb4f10e2005-09-01 17:42:46 -07001108 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109
David Howells90831632006-12-16 12:13:14 +11001110 case 31:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001111 ret += tcrypt_test("pcbc(fcrypt)");
David Howells90831632006-12-16 12:13:14 +11001112 break;
1113
Noriaki TAKAMIYA02ab5a72007-01-24 21:48:19 +11001114 case 32:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001115 ret += tcrypt_test("ecb(camellia)");
1116 ret += tcrypt_test("cbc(camellia)");
Jussi Kivilinna54216bb2012-09-21 10:27:10 +03001117 ret += tcrypt_test("ctr(camellia)");
1118 ret += tcrypt_test("lrw(camellia)");
1119 ret += tcrypt_test("xts(camellia)");
Noriaki TAKAMIYA02ab5a72007-01-24 21:48:19 +11001120 break;
Jonathan Lynchcd12fb902007-11-10 20:08:25 +08001121 case 33:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001122 ret += tcrypt_test("sha224");
Jonathan Lynchcd12fb902007-11-10 20:08:25 +08001123 break;
Noriaki TAKAMIYA02ab5a72007-01-24 21:48:19 +11001124
Tan Swee Heng2407d602007-11-23 19:45:00 +08001125 case 34:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001126 ret += tcrypt_test("salsa20");
Tan Swee Heng2407d602007-11-23 19:45:00 +08001127 break;
1128
Herbert Xu8df213d2007-12-02 14:55:47 +11001129 case 35:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001130 ret += tcrypt_test("gcm(aes)");
Herbert Xu8df213d2007-12-02 14:55:47 +11001131 break;
1132
Zoltan Sogor0b77abb2007-12-07 16:53:23 +08001133 case 36:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001134 ret += tcrypt_test("lzo");
Zoltan Sogor0b77abb2007-12-07 16:53:23 +08001135 break;
1136
Joy Latten93cc74e2007-12-12 20:24:22 +08001137 case 37:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001138 ret += tcrypt_test("ccm(aes)");
Joy Latten93cc74e2007-12-12 20:24:22 +08001139 break;
1140
Kevin Coffman76cb9522008-03-24 21:26:16 +08001141 case 38:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001142 ret += tcrypt_test("cts(cbc(aes))");
Kevin Coffman76cb9522008-03-24 21:26:16 +08001143 break;
1144
Adrian-Ken Rueegseggerfd4adf12008-05-07 22:16:36 +08001145 case 39:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001146 ret += tcrypt_test("rmd128");
Adrian-Ken Rueegseggerfd4adf12008-05-07 22:16:36 +08001147 break;
1148
1149 case 40:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001150 ret += tcrypt_test("rmd160");
Adrian-Ken Rueegseggerfd4adf12008-05-07 22:16:36 +08001151 break;
1152
Adrian-Ken Rueegsegger2998db32008-05-09 21:29:35 +08001153 case 41:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001154 ret += tcrypt_test("rmd256");
Adrian-Ken Rueegsegger2998db32008-05-09 21:29:35 +08001155 break;
1156
1157 case 42:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001158 ret += tcrypt_test("rmd320");
Herbert Xu01b32322008-07-31 15:41:55 +08001159 break;
1160
1161 case 43:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001162 ret += tcrypt_test("ecb(seed)");
Adrian-Ken Rueegsegger2998db32008-05-09 21:29:35 +08001163 break;
1164
Geert Uytterhoeven0c01aed2009-03-04 15:42:15 +08001165 case 44:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001166 ret += tcrypt_test("zlib");
Geert Uytterhoeven0c01aed2009-03-04 15:42:15 +08001167 break;
1168
Jarod Wilson5d667322009-05-04 19:23:40 +08001169 case 45:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001170 ret += tcrypt_test("rfc4309(ccm(aes))");
Jarod Wilson5d667322009-05-04 19:23:40 +08001171 break;
1172
Jussi Kivilinna54216bb2012-09-21 10:27:10 +03001173 case 46:
1174 ret += tcrypt_test("ghash");
1175 break;
1176
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 case 100:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001178 ret += tcrypt_test("hmac(md5)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 break;
Herbert Xuef2736f2005-06-22 13:26:03 -07001180
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 case 101:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001182 ret += tcrypt_test("hmac(sha1)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 break;
Herbert Xuef2736f2005-06-22 13:26:03 -07001184
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185 case 102:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001186 ret += tcrypt_test("hmac(sha256)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 break;
1188
Andrew Donofrioa28091a2006-12-10 12:10:20 +11001189 case 103:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001190 ret += tcrypt_test("hmac(sha384)");
Andrew Donofrioa28091a2006-12-10 12:10:20 +11001191 break;
1192
1193 case 104:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001194 ret += tcrypt_test("hmac(sha512)");
Andrew Donofrioa28091a2006-12-10 12:10:20 +11001195 break;
Herbert Xu38ed9ab2008-01-01 15:59:28 +11001196
Jonathan Lynchcd12fb902007-11-10 20:08:25 +08001197 case 105:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001198 ret += tcrypt_test("hmac(sha224)");
Jonathan Lynchcd12fb902007-11-10 20:08:25 +08001199 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200
Herbert Xu38ed9ab2008-01-01 15:59:28 +11001201 case 106:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001202 ret += tcrypt_test("xcbc(aes)");
Herbert Xu38ed9ab2008-01-01 15:59:28 +11001203 break;
1204
Adrian-Ken Rueegseggerfd4adf12008-05-07 22:16:36 +08001205 case 107:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001206 ret += tcrypt_test("hmac(rmd128)");
Adrian-Ken Rueegseggerfd4adf12008-05-07 22:16:36 +08001207 break;
1208
1209 case 108:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001210 ret += tcrypt_test("hmac(rmd160)");
Adrian-Ken Rueegseggerfd4adf12008-05-07 22:16:36 +08001211 break;
1212
Shane Wangf1939f72009-09-02 20:05:22 +10001213 case 109:
1214 ret += tcrypt_test("vmac(aes)");
1215 break;
Sonic Zhanga482b082012-05-25 17:54:13 +08001216 case 110:
1217 ret += tcrypt_test("hmac(crc32)");
1218 break;
Shane Wangf1939f72009-09-02 20:05:22 +10001219
Jarod Wilsone08ca2d2009-05-04 19:46:29 +08001220 case 150:
Jarod Wilson4e033a62009-05-27 15:10:21 +10001221 ret += tcrypt_test("ansi_cprng");
Jarod Wilsone08ca2d2009-05-04 19:46:29 +08001222 break;
1223
Adrian Hoban69435b92010-11-04 15:02:04 -04001224 case 151:
1225 ret += tcrypt_test("rfc4106(gcm(aes))");
1226 break;
1227
Harald Welteebfd9bc2005-06-22 13:27:23 -07001228 case 200:
Herbert Xucba83562006-08-13 08:26:09 +10001229 test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001230 speed_template_16_24_32);
Herbert Xucba83562006-08-13 08:26:09 +10001231 test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001232 speed_template_16_24_32);
Herbert Xucba83562006-08-13 08:26:09 +10001233 test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001234 speed_template_16_24_32);
Herbert Xucba83562006-08-13 08:26:09 +10001235 test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001236 speed_template_16_24_32);
Rik Snelf3d10442006-11-29 19:01:41 +11001237 test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001238 speed_template_32_40_48);
Rik Snelf3d10442006-11-29 19:01:41 +11001239 test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001240 speed_template_32_40_48);
Rik Snelf19f5112007-09-19 20:23:13 +08001241 test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001242 speed_template_32_48_64);
Rik Snelf19f5112007-09-19 20:23:13 +08001243 test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001244 speed_template_32_48_64);
Jan Glauber9996e342011-04-26 16:34:01 +10001245 test_cipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
1246 speed_template_16_24_32);
1247 test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
1248 speed_template_16_24_32);
Harald Welteebfd9bc2005-06-22 13:27:23 -07001249 break;
1250
1251 case 201:
Herbert Xucba83562006-08-13 08:26:09 +10001252 test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec,
Herbert Xuda7f0332008-07-31 17:08:25 +08001253 des3_speed_template, DES3_SPEED_VECTORS,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001254 speed_template_24);
Herbert Xucba83562006-08-13 08:26:09 +10001255 test_cipher_speed("ecb(des3_ede)", DECRYPT, sec,
Herbert Xuda7f0332008-07-31 17:08:25 +08001256 des3_speed_template, DES3_SPEED_VECTORS,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001257 speed_template_24);
Herbert Xucba83562006-08-13 08:26:09 +10001258 test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec,
Herbert Xuda7f0332008-07-31 17:08:25 +08001259 des3_speed_template, DES3_SPEED_VECTORS,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001260 speed_template_24);
Herbert Xucba83562006-08-13 08:26:09 +10001261 test_cipher_speed("cbc(des3_ede)", DECRYPT, sec,
Herbert Xuda7f0332008-07-31 17:08:25 +08001262 des3_speed_template, DES3_SPEED_VECTORS,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001263 speed_template_24);
Harald Welteebfd9bc2005-06-22 13:27:23 -07001264 break;
1265
1266 case 202:
Herbert Xucba83562006-08-13 08:26:09 +10001267 test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001268 speed_template_16_24_32);
Herbert Xucba83562006-08-13 08:26:09 +10001269 test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001270 speed_template_16_24_32);
Herbert Xucba83562006-08-13 08:26:09 +10001271 test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001272 speed_template_16_24_32);
Herbert Xucba83562006-08-13 08:26:09 +10001273 test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001274 speed_template_16_24_32);
Jussi Kivilinnaee5002a2011-09-26 16:47:15 +03001275 test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
1276 speed_template_16_24_32);
1277 test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
1278 speed_template_16_24_32);
Jussi Kivilinnabee3a902011-10-18 13:32:56 +03001279 test_cipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
1280 speed_template_32_40_48);
1281 test_cipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
1282 speed_template_32_40_48);
Jussi Kivilinna131f7542011-10-18 13:33:38 +03001283 test_cipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
1284 speed_template_32_48_64);
1285 test_cipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
1286 speed_template_32_48_64);
Harald Welteebfd9bc2005-06-22 13:27:23 -07001287 break;
1288
1289 case 203:
Herbert Xucba83562006-08-13 08:26:09 +10001290 test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001291 speed_template_8_32);
Herbert Xucba83562006-08-13 08:26:09 +10001292 test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001293 speed_template_8_32);
Herbert Xucba83562006-08-13 08:26:09 +10001294 test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001295 speed_template_8_32);
Herbert Xucba83562006-08-13 08:26:09 +10001296 test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001297 speed_template_8_32);
Jussi Kivilinna7d47b862011-09-02 01:45:17 +03001298 test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
1299 speed_template_8_32);
1300 test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
1301 speed_template_8_32);
Harald Welteebfd9bc2005-06-22 13:27:23 -07001302 break;
1303
1304 case 204:
Herbert Xucba83562006-08-13 08:26:09 +10001305 test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001306 speed_template_8);
Herbert Xucba83562006-08-13 08:26:09 +10001307 test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001308 speed_template_8);
Herbert Xucba83562006-08-13 08:26:09 +10001309 test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001310 speed_template_8);
Herbert Xucba83562006-08-13 08:26:09 +10001311 test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001312 speed_template_8);
Harald Welteebfd9bc2005-06-22 13:27:23 -07001313 break;
1314
Noriaki TAKAMIYA02ab5a72007-01-24 21:48:19 +11001315 case 205:
1316 test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001317 speed_template_16_24_32);
Noriaki TAKAMIYA02ab5a72007-01-24 21:48:19 +11001318 test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001319 speed_template_16_24_32);
Noriaki TAKAMIYA02ab5a72007-01-24 21:48:19 +11001320 test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001321 speed_template_16_24_32);
Noriaki TAKAMIYA02ab5a72007-01-24 21:48:19 +11001322 test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001323 speed_template_16_24_32);
Jussi Kivilinna4de59332012-03-05 20:26:26 +02001324 test_cipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
1325 speed_template_16_24_32);
1326 test_cipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
1327 speed_template_16_24_32);
1328 test_cipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
1329 speed_template_32_40_48);
1330 test_cipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
1331 speed_template_32_40_48);
1332 test_cipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
1333 speed_template_32_48_64);
1334 test_cipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
1335 speed_template_32_48_64);
Noriaki TAKAMIYA02ab5a72007-01-24 21:48:19 +11001336 break;
1337
Tan Swee Heng5de8f1b2007-12-07 17:17:43 +08001338 case 206:
1339 test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0,
Sebastian Siewior477035c2008-03-11 21:24:26 +08001340 speed_template_16_32);
Tan Swee Heng5de8f1b2007-12-07 17:17:43 +08001341 break;
1342
Jussi Kivilinna7fb7fe42011-10-18 00:03:03 +03001343 case 207:
1344 test_cipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
1345 speed_template_16_32);
1346 test_cipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
1347 speed_template_16_32);
1348 test_cipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
1349 speed_template_16_32);
1350 test_cipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
1351 speed_template_16_32);
1352 test_cipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
1353 speed_template_16_32);
1354 test_cipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
1355 speed_template_16_32);
Jussi Kivilinna87aae4b2011-10-18 13:32:39 +03001356 test_cipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
1357 speed_template_32_48);
1358 test_cipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
1359 speed_template_32_48);
Jussi Kivilinna5209c072011-10-18 13:33:22 +03001360 test_cipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
1361 speed_template_32_64);
1362 test_cipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
1363 speed_template_32_64);
Jussi Kivilinna7fb7fe42011-10-18 00:03:03 +03001364 break;
1365
Jussi Kivilinna31b4cd292012-06-12 16:52:04 +08001366 case 208:
1367 test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
1368 speed_template_8);
1369 break;
1370
Johannes Goetzfrieda2c58262012-07-11 19:37:21 +02001371 case 209:
1372 test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
1373 speed_template_8_16);
1374 test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
1375 speed_template_8_16);
1376 test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
1377 speed_template_8_16);
1378 test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
1379 speed_template_8_16);
1380 test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
1381 speed_template_8_16);
1382 test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
1383 speed_template_8_16);
1384 break;
1385
Johannes Goetzfried9b8b0402012-07-11 19:38:29 +02001386 case 210:
1387 test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
1388 speed_template_16_32);
1389 test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
1390 speed_template_16_32);
1391 test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
1392 speed_template_16_32);
1393 test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
1394 speed_template_16_32);
1395 test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
1396 speed_template_16_32);
1397 test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
1398 speed_template_16_32);
1399 test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
1400 speed_template_32_48);
1401 test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
1402 speed_template_32_48);
1403 test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
1404 speed_template_32_64);
1405 test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
1406 speed_template_32_64);
1407 break;
1408
Michal Ludvige8057922006-05-30 22:04:19 +10001409 case 300:
1410 /* fall through */
1411
1412 case 301:
Herbert Xue9d41162006-08-19 21:38:49 +10001413 test_hash_speed("md4", sec, generic_hash_speed_template);
Michal Ludvige8057922006-05-30 22:04:19 +10001414 if (mode > 300 && mode < 400) break;
1415
1416 case 302:
Herbert Xue9d41162006-08-19 21:38:49 +10001417 test_hash_speed("md5", sec, generic_hash_speed_template);
Michal Ludvige8057922006-05-30 22:04:19 +10001418 if (mode > 300 && mode < 400) break;
1419
1420 case 303:
Herbert Xue9d41162006-08-19 21:38:49 +10001421 test_hash_speed("sha1", sec, generic_hash_speed_template);
Michal Ludvige8057922006-05-30 22:04:19 +10001422 if (mode > 300 && mode < 400) break;
1423
1424 case 304:
Herbert Xue9d41162006-08-19 21:38:49 +10001425 test_hash_speed("sha256", sec, generic_hash_speed_template);
Michal Ludvige8057922006-05-30 22:04:19 +10001426 if (mode > 300 && mode < 400) break;
1427
1428 case 305:
Herbert Xue9d41162006-08-19 21:38:49 +10001429 test_hash_speed("sha384", sec, generic_hash_speed_template);
Michal Ludvige8057922006-05-30 22:04:19 +10001430 if (mode > 300 && mode < 400) break;
1431
1432 case 306:
Herbert Xue9d41162006-08-19 21:38:49 +10001433 test_hash_speed("sha512", sec, generic_hash_speed_template);
Michal Ludvige8057922006-05-30 22:04:19 +10001434 if (mode > 300 && mode < 400) break;
1435
1436 case 307:
Herbert Xue9d41162006-08-19 21:38:49 +10001437 test_hash_speed("wp256", sec, generic_hash_speed_template);
Michal Ludvige8057922006-05-30 22:04:19 +10001438 if (mode > 300 && mode < 400) break;
1439
1440 case 308:
Herbert Xue9d41162006-08-19 21:38:49 +10001441 test_hash_speed("wp384", sec, generic_hash_speed_template);
Michal Ludvige8057922006-05-30 22:04:19 +10001442 if (mode > 300 && mode < 400) break;
1443
1444 case 309:
Herbert Xue9d41162006-08-19 21:38:49 +10001445 test_hash_speed("wp512", sec, generic_hash_speed_template);
Michal Ludvige8057922006-05-30 22:04:19 +10001446 if (mode > 300 && mode < 400) break;
1447
1448 case 310:
Herbert Xue9d41162006-08-19 21:38:49 +10001449 test_hash_speed("tgr128", sec, generic_hash_speed_template);
Michal Ludvige8057922006-05-30 22:04:19 +10001450 if (mode > 300 && mode < 400) break;
1451
1452 case 311:
Herbert Xue9d41162006-08-19 21:38:49 +10001453 test_hash_speed("tgr160", sec, generic_hash_speed_template);
Michal Ludvige8057922006-05-30 22:04:19 +10001454 if (mode > 300 && mode < 400) break;
1455
1456 case 312:
Herbert Xue9d41162006-08-19 21:38:49 +10001457 test_hash_speed("tgr192", sec, generic_hash_speed_template);
Michal Ludvige8057922006-05-30 22:04:19 +10001458 if (mode > 300 && mode < 400) break;
1459
Jonathan Lynchcd12fb902007-11-10 20:08:25 +08001460 case 313:
1461 test_hash_speed("sha224", sec, generic_hash_speed_template);
1462 if (mode > 300 && mode < 400) break;
1463
Adrian-Ken Rueegseggerfd4adf12008-05-07 22:16:36 +08001464 case 314:
1465 test_hash_speed("rmd128", sec, generic_hash_speed_template);
1466 if (mode > 300 && mode < 400) break;
1467
1468 case 315:
1469 test_hash_speed("rmd160", sec, generic_hash_speed_template);
1470 if (mode > 300 && mode < 400) break;
1471
Adrian-Ken Rueegsegger2998db32008-05-09 21:29:35 +08001472 case 316:
1473 test_hash_speed("rmd256", sec, generic_hash_speed_template);
1474 if (mode > 300 && mode < 400) break;
1475
1476 case 317:
1477 test_hash_speed("rmd320", sec, generic_hash_speed_template);
1478 if (mode > 300 && mode < 400) break;
1479
Huang Ying18bcc912010-03-10 18:30:32 +08001480 case 318:
1481 test_hash_speed("ghash-generic", sec, hash_speed_template_16);
1482 if (mode > 300 && mode < 400) break;
1483
Tim Chene3899e42012-09-27 15:44:24 -07001484 case 319:
1485 test_hash_speed("crc32c", sec, generic_hash_speed_template);
1486 if (mode > 300 && mode < 400) break;
1487
Michal Ludvige8057922006-05-30 22:04:19 +10001488 case 399:
1489 break;
1490
David S. Millerbeb63da2010-05-19 14:11:21 +10001491 case 400:
1492 /* fall through */
1493
1494 case 401:
1495 test_ahash_speed("md4", sec, generic_hash_speed_template);
1496 if (mode > 400 && mode < 500) break;
1497
1498 case 402:
1499 test_ahash_speed("md5", sec, generic_hash_speed_template);
1500 if (mode > 400 && mode < 500) break;
1501
1502 case 403:
1503 test_ahash_speed("sha1", sec, generic_hash_speed_template);
1504 if (mode > 400 && mode < 500) break;
1505
1506 case 404:
1507 test_ahash_speed("sha256", sec, generic_hash_speed_template);
1508 if (mode > 400 && mode < 500) break;
1509
1510 case 405:
1511 test_ahash_speed("sha384", sec, generic_hash_speed_template);
1512 if (mode > 400 && mode < 500) break;
1513
1514 case 406:
1515 test_ahash_speed("sha512", sec, generic_hash_speed_template);
1516 if (mode > 400 && mode < 500) break;
1517
1518 case 407:
1519 test_ahash_speed("wp256", sec, generic_hash_speed_template);
1520 if (mode > 400 && mode < 500) break;
1521
1522 case 408:
1523 test_ahash_speed("wp384", sec, generic_hash_speed_template);
1524 if (mode > 400 && mode < 500) break;
1525
1526 case 409:
1527 test_ahash_speed("wp512", sec, generic_hash_speed_template);
1528 if (mode > 400 && mode < 500) break;
1529
1530 case 410:
1531 test_ahash_speed("tgr128", sec, generic_hash_speed_template);
1532 if (mode > 400 && mode < 500) break;
1533
1534 case 411:
1535 test_ahash_speed("tgr160", sec, generic_hash_speed_template);
1536 if (mode > 400 && mode < 500) break;
1537
1538 case 412:
1539 test_ahash_speed("tgr192", sec, generic_hash_speed_template);
1540 if (mode > 400 && mode < 500) break;
1541
1542 case 413:
1543 test_ahash_speed("sha224", sec, generic_hash_speed_template);
1544 if (mode > 400 && mode < 500) break;
1545
1546 case 414:
1547 test_ahash_speed("rmd128", sec, generic_hash_speed_template);
1548 if (mode > 400 && mode < 500) break;
1549
1550 case 415:
1551 test_ahash_speed("rmd160", sec, generic_hash_speed_template);
1552 if (mode > 400 && mode < 500) break;
1553
1554 case 416:
1555 test_ahash_speed("rmd256", sec, generic_hash_speed_template);
1556 if (mode > 400 && mode < 500) break;
1557
1558 case 417:
1559 test_ahash_speed("rmd320", sec, generic_hash_speed_template);
1560 if (mode > 400 && mode < 500) break;
1561
1562 case 499:
1563 break;
1564
Jussi Kivilinna3f3baf32011-10-18 00:02:58 +03001565 case 500:
1566 test_acipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
1567 speed_template_16_24_32);
1568 test_acipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
1569 speed_template_16_24_32);
1570 test_acipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
1571 speed_template_16_24_32);
1572 test_acipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
1573 speed_template_16_24_32);
1574 test_acipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
1575 speed_template_32_40_48);
1576 test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
1577 speed_template_32_40_48);
1578 test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
1579 speed_template_32_48_64);
1580 test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
1581 speed_template_32_48_64);
1582 test_acipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
1583 speed_template_16_24_32);
1584 test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
1585 speed_template_16_24_32);
Nicolas Royerde1975332012-07-01 19:19:47 +02001586 test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
1587 speed_template_16_24_32);
1588 test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
1589 speed_template_16_24_32);
1590 test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0,
1591 speed_template_16_24_32);
1592 test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0,
1593 speed_template_16_24_32);
Jussi Kivilinna3f3baf32011-10-18 00:02:58 +03001594 break;
1595
1596 case 501:
1597 test_acipher_speed("ecb(des3_ede)", ENCRYPT, sec,
1598 des3_speed_template, DES3_SPEED_VECTORS,
1599 speed_template_24);
1600 test_acipher_speed("ecb(des3_ede)", DECRYPT, sec,
1601 des3_speed_template, DES3_SPEED_VECTORS,
1602 speed_template_24);
1603 test_acipher_speed("cbc(des3_ede)", ENCRYPT, sec,
1604 des3_speed_template, DES3_SPEED_VECTORS,
1605 speed_template_24);
1606 test_acipher_speed("cbc(des3_ede)", DECRYPT, sec,
1607 des3_speed_template, DES3_SPEED_VECTORS,
1608 speed_template_24);
Nicolas Royerde1975332012-07-01 19:19:47 +02001609 test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec,
1610 des3_speed_template, DES3_SPEED_VECTORS,
1611 speed_template_24);
1612 test_acipher_speed("cfb(des3_ede)", DECRYPT, sec,
1613 des3_speed_template, DES3_SPEED_VECTORS,
1614 speed_template_24);
1615 test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec,
1616 des3_speed_template, DES3_SPEED_VECTORS,
1617 speed_template_24);
1618 test_acipher_speed("ofb(des3_ede)", DECRYPT, sec,
1619 des3_speed_template, DES3_SPEED_VECTORS,
1620 speed_template_24);
Jussi Kivilinna3f3baf32011-10-18 00:02:58 +03001621 break;
1622
1623 case 502:
1624 test_acipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
1625 speed_template_8);
1626 test_acipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
1627 speed_template_8);
1628 test_acipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
1629 speed_template_8);
1630 test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
1631 speed_template_8);
Nicolas Royerde1975332012-07-01 19:19:47 +02001632 test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0,
1633 speed_template_8);
1634 test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0,
1635 speed_template_8);
1636 test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0,
1637 speed_template_8);
1638 test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0,
1639 speed_template_8);
Jussi Kivilinna3f3baf32011-10-18 00:02:58 +03001640 break;
1641
Jussi Kivilinna7fb7fe42011-10-18 00:03:03 +03001642 case 503:
1643 test_acipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
1644 speed_template_16_32);
1645 test_acipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
1646 speed_template_16_32);
1647 test_acipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
1648 speed_template_16_32);
1649 test_acipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
1650 speed_template_16_32);
1651 test_acipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
1652 speed_template_16_32);
1653 test_acipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
1654 speed_template_16_32);
Jussi Kivilinna87aae4b2011-10-18 13:32:39 +03001655 test_acipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
1656 speed_template_32_48);
1657 test_acipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
1658 speed_template_32_48);
Jussi Kivilinna5209c072011-10-18 13:33:22 +03001659 test_acipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
1660 speed_template_32_64);
1661 test_acipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
1662 speed_template_32_64);
Jussi Kivilinna7fb7fe42011-10-18 00:03:03 +03001663 break;
1664
Johannes Goetzfried107778b2012-05-28 15:54:24 +02001665 case 504:
1666 test_acipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
1667 speed_template_16_24_32);
1668 test_acipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
1669 speed_template_16_24_32);
1670 test_acipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
1671 speed_template_16_24_32);
1672 test_acipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
1673 speed_template_16_24_32);
1674 test_acipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
1675 speed_template_16_24_32);
1676 test_acipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
1677 speed_template_16_24_32);
1678 test_acipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
1679 speed_template_32_40_48);
1680 test_acipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
1681 speed_template_32_40_48);
1682 test_acipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
1683 speed_template_32_48_64);
1684 test_acipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
1685 speed_template_32_48_64);
1686 break;
1687
Jussi Kivilinna31b4cd292012-06-12 16:52:04 +08001688 case 505:
1689 test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
1690 speed_template_8);
1691 break;
1692
Johannes Goetzfrieda2c58262012-07-11 19:37:21 +02001693 case 506:
1694 test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
1695 speed_template_8_16);
1696 test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
1697 speed_template_8_16);
1698 test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
1699 speed_template_8_16);
1700 test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
1701 speed_template_8_16);
1702 test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
1703 speed_template_8_16);
1704 test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
1705 speed_template_8_16);
1706 break;
1707
Johannes Goetzfried9b8b0402012-07-11 19:38:29 +02001708 case 507:
1709 test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
1710 speed_template_16_32);
1711 test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
1712 speed_template_16_32);
1713 test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
1714 speed_template_16_32);
1715 test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
1716 speed_template_16_32);
1717 test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
1718 speed_template_16_32);
1719 test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
1720 speed_template_16_32);
1721 test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
1722 speed_template_32_48);
1723 test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
1724 speed_template_32_48);
1725 test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
1726 speed_template_32_64);
1727 test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
1728 speed_template_32_64);
1729 break;
1730
Jussi Kivilinnabf9c5182012-10-26 14:48:51 +03001731 case 508:
1732 test_acipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
1733 speed_template_16_32);
1734 test_acipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
1735 speed_template_16_32);
1736 test_acipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
1737 speed_template_16_32);
1738 test_acipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
1739 speed_template_16_32);
1740 test_acipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
1741 speed_template_16_32);
1742 test_acipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
1743 speed_template_16_32);
1744 test_acipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
1745 speed_template_32_48);
1746 test_acipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
1747 speed_template_32_48);
1748 test_acipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
1749 speed_template_32_64);
1750 test_acipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
1751 speed_template_32_64);
1752 break;
1753
Linus Torvalds1da177e2005-04-16 15:20:36 -07001754 case 1000:
1755 test_available();
1756 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757 }
Jarod Wilson4e033a62009-05-27 15:10:21 +10001758
1759 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760}
1761
Herbert Xu7be380f2009-07-14 16:06:54 +08001762static int do_alg_test(const char *alg, u32 type, u32 mask)
Steffen Klasserta873a5f2009-06-19 19:46:53 +08001763{
Herbert Xu7be380f2009-07-14 16:06:54 +08001764 return crypto_has_alg(alg, type, mask ?: CRYPTO_ALG_TYPE_MASK) ?
1765 0 : -ENOENT;
Steffen Klasserta873a5f2009-06-19 19:46:53 +08001766}
1767
Kamalesh Babulal3af5b902008-04-05 21:00:57 +08001768static int __init tcrypt_mod_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001769{
Mikko Herranene3a4ea42007-11-26 22:12:07 +08001770 int err = -ENOMEM;
Herbert Xuf139cfa2008-07-31 12:23:53 +08001771 int i;
Mikko Herranene3a4ea42007-11-26 22:12:07 +08001772
Herbert Xuf139cfa2008-07-31 12:23:53 +08001773 for (i = 0; i < TVMEMSIZE; i++) {
1774 tvmem[i] = (void *)__get_free_page(GFP_KERNEL);
1775 if (!tvmem[i])
1776 goto err_free_tv;
1777 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001778
Steffen Klasserta873a5f2009-06-19 19:46:53 +08001779 if (alg)
Herbert Xu7be380f2009-07-14 16:06:54 +08001780 err = do_alg_test(alg, type, mask);
Steffen Klasserta873a5f2009-06-19 19:46:53 +08001781 else
1782 err = do_test(mode);
1783
Jarod Wilson4e033a62009-05-27 15:10:21 +10001784 if (err) {
1785 printk(KERN_ERR "tcrypt: one or more tests failed!\n");
1786 goto err_free_tv;
1787 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001788
Jarod Wilson4e033a62009-05-27 15:10:21 +10001789 /* We intentionaly return -EAGAIN to prevent keeping the module,
1790 * unless we're running in fips mode. It does all its work from
1791 * init() and doesn't offer any runtime functionality, but in
1792 * the fips case, checking for a successful load is helpful.
Michal Ludvig14fdf472006-05-30 14:49:38 +10001793 * => we don't need it in the memory, do we?
1794 * -- mludvig
1795 */
Jarod Wilson4e033a62009-05-27 15:10:21 +10001796 if (!fips_enabled)
1797 err = -EAGAIN;
Mikko Herranene3a4ea42007-11-26 22:12:07 +08001798
Herbert Xuf139cfa2008-07-31 12:23:53 +08001799err_free_tv:
1800 for (i = 0; i < TVMEMSIZE && tvmem[i]; i++)
1801 free_page((unsigned long)tvmem[i]);
Mikko Herranene3a4ea42007-11-26 22:12:07 +08001802
1803 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001804}
1805
1806/*
1807 * If an init function is provided, an exit function must also be provided
1808 * to allow module unload.
1809 */
Kamalesh Babulal3af5b902008-04-05 21:00:57 +08001810static void __exit tcrypt_mod_fini(void) { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001811
Kamalesh Babulal3af5b902008-04-05 21:00:57 +08001812module_init(tcrypt_mod_init);
1813module_exit(tcrypt_mod_fini);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001814
Steffen Klasserta873a5f2009-06-19 19:46:53 +08001815module_param(alg, charp, 0);
1816module_param(type, uint, 0);
Herbert Xu7be380f2009-07-14 16:06:54 +08001817module_param(mask, uint, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001818module_param(mode, int, 0);
Harald Welteebfd9bc2005-06-22 13:27:23 -07001819module_param(sec, uint, 0);
Herbert Xu6a179442005-06-22 13:29:03 -07001820MODULE_PARM_DESC(sec, "Length in seconds of speed tests "
1821 "(defaults to zero which uses CPU cycles instead)");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001822
1823MODULE_LICENSE("GPL");
1824MODULE_DESCRIPTION("Quick & dirty crypto testing module");
1825MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");