Blame view

crypto/tcrypt.c 79.1 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;
f139cfa7c   Herbert Xu   crypto: tcrypt - ...
63
  static char *tvmem[TVMEMSIZE];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
64
65
  
  static char *check[] = {
b7e275304   Gilad Ben-Yossef   crypto: sm3 - add...
66
  	"des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", "sm3",
cd12fb906   Jonathan Lynch   [CRYPTO] sha256-g...
67
68
  	"blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
  	"cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
90831639a   David Howells   [CRYPTO] fcrypt: ...
69
  	"khazad", "wp512", "wp384", "wp256", "tnepres", "xeta",  "fcrypt",
2998db37b   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
70
  	"camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320",
8c3f97ab2   Radu Alexe   crypto: tcrypt - ...
71
72
  	"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
73
  };
ee5bbc9fd   Ard Biesheuvel   crypto: tcrypt - ...
74
  static u32 block_sizes[] = { 16, 64, 256, 1024, 1472, 8192, 0 };
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
75
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
  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 - ...
133
134
  static inline int do_one_aead_op(struct aead_request *req, int ret)
  {
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
135
  	struct crypto_wait *wait = req->base.data;
1425d2d17   Vutla, Lokesh   crypto: tcrypt - ...
136

646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
137
  	return crypto_wait_req(ret, wait);
1425d2d17   Vutla, Lokesh   crypto: tcrypt - ...
138
  }
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
139
140
141
142
143
144
145
146
147
148
149
  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 - ...
