Blame view

crypto/tcrypt.c 78.9 KB
2874c5fd2   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-or-later
ef2736fc7   Herbert Xu   [CRYPTO]: White s...
2
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3
4
5
6
7
8
9
   * Quick & dirty crypto testing module.
   *
   * This will only exist until we have a better testing mechanism
   * (e.g. a char device).
   *
   * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
   * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
e3a4ea4fd   Mikko Herranen   [CRYPTO] tcrypt: ...
10
   * Copyright (c) 2007 Nokia Siemens Networks
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
11
   *
69435b94d   Adrian Hoban   crypto: rfc4106 -...
12
13
14
15
16
17
   * Updated RFC4106 AES-GCM testing.
   *    Authors: Aidan O'Mahony (aidan.o.mahony@intel.com)
   *             Adrian Hoban <adrian.hoban@intel.com>
   *             Gabriele Paoloni <gabriele.paoloni@intel.com>
   *             Tadeusz Struk (tadeusz.struk@intel.com)
   *             Copyright (c) 2010, Intel Corporation.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
18
   */
76512f2d8   Rabin Vincent   crypto: tcrypt - ...
19
  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1ce5a04d9   Herbert Xu   crypto: tcrypt - ...
20
  #include <crypto/aead.h>
18e33e6d5   Herbert Xu   crypto: hash - Mo...
21
  #include <crypto/hash.h>
7166e589d   Herbert Xu   crypto: tcrypt - ...
22
  #include <crypto/skcipher.h>
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
23
  #include <linux/err.h>
daf0944cf   Herbert Xu   crypto: tcrypt - ...
24
  #include <linux/fips.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
25
  #include <linux/init.h>
5a0e3ad6a   Tejun Heo   include cleanup: ...
26
  #include <linux/gfp.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
27
  #include <linux/module.h>
378f058cc   David Hardeman   [PATCH] Use sg_se...
28
  #include <linux/scatterlist.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
29
  #include <linux/string.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30
  #include <linux/moduleparam.h>
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
31
  #include <linux/jiffies.h>
6a17944ca   Herbert Xu   [CRYPTO]: Use CPU...
32
33
  #include <linux/timex.h>
  #include <linux/interrupt.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
35
36
  #include "tcrypt.h"
  
  /*
f139cfa7c   Herbert Xu   crypto: tcrypt - ...
37
   * Need slab memory for testing (size in number of pages).
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38
   */
f139cfa7c   Herbert Xu   crypto: tcrypt - ...
39
  #define TVMEMSIZE	4
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
41
  
  /*
da7f033dd   Herbert Xu   crypto: cryptomgr...
42
  * Used by test_cipher_speed()
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43
44
45
  */
  #define ENCRYPT 1
  #define DECRYPT 0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46

f074f7b10   Horia Geant?   crypto: tcrypt - ...
47
  #define MAX_DIGEST_SIZE		64
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
48
  /*
263a8df0d   Luca Clementi   crypto: tcrypt - ...
49
50
51
52
53
   * return a string with the driver name
   */
  #define get_driver_name(tfm_type, tfm) crypto_tfm_alg_driver_name(tfm_type ## _tfm(tfm))
  
  /*
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
54
55
   * Used by test_cipher_speed()
   */
6a17944ca   Herbert Xu   [CRYPTO]: Use CPU...
56
  static unsigned int sec;
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
57

a873a5f1c   Steffen Klassert   crypto: tcrypt - ...
58
59
  static char *alg = NULL;
  static u32 type;
7be380f72   Herbert Xu   crypto: tcrypt - ...
60
  static u32 mask;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
61
  static int mode;
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
62
  static u32 num_mb = 8;
ba974adb4   Herbert Xu   crypto: tcrypt - ...
63
  static unsigned int klen;
f139cfa7c   Herbert Xu   crypto: tcrypt - ...
64
  static char *tvmem[TVMEMSIZE];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
65

07d8f1858   Corentin Labbe   crypto: tcrypt - ...
66
  static const char *check[] = {
b7e275304   Gilad Ben-Yossef   crypto: sm3 - add...
67
  	"des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", "sm3",
cd12fb906   Jonathan Lynch   [CRYPTO] sha256-g...
68
69
  	"blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
  	"cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
90831639a   David Howells   [CRYPTO] fcrypt: ...
70
  	"khazad", "wp512", "wp384", "wp256", "tnepres", "xeta",  "fcrypt",
2998db37b   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
71
  	"camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320",
e1228ca2e   Radu Alexe   crypto: tcrypt - ...
72
73
  	"lzo", "lzo-rle", "cts", "zlib", "sha3-224", "sha3-256", "sha3-384",
  	"sha3-512", "streebog256", "streebog512", "rsa", NULL
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
74
  };
ee5bbc9fd   Ard Biesheuvel   crypto: tcrypt - ...
75
  static u32 block_sizes[] = { 16, 64, 256, 1024, 1472, 8192, 0 };
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
  static u32 aead_sizes[] = { 16, 64, 256, 512, 1024, 2048, 4096, 8192, 0 };
  
  #define XBUFSIZE 8
  #define MAX_IVLEN 32
  
  static int testmgr_alloc_buf(char *buf[XBUFSIZE])
  {
  	int i;
  
  	for (i = 0; i < XBUFSIZE; i++) {
  		buf[i] = (void *)__get_free_page(GFP_KERNEL);
  		if (!buf[i])
  			goto err_free_buf;
  	}
  
  	return 0;
  
  err_free_buf:
  	while (i-- > 0)
  		free_page((unsigned long)buf[i]);
  
  	return -ENOMEM;
  }
  
  static void testmgr_free_buf(char *buf[XBUFSIZE])
  {
  	int i;
  
  	for (i = 0; i < XBUFSIZE; i++)
  		free_page((unsigned long)buf[i]);
  }
  
  static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],
  			 unsigned int buflen, const void *assoc,
  			 unsigned int aad_size)
  {
  	int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE;
  	int k, rem;
  
  	if (np > XBUFSIZE) {
  		rem = PAGE_SIZE;
  		np = XBUFSIZE;
  	} else {
  		rem = buflen % PAGE_SIZE;
  	}
  
  	sg_init_table(sg, np + 1);
  
  	sg_set_buf(&sg[0], assoc, aad_size);
  
  	if (rem)
  		np--;
  	for (k = 0; k < np; k++)
  		sg_set_buf(&sg[k + 1], xbuf[k], PAGE_SIZE);
  
  	if (rem)
  		sg_set_buf(&sg[k + 1], xbuf[k], rem);
  }
1425d2d17   Vutla, Lokesh   crypto: tcrypt - ...
134
135
  static inline int do_one_aead_op(struct aead_request *req, int ret)
  {
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
136
  	struct crypto_wait *wait = req->base.data;
1425d2d17   Vutla, Lokesh   crypto: tcrypt - ...
137

646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
138
  	return crypto_wait_req(ret, wait);
1425d2d17   Vutla, Lokesh   crypto: tcrypt - ...
139
  }
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
140
141
142
143
144
145
146
147
148
149
150
  struct test_mb_aead_data {
  	struct scatterlist sg[XBUFSIZE];
  	struct scatterlist sgout[XBUFSIZE];
  	struct aead_request *req;
  	struct crypto_wait wait;
  	char *xbuf[XBUFSIZE];
  	char *xoutbuf[XBUFSIZE];
  	char *axbuf[XBUFSIZE];
  };
  
  static int do_mult_aead_op(struct test_mb_aead_data *data, int enc,
4e234eed5   Kees Cook   crypto: tcrypt - ...
151
  				u32 num_mb, int *rc)
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
152
  {
4e234eed5   Kees Cook   crypto: tcrypt - ...
153
  	int i, err = 0;
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
  
  	/* Fire up a bunch of concurrent requests */
  	for (i = 0; i < num_mb; i++) {
  		if (enc == ENCRYPT)
  			rc[i] = crypto_aead_encrypt(data[i].req);
  		else
  			rc[i] = crypto_aead_decrypt(data[i].req);
  	}
  
  	/* Wait for all requests to finish */
  	for (i = 0; i < num_mb; i++) {
  		rc[i] = crypto_wait_req(rc[i], &data[i].wait);
  
  		if (rc[i]) {
  			pr_info("concurrent request %d error %d
  ", i, rc[i]);
  			err = rc[i];
  		}
  	}
  
  	return err;
  }
  
  static int test_mb_aead_jiffies(struct test_mb_aead_data *data, int enc,
  				int blen, int secs, u32 num_mb)
53f52d7ae   Tim Chen   crypto: tcrypt - ...
179
180
181
  {
  	unsigned long start, end;
  	int bcount;
4e234eed5   Kees Cook   crypto: tcrypt - ...
182
183
184
185
186
187
  	int ret = 0;
  	int *rc;
  
  	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
  	if (!rc)
  		return -ENOMEM;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
188

3e3dc25fe   Mark Rustad   crypto: Resolve s...
189
  	for (start = jiffies, end = start + secs * HZ, bcount = 0;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
190
  	     time_before(jiffies, end); bcount++) {
4e234eed5   Kees Cook   crypto: tcrypt - ...
191
  		ret = do_mult_aead_op(data, enc, num_mb, rc);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
192
  		if (ret)
4e234eed5   Kees Cook   crypto: tcrypt - ...
193
  			goto out;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
194
  	}
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
195
196
197
  	pr_cont("%d operations in %d seconds (%ld bytes)
  ",
  		bcount * num_mb, secs, (long)bcount * blen * num_mb);
4e234eed5   Kees Cook   crypto: tcrypt - ...
198
199
200
201
  
  out:
  	kfree(rc);
  	return ret;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
202
  }
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
203
204
  static int test_mb_aead_cycles(struct test_mb_aead_data *data, int enc,
  			       int blen, u32 num_mb)
53f52d7ae   Tim Chen   crypto: tcrypt - ...
205
206
207
208
  {
  	unsigned long cycles = 0;
  	int ret = 0;
  	int i;
4e234eed5   Kees Cook   crypto: tcrypt - ...
209
210
211
212
213
  	int *rc;
  
  	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
  	if (!rc)
  		return -ENOMEM;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
214

53f52d7ae   Tim Chen   crypto: tcrypt - ...
215
216
  	/* Warm-up run. */
  	for (i = 0; i < 4; i++) {
4e234eed5   Kees Cook   crypto: tcrypt - ...
217
  		ret = do_mult_aead_op(data, enc, num_mb, rc);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
218
219
220
221
222
223
224
225
226
  		if (ret)
  			goto out;
  	}
  
  	/* The real thing. */
  	for (i = 0; i < 8; i++) {
  		cycles_t start, end;
  
  		start = get_cycles();
4e234eed5   Kees Cook   crypto: tcrypt - ...
227
  		ret = do_mult_aead_op(data, enc, num_mb, rc);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
228
229
230
231
232
233
234
  		end = get_cycles();
  
  		if (ret)
  			goto out;
  
  		cycles += end - start;
  	}
4e234eed5   Kees Cook   crypto: tcrypt - ...
235
236
237
  	pr_cont("1 operation in %lu cycles (%d bytes)
  ",
  		(cycles + 4) / (8 * num_mb), blen);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
238

4e234eed5   Kees Cook   crypto: tcrypt - ...
239
240
  out:
  	kfree(rc);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
241
242
  	return ret;
  }
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
243
244
245
246
247
248
249
250
251
252
  static void test_mb_aead_speed(const char *algo, int enc, int secs,
  			       struct aead_speed_template *template,
  			       unsigned int tcount, u8 authsize,
  			       unsigned int aad_size, u8 *keysize, u32 num_mb)
  {
  	struct test_mb_aead_data *data;
  	struct crypto_aead *tfm;
  	unsigned int i, j, iv_len;
  	const char *key;
  	const char *e;
9be86c317   Horia Geantă   LF-286 crypto: tc...
253
  	void *assoc, *assoc_out;
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
254
255
256
  	u32 *b_size;
  	char *iv;
  	int ret;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
257

53f52d7ae   Tim Chen   crypto: tcrypt - ...
258

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
259
260
261
262
263
  	if (aad_size >= PAGE_SIZE) {
  		pr_err("associate data length (%u) too big
  ", aad_size);
  		return;
  	}
53f52d7ae   Tim Chen   crypto: tcrypt - ...
264

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
  	iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
  	if (!iv)
  		return;
  
  	if (enc == ENCRYPT)
  		e = "encryption";
  	else
  		e = "decryption";
  
  	data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL);
  	if (!data)
  		goto out_free_iv;
  
  	tfm = crypto_alloc_aead(algo, 0, 0);
  	if (IS_ERR(tfm)) {
  		pr_err("failed to load transform for %s: %ld
  ",
  			algo, PTR_ERR(tfm));
  		goto out_free_data;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
284
  	}
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
285
  	ret = crypto_aead_setauthsize(tfm, authsize);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
286

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
287
288
289
290
291
292
  	for (i = 0; i < num_mb; ++i)
  		if (testmgr_alloc_buf(data[i].xbuf)) {
  			while (i--)
  				testmgr_free_buf(data[i].xbuf);
  			goto out_free_tfm;
  		}
53f52d7ae   Tim Chen   crypto: tcrypt - ...
293

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
294
295
296
297
298
299
300
301
302
303
  	for (i = 0; i < num_mb; ++i)
  		if (testmgr_alloc_buf(data[i].axbuf)) {
  			while (i--)
  				testmgr_free_buf(data[i].axbuf);
  			goto out_free_xbuf;
  		}
  
  	for (i = 0; i < num_mb; ++i)
  		if (testmgr_alloc_buf(data[i].xoutbuf)) {
  			while (i--)
c6ba4f3e6   Colin Ian King   crypto: tcrypt - ...
304
  				testmgr_free_buf(data[i].xoutbuf);
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
  			goto out_free_axbuf;
  		}
  
  	for (i = 0; i < num_mb; ++i) {
  		data[i].req = aead_request_alloc(tfm, GFP_KERNEL);
  		if (!data[i].req) {
  			pr_err("alg: skcipher: Failed to allocate request for %s
  ",
  			       algo);
  			while (i--)
  				aead_request_free(data[i].req);
  			goto out_free_xoutbuf;
  		}
  	}
  
  	for (i = 0; i < num_mb; ++i) {
  		crypto_init_wait(&data[i].wait);
  		aead_request_set_callback(data[i].req,
  					  CRYPTO_TFM_REQ_MAY_BACKLOG,
  					  crypto_req_done, &data[i].wait);
  	}
  
  	pr_info("
  testing speed of multibuffer %s (%s) %s
  ", algo,
  		get_driver_name(crypto_aead, tfm), e);
  
  	i = 0;
  	do {
  		b_size = aead_sizes;
  		do {
  			if (*b_size + authsize > XBUFSIZE * PAGE_SIZE) {
38dbe2d19   Colin Ian King   crypto: tcrypt - ...
337
338
  				pr_err("template (%u) too big for buffer (%lu)
  ",
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
  				       authsize + *b_size,
  				       XBUFSIZE * PAGE_SIZE);
  				goto out;
  			}
  
  			pr_info("test %u (%d bit key, %d byte blocks): ", i,
  				*keysize * 8, *b_size);
  
  			/* Set up tfm global state, i.e. the key */
  
  			memset(tvmem[0], 0xff, PAGE_SIZE);
  			key = tvmem[0];
  			for (j = 0; j < tcount; j++) {
  				if (template[j].klen == *keysize) {
  					key = template[j].key;
  					break;
  				}
  			}
  
  			crypto_aead_clear_flags(tfm, ~0);
  
  			ret = crypto_aead_setkey(tfm, key, *keysize);
  			if (ret) {
  				pr_err("setkey() failed flags=%x
  ",
  				       crypto_aead_get_flags(tfm));
  				goto out;
  			}
  
  			iv_len = crypto_aead_ivsize(tfm);
  			if (iv_len)
  				memset(iv, 0xff, iv_len);
  
  			/* Now setup per request stuff, i.e. buffers */
  
  			for (j = 0; j < num_mb; ++j) {
  				struct test_mb_aead_data *cur = &data[j];
  
  				assoc = cur->axbuf[0];
  				memset(assoc, 0xff, aad_size);
9be86c317   Horia Geantă   LF-286 crypto: tc...
379
380
  				assoc_out = cur->axbuf[1];
  				memset(assoc_out, 0xff, aad_size);
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
381
382
383
384
385
386
387
  
  				sg_init_aead(cur->sg, cur->xbuf,
  					     *b_size + (enc ? 0 : authsize),
  					     assoc, aad_size);
  
  				sg_init_aead(cur->sgout, cur->xoutbuf,
  					     *b_size + (enc ? authsize : 0),
9be86c317   Horia Geantă   LF-286 crypto: tc...
388
  					     assoc_out, aad_size);
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
389
390
391
392
393
394
395
396
397
398
399
400
401
  
  				aead_request_set_ad(cur->req, aad_size);
  
  				if (!enc) {
  
  					aead_request_set_crypt(cur->req,
  							       cur->sgout,
  							       cur->sg,
  							       *b_size, iv);
  					ret = crypto_aead_encrypt(cur->req);
  					ret = do_one_aead_op(cur->req, ret);
  
  					if (ret) {
129a4dba1   Randy Dunlap   crypto: tcrypt - ...
402
403
  						pr_err("calculating auth failed (%d)
  ",
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
404
405
406
  						       ret);
  						break;
  					}
9be86c317   Horia Geantă   LF-286 crypto: tc...
407
408
409
  
  					memset(assoc, 0xff, aad_size);
  					memset(assoc_out, 0xff, aad_size);
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
410
411
412
413
414
415
416
417
  				}
  
  				aead_request_set_crypt(cur->req, cur->sg,
  						       cur->sgout, *b_size +
  						       (enc ? 0 : authsize),
  						       iv);
  
  			}
2af632996   Horia Geantă   crypto: tcrypt - ...
418
  			if (secs) {
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
419
420
  				ret = test_mb_aead_jiffies(data, enc, *b_size,
  							   secs, num_mb);
2af632996   Horia Geantă   crypto: tcrypt - ...
421
422
  				cond_resched();
  			} else {
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
423
424
  				ret = test_mb_aead_cycles(data, enc, *b_size,
  							  num_mb);
2af632996   Horia Geantă   crypto: tcrypt - ...
425
  			}
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
  
  			if (ret) {
  				pr_err("%s() failed return code=%d
  ", e, ret);
  				break;
  			}
  			b_size++;
  			i++;
  		} while (*b_size);
  		keysize++;
  	} while (*keysize);
  
  out:
  	for (i = 0; i < num_mb; ++i)
  		aead_request_free(data[i].req);
  out_free_xoutbuf:
  	for (i = 0; i < num_mb; ++i)
  		testmgr_free_buf(data[i].xoutbuf);
  out_free_axbuf:
  	for (i = 0; i < num_mb; ++i)
  		testmgr_free_buf(data[i].axbuf);
  out_free_xbuf:
  	for (i = 0; i < num_mb; ++i)
  		testmgr_free_buf(data[i].xbuf);
  out_free_tfm:
  	crypto_free_aead(tfm);
  out_free_data:
  	kfree(data);
  out_free_iv:
  	kfree(iv);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
456
  }
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
457
458
  static int test_aead_jiffies(struct aead_request *req, int enc,
  				int blen, int secs)
53f52d7ae   Tim Chen   crypto: tcrypt - ...
459
  {
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
460
461
462
  	unsigned long start, end;
  	int bcount;
  	int ret;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
463

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
  	for (start = jiffies, end = start + secs * HZ, bcount = 0;
  	     time_before(jiffies, end); bcount++) {
  		if (enc)
  			ret = do_one_aead_op(req, crypto_aead_encrypt(req));
  		else
  			ret = do_one_aead_op(req, crypto_aead_decrypt(req));
  
  		if (ret)
  			return ret;
  	}
  
  	printk("%d operations in %d seconds (%ld bytes)
  ",
  	       bcount, secs, (long)bcount * blen);
  	return 0;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
479
  }
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
480
  static int test_aead_cycles(struct aead_request *req, int enc, int blen)
53f52d7ae   Tim Chen   crypto: tcrypt - ...
481
  {
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
482
483
484
  	unsigned long cycles = 0;
  	int ret = 0;
  	int i;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
485

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
486
487
488
489
490
491
492
493
494
  	/* Warm-up run. */
  	for (i = 0; i < 4; i++) {
  		if (enc)
  			ret = do_one_aead_op(req, crypto_aead_encrypt(req));
  		else
  			ret = do_one_aead_op(req, crypto_aead_decrypt(req));
  
  		if (ret)
  			goto out;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
495
  	}
c47689931   Cristian Stoica   crypto: tcrypt - ...
496

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
497
498
499
  	/* The real thing. */
  	for (i = 0; i < 8; i++) {
  		cycles_t start, end;
5601e014f   Tudor-Dan Ambarus   crypto: tcrypt - ...
500

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
501
502
503
504
505
506
  		start = get_cycles();
  		if (enc)
  			ret = do_one_aead_op(req, crypto_aead_encrypt(req));
  		else
  			ret = do_one_aead_op(req, crypto_aead_decrypt(req));
  		end = get_cycles();
5601e014f   Tudor-Dan Ambarus   crypto: tcrypt - ...
507

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
508
509
  		if (ret)
  			goto out;
c47689931   Cristian Stoica   crypto: tcrypt - ...
510

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
511
512
513
514
515
516
517
518
519
520
  		cycles += end - start;
  	}
  
  out:
  	if (ret == 0)
  		printk("1 operation in %lu cycles (%d bytes)
  ",
  		       (cycles + 4) / 8, blen);
  
  	return ret;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
521
  }
3e3dc25fe   Mark Rustad   crypto: Resolve s...
522
  static void test_aead_speed(const char *algo, int enc, unsigned int secs,
53f52d7ae   Tim Chen   crypto: tcrypt - ...
523
524
525
526
527
528
529
530
531
532
  			    struct aead_speed_template *template,
  			    unsigned int tcount, u8 authsize,
  			    unsigned int aad_size, u8 *keysize)
  {
  	unsigned int i, j;
  	struct crypto_aead *tfm;
  	int ret = -ENOMEM;
  	const char *key;
  	struct aead_request *req;
  	struct scatterlist *sg;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
533
534
  	struct scatterlist *sgout;
  	const char *e;
9be86c317   Horia Geantă   LF-286 crypto: tc...
535
  	void *assoc, *assoc_out;
96692a730   Cristian Stoica   crypto: tcrypt - ...
536
  	char *iv;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
537
538
539
540
541
  	char *xbuf[XBUFSIZE];
  	char *xoutbuf[XBUFSIZE];
  	char *axbuf[XBUFSIZE];
  	unsigned int *b_size;
  	unsigned int iv_len;
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
542
  	struct crypto_wait wait;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
543

96692a730   Cristian Stoica   crypto: tcrypt - ...
544
545
546
  	iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
  	if (!iv)
  		return;
ac5f863f8   Christian Engelmayer   crypto: tcrypt - ...
547
548
549
  	if (aad_size >= PAGE_SIZE) {
  		pr_err("associate data length (%u) too big
  ", aad_size);
96692a730   Cristian Stoica   crypto: tcrypt - ...
550
  		goto out_noxbuf;
ac5f863f8   Christian Engelmayer   crypto: tcrypt - ...
551
  	}
53f52d7ae   Tim Chen   crypto: tcrypt - ...
552
553
554
555
556
557
558
559
560
561
562
  	if (enc == ENCRYPT)
  		e = "encryption";
  	else
  		e = "decryption";
  
  	if (testmgr_alloc_buf(xbuf))
  		goto out_noxbuf;
  	if (testmgr_alloc_buf(axbuf))
  		goto out_noaxbuf;
  	if (testmgr_alloc_buf(xoutbuf))
  		goto out_nooutbuf;
a3f2185a2   Herbert Xu   crypto: tcrypt - ...
563
  	sg = kmalloc(sizeof(*sg) * 9 * 2, GFP_KERNEL);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
564
565
  	if (!sg)
  		goto out_nosg;
a3f2185a2   Herbert Xu   crypto: tcrypt - ...
566
  	sgout = &sg[9];
53f52d7ae   Tim Chen   crypto: tcrypt - ...
567

5e4b8c1fc   Herbert Xu   crypto: aead - Re...
568
  	tfm = crypto_alloc_aead(algo, 0, 0);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
569
570
571
572
573
  
  	if (IS_ERR(tfm)) {
  		pr_err("alg: aead: Failed to load transform for %s: %ld
  ", algo,
  		       PTR_ERR(tfm));
a2ea6ed6a   Christian Engelmayer   crypto: tcrypt - ...
574
  		goto out_notfm;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
575
  	}
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
576
  	crypto_init_wait(&wait);
263a8df0d   Luca Clementi   crypto: tcrypt - ...
577
578
579
580
  	printk(KERN_INFO "
  testing speed of %s (%s) %s
  ", algo,
  			get_driver_name(crypto_aead, tfm), e);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
581
582
583
584
585
  	req = aead_request_alloc(tfm, GFP_KERNEL);
  	if (!req) {
  		pr_err("alg: aead: Failed to allocate request for %s
  ",
  		       algo);
6af1f93e2   Christian Engelmayer   crypto: tcrypt - ...
586
  		goto out_noreq;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
587
  	}
1425d2d17   Vutla, Lokesh   crypto: tcrypt - ...
588
  	aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
589
  				  crypto_req_done, &wait);
1425d2d17   Vutla, Lokesh   crypto: tcrypt - ...
590

53f52d7ae   Tim Chen   crypto: tcrypt - ...
591
592
593
594
595
  	i = 0;
  	do {
  		b_size = aead_sizes;
  		do {
  			assoc = axbuf[0];
ac5f863f8   Christian Engelmayer   crypto: tcrypt - ...
596
  			memset(assoc, 0xff, aad_size);
9be86c317   Horia Geantă   LF-286 crypto: tc...
597
598
  			assoc_out = axbuf[1];
  			memset(assoc_out, 0xff, aad_size);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
  
  			if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
  				pr_err("template (%u) too big for tvmem (%lu)
  ",
  				       *keysize + *b_size,
  					TVMEMSIZE * PAGE_SIZE);
  				goto out;
  			}
  
  			key = tvmem[0];
  			for (j = 0; j < tcount; j++) {
  				if (template[j].klen == *keysize) {
  					key = template[j].key;
  					break;
  				}
  			}
  			ret = crypto_aead_setkey(tfm, key, *keysize);
  			ret = crypto_aead_setauthsize(tfm, authsize);
  
  			iv_len = crypto_aead_ivsize(tfm);
  			if (iv_len)
96692a730   Cristian Stoica   crypto: tcrypt - ...
620
  				memset(iv, 0xff, iv_len);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
621
622
623
624
625
626
627
628
629
630
631
632
633
634
  
  			crypto_aead_clear_flags(tfm, ~0);
  			printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ",
  					i, *keysize * 8, *b_size);
  
  
  			memset(tvmem[0], 0xff, PAGE_SIZE);
  
  			if (ret) {
  				pr_err("setkey() failed flags=%x
  ",
  						crypto_aead_get_flags(tfm));
  				goto out;
  			}
5601e014f   Tudor-Dan Ambarus   crypto: tcrypt - ...
635
636
  			sg_init_aead(sg, xbuf, *b_size + (enc ? 0 : authsize),
  				     assoc, aad_size);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
637

31267270a   Herbert Xu   crypto: tcrypt - ...
638
  			sg_init_aead(sgout, xoutbuf,
9be86c317   Horia Geantă   LF-286 crypto: tc...
639
  				     *b_size + (enc ? authsize : 0), assoc_out,
5601e014f   Tudor-Dan Ambarus   crypto: tcrypt - ...
640
  				     aad_size);
31267270a   Herbert Xu   crypto: tcrypt - ...
641

4431bd495   Gilad Ben-Yossef   crypto: tcrypt - ...
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
  			aead_request_set_ad(req, aad_size);
  
  			if (!enc) {
  
  				/*
  				 * For decryption we need a proper auth so
  				 * we do the encryption path once with buffers
  				 * reversed (input <-> output) to calculate it
  				 */
  				aead_request_set_crypt(req, sgout, sg,
  						       *b_size, iv);
  				ret = do_one_aead_op(req,
  						     crypto_aead_encrypt(req));
  
  				if (ret) {
129a4dba1   Randy Dunlap   crypto: tcrypt - ...
657
658
  					pr_err("calculating auth failed (%d)
  ",
4431bd495   Gilad Ben-Yossef   crypto: tcrypt - ...
659
660
661
  					       ret);
  					break;
  				}
9be86c317   Horia Geantă   LF-286 crypto: tc...
662
663
664
  
  				memset(assoc, 0xff, aad_size);
  				memset(assoc_out, 0xff, aad_size);
4431bd495   Gilad Ben-Yossef   crypto: tcrypt - ...
665
  			}
7aacbfcb3   Robert Baronescu   crypto: tcrypt - ...
666
667
668
  			aead_request_set_crypt(req, sg, sgout,
  					       *b_size + (enc ? 0 : authsize),
  					       iv);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
669

2af632996   Horia Geantă   crypto: tcrypt - ...
670
  			if (secs) {
3e3dc25fe   Mark Rustad   crypto: Resolve s...
671
672
  				ret = test_aead_jiffies(req, enc, *b_size,
  							secs);
2af632996   Horia Geantă   crypto: tcrypt - ...
673
674
  				cond_resched();
  			} else {
53f52d7ae   Tim Chen   crypto: tcrypt - ...
675
  				ret = test_aead_cycles(req, enc, *b_size);
2af632996   Horia Geantă   crypto: tcrypt - ...
676
  			}
53f52d7ae   Tim Chen   crypto: tcrypt - ...
677
678
679
680
681
682
683
684
685
686
687
688
689
  
  			if (ret) {
  				pr_err("%s() failed return code=%d
  ", e, ret);
  				break;
  			}
  			b_size++;
  			i++;
  		} while (*b_size);
  		keysize++;
  	} while (*keysize);
  
  out:
6af1f93e2   Christian Engelmayer   crypto: tcrypt - ...
690
691
  	aead_request_free(req);
  out_noreq:
53f52d7ae   Tim Chen   crypto: tcrypt - ...
692
  	crypto_free_aead(tfm);
a2ea6ed6a   Christian Engelmayer   crypto: tcrypt - ...
693
  out_notfm:
53f52d7ae   Tim Chen   crypto: tcrypt - ...
694
695
696
697
698
699
700
701
  	kfree(sg);
  out_nosg:
  	testmgr_free_buf(xoutbuf);
  out_nooutbuf:
  	testmgr_free_buf(axbuf);
  out_noaxbuf:
  	testmgr_free_buf(xbuf);
  out_noxbuf:
96692a730   Cristian Stoica   crypto: tcrypt - ...
702
  	kfree(iv);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
703
  }
d5dc39274   Sebastian Siewior   [CRYPTO] tcrypt: ...
704

beb63da73   David S. Miller   crypto: tcrypt - ...
705
706
707
708
709
710
711
712
713
714
  static void test_hash_sg_init(struct scatterlist *sg)
  {
  	int i;
  
  	sg_init_table(sg, TVMEMSIZE);
  	for (i = 0; i < TVMEMSIZE; i++) {
  		sg_set_buf(sg + i, tvmem[i], PAGE_SIZE);
  		memset(tvmem[i], 0xff, PAGE_SIZE);
  	}
  }
beb63da73   David S. Miller   crypto: tcrypt - ...
715
716
  static inline int do_one_ahash_op(struct ahash_request *req, int ret)
  {
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
717
  	struct crypto_wait *wait = req->base.data;
beb63da73   David S. Miller   crypto: tcrypt - ...
718

646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
719
  	return crypto_wait_req(ret, wait);
beb63da73   David S. Miller   crypto: tcrypt - ...
720
  }
72259deb3   Herbert Xu   crypto: tcrypt - ...
721
  struct test_mb_ahash_data {
7c3f13238   Gilad Ben-Yossef   crypto: tcrypt - ...
722
  	struct scatterlist sg[XBUFSIZE];
72259deb3   Herbert Xu   crypto: tcrypt - ...
723
724
  	char result[64];
  	struct ahash_request *req;
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
725
  	struct crypto_wait wait;
72259deb3   Herbert Xu   crypto: tcrypt - ...
726
727
  	char *xbuf[XBUFSIZE];
  };
087bcd225   Megha Dey   crypto: tcrypt - ...
728

4e234eed5   Kees Cook   crypto: tcrypt - ...
729
730
  static inline int do_mult_ahash_op(struct test_mb_ahash_data *data, u32 num_mb,
  				   int *rc)
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
731
  {
4e234eed5   Kees Cook   crypto: tcrypt - ...
732
  	int i, err = 0;
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
  
  	/* Fire up a bunch of concurrent requests */
  	for (i = 0; i < num_mb; i++)
  		rc[i] = crypto_ahash_digest(data[i].req);
  
  	/* Wait for all requests to finish */
  	for (i = 0; i < num_mb; i++) {
  		rc[i] = crypto_wait_req(rc[i], &data[i].wait);
  
  		if (rc[i]) {
  			pr_info("concurrent request %d error %d
  ", i, rc[i]);
  			err = rc[i];
  		}
  	}
  
  	return err;
  }
  
  static int test_mb_ahash_jiffies(struct test_mb_ahash_data *data, int blen,
  				 int secs, u32 num_mb)
  {
  	unsigned long start, end;
  	int bcount;
4e234eed5   Kees Cook   crypto: tcrypt - ...
757
758
759
760
761
762
  	int ret = 0;
  	int *rc;
  
  	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
  	if (!rc)
  		return -ENOMEM;
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
763
764
765
  
  	for (start = jiffies, end = start + secs * HZ, bcount = 0;
  	     time_before(jiffies, end); bcount++) {
4e234eed5   Kees Cook   crypto: tcrypt - ...
766
  		ret = do_mult_ahash_op(data, num_mb, rc);
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
767
  		if (ret)
4e234eed5   Kees Cook   crypto: tcrypt - ...
768
  			goto out;
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
769
770
771
772
773
  	}
  
  	pr_cont("%d operations in %d seconds (%ld bytes)
  ",
  		bcount * num_mb, secs, (long)bcount * blen * num_mb);
4e234eed5   Kees Cook   crypto: tcrypt - ...
774
775
776
777
  
  out:
  	kfree(rc);
  	return ret;
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
778
779
780
781
782
783
784
785
  }
  
  static int test_mb_ahash_cycles(struct test_mb_ahash_data *data, int blen,
  				u32 num_mb)
  {
  	unsigned long cycles = 0;
  	int ret = 0;
  	int i;
4e234eed5   Kees Cook   crypto: tcrypt - ...
786
787
788
789
790
  	int *rc;
  
  	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
  	if (!rc)
  		return -ENOMEM;
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
791
792
793
  
  	/* Warm-up run. */
  	for (i = 0; i < 4; i++) {
4e234eed5   Kees Cook   crypto: tcrypt - ...
794
  		ret = do_mult_ahash_op(data, num_mb, rc);
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
795
796
797
798
799
800
801
802
803
  		if (ret)
  			goto out;
  	}
  
  	/* The real thing. */
  	for (i = 0; i < 8; i++) {
  		cycles_t start, end;
  
  		start = get_cycles();
4e234eed5   Kees Cook   crypto: tcrypt - ...
804
  		ret = do_mult_ahash_op(data, num_mb, rc);
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
805
806
807
808
809
810
811
  		end = get_cycles();
  
  		if (ret)
  			goto out;
  
  		cycles += end - start;
  	}
4e234eed5   Kees Cook   crypto: tcrypt - ...
812
813
814
  	pr_cont("1 operation in %lu cycles (%d bytes)
  ",
  		(cycles + 4) / (8 * num_mb), blen);
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
815

4e234eed5   Kees Cook   crypto: tcrypt - ...
816
817
  out:
  	kfree(rc);
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
818
819
820
821
  	return ret;
  }
  
  static void test_mb_ahash_speed(const char *algo, unsigned int secs,
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
822
  				struct hash_speed *speed, u32 num_mb)
087bcd225   Megha Dey   crypto: tcrypt - ...
823
  {
72259deb3   Herbert Xu   crypto: tcrypt - ...
824
  	struct test_mb_ahash_data *data;
087bcd225   Megha Dey   crypto: tcrypt - ...
825
  	struct crypto_ahash *tfm;
72259deb3   Herbert Xu   crypto: tcrypt - ...
826
827
  	unsigned int i, j, k;
  	int ret;
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
828
  	data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL);
72259deb3   Herbert Xu   crypto: tcrypt - ...
829
830
  	if (!data)
  		return;
087bcd225   Megha Dey   crypto: tcrypt - ...
831
832
833
834
835
836
  
  	tfm = crypto_alloc_ahash(algo, 0, 0);
  	if (IS_ERR(tfm)) {
  		pr_err("failed to load transform for %s: %ld
  ",
  			algo, PTR_ERR(tfm));
72259deb3   Herbert Xu   crypto: tcrypt - ...
837
  		goto free_data;
087bcd225   Megha Dey   crypto: tcrypt - ...
838
  	}
72259deb3   Herbert Xu   crypto: tcrypt - ...
839

8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
840
  	for (i = 0; i < num_mb; ++i) {
72259deb3   Herbert Xu   crypto: tcrypt - ...
841
842
  		if (testmgr_alloc_buf(data[i].xbuf))
  			goto out;
087bcd225   Megha Dey   crypto: tcrypt - ...
843

646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
844
  		crypto_init_wait(&data[i].wait);
087bcd225   Megha Dey   crypto: tcrypt - ...
845

72259deb3   Herbert Xu   crypto: tcrypt - ...
846
847
  		data[i].req = ahash_request_alloc(tfm, GFP_KERNEL);
  		if (!data[i].req) {
f83f5b12e   Krzysztof Kozlowski   crypto: tcrypt - ...
848
849
850
  			pr_err("alg: hash: Failed to allocate request for %s
  ",
  			       algo);
72259deb3   Herbert Xu   crypto: tcrypt - ...
851
  			goto out;
087bcd225   Megha Dey   crypto: tcrypt - ...
852
  		}
087bcd225   Megha Dey   crypto: tcrypt - ...
853

646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
854
855
  		ahash_request_set_callback(data[i].req, 0, crypto_req_done,
  					   &data[i].wait);
7c3f13238   Gilad Ben-Yossef   crypto: tcrypt - ...
856
857
858
859
860
861
  
  		sg_init_table(data[i].sg, XBUFSIZE);
  		for (j = 0; j < XBUFSIZE; j++) {
  			sg_set_buf(data[i].sg + j, data[i].xbuf[j], PAGE_SIZE);
  			memset(data[i].xbuf[j], 0xff, PAGE_SIZE);
  		}
087bcd225   Megha Dey   crypto: tcrypt - ...
862
  	}
72259deb3   Herbert Xu   crypto: tcrypt - ...
863
864
865
866
  	pr_info("
  testing speed of multibuffer %s (%s)
  ", algo,
  		get_driver_name(crypto_ahash, tfm));
087bcd225   Megha Dey   crypto: tcrypt - ...
867
868
  
  	for (i = 0; speed[i].blen != 0; i++) {
72259deb3   Herbert Xu   crypto: tcrypt - ...
869
870
871
  		/* For some reason this only tests digests. */
  		if (speed[i].blen != speed[i].plen)
  			continue;
7c3f13238   Gilad Ben-Yossef   crypto: tcrypt - ...
872
  		if (speed[i].blen > XBUFSIZE * PAGE_SIZE) {
f83f5b12e   Krzysztof Kozlowski   crypto: tcrypt - ...
873
874
  			pr_err("template (%u) too big for tvmem (%lu)
  ",
7c3f13238   Gilad Ben-Yossef   crypto: tcrypt - ...
875
  			       speed[i].blen, XBUFSIZE * PAGE_SIZE);
f83f5b12e   Krzysztof Kozlowski   crypto: tcrypt - ...
876
  			goto out;
087bcd225   Megha Dey   crypto: tcrypt - ...
877
  		}
ba974adb4   Herbert Xu   crypto: tcrypt - ...
878
879
  		if (klen)
  			crypto_ahash_setkey(tfm, tvmem[0], klen);
087bcd225   Megha Dey   crypto: tcrypt - ...
880

8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
881
  		for (k = 0; k < num_mb; k++)
72259deb3   Herbert Xu   crypto: tcrypt - ...
882
883
  			ahash_request_set_crypt(data[k].req, data[k].sg,
  						data[k].result, speed[i].blen);
087bcd225   Megha Dey   crypto: tcrypt - ...
884

72259deb3   Herbert Xu   crypto: tcrypt - ...
885
886
  		pr_info("test%3u "
  			"(%5u byte blocks,%5u bytes per update,%4u updates): ",
087bcd225   Megha Dey   crypto: tcrypt - ...
887
888
  			i, speed[i].blen, speed[i].plen,
  			speed[i].blen / speed[i].plen);
2af632996   Horia Geantă   crypto: tcrypt - ...
889
  		if (secs) {
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
890
891
  			ret = test_mb_ahash_jiffies(data, speed[i].blen, secs,
  						    num_mb);
2af632996   Horia Geantă   crypto: tcrypt - ...
892
893
  			cond_resched();
  		} else {
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
894
  			ret = test_mb_ahash_cycles(data, speed[i].blen, num_mb);
2af632996   Horia Geantă   crypto: tcrypt - ...
895
  		}
087bcd225   Megha Dey   crypto: tcrypt - ...
896

72259deb3   Herbert Xu   crypto: tcrypt - ...
897
898
899
900
901
902
  
  		if (ret) {
  			pr_err("At least one hashing failed ret=%d
  ", ret);
  			break;
  		}
087bcd225   Megha Dey   crypto: tcrypt - ...
903
  	}
087bcd225   Megha Dey   crypto: tcrypt - ...
904
905
  
  out:
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
906
  	for (k = 0; k < num_mb; ++k)
72259deb3   Herbert Xu   crypto: tcrypt - ...
907
  		ahash_request_free(data[k].req);
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
908
  	for (k = 0; k < num_mb; ++k)
72259deb3   Herbert Xu   crypto: tcrypt - ...
909
910
911
912
913
914
  		testmgr_free_buf(data[k].xbuf);
  
  	crypto_free_ahash(tfm);
  
  free_data:
  	kfree(data);
087bcd225   Megha Dey   crypto: tcrypt - ...
915
  }
beb63da73   David S. Miller   crypto: tcrypt - ...
916
  static int test_ahash_jiffies_digest(struct ahash_request *req, int blen,
3e3dc25fe   Mark Rustad   crypto: Resolve s...
917
  				     char *out, int secs)
beb63da73   David S. Miller   crypto: tcrypt - ...
918
919
920
921
  {
  	unsigned long start, end;
  	int bcount;
  	int ret;
3e3dc25fe   Mark Rustad   crypto: Resolve s...
922
  	for (start = jiffies, end = start + secs * HZ, bcount = 0;
beb63da73   David S. Miller   crypto: tcrypt - ...
923
924
925
926
927
928
929
930
  	     time_before(jiffies, end); bcount++) {
  		ret = do_one_ahash_op(req, crypto_ahash_digest(req));
  		if (ret)
  			return ret;
  	}
  
  	printk("%6u opers/sec, %9lu bytes/sec
  ",
3e3dc25fe   Mark Rustad   crypto: Resolve s...
931
  	       bcount / secs, ((long)bcount * blen) / secs);
beb63da73   David S. Miller   crypto: tcrypt - ...
932
933
934
935
936
  
  	return 0;
  }
  
  static int test_ahash_jiffies(struct ahash_request *req, int blen,
3e3dc25fe   Mark Rustad   crypto: Resolve s...
937
  			      int plen, char *out, int secs)
beb63da73   David S. Miller   crypto: tcrypt - ...
938
939
940
941
942
943
  {
  	unsigned long start, end;
  	int bcount, pcount;
  	int ret;
  
  	if (plen == blen)
3e3dc25fe   Mark Rustad   crypto: Resolve s...
944
  		return test_ahash_jiffies_digest(req, blen, out, secs);
beb63da73   David S. Miller   crypto: tcrypt - ...
945

3e3dc25fe   Mark Rustad   crypto: Resolve s...
946
  	for (start = jiffies, end = start + secs * HZ, bcount = 0;
beb63da73   David S. Miller   crypto: tcrypt - ...
947
  	     time_before(jiffies, end); bcount++) {
43a9607d8   Herbert Xu   crypto: tcrypt - ...
948
  		ret = do_one_ahash_op(req, crypto_ahash_init(req));
beb63da73   David S. Miller   crypto: tcrypt - ...
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
  		if (ret)
  			return ret;
  		for (pcount = 0; pcount < blen; pcount += plen) {
  			ret = do_one_ahash_op(req, crypto_ahash_update(req));
  			if (ret)
  				return ret;
  		}
  		/* we assume there is enough space in 'out' for the result */
  		ret = do_one_ahash_op(req, crypto_ahash_final(req));
  		if (ret)
  			return ret;
  	}
  
  	pr_cont("%6u opers/sec, %9lu bytes/sec
  ",
3e3dc25fe   Mark Rustad   crypto: Resolve s...
964
  		bcount / secs, ((long)bcount * blen) / secs);
beb63da73   David S. Miller   crypto: tcrypt - ...
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
  
  	return 0;
  }
  
  static int test_ahash_cycles_digest(struct ahash_request *req, int blen,
  				    char *out)
  {
  	unsigned long cycles = 0;
  	int ret, i;
  
  	/* Warm-up run. */
  	for (i = 0; i < 4; i++) {
  		ret = do_one_ahash_op(req, crypto_ahash_digest(req));
  		if (ret)
  			goto out;
  	}
  
  	/* The real thing. */
  	for (i = 0; i < 8; i++) {
  		cycles_t start, end;
  
  		start = get_cycles();
  
  		ret = do_one_ahash_op(req, crypto_ahash_digest(req));
  		if (ret)
  			goto out;
  
  		end = get_cycles();
  
  		cycles += end - start;
  	}
  
  out:
  	if (ret)
  		return ret;
  
  	pr_cont("%6lu cycles/operation, %4lu cycles/byte
  ",
  		cycles / 8, cycles / (8 * blen));
  
  	return 0;
  }
  
  static int test_ahash_cycles(struct ahash_request *req, int blen,
  			     int plen, char *out)
  {
  	unsigned long cycles = 0;
  	int i, pcount, ret;
  
  	if (plen == blen)
  		return test_ahash_cycles_digest(req, blen, out);
  
  	/* Warm-up run. */
  	for (i = 0; i < 4; i++) {
43a9607d8   Herbert Xu   crypto: tcrypt - ...
1019
  		ret = do_one_ahash_op(req, crypto_ahash_init(req));
beb63da73   David S. Miller   crypto: tcrypt - ...
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
  		if (ret)
  			goto out;
  		for (pcount = 0; pcount < blen; pcount += plen) {
  			ret = do_one_ahash_op(req, crypto_ahash_update(req));
  			if (ret)
  				goto out;
  		}
  		ret = do_one_ahash_op(req, crypto_ahash_final(req));
  		if (ret)
  			goto out;
  	}
  
  	/* The real thing. */
  	for (i = 0; i < 8; i++) {
  		cycles_t start, end;
  
  		start = get_cycles();
43a9607d8   Herbert Xu   crypto: tcrypt - ...
1037
  		ret = do_one_ahash_op(req, crypto_ahash_init(req));
beb63da73   David S. Miller   crypto: tcrypt - ...
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
  		if (ret)
  			goto out;
  		for (pcount = 0; pcount < blen; pcount += plen) {
  			ret = do_one_ahash_op(req, crypto_ahash_update(req));
  			if (ret)
  				goto out;
  		}
  		ret = do_one_ahash_op(req, crypto_ahash_final(req));
  		if (ret)
  			goto out;
  
  		end = get_cycles();
  
  		cycles += end - start;
  	}
  
  out:
  	if (ret)
  		return ret;
  
  	pr_cont("%6lu cycles/operation, %4lu cycles/byte
  ",
  		cycles / 8, cycles / (8 * blen));
  
  	return 0;
  }
0660511c0   Herbert Xu   crypto: tcrypt - ...
1064
1065
  static void test_ahash_speed_common(const char *algo, unsigned int secs,
  				    struct hash_speed *speed, unsigned mask)
beb63da73   David S. Miller   crypto: tcrypt - ...
1066
1067
  {
  	struct scatterlist sg[TVMEMSIZE];
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
1068
  	struct crypto_wait wait;
beb63da73   David S. Miller   crypto: tcrypt - ...
1069
1070
  	struct ahash_request *req;
  	struct crypto_ahash *tfm;
f074f7b10   Horia Geant?   crypto: tcrypt - ...
1071
  	char *output;
beb63da73   David S. Miller   crypto: tcrypt - ...
1072
  	int i, ret;
0660511c0   Herbert Xu   crypto: tcrypt - ...
1073
  	tfm = crypto_alloc_ahash(algo, 0, mask);
beb63da73   David S. Miller   crypto: tcrypt - ...
1074
1075
1076
1077
1078
1079
  	if (IS_ERR(tfm)) {
  		pr_err("failed to load transform for %s: %ld
  ",
  		       algo, PTR_ERR(tfm));
  		return;
  	}
263a8df0d   Luca Clementi   crypto: tcrypt - ...
1080
1081
1082
1083
  	printk(KERN_INFO "
  testing speed of async %s (%s)
  ", algo,
  			get_driver_name(crypto_ahash, tfm));
f074f7b10   Horia Geant?   crypto: tcrypt - ...
1084
1085
1086
1087
  	if (crypto_ahash_digestsize(tfm) > MAX_DIGEST_SIZE) {
  		pr_err("digestsize(%u) > %d
  ", crypto_ahash_digestsize(tfm),
  		       MAX_DIGEST_SIZE);
beb63da73   David S. Miller   crypto: tcrypt - ...
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
  		goto out;
  	}
  
  	test_hash_sg_init(sg);
  	req = ahash_request_alloc(tfm, GFP_KERNEL);
  	if (!req) {
  		pr_err("ahash request allocation failure
  ");
  		goto out;
  	}
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
1098
  	crypto_init_wait(&wait);
beb63da73   David S. Miller   crypto: tcrypt - ...
1099
  	ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
1100
  				   crypto_req_done, &wait);
beb63da73   David S. Miller   crypto: tcrypt - ...
1101

f074f7b10   Horia Geant?   crypto: tcrypt - ...
1102
1103
1104
  	output = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL);
  	if (!output)
  		goto out_nomem;
beb63da73   David S. Miller   crypto: tcrypt - ...
1105
1106
1107
1108
1109
1110
1111
  	for (i = 0; speed[i].blen != 0; i++) {
  		if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
  			pr_err("template (%u) too big for tvmem (%lu)
  ",
  			       speed[i].blen, TVMEMSIZE * PAGE_SIZE);
  			break;
  		}
ba974adb4   Herbert Xu   crypto: tcrypt - ...
1112
1113
  		if (klen)
  			crypto_ahash_setkey(tfm, tvmem[0], klen);
331351f89   Horia Geantă   crypto: tcrypt - ...
1114

beb63da73   David S. Miller   crypto: tcrypt - ...
1115
1116
1117
1118
1119
  		pr_info("test%3u "
  			"(%5u byte blocks,%5u bytes per update,%4u updates): ",
  			i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
  
  		ahash_request_set_crypt(req, sg, output, speed[i].plen);
2af632996   Horia Geantă   crypto: tcrypt - ...
1120
  		if (secs) {
beb63da73   David S. Miller   crypto: tcrypt - ...
1121
  			ret = test_ahash_jiffies(req, speed[i].blen,
3e3dc25fe   Mark Rustad   crypto: Resolve s...
1122
  						 speed[i].plen, output, secs);
2af632996   Horia Geantă   crypto: tcrypt - ...
1123
1124
  			cond_resched();
  		} else {
beb63da73   David S. Miller   crypto: tcrypt - ...
1125
1126
  			ret = test_ahash_cycles(req, speed[i].blen,
  						speed[i].plen, output);
2af632996   Horia Geantă   crypto: tcrypt - ...
1127
  		}
beb63da73   David S. Miller   crypto: tcrypt - ...
1128
1129
1130
1131
1132
1133
1134
  
  		if (ret) {
  			pr_err("hashing failed ret=%d
  ", ret);
  			break;
  		}
  	}
f074f7b10   Horia Geant?   crypto: tcrypt - ...
1135
1136
1137
  	kfree(output);
  
  out_nomem:
beb63da73   David S. Miller   crypto: tcrypt - ...
1138
1139
1140
1141
1142
  	ahash_request_free(req);
  
  out:
  	crypto_free_ahash(tfm);
  }
0660511c0   Herbert Xu   crypto: tcrypt - ...
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
  static void test_ahash_speed(const char *algo, unsigned int secs,
  			     struct hash_speed *speed)
  {
  	return test_ahash_speed_common(algo, secs, speed, 0);
  }
  
  static void test_hash_speed(const char *algo, unsigned int secs,
  			    struct hash_speed *speed)
  {
  	return test_ahash_speed_common(algo, secs, speed, CRYPTO_ALG_ASYNC);
  }
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1154
1155
1156
1157
1158
1159
1160
1161
  struct test_mb_skcipher_data {
  	struct scatterlist sg[XBUFSIZE];
  	struct skcipher_request *req;
  	struct crypto_wait wait;
  	char *xbuf[XBUFSIZE];
  };
  
  static int do_mult_acipher_op(struct test_mb_skcipher_data *data, int enc,
4e234eed5   Kees Cook   crypto: tcrypt - ...
1162
  				u32 num_mb, int *rc)
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1163
  {
4e234eed5   Kees Cook   crypto: tcrypt - ...
1164
  	int i, err = 0;
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
  
  	/* Fire up a bunch of concurrent requests */
  	for (i = 0; i < num_mb; i++) {
  		if (enc == ENCRYPT)
  			rc[i] = crypto_skcipher_encrypt(data[i].req);
  		else
  			rc[i] = crypto_skcipher_decrypt(data[i].req);
  	}
  
  	/* Wait for all requests to finish */
  	for (i = 0; i < num_mb; i++) {
  		rc[i] = crypto_wait_req(rc[i], &data[i].wait);
  
  		if (rc[i]) {
  			pr_info("concurrent request %d error %d
  ", i, rc[i]);
  			err = rc[i];
  		}
  	}
  
  	return err;
  }
  
  static int test_mb_acipher_jiffies(struct test_mb_skcipher_data *data, int enc,
  				int blen, int secs, u32 num_mb)
  {
  	unsigned long start, end;
  	int bcount;
4e234eed5   Kees Cook   crypto: tcrypt - ...
1193
1194
1195
1196
1197
1198
  	int ret = 0;
  	int *rc;
  
  	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
  	if (!rc)
  		return -ENOMEM;
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1199
1200
1201
  
  	for (start = jiffies, end = start + secs * HZ, bcount = 0;
  	     time_before(jiffies, end); bcount++) {
4e234eed5   Kees Cook   crypto: tcrypt - ...
1202
  		ret = do_mult_acipher_op(data, enc, num_mb, rc);
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1203
  		if (ret)
4e234eed5   Kees Cook   crypto: tcrypt - ...
1204
  			goto out;
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1205
1206
1207
1208
1209
  	}
  
  	pr_cont("%d operations in %d seconds (%ld bytes)
  ",
  		bcount * num_mb, secs, (long)bcount * blen * num_mb);
4e234eed5   Kees Cook   crypto: tcrypt - ...
1210
1211
1212
1213
  
  out:
  	kfree(rc);
  	return ret;
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1214
1215
1216
1217
1218
1219
1220
1221
  }
  
  static int test_mb_acipher_cycles(struct test_mb_skcipher_data *data, int enc,
  			       int blen, u32 num_mb)
  {
  	unsigned long cycles = 0;
  	int ret = 0;
  	int i;
4e234eed5   Kees Cook   crypto: tcrypt - ...
1222
1223
1224
1225
1226
  	int *rc;
  
  	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
  	if (!rc)
  		return -ENOMEM;
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1227
1228
1229
  
  	/* Warm-up run. */
  	for (i = 0; i < 4; i++) {
4e234eed5   Kees Cook   crypto: tcrypt - ...
1230
  		ret = do_mult_acipher_op(data, enc, num_mb, rc);
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1231
1232
1233
1234
1235
1236
1237
1238
1239
  		if (ret)
  			goto out;
  	}
  
  	/* The real thing. */
  	for (i = 0; i < 8; i++) {
  		cycles_t start, end;
  
  		start = get_cycles();
4e234eed5   Kees Cook   crypto: tcrypt - ...
1240
  		ret = do_mult_acipher_op(data, enc, num_mb, rc);
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1241
1242
1243
1244
1245
1246
1247
  		end = get_cycles();
  
  		if (ret)
  			goto out;
  
  		cycles += end - start;
  	}
4e234eed5   Kees Cook   crypto: tcrypt - ...
1248
1249
1250
  	pr_cont("1 operation in %lu cycles (%d bytes)
  ",
  		(cycles + 4) / (8 * num_mb), blen);
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1251

4e234eed5   Kees Cook   crypto: tcrypt - ...
1252
1253
  out:
  	kfree(rc);
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
  	return ret;
  }
  
  static void test_mb_skcipher_speed(const char *algo, int enc, int secs,
  				   struct cipher_speed_template *template,
  				   unsigned int tcount, u8 *keysize, u32 num_mb)
  {
  	struct test_mb_skcipher_data *data;
  	struct crypto_skcipher *tfm;
  	unsigned int i, j, iv_len;
  	const char *key;
  	const char *e;
  	u32 *b_size;
  	char iv[128];
  	int ret;
  
  	if (enc == ENCRYPT)
  		e = "encryption";
  	else
  		e = "decryption";
  
  	data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL);
  	if (!data)
  		return;
  
  	tfm = crypto_alloc_skcipher(algo, 0, 0);
  	if (IS_ERR(tfm)) {
  		pr_err("failed to load transform for %s: %ld
  ",
  			algo, PTR_ERR(tfm));
  		goto out_free_data;
  	}
  
  	for (i = 0; i < num_mb; ++i)
  		if (testmgr_alloc_buf(data[i].xbuf)) {
  			while (i--)
  				testmgr_free_buf(data[i].xbuf);
  			goto out_free_tfm;
  		}
  
  
  	for (i = 0; i < num_mb; ++i)
  		if (testmgr_alloc_buf(data[i].xbuf)) {
  			while (i--)
  				testmgr_free_buf(data[i].xbuf);
  			goto out_free_tfm;
  		}
  
  
  	for (i = 0; i < num_mb; ++i) {
  		data[i].req = skcipher_request_alloc(tfm, GFP_KERNEL);
  		if (!data[i].req) {
  			pr_err("alg: skcipher: Failed to allocate request for %s
  ",
  			       algo);
  			while (i--)
  				skcipher_request_free(data[i].req);
  			goto out_free_xbuf;
  		}
  	}
  
  	for (i = 0; i < num_mb; ++i) {
  		skcipher_request_set_callback(data[i].req,
  					      CRYPTO_TFM_REQ_MAY_BACKLOG,
  					      crypto_req_done, &data[i].wait);
  		crypto_init_wait(&data[i].wait);
  	}
  
  	pr_info("
  testing speed of multibuffer %s (%s) %s
  ", algo,
  		get_driver_name(crypto_skcipher, tfm), e);
  
  	i = 0;
  	do {
  		b_size = block_sizes;
  		do {
  			if (*b_size > XBUFSIZE * PAGE_SIZE) {
38dbe2d19   Colin Ian King   crypto: tcrypt - ...
1332
1333
  				pr_err("template (%u) too big for buffer (%lu)
  ",
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
  				       *b_size, XBUFSIZE * PAGE_SIZE);
  				goto out;
  			}
  
  			pr_info("test %u (%d bit key, %d byte blocks): ", i,
  				*keysize * 8, *b_size);
  
  			/* Set up tfm global state, i.e. the key */
  
  			memset(tvmem[0], 0xff, PAGE_SIZE);
  			key = tvmem[0];
  			for (j = 0; j < tcount; j++) {
  				if (template[j].klen == *keysize) {
  					key = template[j].key;
  					break;
  				}
  			}
  
  			crypto_skcipher_clear_flags(tfm, ~0);
  
  			ret = crypto_skcipher_setkey(tfm, key, *keysize);
  			if (ret) {
  				pr_err("setkey() failed flags=%x
  ",
  				       crypto_skcipher_get_flags(tfm));
  				goto out;
  			}
  
  			iv_len = crypto_skcipher_ivsize(tfm);
  			if (iv_len)
  				memset(&iv, 0xff, iv_len);
  
  			/* Now setup per request stuff, i.e. buffers */
  
  			for (j = 0; j < num_mb; ++j) {
  				struct test_mb_skcipher_data *cur = &data[j];
  				unsigned int k = *b_size;
  				unsigned int pages = DIV_ROUND_UP(k, PAGE_SIZE);
  				unsigned int p = 0;
  
  				sg_init_table(cur->sg, pages);
  
  				while (k > PAGE_SIZE) {
  					sg_set_buf(cur->sg + p, cur->xbuf[p],
  						   PAGE_SIZE);
  					memset(cur->xbuf[p], 0xff, PAGE_SIZE);
  					p++;
  					k -= PAGE_SIZE;
  				}
  
  				sg_set_buf(cur->sg + p, cur->xbuf[p], k);
  				memset(cur->xbuf[p], 0xff, k);
  
  				skcipher_request_set_crypt(cur->req, cur->sg,
  							   cur->sg, *b_size,
  							   iv);
  			}
2af632996   Horia Geantă   crypto: tcrypt - ...
1391
  			if (secs) {
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1392
1393
1394
  				ret = test_mb_acipher_jiffies(data, enc,
  							      *b_size, secs,
  							      num_mb);
2af632996   Horia Geantă   crypto: tcrypt - ...
1395
1396
  				cond_resched();
  			} else {
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1397
1398
  				ret = test_mb_acipher_cycles(data, enc,
  							     *b_size, num_mb);
2af632996   Horia Geantă   crypto: tcrypt - ...
1399
  			}
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
  
  			if (ret) {
  				pr_err("%s() failed flags=%x
  ", e,
  				       crypto_skcipher_get_flags(tfm));
  				break;
  			}
  			b_size++;
  			i++;
  		} while (*b_size);
  		keysize++;
  	} while (*keysize);
  
  out:
  	for (i = 0; i < num_mb; ++i)
  		skcipher_request_free(data[i].req);
  out_free_xbuf:
  	for (i = 0; i < num_mb; ++i)
  		testmgr_free_buf(data[i].xbuf);
  out_free_tfm:
  	crypto_free_skcipher(tfm);
  out_free_data:
  	kfree(data);
  }
7166e589d   Herbert Xu   crypto: tcrypt - ...
1424
  static inline int do_one_acipher_op(struct skcipher_request *req, int ret)
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1425
  {
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
1426
  	struct crypto_wait *wait = req->base.data;
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1427

646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
1428
  	return crypto_wait_req(ret, wait);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1429
  }
7166e589d   Herbert Xu   crypto: tcrypt - ...
1430
  static int test_acipher_jiffies(struct skcipher_request *req, int enc,
3e3dc25fe   Mark Rustad   crypto: Resolve s...
1431
  				int blen, int secs)
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1432
1433
1434
1435
  {
  	unsigned long start, end;
  	int bcount;
  	int ret;
3e3dc25fe   Mark Rustad   crypto: Resolve s...
1436
  	for (start = jiffies, end = start + secs * HZ, bcount = 0;
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1437
1438
1439
  	     time_before(jiffies, end); bcount++) {
  		if (enc)
  			ret = do_one_acipher_op(req,
7166e589d   Herbert Xu   crypto: tcrypt - ...
1440
  						crypto_skcipher_encrypt(req));
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1441
1442
  		else
  			ret = do_one_acipher_op(req,
7166e589d   Herbert Xu   crypto: tcrypt - ...
1443
  						crypto_skcipher_decrypt(req));
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1444
1445
1446
1447
1448
1449
1450
  
  		if (ret)
  			return ret;
  	}
  
  	pr_cont("%d operations in %d seconds (%ld bytes)
  ",
3e3dc25fe   Mark Rustad   crypto: Resolve s...
1451
  		bcount, secs, (long)bcount * blen);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1452
1453
  	return 0;
  }
7166e589d   Herbert Xu   crypto: tcrypt - ...
1454
  static int test_acipher_cycles(struct skcipher_request *req, int enc,
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
  			       int blen)
  {
  	unsigned long cycles = 0;
  	int ret = 0;
  	int i;
  
  	/* Warm-up run. */
  	for (i = 0; i < 4; i++) {
  		if (enc)
  			ret = do_one_acipher_op(req,
7166e589d   Herbert Xu   crypto: tcrypt - ...
1465
  						crypto_skcipher_encrypt(req));
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1466
1467
  		else
  			ret = do_one_acipher_op(req,
7166e589d   Herbert Xu   crypto: tcrypt - ...
1468
  						crypto_skcipher_decrypt(req));
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
  
  		if (ret)
  			goto out;
  	}
  
  	/* The real thing. */
  	for (i = 0; i < 8; i++) {
  		cycles_t start, end;
  
  		start = get_cycles();
  		if (enc)
  			ret = do_one_acipher_op(req,
7166e589d   Herbert Xu   crypto: tcrypt - ...
1481
  						crypto_skcipher_encrypt(req));
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1482
1483
  		else
  			ret = do_one_acipher_op(req,
7166e589d   Herbert Xu   crypto: tcrypt - ...
1484
  						crypto_skcipher_decrypt(req));
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
  		end = get_cycles();
  
  		if (ret)
  			goto out;
  
  		cycles += end - start;
  	}
  
  out:
  	if (ret == 0)
  		pr_cont("1 operation in %lu cycles (%d bytes)
  ",
  			(cycles + 4) / 8, blen);
  
  	return ret;
  }
7166e589d   Herbert Xu   crypto: tcrypt - ...
1501
1502
1503
  static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
  				struct cipher_speed_template *template,
  				unsigned int tcount, u8 *keysize, bool async)
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1504
  {
de1975334   Nicolas Royer   crypto: atmel - a...
1505
  	unsigned int ret, i, j, k, iv_len;
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
1506
  	struct crypto_wait wait;
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1507
1508
  	const char *key;
  	char iv[128];
7166e589d   Herbert Xu   crypto: tcrypt - ...
1509
1510
  	struct skcipher_request *req;
  	struct crypto_skcipher *tfm;
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1511
1512
1513
1514
1515
1516
1517
  	const char *e;
  	u32 *b_size;
  
  	if (enc == ENCRYPT)
  		e = "encryption";
  	else
  		e = "decryption";
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
1518
  	crypto_init_wait(&wait);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1519

7166e589d   Herbert Xu   crypto: tcrypt - ...
1520
  	tfm = crypto_alloc_skcipher(algo, 0, async ? 0 : CRYPTO_ALG_ASYNC);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1521
1522
1523
1524
1525
1526
1527
  
  	if (IS_ERR(tfm)) {
  		pr_err("failed to load transform for %s: %ld
  ", algo,
  		       PTR_ERR(tfm));
  		return;
  	}
8e3b7fd7e   Horia Geantă   crypto: tcrypt - ...
1528
1529
1530
1531
  	pr_info("
  testing speed of %s %s (%s) %s
  ", async ? "async" : "sync",
  		algo, get_driver_name(crypto_skcipher, tfm), e);
263a8df0d   Luca Clementi   crypto: tcrypt - ...
1532

7166e589d   Herbert Xu   crypto: tcrypt - ...
1533
  	req = skcipher_request_alloc(tfm, GFP_KERNEL);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1534
1535
1536
1537
1538
1539
  	if (!req) {
  		pr_err("tcrypt: skcipher: Failed to allocate request for %s
  ",
  		       algo);
  		goto out;
  	}
7166e589d   Herbert Xu   crypto: tcrypt - ...
1540
  	skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
1541
  				      crypto_req_done, &wait);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
  
  	i = 0;
  	do {
  		b_size = block_sizes;
  
  		do {
  			struct scatterlist sg[TVMEMSIZE];
  
  			if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
  				pr_err("template (%u) too big for "
  				       "tvmem (%lu)
  ", *keysize + *b_size,
  				       TVMEMSIZE * PAGE_SIZE);
  				goto out_free_req;
  			}
  
  			pr_info("test %u (%d bit key, %d byte blocks): ", i,
  				*keysize * 8, *b_size);
  
  			memset(tvmem[0], 0xff, PAGE_SIZE);
  
  			/* set key, plain text and IV */
  			key = tvmem[0];
  			for (j = 0; j < tcount; j++) {
  				if (template[j].klen == *keysize) {
  					key = template[j].key;
  					break;
  				}
  			}
7166e589d   Herbert Xu   crypto: tcrypt - ...
1571
  			crypto_skcipher_clear_flags(tfm, ~0);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1572

7166e589d   Herbert Xu   crypto: tcrypt - ...
1573
  			ret = crypto_skcipher_setkey(tfm, key, *keysize);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1574
1575
1576
  			if (ret) {
  				pr_err("setkey() failed flags=%x
  ",
7166e589d   Herbert Xu   crypto: tcrypt - ...
1577
  					crypto_skcipher_get_flags(tfm));
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1578
1579
  				goto out_free_req;
  			}
de1975334   Nicolas Royer   crypto: atmel - a...
1580
  			k = *keysize + *b_size;
007ee8dec   Horia Geant?   crypto: tcrypt - ...
1581
  			sg_init_table(sg, DIV_ROUND_UP(k, PAGE_SIZE));
de1975334   Nicolas Royer   crypto: atmel - a...
1582
1583
  			if (k > PAGE_SIZE) {
  				sg_set_buf(sg, tvmem[0] + *keysize,
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1584
  				   PAGE_SIZE - *keysize);
de1975334   Nicolas Royer   crypto: atmel - a...
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
  				k -= PAGE_SIZE;
  				j = 1;
  				while (k > PAGE_SIZE) {
  					sg_set_buf(sg + j, tvmem[j], PAGE_SIZE);
  					memset(tvmem[j], 0xff, PAGE_SIZE);
  					j++;
  					k -= PAGE_SIZE;
  				}
  				sg_set_buf(sg + j, tvmem[j], k);
  				memset(tvmem[j], 0xff, k);
  			} else {
  				sg_set_buf(sg, tvmem[0] + *keysize, *b_size);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1597
  			}
7166e589d   Herbert Xu   crypto: tcrypt - ...
1598
  			iv_len = crypto_skcipher_ivsize(tfm);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1599
1600
  			if (iv_len)
  				memset(&iv, 0xff, iv_len);
7166e589d   Herbert Xu   crypto: tcrypt - ...
1601
  			skcipher_request_set_crypt(req, sg, sg, *b_size, iv);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1602

2af632996   Horia Geantă   crypto: tcrypt - ...
1603
  			if (secs) {
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1604
  				ret = test_acipher_jiffies(req, enc,
3e3dc25fe   Mark Rustad   crypto: Resolve s...
1605
  							   *b_size, secs);
2af632996   Horia Geantă   crypto: tcrypt - ...
1606
1607
  				cond_resched();
  			} else {
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1608
1609
  				ret = test_acipher_cycles(req, enc,
  							  *b_size);
2af632996   Horia Geantă   crypto: tcrypt - ...
1610
  			}
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1611
1612
1613
1614
  
  			if (ret) {
  				pr_err("%s() failed flags=%x
  ", e,
7166e589d   Herbert Xu   crypto: tcrypt - ...
1615
  				       crypto_skcipher_get_flags(tfm));
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1616
1617
1618
1619
1620
1621
1622
1623
1624
  				break;
  			}
  			b_size++;
  			i++;
  		} while (*b_size);
  		keysize++;
  	} while (*keysize);
  
  out_free_req:
7166e589d   Herbert Xu   crypto: tcrypt - ...
1625
  	skcipher_request_free(req);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1626
  out:
7166e589d   Herbert Xu   crypto: tcrypt - ...
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
  	crypto_free_skcipher(tfm);
  }
  
  static void test_acipher_speed(const char *algo, int enc, unsigned int secs,
  			       struct cipher_speed_template *template,
  			       unsigned int tcount, u8 *keysize)
  {
  	return test_skcipher_speed(algo, enc, secs, template, tcount, keysize,
  				   true);
  }
  
  static void test_cipher_speed(const char *algo, int enc, unsigned int secs,
  			      struct cipher_speed_template *template,
  			      unsigned int tcount, u8 *keysize)
  {
  	return test_skcipher_speed(algo, enc, secs, template, tcount, keysize,
  				   false);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1644
  }
ef2736fc7   Herbert Xu   [CRYPTO]: White s...
1645
  static void test_available(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1646
  {
07d8f1858   Corentin Labbe   crypto: tcrypt - ...
1647
  	const char **name = check;
ef2736fc7   Herbert Xu   [CRYPTO]: White s...
1648

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1649
1650
  	while (*name) {
  		printk("alg %s ", *name);
6158efc09   Herbert Xu   [CRYPTO] tcrypt: ...
1651
  		printk(crypto_has_alg(*name, 0, 0) ?
e4d5b79c6   Herbert Xu   [CRYPTO] users: U...
1652
1653
1654
  		       "found
  " : "not found
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1655
  		name++;
ef2736fc7   Herbert Xu   [CRYPTO]: White s...
1656
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1657
  }
01b323245   Herbert Xu   crypto: tcrypt - ...
1658
1659
  static inline int tcrypt_test(const char *alg)
  {
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1660
  	int ret;
76512f2d8   Rabin Vincent   crypto: tcrypt - ...
1661
1662
  	pr_debug("testing %s
  ", alg);
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1663
1664
1665
1666
1667
  	ret = alg_test(alg, alg, 0, 0);
  	/* non-fips algs return -EINVAL in fips mode */
  	if (fips_enabled && ret == -EINVAL)
  		ret = 0;
  	return ret;
01b323245   Herbert Xu   crypto: tcrypt - ...
1668
  }
4e234eed5   Kees Cook   crypto: tcrypt - ...
1669
  static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
01b323245   Herbert Xu   crypto: tcrypt - ...
1670
1671
  {
  	int i;
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1672
  	int ret = 0;
01b323245   Herbert Xu   crypto: tcrypt - ...
1673
1674
  
  	switch (m) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1675
  	case 0:
8606813a6   Herbert Xu   crypto: tcrypt - ...
1676
1677
1678
1679
1680
1681
  		if (alg) {
  			if (!crypto_has_alg(alg, type,
  					    mask ?: CRYPTO_ALG_TYPE_MASK))
  				ret = -ENOENT;
  			break;
  		}
01b323245   Herbert Xu   crypto: tcrypt - ...
1682
  		for (i = 1; i < 200; i++)
4e234eed5   Kees Cook   crypto: tcrypt - ...
1683
  			ret += do_test(NULL, 0, 0, i, num_mb);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1684
1685
1686
  		break;
  
  	case 1:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1687
  		ret += tcrypt_test("md5");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1688
1689
1690
  		break;
  
  	case 2:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1691
  		ret += tcrypt_test("sha1");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1692
1693
1694
  		break;
  
  	case 3:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1695
1696
  		ret += tcrypt_test("ecb(des)");
  		ret += tcrypt_test("cbc(des)");
8163fc30d   Jussi Kivilinna   crypto: testmgr -...
1697
  		ret += tcrypt_test("ctr(des)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1698
1699
1700
  		break;
  
  	case 4:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1701
1702
  		ret += tcrypt_test("ecb(des3_ede)");
  		ret += tcrypt_test("cbc(des3_ede)");
e080b17a8   Jussi Kivilinna   crypto: testmgr -...
1703
  		ret += tcrypt_test("ctr(des3_ede)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1704
1705
1706
  		break;
  
  	case 5:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1707
  		ret += tcrypt_test("md4");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1708
  		break;
ef2736fc7   Herbert Xu   [CRYPTO]: White s...
1709

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1710
  	case 6:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1711
  		ret += tcrypt_test("sha256");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1712
  		break;
ef2736fc7   Herbert Xu   [CRYPTO]: White s...
1713

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1714
  	case 7:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1715
1716
  		ret += tcrypt_test("ecb(blowfish)");
  		ret += tcrypt_test("cbc(blowfish)");
85b63e342   Jussi Kivilinna   crypto: testmgr -...
1717
  		ret += tcrypt_test("ctr(blowfish)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1718
1719
1720
  		break;
  
  	case 8:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1721
1722
  		ret += tcrypt_test("ecb(twofish)");
  		ret += tcrypt_test("cbc(twofish)");
573da6208   Jussi Kivilinna   crypto: testmgr -...
1723
  		ret += tcrypt_test("ctr(twofish)");
bee3a90ef   Jussi Kivilinna   crypto: tcrypt - ...
1724
  		ret += tcrypt_test("lrw(twofish)");
131f75416   Jussi Kivilinna   crypto: tcrypt - ...
1725
  		ret += tcrypt_test("xts(twofish)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1726
  		break;
ef2736fc7   Herbert Xu   [CRYPTO]: White s...
1727

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1728
  	case 9:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1729
  		ret += tcrypt_test("ecb(serpent)");
9d25917d4   Jussi Kivilinna   crypto: testmgr -...
1730
1731
  		ret += tcrypt_test("cbc(serpent)");
  		ret += tcrypt_test("ctr(serpent)");
87aae4bfb   Jussi Kivilinna   crypto: tcrypt - ...
1732
  		ret += tcrypt_test("lrw(serpent)");
5209c07ac   Jussi Kivilinna   crypto: tcrypt - ...
1733
  		ret += tcrypt_test("xts(serpent)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1734
1735
1736
  		break;
  
  	case 10:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1737
1738
1739
1740
1741
1742
  		ret += tcrypt_test("ecb(aes)");
  		ret += tcrypt_test("cbc(aes)");
  		ret += tcrypt_test("lrw(aes)");
  		ret += tcrypt_test("xts(aes)");
  		ret += tcrypt_test("ctr(aes)");
  		ret += tcrypt_test("rfc3686(ctr(aes))");
dfb89ab3f   Gilad Ben-Yossef   crypto: tcrypt - ...
1743
  		ret += tcrypt_test("ofb(aes)");
7da666707   Dmitry Eremin-Solenikov   crypto: testmgr -...
1744
  		ret += tcrypt_test("cfb(aes)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1745
1746
1747
  		break;
  
  	case 11:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1748
  		ret += tcrypt_test("sha384");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1749
  		break;
ef2736fc7   Herbert Xu   [CRYPTO]: White s...
1750

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1751
  	case 12:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1752
  		ret += tcrypt_test("sha512");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1753
1754
1755
  		break;
  
  	case 13:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1756
  		ret += tcrypt_test("deflate");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1757
1758
1759
  		break;
  
  	case 14:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1760
  		ret += tcrypt_test("ecb(cast5)");
a2c582609   Johannes Goetzfried   crypto: testmgr -...
1761
1762
  		ret += tcrypt_test("cbc(cast5)");
  		ret += tcrypt_test("ctr(cast5)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1763
1764
1765
  		break;
  
  	case 15:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1766
  		ret += tcrypt_test("ecb(cast6)");
9b8b04051   Johannes Goetzfried   crypto: testmgr -...
1767
1768
1769
1770
  		ret += tcrypt_test("cbc(cast6)");
  		ret += tcrypt_test("ctr(cast6)");
  		ret += tcrypt_test("lrw(cast6)");
  		ret += tcrypt_test("xts(cast6)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1771
1772
1773
  		break;
  
  	case 16:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1774
  		ret += tcrypt_test("ecb(arc4)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1775
1776
1777
  		break;
  
  	case 17:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1778
  		ret += tcrypt_test("michael_mic");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1779
1780
1781
  		break;
  
  	case 18:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1782
  		ret += tcrypt_test("crc32c");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1783
1784
1785
  		break;
  
  	case 19:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1786
  		ret += tcrypt_test("ecb(tea)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1787
1788
1789
  		break;
  
  	case 20:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1790
  		ret += tcrypt_test("ecb(xtea)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1791
1792
1793
  		break;
  
  	case 21:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1794
  		ret += tcrypt_test("ecb(khazad)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1795
1796
1797
  		break;
  
  	case 22:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1798
  		ret += tcrypt_test("wp512");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1799
1800
1801
  		break;
  
  	case 23:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1802
  		ret += tcrypt_test("wp384");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1803
1804
1805
  		break;
  
  	case 24:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1806
  		ret += tcrypt_test("wp256");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1807
1808
1809
  		break;
  
  	case 25:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1810
  		ret += tcrypt_test("ecb(tnepres)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1811
1812
1813
  		break;
  
  	case 26:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1814
1815
  		ret += tcrypt_test("ecb(anubis)");
  		ret += tcrypt_test("cbc(anubis)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1816
1817
1818
  		break;
  
  	case 27:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1819
  		ret += tcrypt_test("tgr192");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1820
1821
1822
  		break;
  
  	case 28:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1823
  		ret += tcrypt_test("tgr160");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1824
1825
1826
  		break;
  
  	case 29:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1827
  		ret += tcrypt_test("tgr128");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1828
  		break;
2998db37b   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
1829

fb4f10ed5   Aaron Grothe   [CRYPTO]: Fix XTE...
1830
  	case 30:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1831
  		ret += tcrypt_test("ecb(xeta)");
fb4f10ed5   Aaron Grothe   [CRYPTO]: Fix XTE...
1832
  		break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1833

90831639a   David Howells   [CRYPTO] fcrypt: ...
1834
  	case 31:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1835
  		ret += tcrypt_test("pcbc(fcrypt)");
90831639a   David Howells   [CRYPTO] fcrypt: ...
1836
  		break;
02ab5a705   Noriaki TAKAMIYA   [CRYPTO] camellia...
1837
  	case 32:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1838
1839
  		ret += tcrypt_test("ecb(camellia)");
  		ret += tcrypt_test("cbc(camellia)");
54216bbd7   Jussi Kivilinna   crypto: tcrypt - ...
1840
1841
1842
  		ret += tcrypt_test("ctr(camellia)");
  		ret += tcrypt_test("lrw(camellia)");
  		ret += tcrypt_test("xts(camellia)");
02ab5a705   Noriaki TAKAMIYA   [CRYPTO] camellia...
1843
  		break;
93b5e86a6   Jussi Kivilinna   crypto: add CMAC ...
1844

cd12fb906   Jonathan Lynch   [CRYPTO] sha256-g...
1845
  	case 33:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1846
  		ret += tcrypt_test("sha224");
cd12fb906   Jonathan Lynch   [CRYPTO] sha256-g...
1847
  		break;
02ab5a705   Noriaki TAKAMIYA   [CRYPTO] camellia...
1848

2407d6087   Tan Swee Heng   [CRYPTO] salsa20:...
1849
  	case 34:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1850
  		ret += tcrypt_test("salsa20");
2407d6087   Tan Swee Heng   [CRYPTO] salsa20:...
1851
  		break;
8df213d9b   Herbert Xu   [CRYPTO] tcrypt: ...
1852
  	case 35:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1853
  		ret += tcrypt_test("gcm(aes)");
8df213d9b   Herbert Xu   [CRYPTO] tcrypt: ...
1854
  		break;
0b77abb3b   Zoltan Sogor   [CRYPTO] lzo: Add...
1855
  	case 36:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1856
  		ret += tcrypt_test("lzo");
0b77abb3b   Zoltan Sogor   [CRYPTO] lzo: Add...
1857
  		break;
93cc74e07   Joy Latten   [CRYPTO] tcrypt: ...
1858
  	case 37:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1859
  		ret += tcrypt_test("ccm(aes)");
93cc74e07   Joy Latten   [CRYPTO] tcrypt: ...
1860
  		break;
76cb95217   Kevin Coffman   [CRYPTO] cts: Add...
1861
  	case 38:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1862
  		ret += tcrypt_test("cts(cbc(aes))");
76cb95217   Kevin Coffman   [CRYPTO] cts: Add...
1863
  		break;
fd4adf1a0   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
1864
          case 39:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1865
  		ret += tcrypt_test("rmd128");
fd4adf1a0   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
1866
1867
1868
  		break;
  
          case 40:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1869
  		ret += tcrypt_test("rmd160");
fd4adf1a0   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
1870
  		break;
2998db37b   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
1871
  	case 41:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1872
  		ret += tcrypt_test("rmd256");
2998db37b   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
1873
1874
1875
  		break;
  
  	case 42:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1876
  		ret += tcrypt_test("rmd320");
01b323245   Herbert Xu   crypto: tcrypt - ...
1877
1878
1879
  		break;
  
  	case 43:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1880
  		ret += tcrypt_test("ecb(seed)");
2998db37b   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
1881
  		break;
5d667322a   Jarod Wilson   crypto: testmgr -...
1882
  	case 45:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1883
  		ret += tcrypt_test("rfc4309(ccm(aes))");
5d667322a   Jarod Wilson   crypto: testmgr -...
1884
  		break;
54216bbd7   Jussi Kivilinna   crypto: tcrypt - ...
1885
1886
1887
  	case 46:
  		ret += tcrypt_test("ghash");
  		break;
68411521c   Herbert Xu   Reinstate "crypto...
1888
1889
1890
  	case 47:
  		ret += tcrypt_test("crct10dif");
  		break;
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
  	case 48:
  		ret += tcrypt_test("sha3-224");
  		break;
  
  	case 49:
  		ret += tcrypt_test("sha3-256");
  		break;
  
  	case 50:
  		ret += tcrypt_test("sha3-384");
  		break;
  
  	case 51:
  		ret += tcrypt_test("sha3-512");
  		break;
b7e275304   Gilad Ben-Yossef   crypto: sm3 - add...
1906
1907
1908
  	case 52:
  		ret += tcrypt_test("sm3");
  		break;
25a0b9d4e   Vitaly Chikunov   crypto: streebog ...
1909
1910
1911
1912
1913
1914
1915
  	case 53:
  		ret += tcrypt_test("streebog256");
  		break;
  
  	case 54:
  		ret += tcrypt_test("streebog512");
  		break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1916
  	case 100:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1917
  		ret += tcrypt_test("hmac(md5)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1918
  		break;
ef2736fc7   Herbert Xu   [CRYPTO]: White s...
1919

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1920
  	case 101:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1921
  		ret += tcrypt_test("hmac(sha1)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1922
  		break;
ef2736fc7   Herbert Xu   [CRYPTO]: White s...
1923

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1924
  	case 102:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1925
  		ret += tcrypt_test("hmac(sha256)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1926
  		break;
a28091ae1   Andrew Donofrio   [CRYPTO] tcrypt: ...
1927
  	case 103:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1928
  		ret += tcrypt_test("hmac(sha384)");
a28091ae1   Andrew Donofrio   [CRYPTO] tcrypt: ...
1929
1930
1931
  		break;
  
  	case 104:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1932
  		ret += tcrypt_test("hmac(sha512)");
a28091ae1   Andrew Donofrio   [CRYPTO] tcrypt: ...
1933
  		break;
38ed9ab23   Herbert Xu   [CRYPTO] tcrypt: ...
1934

cd12fb906   Jonathan Lynch   [CRYPTO] sha256-g...
1935
  	case 105:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1936
  		ret += tcrypt_test("hmac(sha224)");
cd12fb906   Jonathan Lynch   [CRYPTO] sha256-g...
1937
  		break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1938

38ed9ab23   Herbert Xu   [CRYPTO] tcrypt: ...
1939
  	case 106:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1940
  		ret += tcrypt_test("xcbc(aes)");
38ed9ab23   Herbert Xu   [CRYPTO] tcrypt: ...
1941
  		break;
fd4adf1a0   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
1942
  	case 107:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1943
  		ret += tcrypt_test("hmac(rmd128)");
fd4adf1a0   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
1944
1945
1946
  		break;
  
  	case 108:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1947
  		ret += tcrypt_test("hmac(rmd160)");
fd4adf1a0   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
1948
  		break;
f1939f7c5   Shane Wang   crypto: vmac - Ne...
1949
  	case 109:
0917b8731   Eric Biggers   crypto: vmac - re...
1950
  		ret += tcrypt_test("vmac64(aes)");
f1939f7c5   Shane Wang   crypto: vmac - Ne...
1951
  		break;
93b5e86a6   Jussi Kivilinna   crypto: add CMAC ...
1952

98eca72fa   raveendra padasalagi   crypto: sha3 - Ad...
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
  	case 111:
  		ret += tcrypt_test("hmac(sha3-224)");
  		break;
  
  	case 112:
  		ret += tcrypt_test("hmac(sha3-256)");
  		break;
  
  	case 113:
  		ret += tcrypt_test("hmac(sha3-384)");
  		break;
  
  	case 114:
  		ret += tcrypt_test("hmac(sha3-512)");
  		break;
25a0b9d4e   Vitaly Chikunov   crypto: streebog ...
1968
1969
1970
1971
1972
1973
1974
  	case 115:
  		ret += tcrypt_test("hmac(streebog256)");
  		break;
  
  	case 116:
  		ret += tcrypt_test("hmac(streebog512)");
  		break;
e1228ca2e   Radu Alexe   crypto: tcrypt - ...
1975
1976
1977
  	case 117:
  		ret += tcrypt_test("rsa");
  		break;
e08ca2da3   Jarod Wilson   crypto: testmgr -...
1978
  	case 150:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1979
  		ret += tcrypt_test("ansi_cprng");
e08ca2da3   Jarod Wilson   crypto: testmgr -...
1980
  		break;
69435b94d   Adrian Hoban   crypto: rfc4106 -...
1981
1982
1983
  	case 151:
  		ret += tcrypt_test("rfc4106(gcm(aes))");
  		break;
e9b7441a9   Jussi Kivilinna   crypto: testmgr -...
1984
1985
1986
  	case 152:
  		ret += tcrypt_test("rfc4543(gcm(aes))");
  		break;
93b5e86a6   Jussi Kivilinna   crypto: add CMAC ...
1987
1988
1989
1990
1991
1992
1993
  	case 153:
  		ret += tcrypt_test("cmac(aes)");
  		break;
  
  	case 154:
  		ret += tcrypt_test("cmac(des3_ede)");
  		break;
bbf9c8934   Horia Geanta   crypto: caam - fi...
1994
1995
1996
  	case 155:
  		ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))");
  		break;
bca4feb0d   Horia Geanta   crypto: testmgr -...
1997
1998
1999
2000
2001
2002
2003
  	case 156:
  		ret += tcrypt_test("authenc(hmac(md5),ecb(cipher_null))");
  		break;
  
  	case 157:
  		ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))");
  		break;
5208ed2ca   Nitesh Lal   crypto: testmgr -...
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
  	case 181:
  		ret += tcrypt_test("authenc(hmac(sha1),cbc(des))");
  		break;
  	case 182:
  		ret += tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))");
  		break;
  	case 183:
  		ret += tcrypt_test("authenc(hmac(sha224),cbc(des))");
  		break;
  	case 184:
  		ret += tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))");
  		break;
  	case 185:
  		ret += tcrypt_test("authenc(hmac(sha256),cbc(des))");
  		break;
  	case 186:
  		ret += tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))");
  		break;
  	case 187:
  		ret += tcrypt_test("authenc(hmac(sha384),cbc(des))");
  		break;
  	case 188:
  		ret += tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))");
  		break;
  	case 189:
  		ret += tcrypt_test("authenc(hmac(sha512),cbc(des))");
  		break;
  	case 190:
  		ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))");
  		break;
cd83a8a7c   Gilad Ben-Yossef   crypto: testmgr -...
2034
2035
  	case 191:
  		ret += tcrypt_test("ecb(sm4)");
95ba59736   Gilad Ben-Yossef   crypto: testmgr -...
2036
2037
  		ret += tcrypt_test("cbc(sm4)");
  		ret += tcrypt_test("ctr(sm4)");
cd83a8a7c   Gilad Ben-Yossef   crypto: testmgr -...
2038
  		break;
da9975f0d   Radu Alexe   crypto: add suppo...
2039
2040
2041
  	case 192:
  		ret += tcrypt_test("tls10(hmac(sha1),cbc(aes))");
  		break;
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
2042
  	case 200:
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2043
  		test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2044
  				speed_template_16_24_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2045
  		test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2046
  				speed_template_16_24_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2047
  		test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2048
  				speed_template_16_24_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2049
  		test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2050
  				speed_template_16_24_32);
f3d1044cd   Rik Snel   [CRYPTO] tcrypt: ...
2051
  		test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2052
  				speed_template_32_40_48);
f3d1044cd   Rik Snel   [CRYPTO] tcrypt: ...
2053
  		test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2054
  				speed_template_32_40_48);
f19f5111c   Rik Snel   [CRYPTO] xts: XTS...
2055
  		test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
b66ad0b7a   Horia Geantă   crypto: tcrypt - ...
2056
  				speed_template_32_64);
f19f5111c   Rik Snel   [CRYPTO] xts: XTS...
2057
  		test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
b66ad0b7a   Horia Geantă   crypto: tcrypt - ...
2058
  				speed_template_32_64);
1503a24f5   Herbert Xu   crypto: tcrypt - ...
2059
2060
2061
2062
  		test_cipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
  				speed_template_16_24_32);
  		test_cipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
  				speed_template_16_24_32);
9996e3421   Jan Glauber   crypto: tcrypt - ...
2063
2064
2065
2066
  		test_cipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
  				speed_template_16_24_32);
  		test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
  				speed_template_16_24_32);