150
  				u32 num_mb, int *rc)
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
151
  {
4e234eed5   Kees Cook   crypto: tcrypt - ...
152
  	int i, err = 0;
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
  
  	/* 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 - ...
178
179
180
  {
  	unsigned long start, end;
  	int bcount;
4e234eed5   Kees Cook   crypto: tcrypt - ...
181
182
183
184
185
186
  	int ret = 0;
  	int *rc;
  
  	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
  	if (!rc)
  		return -ENOMEM;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
187

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

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

4e234eed5   Kees Cook   crypto: tcrypt - ...
238
239
  out:
  	kfree(rc);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
240
241
  	return ret;
  }
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
242
243
244
245
246
247
248
249
250
251
  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;
029bf5a02   Horia Geantă   MLK-21644 crypto:...
252
  	void *assoc, *assoc_out;
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
253
254
255
  	u32 *b_size;
  	char *iv;
  	int ret;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
256

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

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

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
  	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 - ...
283
  	}
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
284
  	ret = crypto_aead_setauthsize(tfm, authsize);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
285

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
286
287
288
289
290
291
  	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 - ...
292

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
293
294
295
296
297
298
299
300
301
302
  	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 - ...
303
  				testmgr_free_buf(data[i].xoutbuf);
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
304
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
  			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 - ...
336
337
  				pr_err("template (%u) too big for buffer (%lu)
  ",
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
338
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
  				       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);
029bf5a02   Horia Geantă   MLK-21644 crypto:...
378
379
  				assoc_out = cur->axbuf[1];
  				memset(assoc_out, 0xff, aad_size);
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
380
381
382
383
384
385
386
  
  				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),
029bf5a02   Horia Geantă   MLK-21644 crypto:...
387
  					     assoc_out, aad_size);
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
  
  				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) {
  						pr_err("calculating auth failed failed (%d)
  ",
  						       ret);
  						break;
  					}
029bf5a02   Horia Geantă   MLK-21644 crypto:...
406
407
408
  
  					memset(assoc, 0xff, aad_size);
  					memset(assoc_out, 0xff, aad_size);
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
409
410
411
412
413
414
415
416
  				}
  
  				aead_request_set_crypt(cur->req, cur->sg,
  						       cur->sgout, *b_size +
  						       (enc ? 0 : authsize),
  						       iv);
  
  			}
2af632996   Horia Geantă   crypto: tcrypt - ...
417
  			if (secs) {
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
418
419
  				ret = test_mb_aead_jiffies(data, enc, *b_size,
  							   secs, num_mb);
2af632996   Horia Geantă   crypto: tcrypt - ...
420
421
  				cond_resched();
  			} else {
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
422
423
  				ret = test_mb_aead_cycles(data, enc, *b_size,
  							  num_mb);
2af632996   Horia Geantă   crypto: tcrypt - ...
424
  			}
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
425
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
  
  			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 - ...
455
  }
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
456
457
  static int test_aead_jiffies(struct aead_request *req, int enc,
  				int blen, int secs)
53f52d7ae   Tim Chen   crypto: tcrypt - ...
458
  {
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
459
460
461
  	unsigned long start, end;
  	int bcount;
  	int ret;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
462

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
  	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 - ...
478
  }
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
479
  static int test_aead_cycles(struct aead_request *req, int enc, int blen)
53f52d7ae   Tim Chen   crypto: tcrypt - ...
480
  {
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
481
482
483
  	unsigned long cycles = 0;
  	int ret = 0;
  	int i;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
484

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
485
486
487
488
489
490
491
492
493
  	/* 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 - ...
494
  	}
c47689931   Cristian Stoica   crypto: tcrypt - ...
495

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

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
500
501
502
503
504
505
  		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 - ...
506

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

427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
510
511
512
513
514
515
516
517
518
519
  		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 - ...
520
  }
3e3dc25fe   Mark Rustad   crypto: Resolve s...
521
  static void test_aead_speed(const char *algo, int enc, unsigned int secs,
53f52d7ae   Tim Chen   crypto: tcrypt - ...
522
523
524
525
526
527
528
529
530
531
  			    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 - ...
532
533
  	struct scatterlist *sgout;
  	const char *e;
029bf5a02   Horia Geantă   MLK-21644 crypto:...
534
  	void *assoc, *assoc_out;
96692a730   Cristian Stoica   crypto: tcrypt - ...
535
  	char *iv;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
536
537
538
539
540
  	char *xbuf[XBUFSIZE];
  	char *xoutbuf[XBUFSIZE];
  	char *axbuf[XBUFSIZE];
  	unsigned int *b_size;
  	unsigned int iv_len;
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
541
  	struct crypto_wait wait;
53f52d7ae   Tim Chen   crypto: tcrypt - ...
542

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

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

53f52d7ae   Tim Chen   crypto: tcrypt - ...
590
591
592
593
594
  	i = 0;
  	do {
  		b_size = aead_sizes;
  		do {
  			assoc = axbuf[0];
ac5f863f8   Christian Engelmayer   crypto: tcrypt - ...
595
  			memset(assoc, 0xff, aad_size);
029bf5a02   Horia Geantă   MLK-21644 crypto:...
596
597
  			assoc_out = axbuf[1];
  			memset(assoc_out, 0xff, aad_size);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
  
  			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 - ...
619
  				memset(iv, 0xff, iv_len);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
620
621
622
623
624
625
626
627
628
629
630
631
632
633
  
  			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 - ...
634
635
  			sg_init_aead(sg, xbuf, *b_size + (enc ? 0 : authsize),
  				     assoc, aad_size);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
636

31267270a   Herbert Xu   crypto: tcrypt - ...
637
  			sg_init_aead(sgout, xoutbuf,
029bf5a02   Horia Geantă   MLK-21644 crypto:...
638
  				     *b_size + (enc ? authsize : 0), assoc_out,
5601e014f   Tudor-Dan Ambarus   crypto: tcrypt - ...
639
  				     aad_size);
31267270a   Herbert Xu   crypto: tcrypt - ...
640

4431bd495   Gilad Ben-Yossef   crypto: tcrypt - ...
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
  			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) {
  					pr_err("calculating auth failed failed (%d)
  ",
  					       ret);
  					break;
  				}
029bf5a02   Horia Geantă   MLK-21644 crypto:...
661
662
663
  
  				memset(assoc, 0xff, aad_size);
  				memset(assoc_out, 0xff, aad_size);
4431bd495   Gilad Ben-Yossef   crypto: tcrypt - ...
664
  			}
7aacbfcb3   Robert Baronescu   crypto: tcrypt - ...
665
666
667
  			aead_request_set_crypt(req, sg, sgout,
  					       *b_size + (enc ? 0 : authsize),
  					       iv);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
668

2af632996   Horia Geantă   crypto: tcrypt - ...
669
  			if (secs) {
3e3dc25fe   Mark Rustad   crypto: Resolve s...
670
671
  				ret = test_aead_jiffies(req, enc, *b_size,
  							secs);
2af632996   Horia Geantă   crypto: tcrypt - ...
672
673
  				cond_resched();
  			} else {
53f52d7ae   Tim Chen   crypto: tcrypt - ...
674
  				ret = test_aead_cycles(req, enc, *b_size);
2af632996   Horia Geantă   crypto: tcrypt - ...
675
  			}
53f52d7ae   Tim Chen   crypto: tcrypt - ...
676
677
678
679
680
681
682
683
684
685
686
687
688
  
  			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 - ...
689
690
  	aead_request_free(req);
  out_noreq:
53f52d7ae   Tim Chen   crypto: tcrypt - ...
691
  	crypto_free_aead(tfm);
a2ea6ed6a   Christian Engelmayer   crypto: tcrypt - ...
692
  out_notfm:
53f52d7ae   Tim Chen   crypto: tcrypt - ...
693
694
695
696
697
698
699
700
  	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 - ...
701
  	kfree(iv);
53f52d7ae   Tim Chen   crypto: tcrypt - ...
702
  }
d5dc39274   Sebastian Siewior   [CRYPTO] tcrypt: ...
703

beb63da73   David S. Miller   crypto: tcrypt - ...
704
705
706
707
708
709
710
711
712
713
  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 - ...
714
715
  static inline int do_one_ahash_op(struct ahash_request *req, int ret)
  {
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
716
  	struct crypto_wait *wait = req->base.data;
beb63da73   David S. Miller   crypto: tcrypt - ...
717

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

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

4e234eed5   Kees Cook   crypto: tcrypt - ...
815
816
  out:
  	kfree(rc);
b34a0f67b   Gilad Ben-Yossef   crypto: tcrypt - ...
817
818
819
820
  	return ret;
  }
  
  static void test_mb_ahash_speed(const char *algo, unsigned int secs,
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
821
  				struct hash_speed *speed, u32 num_mb)
087bcd225   Megha Dey   crypto: tcrypt - ...
822
  {
72259deb3   Herbert Xu   crypto: tcrypt - ...
823
  	struct test_mb_ahash_data *data;
087bcd225   Megha Dey   crypto: tcrypt - ...
824
  	struct crypto_ahash *tfm;
72259deb3   Herbert Xu   crypto: tcrypt - ...
825
826
  	unsigned int i, j, k;
  	int ret;
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
827
  	data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL);
72259deb3   Herbert Xu   crypto: tcrypt - ...
828
829
  	if (!data)
  		return;
087bcd225   Megha Dey   crypto: tcrypt - ...
830
831
832
833
834
835
  
  	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 - ...
836
  		goto free_data;
087bcd225   Megha Dey   crypto: tcrypt - ...
837
  	}
72259deb3   Herbert Xu   crypto: tcrypt - ...
838

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

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

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

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

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

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

3e3dc25fe   Mark Rustad   crypto: Resolve s...
945
  	for (start = jiffies, end = start + secs * HZ, bcount = 0;
beb63da73   David S. Miller   crypto: tcrypt - ...
946
  	     time_before(jiffies, end); bcount++) {
43a9607d8   Herbert Xu   crypto: tcrypt - ...
947
  		ret = do_one_ahash_op(req, crypto_ahash_init(req));
beb63da73   David S. Miller   crypto: tcrypt - ...
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
  		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...
963
  		bcount / secs, ((long)bcount * blen) / secs);
beb63da73   David S. Miller   crypto: tcrypt - ...
964
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
  
  	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 - ...
1018
  		ret = do_one_ahash_op(req, crypto_ahash_init(req));
beb63da73   David S. Miller   crypto: tcrypt - ...
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
  		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 - ...
1036
  		ret = do_one_ahash_op(req, crypto_ahash_init(req));
beb63da73   David S. Miller   crypto: tcrypt - ...
1037
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
  		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 - ...
1063
1064
  static void test_ahash_speed_common(const char *algo, unsigned int secs,
  				    struct hash_speed *speed, unsigned mask)
beb63da73   David S. Miller   crypto: tcrypt - ...
1065
1066
  {
  	struct scatterlist sg[TVMEMSIZE];
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
1067
  	struct crypto_wait wait;
beb63da73   David S. Miller   crypto: tcrypt - ...
1068
1069
  	struct ahash_request *req;
  	struct crypto_ahash *tfm;
f074f7b10   Horia Geant?   crypto: tcrypt - ...
1070
  	char *output;
beb63da73   David S. Miller   crypto: tcrypt - ...
1071
  	int i, ret;
0660511c0   Herbert Xu   crypto: tcrypt - ...
1072
  	tfm = crypto_alloc_ahash(algo, 0, mask);
beb63da73   David S. Miller   crypto: tcrypt - ...
1073
1074
1075
1076
1077
1078
  	if (IS_ERR(tfm)) {
  		pr_err("failed to load transform for %s: %ld
  ",
  		       algo, PTR_ERR(tfm));
  		return;
  	}
263a8df0d   Luca Clementi   crypto: tcrypt - ...
1079
1080
1081
1082
  	printk(KERN_INFO "
  testing speed of async %s (%s)
  ", algo,
  			get_driver_name(crypto_ahash, tfm));
f074f7b10   Horia Geant?   crypto: tcrypt - ...
1083
1084
1085
1086
  	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 - ...
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
  		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 - ...
1097
  	crypto_init_wait(&wait);
beb63da73   David S. Miller   crypto: tcrypt - ...
1098
  	ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
1099
  				   crypto_req_done, &wait);
beb63da73   David S. Miller   crypto: tcrypt - ...
1100

f074f7b10   Horia Geant?   crypto: tcrypt - ...
1101
1102
1103
  	output = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL);
  	if (!output)
  		goto out_nomem;
beb63da73   David S. Miller   crypto: tcrypt - ...
1104
1105
1106
1107
1108
1109
1110
  	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;
  		}
331351f89   Horia Geantă   crypto: tcrypt - ...
1111
1112
  		if (speed[i].klen)
  			crypto_ahash_setkey(tfm, tvmem[0], speed[i].klen);
beb63da73   David S. Miller   crypto: tcrypt - ...
1113
1114
1115
1116
1117
  		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 - ...
1118
  		if (secs) {
beb63da73   David S. Miller   crypto: tcrypt - ...
1119
  			ret = test_ahash_jiffies(req, speed[i].blen,
3e3dc25fe   Mark Rustad   crypto: Resolve s...
1120
  						 speed[i].plen, output, secs);
2af632996   Horia Geantă   crypto: tcrypt - ...
1121
1122
  			cond_resched();
  		} else {
beb63da73   David S. Miller   crypto: tcrypt - ...
1123
1124
  			ret = test_ahash_cycles(req, speed[i].blen,
  						speed[i].plen, output);
2af632996   Horia Geantă   crypto: tcrypt - ...
1125
  		}
beb63da73   David S. Miller   crypto: tcrypt - ...
1126
1127
1128
1129
1130
1131
1132
  
  		if (ret) {
  			pr_err("hashing failed ret=%d
  ", ret);
  			break;
  		}
  	}
f074f7b10   Horia Geant?   crypto: tcrypt - ...
1133
1134
1135
  	kfree(output);
  
  out_nomem:
beb63da73   David S. Miller   crypto: tcrypt - ...
1136
1137
1138
1139
1140
  	ahash_request_free(req);
  
  out:
  	crypto_free_ahash(tfm);
  }
0660511c0   Herbert Xu   crypto: tcrypt - ...
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
  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 - ...
1152
1153
1154
1155
1156
1157
1158
1159
  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 - ...
1160
  				u32 num_mb, int *rc)
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1161
  {
4e234eed5   Kees Cook   crypto: tcrypt - ...
1162
  	int i, err = 0;
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1163
1164
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
  
  	/* 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 - ...
1191
1192
1193
1194
1195
1196
  	int ret = 0;
  	int *rc;
  
  	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
  	if (!rc)
  		return -ENOMEM;
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1197
1198
1199
  
  	for (start = jiffies, end = start + secs * HZ, bcount = 0;
  	     time_before(jiffies, end); bcount++) {
4e234eed5   Kees Cook   crypto: tcrypt - ...
1200
  		ret = do_mult_acipher_op(data, enc, num_mb, rc);
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1201
  		if (ret)
4e234eed5   Kees Cook   crypto: tcrypt - ...
1202
  			goto out;
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1203
1204
1205
1206
1207
  	}
  
  	pr_cont("%d operations in %d seconds (%ld bytes)
  ",
  		bcount * num_mb, secs, (long)bcount * blen * num_mb);
4e234eed5   Kees Cook   crypto: tcrypt - ...
1208
1209
1210
1211
  
  out:
  	kfree(rc);
  	return ret;
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1212
1213
1214
1215
1216
1217
1218
1219
  }
  
  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 - ...
1220
1221
1222
1223
1224
  	int *rc;
  
  	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
  	if (!rc)
  		return -ENOMEM;
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1225
1226
1227
  
  	/* Warm-up run. */
  	for (i = 0; i < 4; i++) {
4e234eed5   Kees Cook   crypto: tcrypt - ...
1228
  		ret = do_mult_acipher_op(data, enc, num_mb, rc);
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1229
1230
1231
1232
1233
1234
1235
1236
1237
  		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 - ...
1238
  		ret = do_mult_acipher_op(data, enc, num_mb, rc);
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1239
1240
1241
1242
1243
1244
1245
  		end = get_cycles();
  
  		if (ret)
  			goto out;
  
  		cycles += end - start;
  	}
4e234eed5   Kees Cook   crypto: tcrypt - ...
1246
1247
1248
  	pr_cont("1 operation in %lu cycles (%d bytes)
  ",
  		(cycles + 4) / (8 * num_mb), blen);
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1249

4e234eed5   Kees Cook   crypto: tcrypt - ...
1250
1251
  out:
  	kfree(rc);
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1252
1253
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
  	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 - ...
1330
1331
  				pr_err("template (%u) too big for buffer (%lu)
  ",
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1332
1333
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
  				       *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 - ...
1389
  			if (secs) {
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1390
1391
1392
  				ret = test_mb_acipher_jiffies(data, enc,
  							      *b_size, secs,
  							      num_mb);
2af632996   Horia Geantă   crypto: tcrypt - ...
1393
1394
  				cond_resched();
  			} else {
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1395
1396
  				ret = test_mb_acipher_cycles(data, enc,
  							     *b_size, num_mb);
2af632996   Horia Geantă   crypto: tcrypt - ...
1397
  			}
e161c5930   Gilad Ben-Yossef   crypto: tcrypt - ...
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
  
  			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 - ...
1422
  static inline int do_one_acipher_op(struct skcipher_request *req, int ret)
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1423
  {
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
1424
  	struct crypto_wait *wait = req->base.data;
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1425

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

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

7166e589d   Herbert Xu   crypto: tcrypt - ...
1531
  	req = skcipher_request_alloc(tfm, GFP_KERNEL);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1532
1533
1534
1535
1536
1537
  	if (!req) {
  		pr_err("tcrypt: skcipher: Failed to allocate request for %s
  ",
  		       algo);
  		goto out;
  	}
7166e589d   Herbert Xu   crypto: tcrypt - ...
1538
  	skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
646710419   Gilad Ben-Yossef   crypto: tcrypt - ...
1539
  				      crypto_req_done, &wait);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1540
1541
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
  
  	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 - ...
1569
  			crypto_skcipher_clear_flags(tfm, ~0);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1570

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

2af632996   Horia Geantă   crypto: tcrypt - ...
1601
  			if (secs) {
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1602
  				ret = test_acipher_jiffies(req, enc,
3e3dc25fe   Mark Rustad   crypto: Resolve s...
1603
  							   *b_size, secs);
2af632996   Horia Geantă   crypto: tcrypt - ...
1604
1605
  				cond_resched();
  			} else {
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1606
1607
  				ret = test_acipher_cycles(req, enc,
  							  *b_size);
2af632996   Horia Geantă   crypto: tcrypt - ...
1608
  			}
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1609
1610
1611
1612
  
  			if (ret) {
  				pr_err("%s() failed flags=%x
  ", e,
7166e589d   Herbert Xu   crypto: tcrypt - ...
1613
  				       crypto_skcipher_get_flags(tfm));
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1614
1615
1616
1617
1618
1619
1620
1621
1622
  				break;
  			}
  			b_size++;
  			i++;
  		} while (*b_size);
  		keysize++;
  	} while (*keysize);
  
  out_free_req:
7166e589d   Herbert Xu   crypto: tcrypt - ...
1623
  	skcipher_request_free(req);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
1624
  out:
7166e589d   Herbert Xu   crypto: tcrypt - ...
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
  	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 - ...
1642
  }
ef2736fc7   Herbert Xu   [CRYPTO]: White s...
1643
  static void test_available(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1644
1645
  {
  	char **name = check;
ef2736fc7   Herbert Xu   [CRYPTO]: White s...
1646

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

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

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

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

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

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

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

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

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

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

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

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

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

98eca72fa   raveendra padasalagi   crypto: sha3 - Ad...
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
  	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 ...
1966
1967
1968
1969
1970
1971
1972
  	case 115:
  		ret += tcrypt_test("hmac(streebog256)");
  		break;
  
  	case 116:
  		ret += tcrypt_test("hmac(streebog512)");
  		break;
8c3f97ab2   Radu Alexe   crypto: tcrypt - ...
1973
1974
1975
  	case 117:
  		ret += tcrypt_test("rsa");
  		break;
e08ca2da3   Jarod Wilson   crypto: testmgr -...
1976
  	case 150:
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
1977
  		ret += tcrypt_test("ansi_cprng");
e08ca2da3   Jarod Wilson   crypto: testmgr -...
1978
  		break;
69435b94d   Adrian Hoban   crypto: rfc4106 -...
1979
1980
1981
  	case 151:
  		ret += tcrypt_test("rfc4106(gcm(aes))");
  		break;
e9b7441a9   Jussi Kivilinna   crypto: testmgr -...
1982
1983
1984
  	case 152:
  		ret += tcrypt_test("rfc4543(gcm(aes))");
  		break;
93b5e86a6   Jussi Kivilinna   crypto: add CMAC ...
1985
1986
1987
1988
1989
1990
1991
  	case 153:
  		ret += tcrypt_test("cmac(aes)");
  		break;
  
  	case 154:
  		ret += tcrypt_test("cmac(des3_ede)");
  		break;
bbf9c8934   Horia Geanta   crypto: caam - fi...
1992
1993
1994
  	case 155:
  		ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))");
  		break;
bca4feb0d   Horia Geanta   crypto: testmgr -...
1995
1996
1997
1998
1999
2000
2001
  	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 -...
2002
2003
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
  	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 -...
2032
2033
  	case 191:
  		ret += tcrypt_test("ecb(sm4)");
95ba59736   Gilad Ben-Yossef   crypto: testmgr -...
2034
2035
  		ret += tcrypt_test("cbc(sm4)");
  		ret += tcrypt_test("ctr(sm4)");
cd83a8a7c   Gilad Ben-Yossef   crypto: testmgr -...
2036
  		break;
a9278aade   Radu Alexe   crypto: add suppo...
2037
2038
2039
  	case 192:
  		ret += tcrypt_test("tls10(hmac(sha1),cbc(aes))");
  		break;
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
2040
  	case 200:
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2041
  		test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2042
  				speed_template_16_24_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2043
  		test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2044
  				speed_template_16_24_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2045
  		test_cipher_speed("cbc(aes)", ENCRYPT, 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)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2048
  				speed_template_16_24_32);
f3d1044cd   Rik Snel   [CRYPTO] tcrypt: ...
2049
  		test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2050
  				speed_template_32_40_48);
f3d1044cd   Rik Snel   [CRYPTO] tcrypt: ...
2051
  		test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2052
  				speed_template_32_40_48);