7da666707   Dmitry Eremin-Solenikov   crypto: testmgr -...
2067
2068
2069
2070
  		test_cipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
  				speed_template_16_24_32);
  		test_cipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
  				speed_template_16_24_32);
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
2071
2072
2073
  		break;
  
  	case 201:
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2074
  		test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec,
da7f033dd   Herbert Xu   crypto: cryptomgr...
2075
  				des3_speed_template, DES3_SPEED_VECTORS,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2076
  				speed_template_24);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2077
  		test_cipher_speed("ecb(des3_ede)", DECRYPT, sec,
da7f033dd   Herbert Xu   crypto: cryptomgr...
2078
  				des3_speed_template, DES3_SPEED_VECTORS,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2079
  				speed_template_24);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2080
  		test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec,
da7f033dd   Herbert Xu   crypto: cryptomgr...
2081
  				des3_speed_template, DES3_SPEED_VECTORS,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2082
  				speed_template_24);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2083
  		test_cipher_speed("cbc(des3_ede)", DECRYPT, sec,
da7f033dd   Herbert Xu   crypto: cryptomgr...
2084
  				des3_speed_template, DES3_SPEED_VECTORS,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2085
  				speed_template_24);
87131507e   Jussi Kivilinna   crypto: tcrypt - ...
2086
2087
2088
2089
2090
2091
  		test_cipher_speed("ctr(des3_ede)", ENCRYPT, sec,
  				des3_speed_template, DES3_SPEED_VECTORS,
  				speed_template_24);
  		test_cipher_speed("ctr(des3_ede)", DECRYPT, sec,
  				des3_speed_template, DES3_SPEED_VECTORS,
  				speed_template_24);
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
2092
2093
2094
  		break;
  
  	case 202:
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2095
  		test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2096
  				speed_template_16_24_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2097
  		test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2098
  				speed_template_16_24_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2099
  		test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2100
  				speed_template_16_24_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2101
  		test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2102
  				speed_template_16_24_32);