f19f5111c   Rik Snel   [CRYPTO] xts: XTS...
2053
  		test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
b66ad0b7a   Horia Geantă   crypto: tcrypt - ...
2054
  				speed_template_32_64);
f19f5111c   Rik Snel   [CRYPTO] xts: XTS...
2055
  		test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
b66ad0b7a   Horia Geantă   crypto: tcrypt - ...
2056
  				speed_template_32_64);
1503a24f5   Herbert Xu   crypto: tcrypt - ...
2057
2058
2059
2060
  		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 - ...
2061
2062
2063
2064
  		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 -...
2065
2066
2067
2068
  		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...
2069
2070
2071
  		break;
  
  	case 201:
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2072
  		test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec,
da7f033dd   Herbert Xu   crypto: cryptomgr...
2073
  				des3_speed_template, DES3_SPEED_VECTORS,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2074
  				speed_template_24);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2075
  		test_cipher_speed("ecb(des3_ede)", DECRYPT, sec,
da7f033dd   Herbert Xu   crypto: cryptomgr...
2076
  				des3_speed_template, DES3_SPEED_VECTORS,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2077
  				speed_template_24);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2078
  		test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec,
da7f033dd   Herbert Xu   crypto: cryptomgr...
2079
  				des3_speed_template, DES3_SPEED_VECTORS,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2080
  				speed_template_24);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2081
  		test_cipher_speed("cbc(des3_ede)", DECRYPT, sec,
da7f033dd   Herbert Xu   crypto: cryptomgr...
2082
  				des3_speed_template, DES3_SPEED_VECTORS,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2083
  				speed_template_24);
87131507e   Jussi Kivilinna   crypto: tcrypt - ...
2084
2085
2086
2087
2088
2089
  		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...
2090
2091
2092
  		break;
  
  	case 202:
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2093
  		test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2094
  				speed_template_16_24_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2095
  		test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2096
  				speed_template_16_24_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2097
  		test_cipher_speed("cbc(twofish)", ENCRYPT, 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)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2100
  				speed_template_16_24_32);
ee5002a54   Jussi Kivilinna   crypto: tcrypt - ...
2101
2102
2103
2104
  		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 - ...
2105
2106
2107
2108
  		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 - ...
2109
2110
2111
2112
  		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...
2113
2114
2115
  		break;
  
  	case 203:
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2116
  		test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2117
  				  speed_template_8_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2118
  		test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2119
  				  speed_template_8_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2120
  		test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2121
  				  speed_template_8_32);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2122
  		test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2123
  				  speed_template_8_32);
7d47b86cf   Jussi Kivilinna   crypto: tcrypt - ...
2124
2125
2126
2127
  		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...
2128
2129
2130
  		break;
  
  	case 204:
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2131
  		test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2132
  				  speed_template_8);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2133
  		test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2134
  				  speed_template_8);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2135
  		test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2136
  				  speed_template_8);