ee5002a54   Jussi Kivilinna   crypto: tcrypt - ...
2103
2104
2105
2106
  		test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
  				speed_template_16_24_32);
  		test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
  				speed_template_16_24_32);
bee3a90ef   Jussi Kivilinna   crypto: tcrypt - ...
2107
2108
2109
2110
  		test_cipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
  				speed_template_32_40_48);
  		test_cipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
  				speed_template_32_40_48);
131f75416   Jussi Kivilinna   crypto: tcrypt - ...
2111
2112
2113
2114
  		test_cipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
  				speed_template_32_48_64);
  		test_cipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
  				speed_template_32_48_64);
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
2115
2116
2117
  		break;
  
  	case 203:
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2118
  		test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2119
  				  speed_template_8_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2120
  		test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2121
  				  speed_template_8_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2122
  		test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2123
  				  speed_template_8_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2124
  		test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2125
  				  speed_template_8_32);
7d47b86cf   Jussi Kivilinna   crypto: tcrypt - ...
2126
2127
2128
2129
  		test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
  				  speed_template_8_32);
  		test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
  				  speed_template_8_32);
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
2130
2131
2132
  		break;
  
  	case 204:
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2133
  		test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2134
  				  speed_template_8);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2135
  		test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2136
  				  speed_template_8);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2137
  		test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2138
  				  speed_template_8);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2139
  		test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2140
  				  speed_template_8);
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
2141
  		break;
02ab5a705   Noriaki TAKAMIYA   [CRYPTO] camellia...
2142
2143
  	case 205:
  		test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2144
  				speed_template_16_24_32);
02ab5a705   Noriaki TAKAMIYA   [CRYPTO] camellia...
2145
  		test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2146
  				speed_template_16_24_32);
02ab5a705   Noriaki TAKAMIYA   [CRYPTO] camellia...
2147
  		test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2148
  				speed_template_16_24_32);
02ab5a705   Noriaki TAKAMIYA   [CRYPTO] camellia...
2149
  		test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2150
  				speed_template_16_24_32);
4de593378   Jussi Kivilinna   crypto: tcrypt - ...
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
  		test_cipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
  				speed_template_16_24_32);
  		test_cipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
  				speed_template_16_24_32);
  		test_cipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
  				speed_template_32_40_48);
  		test_cipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
  				speed_template_32_40_48);
  		test_cipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
  				speed_template_32_48_64);
  		test_cipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
  				speed_template_32_48_64);
02ab5a705   Noriaki TAKAMIYA   [CRYPTO] camellia...
2163
  		break;
5de8f1b56   Tan Swee Heng   [CRYPTO] tcrypt: ...
2164
2165
  	case 206:
  		test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2166
  				  speed_template_16_32);