cba83564d   Herbert Xu   [CRYPTO] tcrypt: ...
2137
  		test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2138
  				  speed_template_8);
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
2139
  		break;
02ab5a705   Noriaki TAKAMIYA   [CRYPTO] camellia...
2140
2141
  	case 205:
  		test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2142
  				speed_template_16_24_32);
02ab5a705   Noriaki TAKAMIYA   [CRYPTO] camellia...
2143
  		test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2144
  				speed_template_16_24_32);
02ab5a705   Noriaki TAKAMIYA   [CRYPTO] camellia...
2145
  		test_cipher_speed("cbc(camellia)", ENCRYPT, 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)", DECRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2148
  				speed_template_16_24_32);
4de593378   Jussi Kivilinna   crypto: tcrypt - ...
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
  		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...
2161
  		break;
5de8f1b56   Tan Swee Heng   [CRYPTO] tcrypt: ...
2162
2163
  	case 206:
  		test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0,
477035c2a   Sebastian Siewior   [CRYPTO] tcrypt: ...
2164
  				  speed_template_16_32);
5de8f1b56   Tan Swee Heng   [CRYPTO] tcrypt: ...
2165
  		break;
7fb7fe446   Jussi Kivilinna   crypto: tcrypt - ...
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
  	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 - ...
2179
2180
2181
2182
  		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 - ...
2183
2184
2185
2186
  		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 - ...
2187
  		break;
31b4cd290   Jussi Kivilinna   crypto: testmgr -...
2188
2189
2190
2191
  	case 208:
  		test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
  				  speed_template_8);
  		break;
a2c582609   Johannes Goetzfried   crypto: testmgr -...
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
  	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 -...
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
  	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 - ...
2228
2229
  	case 211:
  		test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec,
34a1c740e   Herbert Xu   crypto: tcrypt - ...
2230
  				NULL, 0, 16, 16, aead_speed_template_20);
1425d2d17   Vutla, Lokesh   crypto: tcrypt - ...
2231
  		test_aead_speed("gcm(aes)", ENCRYPT, sec,
f18611da8   Cyrille Pitchen   crypto: tcrypt - ...
2232
  				NULL, 0, 16, 8, speed_template_16_24_32);
4431bd495   Gilad Ben-Yossef   crypto: tcrypt - ...
2233
2234
2235
2236
  		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 - ...
2237
  		break;
4e4aab63d   Herbert Xu   crypto: tcrypt - ...
2238
2239
  	case 212:
  		test_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec,
34a1c740e   Herbert Xu   crypto: tcrypt - ...
2240
  				NULL, 0, 16, 16, aead_speed_template_19);
4431bd495   Gilad Ben-Yossef   crypto: tcrypt - ...
2241
2242
  		test_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec,
  				NULL, 0, 16, 16, aead_speed_template_19);
4e4aab63d   Herbert Xu   crypto: tcrypt - ...
2243
  		break;
2dce063a3   Martin Willi   crypto: tcrypt - ...
2244
2245
2246
  	case 213:
  		test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, sec,
  				NULL, 0, 16, 8, aead_speed_template_36);
4431bd495   Gilad Ben-Yossef   crypto: tcrypt - ...
2247
2248
  		test_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT, sec,
  				NULL, 0, 16, 8, aead_speed_template_36);
2dce063a3   Martin Willi   crypto: tcrypt - ...
2249
2250
2251
2252
2253
2254
  		break;
  
  	case 214:
  		test_cipher_speed("chacha20", ENCRYPT, sec, NULL, 0,
  				  speed_template_32);
  		break;
427988d98   Gilad Ben-Yossef   crypto: tcrypt - ...
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
  	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 -...
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
  	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 ...
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
  
  	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...
2306
2307
2308
2309
2310
2311
2312
2313
  	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 - ...
2314
2315
2316
2317
2318
2319
  	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: ...
2320
  	case 300:
8606813a6   Herbert Xu   crypto: tcrypt - ...
2321
2322
2323
2324
  		if (alg) {
  			test_hash_speed(alg, sec, generic_hash_speed_template);
  			break;
  		}
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2325
  		/* fall through */
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2326
  	case 301:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2327
  		test_hash_speed("md4", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2328
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2329
  		/* fall through */
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2330
  	case 302:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2331
  		test_hash_speed("md5", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2332
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2333
  		/* fall through */
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2334
  	case 303:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2335
  		test_hash_speed("sha1", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2336
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2337
  		/* fall through */
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2338
  	case 304:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2339
  		test_hash_speed("sha256", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2340
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2341
  		/* fall through */
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2342
  	case 305:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2343
  		test_hash_speed("sha384", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2344
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2345
  		/* fall through */
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2346
  	case 306:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2347
  		test_hash_speed("sha512", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2348
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2349
  		/* fall through */
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2350
  	case 307:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2351
  		test_hash_speed("wp256", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2352
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2353
  		/* fall through */
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2354
  	case 308:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2355
  		test_hash_speed("wp384", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2356
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2357
  		/* fall through */
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2358
  	case 309:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2359
  		test_hash_speed("wp512", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2360
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2361
  		/* fall through */
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2362
  	case 310:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2363
  		test_hash_speed("tgr128", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2364
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2365
  		/* fall through */
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2366
  	case 311:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2367
  		test_hash_speed("tgr160", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2368
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2369
  		/* fall through */
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2370
  	case 312:
e9d41164e   Herbert Xu   [CRYPTO] tcrypt: ...
2371
  		test_hash_speed("tgr192", sec, generic_hash_speed_template);
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2372
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2373
  		/* fall through */
cd12fb906   Jonathan Lynch   [CRYPTO] sha256-g...
2374
2375
2376
  	case 313:
  		test_hash_speed("sha224", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2377
  		/* fall through */
fd4adf1a0   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
2378
2379
2380
  	case 314:
  		test_hash_speed("rmd128", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2381
  		/* fall through */
fd4adf1a0   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
2382
2383
2384
  	case 315:
  		test_hash_speed("rmd160", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2385
  		/* fall through */
2998db37b   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
2386
2387
2388
  	case 316:
  		test_hash_speed("rmd256", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2389
  		/* fall through */
2998db37b   Adrian-Ken Rueegsegger   [CRYPTO] tcrypt: ...
2390
2391
2392
  	case 317:
  		test_hash_speed("rmd320", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2393
  		/* fall through */
18bcc9194   Huang Ying   crypto: tcrypt - ...
2394
2395
2396
  	case 318:
  		test_hash_speed("ghash-generic", sec, hash_speed_template_16);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2397
  		/* fall through */
e3899e4df   Tim Chen   crypto: tcrypt - ...
2398
2399
2400
  	case 319:
  		test_hash_speed("crc32c", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2401
  		/* fall through */
68411521c   Herbert Xu   Reinstate "crypto...
2402
2403
2404
  	case 320:
  		test_hash_speed("crct10dif", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2405
  		/* fall through */
2dce063a3   Martin Willi   crypto: tcrypt - ...
2406
2407
2408
  	case 321:
  		test_hash_speed("poly1305", sec, poly1305_speed_template);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2409
  		/* fall through */
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2410
2411
2412
  	case 322:
  		test_hash_speed("sha3-224", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2413
  		/* fall through */
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2414
2415
2416
  	case 323:
  		test_hash_speed("sha3-256", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2417
  		/* fall through */
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2418
2419
2420
  	case 324:
  		test_hash_speed("sha3-384", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2421
  		/* fall through */
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2422
2423
2424
  	case 325:
  		test_hash_speed("sha3-512", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2425
  		/* fall through */
b7e275304   Gilad Ben-Yossef   crypto: sm3 - add...
2426
2427
2428
  	case 326:
  		test_hash_speed("sm3", sec, generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2429
  		/* fall through */
25a0b9d4e   Vitaly Chikunov   crypto: streebog ...
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
  	case 327:
  		test_hash_speed("streebog256", sec,
  				generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
  		/* fall through */
  	case 328:
  		test_hash_speed("streebog512", sec,
  				generic_hash_speed_template);
  		if (mode > 300 && mode < 400) break;
  		/* fall through */
e80579285   Michal Ludvig   [CRYPTO] tcrypt: ...
2440
2441
  	case 399:
  		break;
beb63da73   David S. Miller   crypto: tcrypt - ...
2442
  	case 400:
8606813a6   Herbert Xu   crypto: tcrypt - ...
2443
2444
2445
2446
  		if (alg) {
  			test_ahash_speed(alg, sec, generic_hash_speed_template);
  			break;
  		}
beb63da73   David S. Miller   crypto: tcrypt - ...
2447
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2448
2449
2450
  	case 401:
  		test_ahash_speed("md4", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2451
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2452
2453
2454
  	case 402:
  		test_ahash_speed("md5", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2455
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2456
2457
2458
  	case 403:
  		test_ahash_speed("sha1", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2459
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2460
2461
2462
  	case 404:
  		test_ahash_speed("sha256", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2463
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2464
2465
2466
  	case 405:
  		test_ahash_speed("sha384", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2467
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2468
2469
2470
  	case 406:
  		test_ahash_speed("sha512", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2471
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2472
2473
2474
  	case 407:
  		test_ahash_speed("wp256", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2475
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2476
2477
2478
  	case 408:
  		test_ahash_speed("wp384", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2479
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2480
2481
2482
  	case 409:
  		test_ahash_speed("wp512", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2483
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2484
2485
2486
  	case 410:
  		test_ahash_speed("tgr128", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2487
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2488
2489
2490
  	case 411:
  		test_ahash_speed("tgr160", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2491
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2492
2493
2494
  	case 412:
  		test_ahash_speed("tgr192", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2495
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2496
2497
2498
  	case 413:
  		test_ahash_speed("sha224", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2499
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2500
2501
2502
  	case 414:
  		test_ahash_speed("rmd128", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2503
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2504
2505
2506
  	case 415:
  		test_ahash_speed("rmd160", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2507
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2508
2509
2510
  	case 416:
  		test_ahash_speed("rmd256", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2511
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2512
2513
2514
  	case 417:
  		test_ahash_speed("rmd320", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2515
  		/* fall through */
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2516
2517
2518
  	case 418:
  		test_ahash_speed("sha3-224", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2519
  		/* fall through */
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2520
2521
2522
  	case 419:
  		test_ahash_speed("sha3-256", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2523
  		/* fall through */
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2524
2525
2526
  	case 420:
  		test_ahash_speed("sha3-384", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2527
  		/* fall through */
79cc6ab89   raveendra padasalagi   crypto: sha3 - Ad...
2528
2529
2530
  	case 421:
  		test_ahash_speed("sha3-512", sec, generic_hash_speed_template);
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2531
  		/* fall through */
087bcd225   Megha Dey   crypto: tcrypt - ...
2532
  	case 422:
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
2533
2534
  		test_mb_ahash_speed("sha1", sec, generic_hash_speed_template,
  				    num_mb);
087bcd225   Megha Dey   crypto: tcrypt - ...
2535
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2536
  		/* fall through */
087bcd225   Megha Dey   crypto: tcrypt - ...
2537
  	case 423:
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
2538
2539
  		test_mb_ahash_speed("sha256", sec, generic_hash_speed_template,
  				    num_mb);
087bcd225   Megha Dey   crypto: tcrypt - ...
2540
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2541
  		/* fall through */
14009c4bd   Megha Dey   crypto: tcrypt - ...
2542
  	case 424:
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
2543
2544
  		test_mb_ahash_speed("sha512", sec, generic_hash_speed_template,
  				    num_mb);
14009c4bd   Megha Dey   crypto: tcrypt - ...
2545
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2546
  		/* fall through */
b7e275304   Gilad Ben-Yossef   crypto: sm3 - add...
2547
  	case 425:
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
2548
2549
  		test_mb_ahash_speed("sm3", sec, generic_hash_speed_template,
  				    num_mb);
b7e275304   Gilad Ben-Yossef   crypto: sm3 - add...
2550
  		if (mode > 400 && mode < 500) break;
59517226a   Gustavo A. R. Silva   crypto: tcrypt - ...
2551
  		/* fall through */
25a0b9d4e   Vitaly Chikunov   crypto: streebog ...
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
  	case 426:
  		test_mb_ahash_speed("streebog256", sec,
  				    generic_hash_speed_template, num_mb);
  		if (mode > 400 && mode < 500) break;
  		/* fall through */
  	case 427:
  		test_mb_ahash_speed("streebog512", sec,
  				    generic_hash_speed_template, num_mb);
  		if (mode > 400 && mode < 500) break;
  		/* fall through */
beb63da73   David S. Miller   crypto: tcrypt - ...
2562
2563
  	case 499:
  		break;
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
  	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 - ...
2578
  				   speed_template_32_64);
3f3baf359   Jussi Kivilinna   crypto: tcrypt - ...
2579
  		test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
b66ad0b7a   Horia Geantă   crypto: tcrypt - ...
2580
  				   speed_template_32_64);
1503a24f5   Herbert Xu   crypto: tcrypt - ...
2581
2582
2583
2584
  		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 - ...
2585
2586
2587
2588
  		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...
2589
2590
2591
2592
2593
2594
2595
2596
  		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...
2597
2598
2599
2600
  		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 - ...
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
  		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...
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
  		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 - ...
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
  		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...
2639
2640
2641
2642
2643
2644
2645
2646
  		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 - ...
2647
  		break;
7fb7fe446   Jussi Kivilinna   crypto: tcrypt - ...
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
  	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 - ...
2661
2662
2663
2664
  		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 - ...
2665
2666
2667
2668
  		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 - ...
2669
  		break;
107778b59   Johannes Goetzfried   crypto: twofish -...
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
  	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 -...
2692
2693
2694
2695
  	case 505:
  		test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
  				   speed_template_8);
  		break;
a2c582609   Johannes Goetzfried   crypto: testmgr -...
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
  	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 -...
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
  	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 - ...
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
  	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 - ...
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
  	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 - ...
2768
2769
2770
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
  	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
2979
2980
2981
  	case 1000:
  		test_available();
  		break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2982
  	}
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
2983
2984
  
  	return ret;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2985
  }
3af5b90bd   Kamalesh Babulal   [CRYPTO] all: Cle...
2986
  static int __init tcrypt_mod_init(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2987
  {
e3a4ea4fd   Mikko Herranen   [CRYPTO] tcrypt: ...
2988
  	int err = -ENOMEM;
f139cfa7c   Herbert Xu   crypto: tcrypt - ...
2989
  	int i;
e3a4ea4fd   Mikko Herranen   [CRYPTO] tcrypt: ...
2990

f139cfa7c   Herbert Xu   crypto: tcrypt - ...
2991
2992
2993
2994
2995
  	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
2996

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

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

4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
3008
3009
3010
3011
  	/* 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: ...
3012
3013
3014
  	 * => we don't need it in the memory, do we?
  	 *                                        -- mludvig
  	 */
4e033a6bc   Jarod Wilson   crypto: tcrypt - ...
3015
3016
  	if (!fips_enabled)
  		err = -EAGAIN;
e3a4ea4fd   Mikko Herranen   [CRYPTO] tcrypt: ...
3017

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

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

a873a5f1c   Steffen Klassert   crypto: tcrypt - ...
3034
3035
  module_param(alg, charp, 0);
  module_param(type, uint, 0);
7be380f72   Herbert Xu   crypto: tcrypt - ...
3036
  module_param(mask, uint, 0);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3037
  module_param(mode, int, 0);
ebfd9bcf1   Harald Welte   [CRYPTO]: Add cip...
3038
  module_param(sec, uint, 0);
6a17944ca   Herbert Xu   [CRYPTO]: Use CPU...
3039
3040
  MODULE_PARM_DESC(sec, "Length in seconds of speed tests "
  		      "(defaults to zero which uses CPU cycles instead)");
8fcdc8685   Gilad Ben-Yossef   crypto: tcrypt - ...
3041
3042
  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)");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3043
3044
3045
3046
  
  MODULE_LICENSE("GPL");
  MODULE_DESCRIPTION("Quick & dirty crypto testing module");
  MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");