5de8f1b56   Tan Swee Heng   [CRYPTO] tcrypt: ...
2167
  		break;
7fb7fe446   Jussi Kivilinna   crypto: tcrypt - ...
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
  	case 207:
  		test_cipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
  				  speed_template_16_32);
  		test_cipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
  				  speed_template_16_32);
  		test_cipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
  				  speed_template_16_32);
  		test_cipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
  				  speed_template_16_32);
  		test_cipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
  				  speed_template_16_32);
  		test_cipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
  				  speed_template_16_32);
87aae4bfb   Jussi Kivilinna   crypto: tcrypt - ...
2181
2182
2183
2184
  		test_cipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
  				  speed_template_32_48);
  		test_cipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
  				  speed_template_32_48);
5209c07ac   Jussi Kivilinna   crypto: tcrypt - ...
2185
2186
2187
2188
  		test_cipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
  				  speed_template_32_64);
  		test_cipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
  				  speed_template_32_64);
7fb7fe446   Jussi Kivilinna   crypto: tcrypt - ...
2189
  		break;
31b4cd290   Jussi Kivilinna   crypto: testmgr -...
2190
2191
2192
2193
  	case 208:
  		test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
  				  speed_template_8);
  		break;
a2c582609   Johannes Goetzfried   crypto: testmgr -...
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
  	case 209:
  		test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
  				  speed_template_8_16);
  		test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
  				  speed_template_8_16);
  		test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
  				  speed_template_8_16);
  		test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
  				  speed_template_8_16);
  		test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
  				  speed_template_8_16);
  		test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
  				  speed_template_8_16);
  		break;
9b8b04051   Johannes Goetzfried   crypto: testmgr -...
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
  	case 210:
  		test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
  				  speed_template_16_32);
  		test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
  				  speed_template_16_32);
  		test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
  				  speed_template_16_32);
  		test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
  				  speed_template_16_32);
  		test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
  				  speed_template_16_32);
  		test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
  				  speed_template_16_32);
  		test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
  				  speed_template_32_48);
  		test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
  				  speed_template_32_48);
  		test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
  				  speed_template_32_64);
  		test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
  				  speed_template_32_64);
  		break;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
2230
2231
  	case 211:
  		test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec,
34a1c740e   Herbert Xu   crypto: tcrypt - ...
2232
  				NULL, 0, 16, 16, aead_speed_template_20);
1425d2d17   Vutla, Lokesh   crypto: tcrypt - ...
2233
  		test_aead_speed("gcm(aes)", ENCRYPT, sec,
f18611da8   Cyrille Pitchen   crypto: tcrypt - ...
2234
  				NULL, 0, 16, 8, speed_template_16_24_32);
4431bd495   Gilad Ben-Yossef   crypto: tcrypt - ...
2235
2236
2237
2238
  		test_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec,
  				NULL, 0, 16, 16, aead_speed_template_20);
  		test_aead_speed("gcm(aes)", DECRYPT, sec,
  				NULL, 0, 16, 8, speed_template_16_24_32);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
2239
  		break;
4e4aab63d   Herbert Xu   crypto: tcrypt - ...
2240
2241
  	case 212:
  		test_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec,
34a1c740e   Herbert Xu   crypto: tcrypt - ...
2242
  				NULL, 0, 16, 16, aead_speed_template_19);
4431bd495   Gilad Ben-Yossef   crypto: tcrypt - ...
2243
2244
  		test_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec,
  				NULL, 0, 16, 16, aead_speed_template_19);
4e4aab63d   Herbert Xu   crypto: tcrypt - ...
2245
  		break;
2dce063a3   Martin Willi   crypto: tcrypt - ...
2246
2247
2248
  	case 213:
  		test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, sec,
  				NULL, 0, 16, 8, aead_speed_template_36);
4431bd495   Gilad Ben-Yossef   crypto: tcrypt - ...
2249
2250
  		test_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT, sec,
  				NULL, 0, 16, 8, aead_speed_template_36);
2dce063a3   Martin Willi   crypto: tcrypt - ...
2251
2252
2253
2254
2255
2256
  		break;
  
  	case 214:
  		test_cipher_speed("chacha20", ENCRYPT, sec, NULL, 0,
  				  speed_template_32);
  		break;
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
  	case 215:
  		test_mb_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec, NULL,
  				   0, 16, 16, aead_speed_template_20, num_mb);
  		test_mb_aead_speed("gcm(aes)", ENCRYPT, sec, NULL, 0, 16, 8,
  				   speed_template_16_24_32, num_mb);
  		test_mb_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec, NULL,
  				   0, 16, 16, aead_speed_template_20, num_mb);
  		test_mb_aead_speed("gcm(aes)", DECRYPT, sec, NULL, 0, 16, 8,
  				   speed_template_16_24_32, num_mb);
  		break;
  
  	case 216:
  		test_mb_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec, NULL, 0,
  				   16, 16, aead_speed_template_19, num_mb);
  		test_mb_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec, NULL, 0,
  				   16, 16, aead_speed_template_19, num_mb);
  		break;
  
  	case 217:
  		test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT,
  				   sec, NULL, 0, 16, 8, aead_speed_template_36,
  				   num_mb);
  		test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT,
  				   sec, NULL, 0, 16, 8, aead_speed_template_36,
  				   num_mb);
  		break;
95ba59736   Gilad Ben-Yossef   crypto: testmgr -...
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
  	case 218:
  		test_cipher_speed("ecb(sm4)", ENCRYPT, sec, NULL, 0,
  				speed_template_16);
  		test_cipher_speed("ecb(sm4)", DECRYPT, sec, NULL, 0,
  				speed_template_16);
  		test_cipher_speed("cbc(sm4)", ENCRYPT, sec, NULL, 0,
  				speed_template_16);
  		test_cipher_speed("cbc(sm4)", DECRYPT, sec, NULL, 0,
  				speed_template_16);
  		test_cipher_speed("ctr(sm4)", ENCRYPT, sec, NULL, 0,
  				speed_template_16);
  		test_cipher_speed("ctr(sm4)", DECRYPT, sec, NULL, 0,
  				speed_template_16);
  		break;
059c2a4d8   Eric Biggers   crypto: adiantum ...
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
  
  	case 219:
  		test_cipher_speed("adiantum(xchacha12,aes)", ENCRYPT, sec, NULL,
  				  0, speed_template_32);
  		test_cipher_speed("adiantum(xchacha12,aes)", DECRYPT, sec, NULL,
  				  0, speed_template_32);
  		test_cipher_speed("adiantum(xchacha20,aes)", ENCRYPT, sec, NULL,
  				  0, speed_template_32);
  		test_cipher_speed("adiantum(xchacha20,aes)", DECRYPT, sec, NULL,
  				  0, speed_template_32);
  		break;
f975abb23   Ard Biesheuvel   crypto: essiv - a...
2308
2309
2310
2311
2312
2313
2314
2315
  	case 220:
  		test_acipher_speed("essiv(cbc(aes),sha256)",
  				  ENCRYPT, sec, NULL, 0,
  				  speed_template_16_24_32);
  		test_acipher_speed("essiv(cbc(aes),sha256)",
  				  DECRYPT, sec, NULL, 0,
  				  speed_template_16_24_32);
  		break;
97bcb1619   Ard Biesheuvel   crypto: tcrypt - ...
2316
2317
2318
2319
2320
2321
  	case 221:
  		test_aead_speed("aegis128", ENCRYPT, sec,
  				NULL, 0, 16, 8, speed_template_16);
  		test_aead_speed("aegis128", DECRYPT, sec,
  				NULL, 0, 16, 8, speed_template_16);
  		break;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2322
  	case 300:
8606813a6   Herbert Xu   crypto: tcrypt - ...
2323
2324
2325
2326
  		if (alg) {
  			test_hash_speed(alg, sec, generic_hash_speed_template);
  			break;
  		}
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2327
  		fallthrough;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2328
  	case 301:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2329
  		test_hash_speed("md4", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2330
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2331
  		fallthrough;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2332
  	case 302:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2333
  		test_hash_speed("md5", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2334
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2335
  		fallthrough;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2336
  	case 303:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2337
  		test_hash_speed("sha1", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2338
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2339
  		fallthrough;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2340
  	case 304:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2341
  		test_hash_speed("sha256", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2342
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2343
  		fallthrough;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2344
  	case 305:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2345
  		test_hash_speed("sha384", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2346
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2347
  		fallthrough;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2348
  	case 306:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2349
  		test_hash_speed("sha512", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2350
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2351
  		fallthrough;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2352
  	case 307:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2353
  		test_hash_speed("wp256", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2354
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2355
  		fallthrough;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2356
  	case 308:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2357
  		test_hash_speed("wp384", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2358
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2359
  		fallthrough;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2360
  	case 309:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2361
  		test_hash_speed("wp512", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2362
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2363
  		fallthrough;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2364
  	case 310:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2365
  		test_hash_speed("tgr128", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2366
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2367
  		fallthrough;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2368
  	case 311:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2369
  		test_hash_speed("tgr160", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2370
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2371
  		fallthrough;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2372
  	case 312:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2373
  		test_hash_speed("tgr192", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2374
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2375
  		fallthrough;
cd12fb906   Jonathan Lynch   [CRYPTO] sha256-g...
2376
2377
2378
  	case 313:
  		test_hash_speed("sha224", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2379
  		fallthrough;
fd4adf1a0   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
2380
2381
2382
  	case 314:
  		test_hash_speed("rmd128", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2383
  		fallthrough;
fd4adf1a0   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
2384
2385
2386
  	case 315:
  		test_hash_speed("rmd160", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2387
  		fallthrough;
2998db37b   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
2388
2389
2390
  	case 316:
  		test_hash_speed("rmd256", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2391
  		fallthrough;
2998db37b   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
2392
2393
2394
  	case 317:
  		test_hash_speed("rmd320", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2395
  		fallthrough;
18bcc9194   Huang Ying   crypto: tcrypt - ...
2396
  	case 318:
ba974adb4   Herbert Xu   crypto: tcrypt - ...
2397
2398
  		klen = 16;
  		test_hash_speed("ghash", sec, generic_hash_speed_template);
18bcc9194   Huang Ying   crypto: tcrypt - ...
2399
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2400
  		fallthrough;
e3899e4df   Tim Chen   crypto: tcrypt - ...
2401
2402
2403
  	case 319:
  		test_hash_speed("crc32c", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2404
  		fallthrough;
68411521c   Herbert Xu   Reinstate "crypto...
2405
2406
2407
  	case 320:
  		test_hash_speed("crct10dif", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2408
  		fallthrough;
2dce063a3   Martin Willi   crypto: tcrypt - ...
2409
2410
2411
  	case 321:
  		test_hash_speed("poly1305", sec, poly1305_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2412
  		fallthrough;
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2413
2414
2415
  	case 322:
  		test_hash_speed("sha3-224", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2416
  		fallthrough;
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2417
2418
2419
  	case 323:
  		test_hash_speed("sha3-256", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2420
  		fallthrough;
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2421
2422
2423
  	case 324:
  		test_hash_speed("sha3-384", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2424
  		fallthrough;
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2425
2426
2427
  	case 325:
  		test_hash_speed("sha3-512", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2428
  		fallthrough;
b7e275304   Gilad Ben-Yossef   crypto: sm3 - add...
2429
2430
2431
  	case 326:
  		test_hash_speed("sm3", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2432
  		fallthrough;
25a0b9d4e   Vitaly Chikunov   crypto: streebog ...
2433
2434
2435
2436
  	case 327:
  		test_hash_speed("streebog256", sec,
  				generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2437
  		fallthrough;
25a0b9d4e   Vitaly Chikunov   crypto: streebog ...
2438
2439
2440
2441
  	case 328:
  		test_hash_speed("streebog512", sec,
  				generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2442
  		fallthrough;
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2443
2444
  	case 399:
  		break;
beb63da73   David S. Miller   crypto: tcrypt - ...
2445
  	case 400:
8606813a6   Herbert Xu   crypto: tcrypt - ...
2446
2447
2448
2449
  		if (alg) {
  			test_ahash_speed(alg, sec, generic_hash_speed_template);
  			break;
  		}
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2450
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2451
2452
2453
  	case 401:
  		test_ahash_speed("md4", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2454
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2455
2456
2457
  	case 402:
  		test_ahash_speed("md5", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2458
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2459
2460
2461
  	case 403:
  		test_ahash_speed("sha1", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2462
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2463
2464
2465
  	case 404:
  		test_ahash_speed("sha256", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2466
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2467
2468
2469
  	case 405:
  		test_ahash_speed("sha384", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2470
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2471
2472
2473
  	case 406:
  		test_ahash_speed("sha512", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2474
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2475
2476
2477
  	case 407:
  		test_ahash_speed("wp256", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2478
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2479
2480
2481
  	case 408:
  		test_ahash_speed("wp384", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2482
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2483
2484
2485
  	case 409:
  		test_ahash_speed("wp512", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2486
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2487
2488
2489
  	case 410:
  		test_ahash_speed("tgr128", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2490
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2491
2492
2493
  	case 411:
  		test_ahash_speed("tgr160", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2494
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2495
2496
2497
  	case 412:
  		test_ahash_speed("tgr192", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2498
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2499
2500
2501
  	case 413:
  		test_ahash_speed("sha224", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2502
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2503
2504
2505
  	case 414:
  		test_ahash_speed("rmd128", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2506
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2507
2508
2509
  	case 415:
  		test_ahash_speed("rmd160", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2510
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2511
2512
2513
  	case 416:
  		test_ahash_speed("rmd256", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2514
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2515
2516
2517
  	case 417:
  		test_ahash_speed("rmd320", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2518
  		fallthrough;
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2519
2520
2521
  	case 418:
  		test_ahash_speed("sha3-224", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2522
  		fallthrough;
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2523
2524
2525
  	case 419:
  		test_ahash_speed("sha3-256", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2526
  		fallthrough;
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2527
2528
2529
  	case 420:
  		test_ahash_speed("sha3-384", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2530
  		fallthrough;
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2531
2532
2533
  	case 421:
  		test_ahash_speed("sha3-512", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2534
  		fallthrough;
087bcd225   Megha Dey   crypto: tcrypt - ...
2535
  	case 422:
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
2536
2537
  		test_mb_ahash_speed("sha1", sec, generic_hash_speed_template,
  				    num_mb);
087bcd225   Megha Dey   crypto: tcrypt - ...
2538
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2539
  		fallthrough;
087bcd225   Megha Dey   crypto: tcrypt - ...
2540
  	case 423:
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
2541
2542
  		test_mb_ahash_speed("sha256", sec, generic_hash_speed_template,
  				    num_mb);
087bcd225   Megha Dey   crypto: tcrypt - ...
2543
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2544
  		fallthrough;
14009c4bd   Megha Dey   crypto: tcrypt - ...
2545
  	case 424:
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
2546
2547
  		test_mb_ahash_speed("sha512", sec, generic_hash_speed_template,
  				    num_mb);
14009c4bd   Megha Dey   crypto: tcrypt - ...
2548
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2549
  		fallthrough;
b7e275304   Gilad Ben-Yossef   crypto: sm3 - add...
2550
  	case 425:
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
2551
2552
  		test_mb_ahash_speed("sm3", sec, generic_hash_speed_template,
  				    num_mb);
b7e275304   Gilad Ben-Yossef   crypto: sm3 - add...
2553
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2554
  		fallthrough;
25a0b9d4e   Vitaly Chikunov   crypto: streebog ...
2555
2556
2557
2558
  	case 426:
  		test_mb_ahash_speed("streebog256", sec,
  				    generic_hash_speed_template, num_mb);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2559
  		fallthrough;
25a0b9d4e   Vitaly Chikunov   crypto: streebog ...
2560
2561
2562
2563
  	case 427:
  		test_mb_ahash_speed("streebog512", sec,
  				    generic_hash_speed_template, num_mb);
  		if (mode > 400 && mode < 500) break;
df561f668   Gustavo A. R. Silva   treewide: Use fal...
2564
  		fallthrough;
beb63da73   David S. Miller   crypto: tcrypt - ...
2565
2566
  	case 499:
  		break;
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
  	case 500:
  		test_acipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
  				   speed_template_32_40_48);
  		test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
  				   speed_template_32_40_48);
  		test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
b66ad0b7a   Horia Geantă   crypto: tcrypt - ...
2581
  				   speed_template_32_64);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
2582
  		test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
b66ad0b7a   Horia Geantă   crypto: tcrypt - ...
2583
  				   speed_template_32_64);
1503a24f5   Herbert Xu   crypto: tcrypt - ...
2584
2585
2586
2587
  		test_acipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
2588
2589
2590
2591
  		test_acipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
de1975334   Nicolas Royer   crypto: atmel - a...
2592
2593
2594
2595
2596
2597
2598
2599
  		test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
69d3150cf   Jussi Kivilinna   crypto: ctr - mak...
2600
2601
2602
2603
  		test_acipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL, 0,
  				   speed_template_20_28_36);
  		test_acipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL, 0,
  				   speed_template_20_28_36);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
  		break;
  
  	case 501:
  		test_acipher_speed("ecb(des3_ede)", ENCRYPT, sec,
  				   des3_speed_template, DES3_SPEED_VECTORS,
  				   speed_template_24);
  		test_acipher_speed("ecb(des3_ede)", DECRYPT, sec,
  				   des3_speed_template, DES3_SPEED_VECTORS,
  				   speed_template_24);
  		test_acipher_speed("cbc(des3_ede)", ENCRYPT, sec,
  				   des3_speed_template, DES3_SPEED_VECTORS,
  				   speed_template_24);
  		test_acipher_speed("cbc(des3_ede)", DECRYPT, sec,
  				   des3_speed_template, DES3_SPEED_VECTORS,
  				   speed_template_24);
de1975334   Nicolas Royer   crypto: atmel - a...
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
  		test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec,
  				   des3_speed_template, DES3_SPEED_VECTORS,
  				   speed_template_24);
  		test_acipher_speed("cfb(des3_ede)", DECRYPT, sec,
  				   des3_speed_template, DES3_SPEED_VECTORS,
  				   speed_template_24);
  		test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec,
  				   des3_speed_template, DES3_SPEED_VECTORS,
  				   speed_template_24);
  		test_acipher_speed("ofb(des3_ede)", DECRYPT, sec,
  				   des3_speed_template, DES3_SPEED_VECTORS,
  				   speed_template_24);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
  		break;
  
  	case 502:
  		test_acipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
  				   speed_template_8);
  		test_acipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
  				   speed_template_8);
  		test_acipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
  				   speed_template_8);
  		test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
  				   speed_template_8);
de1975334   Nicolas Royer   crypto: atmel - a...
2642
2643
2644
2645
2646
2647
2648
2649
  		test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0,
  				   speed_template_8);
  		test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0,
  				   speed_template_8);
  		test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0,
  				   speed_template_8);
  		test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0,
  				   speed_template_8);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
2650
  		break;
7fb7fe446   Jussi Kivilinna   crypto: tcrypt - ...
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
  	case 503:
  		test_acipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_32);
87aae4bfb   Jussi Kivilinna   crypto: tcrypt - ...
2664
2665
2666
2667
  		test_acipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
  				   speed_template_32_48);
  		test_acipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
  				   speed_template_32_48);
5209c07ac   Jussi Kivilinna   crypto: tcrypt - ...
2668
2669
2670
2671
  		test_acipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
  				   speed_template_32_64);
  		test_acipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
  				   speed_template_32_64);
7fb7fe446   Jussi Kivilinna   crypto: tcrypt - ...
2672
  		break;
107778b59   Johannes Goetzfried   crypto: twofish -...
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
  	case 504:
  		test_acipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_24_32);
  		test_acipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
  				   speed_template_32_40_48);
  		test_acipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
  				   speed_template_32_40_48);
  		test_acipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
  				   speed_template_32_48_64);
  		test_acipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
  				   speed_template_32_48_64);
  		break;
31b4cd290   Jussi Kivilinna   crypto: testmgr -...
2695
2696
2697
2698
  	case 505:
  		test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
  				   speed_template_8);
  		break;
a2c582609   Johannes Goetzfried   crypto: testmgr -...
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
  	case 506:
  		test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
  				   speed_template_8_16);
  		test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
  				   speed_template_8_16);
  		test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
  				   speed_template_8_16);
  		test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
  				   speed_template_8_16);
  		test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
  				   speed_template_8_16);
  		test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
  				   speed_template_8_16);
  		break;
9b8b04051   Johannes Goetzfried   crypto: testmgr -...
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
  	case 507:
  		test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
  				   speed_template_32_48);
  		test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
  				   speed_template_32_48);
  		test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
  				   speed_template_32_64);
  		test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
  				   speed_template_32_64);
  		break;
bf9c51818   Jussi Kivilinna   crypto: tcrypt - ...
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
  	case 508:
  		test_acipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
  				   speed_template_16_32);
  		test_acipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
  				   speed_template_32_48);
  		test_acipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
  				   speed_template_32_48);
  		test_acipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
  				   speed_template_32_64);
  		test_acipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
  				   speed_template_32_64);
  		break;
ad8b7c3e9   Jussi Kivilinna   crypto: tcrypt - ...
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
  	case 509:
  		test_acipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
  				   speed_template_8_32);
  		test_acipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
  				   speed_template_8_32);
  		test_acipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
  				   speed_template_8_32);
  		test_acipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
  				   speed_template_8_32);
  		test_acipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
  				   speed_template_8_32);
  		test_acipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
  				   speed_template_8_32);
  		break;
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
  	case 600:
  		test_mb_skcipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
  				       speed_template_32_40_48, num_mb);
  		test_mb_skcipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
  				       speed_template_32_40_48, num_mb);
  		test_mb_skcipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
  				       speed_template_32_64, num_mb);
  		test_mb_skcipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
  				       speed_template_32_64, num_mb);
  		test_mb_skcipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL,
  				       0, speed_template_20_28_36, num_mb);
  		test_mb_skcipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL,
  				       0, speed_template_20_28_36, num_mb);
  		break;
  
  	case 601:
  		test_mb_skcipher_speed("ecb(des3_ede)", ENCRYPT, sec,
  				       des3_speed_template, DES3_SPEED_VECTORS,
  				       speed_template_24, num_mb);
  		test_mb_skcipher_speed("ecb(des3_ede)", DECRYPT, sec,
  				       des3_speed_template, DES3_SPEED_VECTORS,
  				       speed_template_24, num_mb);
  		test_mb_skcipher_speed("cbc(des3_ede)", ENCRYPT, sec,
  				       des3_speed_template, DES3_SPEED_VECTORS,
  				       speed_template_24, num_mb);
  		test_mb_skcipher_speed("cbc(des3_ede)", DECRYPT, sec,
  				       des3_speed_template, DES3_SPEED_VECTORS,
  				       speed_template_24, num_mb);
  		test_mb_skcipher_speed("cfb(des3_ede)", ENCRYPT, sec,
  				       des3_speed_template, DES3_SPEED_VECTORS,
  				       speed_template_24, num_mb);
  		test_mb_skcipher_speed("cfb(des3_ede)", DECRYPT, sec,
  				       des3_speed_template, DES3_SPEED_VECTORS,
  				       speed_template_24, num_mb);
  		test_mb_skcipher_speed("ofb(des3_ede)", ENCRYPT, sec,
  				       des3_speed_template, DES3_SPEED_VECTORS,
  				       speed_template_24, num_mb);
  		test_mb_skcipher_speed("ofb(des3_ede)", DECRYPT, sec,
  				       des3_speed_template, DES3_SPEED_VECTORS,
  				       speed_template_24, num_mb);
  		break;
  
  	case 602:
  		test_mb_skcipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
  				       speed_template_8, num_mb);
  		test_mb_skcipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
  				       speed_template_8, num_mb);
  		test_mb_skcipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
  				       speed_template_8, num_mb);
  		test_mb_skcipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
  				       speed_template_8, num_mb);
  		test_mb_skcipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0,
  				       speed_template_8, num_mb);
  		test_mb_skcipher_speed("cfb(des)", DECRYPT, sec, NULL, 0,
  				       speed_template_8, num_mb);
  		test_mb_skcipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0,
  				       speed_template_8, num_mb);
  		test_mb_skcipher_speed("ofb(des)", DECRYPT, sec, NULL, 0,
  				       speed_template_8, num_mb);
  		break;
  
  	case 603:
  		test_mb_skcipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
  				       speed_template_32_48, num_mb);
  		test_mb_skcipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
  				       speed_template_32_48, num_mb);
  		test_mb_skcipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
  				       speed_template_32_64, num_mb);
  		test_mb_skcipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
  				       speed_template_32_64, num_mb);
  		break;
  
  	case 604:
  		test_mb_skcipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_24_32, num_mb);
  		test_mb_skcipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
  				       speed_template_32_40_48, num_mb);
  		test_mb_skcipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
  				       speed_template_32_40_48, num_mb);
  		test_mb_skcipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
  				       speed_template_32_48_64, num_mb);
  		test_mb_skcipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
  				       speed_template_32_48_64, num_mb);
  		break;
  
  	case 605:
  		test_mb_skcipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
  				       speed_template_8, num_mb);
  		break;
  
  	case 606:
  		test_mb_skcipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
  				       speed_template_8_16, num_mb);
  		test_mb_skcipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
  				       speed_template_8_16, num_mb);
  		test_mb_skcipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
  				       speed_template_8_16, num_mb);
  		test_mb_skcipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
  				       speed_template_8_16, num_mb);
  		test_mb_skcipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
  				       speed_template_8_16, num_mb);
  		test_mb_skcipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
  				       speed_template_8_16, num_mb);
  		break;
  
  	case 607:
  		test_mb_skcipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
  				       speed_template_32_48, num_mb);
  		test_mb_skcipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
  				       speed_template_32_48, num_mb);
  		test_mb_skcipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
  				       speed_template_32_64, num_mb);
  		test_mb_skcipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
  				       speed_template_32_64, num_mb);
  		break;
  
  	case 608:
  		test_mb_skcipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
  				       speed_template_16_32, num_mb);
  		test_mb_skcipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
  				       speed_template_32_48, num_mb);
  		test_mb_skcipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
  				       speed_template_32_48, num_mb);
  		test_mb_skcipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
  				       speed_template_32_64, num_mb);
  		test_mb_skcipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
  				       speed_template_32_64, num_mb);
  		break;
  
  	case 609:
  		test_mb_skcipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
  				       speed_template_8_32, num_mb);
  		test_mb_skcipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
  				       speed_template_8_32, num_mb);
  		test_mb_skcipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
  				       speed_template_8_32, num_mb);
  		test_mb_skcipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
  				       speed_template_8_32, num_mb);
  		test_mb_skcipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
  				       speed_template_8_32, num_mb);
  		test_mb_skcipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
  				       speed_template_8_32, num_mb);
  		break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2982
2983
2984
  	case 1000:
  		test_available();
  		break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2985
  	}
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
2986
2987
  
  	return ret;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2988
  }
3af5b90bd   Kamalesh Babulal   [CRYPTO] all: Cle...
2989
  static int __init tcrypt_mod_init(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2990
  {
e3a4ea4fd   Mikko Herranen   [CRYPTO] tcrypt: ...
2991
  	int err = -ENOMEM;
f139cfa7c   Herbert Xu   crypto: tcrypt - ...
2992
  	int i;
e3a4ea4fd   Mikko Herranen   [CRYPTO] tcrypt: ...
2993

f139cfa7c   Herbert Xu   crypto: tcrypt - ...
2994
2995
2996
2997
2998
  	for (i = 0; i < TVMEMSIZE; i++) {
  		tvmem[i] = (void *)__get_free_page(GFP_KERNEL);
  		if (!tvmem[i])
  			goto err_free_tv;
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2999

4e234eed5   Kees Cook   crypto: tcrypt - ...
3000
  	err = do_test(alg, type, mask, mode, num_mb);
a873a5f1c   Steffen Klassert   crypto: tcrypt - ...
3001

4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
3002
3003
3004
3005
  	if (err) {
  		printk(KERN_ERR "tcrypt: one or more tests failed!
  ");
  		goto err_free_tv;
76512f2d8   Rabin Vincent   crypto: tcrypt - ...
3006
3007
3008
  	} else {
  		pr_debug("all tests passed
  ");
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
3009
  	}
14fdf477a   Michal Ludvig   [CRYPTO] tcrypt: ...
3010

4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
3011
3012
3013
3014
  	/* We intentionaly return -EAGAIN to prevent keeping the module,
  	 * unless we're running in fips mode. It does all its work from
  	 * init() and doesn't offer any runtime functionality, but in
  	 * the fips case, checking for a successful load is helpful.
14fdf477a   Michal Ludvig   [CRYPTO] tcrypt: ...
3015
3016
3017
  	 * => we don't need it in the memory, do we?
  	 *                                        -- mludvig
  	 */
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
3018
3019
  	if (!fips_enabled)
  		err = -EAGAIN;
e3a4ea4fd   Mikko Herranen   [CRYPTO] tcrypt: ...
3020

f139cfa7c   Herbert Xu   crypto: tcrypt - ...
3021
3022
3023
  err_free_tv:
  	for (i = 0; i < TVMEMSIZE && tvmem[i]; i++)
  		free_page((unsigned long)tvmem[i]);
e3a4ea4fd   Mikko Herranen   [CRYPTO] tcrypt: ...
3024
3025
  
  	return err;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3026
3027
3028
3029
3030
3031
  }
  
  /*
   * If an init function is provided, an exit function must also be provided
   * to allow module unload.
   */
3af5b90bd   Kamalesh Babulal   [CRYPTO] all: Cle...
3032
  static void __exit tcrypt_mod_fini(void) { }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3033

c4741b230   Eric Biggers   crypto: run initc...
3034
  subsys_initcall(tcrypt_mod_init);
3af5b90bd   Kamalesh Babulal   [CRYPTO] all: Cle...
3035
  module_exit(tcrypt_mod_fini);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3036

a873a5f1c   Steffen Klassert   crypto: tcrypt - ...
3037
3038
  module_param(alg, charp, 0);
  module_param(type, uint, 0);
7be380f72   Herbert Xu   crypto: tcrypt - ...
3039
  module_param(mask, uint, 0);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3040
  module_param(mode, int, 0);
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
3041
  module_param(sec, uint, 0);
6a17944ca   Herbert Xu   [CRYPTO]: Use CPU...
3042
3043
  MODULE_PARM_DESC(sec, "Length in seconds of speed tests "
  		      "(defaults to zero which uses CPU cycles instead)");
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
3044
3045
  module_param(num_mb, uint, 0000);
  MODULE_PARM_DESC(num_mb, "Number of concurrent requests to be used in mb speed tests (defaults to 8)");
ba974adb4   Herbert Xu   crypto: tcrypt - ...
3046
3047
  module_param(klen, uint, 0);
  MODULE_PARM_DESC(klen, "Key length (defaults to 0)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3048
3049
3050
3051
  
  MODULE_LICENSE("GPL");
  MODULE_DESCRIPTION("Quick & dirty crypto testing module");
  MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");