aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/tcrypt.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/tcrypt.c')
-rw-r--r--crypto/tcrypt.c529
1 files changed, 282 insertions, 247 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 1ab8c017a011..6beabc5abd07 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -82,9 +82,8 @@ static char *check[] = {
82 "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", 82 "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256",
83 "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes", 83 "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
84 "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", 84 "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
85 "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
86 "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", 85 "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
87 "camellia", "seed", "salsa20", "lzo", NULL 86 "camellia", "seed", "salsa20", "lzo", "cts", NULL
88}; 87};
89 88
90static void hexdump(unsigned char *buf, unsigned int len) 89static void hexdump(unsigned char *buf, unsigned int len)
@@ -113,23 +112,11 @@ static void test_hash(char *algo, struct hash_testvec *template,
113 char result[64]; 112 char result[64];
114 struct crypto_hash *tfm; 113 struct crypto_hash *tfm;
115 struct hash_desc desc; 114 struct hash_desc desc;
116 struct hash_testvec *hash_tv;
117 unsigned int tsize;
118 int ret; 115 int ret;
116 void *hash_buff;
119 117
120 printk("\ntesting %s\n", algo); 118 printk("\ntesting %s\n", algo);
121 119
122 tsize = sizeof(struct hash_testvec);
123 tsize *= tcount;
124
125 if (tsize > TVMEMSIZE) {
126 printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE);
127 return;
128 }
129
130 memcpy(tvmem, template, tsize);
131 hash_tv = (void *)tvmem;
132
133 tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC); 120 tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC);
134 if (IS_ERR(tfm)) { 121 if (IS_ERR(tfm)) {
135 printk("failed to load transform for %s: %ld\n", algo, 122 printk("failed to load transform for %s: %ld\n", algo,
@@ -144,28 +131,36 @@ static void test_hash(char *algo, struct hash_testvec *template,
144 printk("test %u:\n", i + 1); 131 printk("test %u:\n", i + 1);
145 memset(result, 0, 64); 132 memset(result, 0, 64);
146 133
147 sg_init_one(&sg[0], hash_tv[i].plaintext, hash_tv[i].psize); 134 hash_buff = kzalloc(template[i].psize, GFP_KERNEL);
135 if (!hash_buff)
136 continue;
137
138 memcpy(hash_buff, template[i].plaintext, template[i].psize);
139 sg_init_one(&sg[0], hash_buff, template[i].psize);
148 140
149 if (hash_tv[i].ksize) { 141 if (template[i].ksize) {
150 ret = crypto_hash_setkey(tfm, hash_tv[i].key, 142 ret = crypto_hash_setkey(tfm, template[i].key,
151 hash_tv[i].ksize); 143 template[i].ksize);
152 if (ret) { 144 if (ret) {
153 printk("setkey() failed ret=%d\n", ret); 145 printk("setkey() failed ret=%d\n", ret);
146 kfree(hash_buff);
154 goto out; 147 goto out;
155 } 148 }
156 } 149 }
157 150
158 ret = crypto_hash_digest(&desc, sg, hash_tv[i].psize, result); 151 ret = crypto_hash_digest(&desc, sg, template[i].psize, result);
159 if (ret) { 152 if (ret) {
160 printk("digest () failed ret=%d\n", ret); 153 printk("digest () failed ret=%d\n", ret);
154 kfree(hash_buff);
161 goto out; 155 goto out;
162 } 156 }
163 157
164 hexdump(result, crypto_hash_digestsize(tfm)); 158 hexdump(result, crypto_hash_digestsize(tfm));
165 printk("%s\n", 159 printk("%s\n",
166 memcmp(result, hash_tv[i].digest, 160 memcmp(result, template[i].digest,
167 crypto_hash_digestsize(tfm)) ? 161 crypto_hash_digestsize(tfm)) ?
168 "fail" : "pass"); 162 "fail" : "pass");
163 kfree(hash_buff);
169 } 164 }
170 165
171 printk("testing %s across pages\n", algo); 166 printk("testing %s across pages\n", algo);
@@ -175,25 +170,25 @@ static void test_hash(char *algo, struct hash_testvec *template,
175 170
176 j = 0; 171 j = 0;
177 for (i = 0; i < tcount; i++) { 172 for (i = 0; i < tcount; i++) {
178 if (hash_tv[i].np) { 173 if (template[i].np) {
179 j++; 174 j++;
180 printk("test %u:\n", j); 175 printk("test %u:\n", j);
181 memset(result, 0, 64); 176 memset(result, 0, 64);
182 177
183 temp = 0; 178 temp = 0;
184 sg_init_table(sg, hash_tv[i].np); 179 sg_init_table(sg, template[i].np);
185 for (k = 0; k < hash_tv[i].np; k++) { 180 for (k = 0; k < template[i].np; k++) {
186 memcpy(&xbuf[IDX[k]], 181 memcpy(&xbuf[IDX[k]],
187 hash_tv[i].plaintext + temp, 182 template[i].plaintext + temp,
188 hash_tv[i].tap[k]); 183 template[i].tap[k]);
189 temp += hash_tv[i].tap[k]; 184 temp += template[i].tap[k];
190 sg_set_buf(&sg[k], &xbuf[IDX[k]], 185 sg_set_buf(&sg[k], &xbuf[IDX[k]],
191 hash_tv[i].tap[k]); 186 template[i].tap[k]);
192 } 187 }
193 188
194 if (hash_tv[i].ksize) { 189 if (template[i].ksize) {
195 ret = crypto_hash_setkey(tfm, hash_tv[i].key, 190 ret = crypto_hash_setkey(tfm, template[i].key,
196 hash_tv[i].ksize); 191 template[i].ksize);
197 192
198 if (ret) { 193 if (ret) {
199 printk("setkey() failed ret=%d\n", ret); 194 printk("setkey() failed ret=%d\n", ret);
@@ -201,7 +196,7 @@ static void test_hash(char *algo, struct hash_testvec *template,
201 } 196 }
202 } 197 }
203 198
204 ret = crypto_hash_digest(&desc, sg, hash_tv[i].psize, 199 ret = crypto_hash_digest(&desc, sg, template[i].psize,
205 result); 200 result);
206 if (ret) { 201 if (ret) {
207 printk("digest () failed ret=%d\n", ret); 202 printk("digest () failed ret=%d\n", ret);
@@ -210,7 +205,7 @@ static void test_hash(char *algo, struct hash_testvec *template,
210 205
211 hexdump(result, crypto_hash_digestsize(tfm)); 206 hexdump(result, crypto_hash_digestsize(tfm));
212 printk("%s\n", 207 printk("%s\n",
213 memcmp(result, hash_tv[i].digest, 208 memcmp(result, template[i].digest,
214 crypto_hash_digestsize(tfm)) ? 209 crypto_hash_digestsize(tfm)) ?
215 "fail" : "pass"); 210 "fail" : "pass");
216 } 211 }
@@ -224,17 +219,18 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
224 unsigned int tcount) 219 unsigned int tcount)
225{ 220{
226 unsigned int ret, i, j, k, temp; 221 unsigned int ret, i, j, k, temp;
227 unsigned int tsize;
228 char *q; 222 char *q;
229 struct crypto_aead *tfm; 223 struct crypto_aead *tfm;
230 char *key; 224 char *key;
231 struct aead_testvec *aead_tv;
232 struct aead_request *req; 225 struct aead_request *req;
233 struct scatterlist sg[8]; 226 struct scatterlist sg[8];
234 struct scatterlist asg[8]; 227 struct scatterlist asg[8];
235 const char *e; 228 const char *e;
236 struct tcrypt_result result; 229 struct tcrypt_result result;
237 unsigned int authsize; 230 unsigned int authsize;
231 void *input;
232 void *assoc;
233 char iv[MAX_IVLEN];
238 234
239 if (enc == ENCRYPT) 235 if (enc == ENCRYPT)
240 e = "encryption"; 236 e = "encryption";
@@ -243,18 +239,6 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
243 239
244 printk(KERN_INFO "\ntesting %s %s\n", algo, e); 240 printk(KERN_INFO "\ntesting %s %s\n", algo, e);
245 241
246 tsize = sizeof(struct aead_testvec);
247 tsize *= tcount;
248
249 if (tsize > TVMEMSIZE) {
250 printk(KERN_INFO "template (%u) too big for tvmem (%u)\n",
251 tsize, TVMEMSIZE);
252 return;
253 }
254
255 memcpy(tvmem, template, tsize);
256 aead_tv = (void *)tvmem;
257
258 init_completion(&result.completion); 242 init_completion(&result.completion);
259 243
260 tfm = crypto_alloc_aead(algo, 0, 0); 244 tfm = crypto_alloc_aead(algo, 0, 0);
@@ -275,46 +259,68 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
275 tcrypt_complete, &result); 259 tcrypt_complete, &result);
276 260
277 for (i = 0, j = 0; i < tcount; i++) { 261 for (i = 0, j = 0; i < tcount; i++) {
278 if (!aead_tv[i].np) { 262 if (!template[i].np) {
279 printk(KERN_INFO "test %u (%d bit key):\n", 263 printk(KERN_INFO "test %u (%d bit key):\n",
280 ++j, aead_tv[i].klen * 8); 264 ++j, template[i].klen * 8);
265
266 /* some tepmplates have no input data but they will
267 * touch input
268 */
269 input = kzalloc(template[i].ilen + template[i].rlen, GFP_KERNEL);
270 if (!input)
271 continue;
272
273 assoc = kzalloc(template[i].alen, GFP_KERNEL);
274 if (!assoc) {
275 kfree(input);
276 continue;
277 }
278
279 memcpy(input, template[i].input, template[i].ilen);
280 memcpy(assoc, template[i].assoc, template[i].alen);
281 if (template[i].iv)
282 memcpy(iv, template[i].iv, MAX_IVLEN);
283 else
284 memset(iv, 0, MAX_IVLEN);
281 285
282 crypto_aead_clear_flags(tfm, ~0); 286 crypto_aead_clear_flags(tfm, ~0);
283 if (aead_tv[i].wk) 287 if (template[i].wk)
284 crypto_aead_set_flags( 288 crypto_aead_set_flags(
285 tfm, CRYPTO_TFM_REQ_WEAK_KEY); 289 tfm, CRYPTO_TFM_REQ_WEAK_KEY);
286 key = aead_tv[i].key; 290
291 if (template[i].key)
292 key = template[i].key;
293 else
294 key = kzalloc(template[i].klen, GFP_KERNEL);
287 295
288 ret = crypto_aead_setkey(tfm, key, 296 ret = crypto_aead_setkey(tfm, key,
289 aead_tv[i].klen); 297 template[i].klen);
290 if (ret) { 298 if (ret) {
291 printk(KERN_INFO "setkey() failed flags=%x\n", 299 printk(KERN_INFO "setkey() failed flags=%x\n",
292 crypto_aead_get_flags(tfm)); 300 crypto_aead_get_flags(tfm));
293 301
294 if (!aead_tv[i].fail) 302 if (!template[i].fail)
295 goto out; 303 goto next_one;
296 } 304 }
297 305
298 authsize = abs(aead_tv[i].rlen - aead_tv[i].ilen); 306 authsize = abs(template[i].rlen - template[i].ilen);
299 ret = crypto_aead_setauthsize(tfm, authsize); 307 ret = crypto_aead_setauthsize(tfm, authsize);
300 if (ret) { 308 if (ret) {
301 printk(KERN_INFO 309 printk(KERN_INFO
302 "failed to set authsize = %u\n", 310 "failed to set authsize = %u\n",
303 authsize); 311 authsize);
304 goto out; 312 goto next_one;
305 } 313 }
306 314
307 sg_init_one(&sg[0], aead_tv[i].input, 315 sg_init_one(&sg[0], input,
308 aead_tv[i].ilen + (enc ? authsize : 0)); 316 template[i].ilen + (enc ? authsize : 0));
309 317
310 sg_init_one(&asg[0], aead_tv[i].assoc, 318 sg_init_one(&asg[0], assoc, template[i].alen);
311 aead_tv[i].alen);
312 319
313 aead_request_set_crypt(req, sg, sg, 320 aead_request_set_crypt(req, sg, sg,
314 aead_tv[i].ilen, 321 template[i].ilen, iv);
315 aead_tv[i].iv);
316 322
317 aead_request_set_assoc(req, asg, aead_tv[i].alen); 323 aead_request_set_assoc(req, asg, template[i].alen);
318 324
319 ret = enc ? 325 ret = enc ?
320 crypto_aead_encrypt(req) : 326 crypto_aead_encrypt(req) :
@@ -335,15 +341,21 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
335 default: 341 default:
336 printk(KERN_INFO "%s () failed err=%d\n", 342 printk(KERN_INFO "%s () failed err=%d\n",
337 e, -ret); 343 e, -ret);
338 goto out; 344 goto next_one;
339 } 345 }
340 346
341 q = kmap(sg_page(&sg[0])) + sg[0].offset; 347 q = kmap(sg_page(&sg[0])) + sg[0].offset;
342 hexdump(q, aead_tv[i].rlen); 348 hexdump(q, template[i].rlen);
343 349
344 printk(KERN_INFO "enc/dec: %s\n", 350 printk(KERN_INFO "enc/dec: %s\n",
345 memcmp(q, aead_tv[i].result, 351 memcmp(q, template[i].result,
346 aead_tv[i].rlen) ? "fail" : "pass"); 352 template[i].rlen) ? "fail" : "pass");
353 kunmap(sg_page(&sg[0]));
354next_one:
355 if (!template[i].key)
356 kfree(key);
357 kfree(assoc);
358 kfree(input);
347 } 359 }
348 } 360 }
349 361
@@ -352,36 +364,41 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
352 memset(axbuf, 0, XBUFSIZE); 364 memset(axbuf, 0, XBUFSIZE);
353 365
354 for (i = 0, j = 0; i < tcount; i++) { 366 for (i = 0, j = 0; i < tcount; i++) {
355 if (aead_tv[i].np) { 367 if (template[i].np) {
356 printk(KERN_INFO "test %u (%d bit key):\n", 368 printk(KERN_INFO "test %u (%d bit key):\n",
357 ++j, aead_tv[i].klen * 8); 369 ++j, template[i].klen * 8);
370
371 if (template[i].iv)
372 memcpy(iv, template[i].iv, MAX_IVLEN);
373 else
374 memset(iv, 0, MAX_IVLEN);
358 375
359 crypto_aead_clear_flags(tfm, ~0); 376 crypto_aead_clear_flags(tfm, ~0);
360 if (aead_tv[i].wk) 377 if (template[i].wk)
361 crypto_aead_set_flags( 378 crypto_aead_set_flags(
362 tfm, CRYPTO_TFM_REQ_WEAK_KEY); 379 tfm, CRYPTO_TFM_REQ_WEAK_KEY);
363 key = aead_tv[i].key; 380 key = template[i].key;
364 381
365 ret = crypto_aead_setkey(tfm, key, aead_tv[i].klen); 382 ret = crypto_aead_setkey(tfm, key, template[i].klen);
366 if (ret) { 383 if (ret) {
367 printk(KERN_INFO "setkey() failed flags=%x\n", 384 printk(KERN_INFO "setkey() failed flags=%x\n",
368 crypto_aead_get_flags(tfm)); 385 crypto_aead_get_flags(tfm));
369 386
370 if (!aead_tv[i].fail) 387 if (!template[i].fail)
371 goto out; 388 goto out;
372 } 389 }
373 390
374 sg_init_table(sg, aead_tv[i].np); 391 sg_init_table(sg, template[i].np);
375 for (k = 0, temp = 0; k < aead_tv[i].np; k++) { 392 for (k = 0, temp = 0; k < template[i].np; k++) {
376 memcpy(&xbuf[IDX[k]], 393 memcpy(&xbuf[IDX[k]],
377 aead_tv[i].input + temp, 394 template[i].input + temp,
378 aead_tv[i].tap[k]); 395 template[i].tap[k]);
379 temp += aead_tv[i].tap[k]; 396 temp += template[i].tap[k];
380 sg_set_buf(&sg[k], &xbuf[IDX[k]], 397 sg_set_buf(&sg[k], &xbuf[IDX[k]],
381 aead_tv[i].tap[k]); 398 template[i].tap[k]);
382 } 399 }
383 400
384 authsize = abs(aead_tv[i].rlen - aead_tv[i].ilen); 401 authsize = abs(template[i].rlen - template[i].ilen);
385 ret = crypto_aead_setauthsize(tfm, authsize); 402 ret = crypto_aead_setauthsize(tfm, authsize);
386 if (ret) { 403 if (ret) {
387 printk(KERN_INFO 404 printk(KERN_INFO
@@ -393,21 +410,21 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
393 if (enc) 410 if (enc)
394 sg[k - 1].length += authsize; 411 sg[k - 1].length += authsize;
395 412
396 sg_init_table(asg, aead_tv[i].anp); 413 sg_init_table(asg, template[i].anp);
397 for (k = 0, temp = 0; k < aead_tv[i].anp; k++) { 414 for (k = 0, temp = 0; k < template[i].anp; k++) {
398 memcpy(&axbuf[IDX[k]], 415 memcpy(&axbuf[IDX[k]],
399 aead_tv[i].assoc + temp, 416 template[i].assoc + temp,
400 aead_tv[i].atap[k]); 417 template[i].atap[k]);
401 temp += aead_tv[i].atap[k]; 418 temp += template[i].atap[k];
402 sg_set_buf(&asg[k], &axbuf[IDX[k]], 419 sg_set_buf(&asg[k], &axbuf[IDX[k]],
403 aead_tv[i].atap[k]); 420 template[i].atap[k]);
404 } 421 }
405 422
406 aead_request_set_crypt(req, sg, sg, 423 aead_request_set_crypt(req, sg, sg,
407 aead_tv[i].ilen, 424 template[i].ilen,
408 aead_tv[i].iv); 425 iv);
409 426
410 aead_request_set_assoc(req, asg, aead_tv[i].alen); 427 aead_request_set_assoc(req, asg, template[i].alen);
411 428
412 ret = enc ? 429 ret = enc ?
413 crypto_aead_encrypt(req) : 430 crypto_aead_encrypt(req) :
@@ -431,18 +448,19 @@ static void test_aead(char *algo, int enc, struct aead_testvec *template,
431 goto out; 448 goto out;
432 } 449 }
433 450
434 for (k = 0, temp = 0; k < aead_tv[i].np; k++) { 451 for (k = 0, temp = 0; k < template[i].np; k++) {
435 printk(KERN_INFO "page %u\n", k); 452 printk(KERN_INFO "page %u\n", k);
436 q = kmap(sg_page(&sg[k])) + sg[k].offset; 453 q = kmap(sg_page(&sg[k])) + sg[k].offset;
437 hexdump(q, aead_tv[i].tap[k]); 454 hexdump(q, template[i].tap[k]);
438 printk(KERN_INFO "%s\n", 455 printk(KERN_INFO "%s\n",
439 memcmp(q, aead_tv[i].result + temp, 456 memcmp(q, template[i].result + temp,
440 aead_tv[i].tap[k] - 457 template[i].tap[k] -
441 (k < aead_tv[i].np - 1 || enc ? 458 (k < template[i].np - 1 || enc ?
442 0 : authsize)) ? 459 0 : authsize)) ?
443 "fail" : "pass"); 460 "fail" : "pass");
444 461
445 temp += aead_tv[i].tap[k]; 462 temp += template[i].tap[k];
463 kunmap(sg_page(&sg[k]));
446 } 464 }
447 } 465 }
448 } 466 }
@@ -456,15 +474,14 @@ static void test_cipher(char *algo, int enc,
456 struct cipher_testvec *template, unsigned int tcount) 474 struct cipher_testvec *template, unsigned int tcount)
457{ 475{
458 unsigned int ret, i, j, k, temp; 476 unsigned int ret, i, j, k, temp;
459 unsigned int tsize;
460 char *q; 477 char *q;
461 struct crypto_ablkcipher *tfm; 478 struct crypto_ablkcipher *tfm;
462 char *key;
463 struct cipher_testvec *cipher_tv;
464 struct ablkcipher_request *req; 479 struct ablkcipher_request *req;
465 struct scatterlist sg[8]; 480 struct scatterlist sg[8];
466 const char *e; 481 const char *e;
467 struct tcrypt_result result; 482 struct tcrypt_result result;
483 void *data;
484 char iv[MAX_IVLEN];
468 485
469 if (enc == ENCRYPT) 486 if (enc == ENCRYPT)
470 e = "encryption"; 487 e = "encryption";
@@ -473,16 +490,7 @@ static void test_cipher(char *algo, int enc,
473 490
474 printk("\ntesting %s %s\n", algo, e); 491 printk("\ntesting %s %s\n", algo, e);
475 492
476 tsize = sizeof (struct cipher_testvec);
477 if (tsize > TVMEMSIZE) {
478 printk("template (%u) too big for tvmem (%u)\n", tsize,
479 TVMEMSIZE);
480 return;
481 }
482 cipher_tv = (void *)tvmem;
483
484 init_completion(&result.completion); 493 init_completion(&result.completion);
485
486 tfm = crypto_alloc_ablkcipher(algo, 0, 0); 494 tfm = crypto_alloc_ablkcipher(algo, 0, 0);
487 495
488 if (IS_ERR(tfm)) { 496 if (IS_ERR(tfm)) {
@@ -502,35 +510,43 @@ static void test_cipher(char *algo, int enc,
502 510
503 j = 0; 511 j = 0;
504 for (i = 0; i < tcount; i++) { 512 for (i = 0; i < tcount; i++) {
505 memcpy(cipher_tv, &template[i], tsize); 513
506 if (!(cipher_tv->np)) { 514 data = kzalloc(template[i].ilen, GFP_KERNEL);
515 if (!data)
516 continue;
517
518 memcpy(data, template[i].input, template[i].ilen);
519 if (template[i].iv)
520 memcpy(iv, template[i].iv, MAX_IVLEN);
521 else
522 memset(iv, 0, MAX_IVLEN);
523
524 if (!(template[i].np)) {
507 j++; 525 j++;
508 printk("test %u (%d bit key):\n", 526 printk("test %u (%d bit key):\n",
509 j, cipher_tv->klen * 8); 527 j, template[i].klen * 8);
510 528
511 crypto_ablkcipher_clear_flags(tfm, ~0); 529 crypto_ablkcipher_clear_flags(tfm, ~0);
512 if (cipher_tv->wk) 530 if (template[i].wk)
513 crypto_ablkcipher_set_flags( 531 crypto_ablkcipher_set_flags(
514 tfm, CRYPTO_TFM_REQ_WEAK_KEY); 532 tfm, CRYPTO_TFM_REQ_WEAK_KEY);
515 key = cipher_tv->key;
516 533
517 ret = crypto_ablkcipher_setkey(tfm, key, 534 ret = crypto_ablkcipher_setkey(tfm, template[i].key,
518 cipher_tv->klen); 535 template[i].klen);
519 if (ret) { 536 if (ret) {
520 printk("setkey() failed flags=%x\n", 537 printk("setkey() failed flags=%x\n",
521 crypto_ablkcipher_get_flags(tfm)); 538 crypto_ablkcipher_get_flags(tfm));
522 539
523 if (!cipher_tv->fail) 540 if (!template[i].fail) {
541 kfree(data);
524 goto out; 542 goto out;
543 }
525 } 544 }
526 545
527 sg_init_one(&sg[0], cipher_tv->input, 546 sg_init_one(&sg[0], data, template[i].ilen);
528 cipher_tv->ilen);
529 547
530 ablkcipher_request_set_crypt(req, sg, sg, 548 ablkcipher_request_set_crypt(req, sg, sg,
531 cipher_tv->ilen, 549 template[i].ilen, iv);
532 cipher_tv->iv);
533
534 ret = enc ? 550 ret = enc ?
535 crypto_ablkcipher_encrypt(req) : 551 crypto_ablkcipher_encrypt(req) :
536 crypto_ablkcipher_decrypt(req); 552 crypto_ablkcipher_decrypt(req);
@@ -549,16 +565,19 @@ static void test_cipher(char *algo, int enc,
549 /* fall through */ 565 /* fall through */
550 default: 566 default:
551 printk("%s () failed err=%d\n", e, -ret); 567 printk("%s () failed err=%d\n", e, -ret);
568 kfree(data);
552 goto out; 569 goto out;
553 } 570 }
554 571
555 q = kmap(sg_page(&sg[0])) + sg[0].offset; 572 q = kmap(sg_page(&sg[0])) + sg[0].offset;
556 hexdump(q, cipher_tv->rlen); 573 hexdump(q, template[i].rlen);
557 574
558 printk("%s\n", 575 printk("%s\n",
559 memcmp(q, cipher_tv->result, 576 memcmp(q, template[i].result,
560 cipher_tv->rlen) ? "fail" : "pass"); 577 template[i].rlen) ? "fail" : "pass");
578 kunmap(sg_page(&sg[0]));
561 } 579 }
580 kfree(data);
562 } 581 }
563 582
564 printk("\ntesting %s %s across pages (chunking)\n", algo, e); 583 printk("\ntesting %s %s across pages (chunking)\n", algo, e);
@@ -566,42 +585,53 @@ static void test_cipher(char *algo, int enc,
566 585
567 j = 0; 586 j = 0;
568 for (i = 0; i < tcount; i++) { 587 for (i = 0; i < tcount; i++) {
569 memcpy(cipher_tv, &template[i], tsize); 588
570 if (cipher_tv->np) { 589 data = kzalloc(template[i].ilen, GFP_KERNEL);
590 if (!data)
591 continue;
592
593 memcpy(data, template[i].input, template[i].ilen);
594
595 if (template[i].iv)
596 memcpy(iv, template[i].iv, MAX_IVLEN);
597 else
598 memset(iv, 0, MAX_IVLEN);
599
600 if (template[i].np) {
571 j++; 601 j++;
572 printk("test %u (%d bit key):\n", 602 printk("test %u (%d bit key):\n",
573 j, cipher_tv->klen * 8); 603 j, template[i].klen * 8);
574 604
575 crypto_ablkcipher_clear_flags(tfm, ~0); 605 crypto_ablkcipher_clear_flags(tfm, ~0);
576 if (cipher_tv->wk) 606 if (template[i].wk)
577 crypto_ablkcipher_set_flags( 607 crypto_ablkcipher_set_flags(
578 tfm, CRYPTO_TFM_REQ_WEAK_KEY); 608 tfm, CRYPTO_TFM_REQ_WEAK_KEY);
579 key = cipher_tv->key;
580 609
581 ret = crypto_ablkcipher_setkey(tfm, key, 610 ret = crypto_ablkcipher_setkey(tfm, template[i].key,
582 cipher_tv->klen); 611 template[i].klen);
583 if (ret) { 612 if (ret) {
584 printk("setkey() failed flags=%x\n", 613 printk("setkey() failed flags=%x\n",
585 crypto_ablkcipher_get_flags(tfm)); 614 crypto_ablkcipher_get_flags(tfm));
586 615
587 if (!cipher_tv->fail) 616 if (!template[i].fail) {
617 kfree(data);
588 goto out; 618 goto out;
619 }
589 } 620 }
590 621
591 temp = 0; 622 temp = 0;
592 sg_init_table(sg, cipher_tv->np); 623 sg_init_table(sg, template[i].np);
593 for (k = 0; k < cipher_tv->np; k++) { 624 for (k = 0; k < template[i].np; k++) {
594 memcpy(&xbuf[IDX[k]], 625 memcpy(&xbuf[IDX[k]],
595 cipher_tv->input + temp, 626 template[i].input + temp,
596 cipher_tv->tap[k]); 627 template[i].tap[k]);
597 temp += cipher_tv->tap[k]; 628 temp += template[i].tap[k];
598 sg_set_buf(&sg[k], &xbuf[IDX[k]], 629 sg_set_buf(&sg[k], &xbuf[IDX[k]],
599 cipher_tv->tap[k]); 630 template[i].tap[k]);
600 } 631 }
601 632
602 ablkcipher_request_set_crypt(req, sg, sg, 633 ablkcipher_request_set_crypt(req, sg, sg,
603 cipher_tv->ilen, 634 template[i].ilen, iv);
604 cipher_tv->iv);
605 635
606 ret = enc ? 636 ret = enc ?
607 crypto_ablkcipher_encrypt(req) : 637 crypto_ablkcipher_encrypt(req) :
@@ -625,19 +655,19 @@ static void test_cipher(char *algo, int enc,
625 } 655 }
626 656
627 temp = 0; 657 temp = 0;
628 for (k = 0; k < cipher_tv->np; k++) { 658 for (k = 0; k < template[i].np; k++) {
629 printk("page %u\n", k); 659 printk("page %u\n", k);
630 q = kmap(sg_page(&sg[k])) + sg[k].offset; 660 q = kmap(sg_page(&sg[k])) + sg[k].offset;
631 hexdump(q, cipher_tv->tap[k]); 661 hexdump(q, template[i].tap[k]);
632 printk("%s\n", 662 printk("%s\n",
633 memcmp(q, cipher_tv->result + temp, 663 memcmp(q, template[i].result + temp,
634 cipher_tv->tap[k]) ? "fail" : 664 template[i].tap[k]) ? "fail" :
635 "pass"); 665 "pass");
636 temp += cipher_tv->tap[k]; 666 temp += template[i].tap[k];
667 kunmap(sg_page(&sg[k]));
637 } 668 }
638 } 669 }
639 } 670 }
640
641out: 671out:
642 crypto_free_ablkcipher(tfm); 672 crypto_free_ablkcipher(tfm);
643 ablkcipher_request_free(req); 673 ablkcipher_request_free(req);
@@ -721,15 +751,18 @@ out:
721 return ret; 751 return ret;
722} 752}
723 753
754static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 };
755
724static void test_cipher_speed(char *algo, int enc, unsigned int sec, 756static void test_cipher_speed(char *algo, int enc, unsigned int sec,
725 struct cipher_testvec *template, 757 struct cipher_testvec *template,
726 unsigned int tcount, struct cipher_speed *speed) 758 unsigned int tcount, u8 *keysize)
727{ 759{
728 unsigned int ret, i, j, iv_len; 760 unsigned int ret, i, j, iv_len;
729 unsigned char *key, *p, iv[128]; 761 unsigned char *key, *p, iv[128];
730 struct crypto_blkcipher *tfm; 762 struct crypto_blkcipher *tfm;
731 struct blkcipher_desc desc; 763 struct blkcipher_desc desc;
732 const char *e; 764 const char *e;
765 u32 *b_size;
733 766
734 if (enc == ENCRYPT) 767 if (enc == ENCRYPT)
735 e = "encryption"; 768 e = "encryption";
@@ -748,52 +781,60 @@ static void test_cipher_speed(char *algo, int enc, unsigned int sec,
748 desc.tfm = tfm; 781 desc.tfm = tfm;
749 desc.flags = 0; 782 desc.flags = 0;
750 783
751 for (i = 0; speed[i].klen != 0; i++) { 784 i = 0;
752 if ((speed[i].blen + speed[i].klen) > TVMEMSIZE) { 785 do {
753 printk("template (%u) too big for tvmem (%u)\n", 786
754 speed[i].blen + speed[i].klen, TVMEMSIZE); 787 b_size = block_sizes;
755 goto out; 788 do {
756 } 789
790 if ((*keysize + *b_size) > TVMEMSIZE) {
791 printk("template (%u) too big for tvmem (%u)\n",
792 *keysize + *b_size, TVMEMSIZE);
793 goto out;
794 }
757 795
758 printk("test %u (%d bit key, %d byte blocks): ", i, 796 printk("test %u (%d bit key, %d byte blocks): ", i,
759 speed[i].klen * 8, speed[i].blen); 797 *keysize * 8, *b_size);
760 798
761 memset(tvmem, 0xff, speed[i].klen + speed[i].blen); 799 memset(tvmem, 0xff, *keysize + *b_size);
762 800
763 /* set key, plain text and IV */ 801 /* set key, plain text and IV */
764 key = (unsigned char *)tvmem; 802 key = (unsigned char *)tvmem;
765 for (j = 0; j < tcount; j++) { 803 for (j = 0; j < tcount; j++) {
766 if (template[j].klen == speed[i].klen) { 804 if (template[j].klen == *keysize) {
767 key = template[j].key; 805 key = template[j].key;
768 break; 806 break;
807 }
769 } 808 }
770 } 809 p = (unsigned char *)tvmem + *keysize;
771 p = (unsigned char *)tvmem + speed[i].klen;
772 810
773 ret = crypto_blkcipher_setkey(tfm, key, speed[i].klen); 811 ret = crypto_blkcipher_setkey(tfm, key, *keysize);
774 if (ret) { 812 if (ret) {
775 printk("setkey() failed flags=%x\n", 813 printk("setkey() failed flags=%x\n",
776 crypto_blkcipher_get_flags(tfm)); 814 crypto_blkcipher_get_flags(tfm));
777 goto out; 815 goto out;
778 } 816 }
779 817
780 iv_len = crypto_blkcipher_ivsize(tfm); 818 iv_len = crypto_blkcipher_ivsize(tfm);
781 if (iv_len) { 819 if (iv_len) {
782 memset(&iv, 0xff, iv_len); 820 memset(&iv, 0xff, iv_len);
783 crypto_blkcipher_set_iv(tfm, iv, iv_len); 821 crypto_blkcipher_set_iv(tfm, iv, iv_len);
784 } 822 }
785 823
786 if (sec) 824 if (sec)
787 ret = test_cipher_jiffies(&desc, enc, p, speed[i].blen, 825 ret = test_cipher_jiffies(&desc, enc, p, *b_size, sec);
788 sec); 826 else
789 else 827 ret = test_cipher_cycles(&desc, enc, p, *b_size);
790 ret = test_cipher_cycles(&desc, enc, p, speed[i].blen);
791 828
792 if (ret) { 829 if (ret) {
793 printk("%s() failed flags=%x\n", e, desc.flags); 830 printk("%s() failed flags=%x\n", e, desc.flags);
794 break; 831 break;
795 } 832 }
796 } 833 b_size++;
834 i++;
835 } while (*b_size);
836 keysize++;
837 } while (*keysize);
797 838
798out: 839out:
799 crypto_free_blkcipher(tfm); 840 crypto_free_blkcipher(tfm);
@@ -1041,22 +1082,10 @@ static void test_comp(char *algo, struct comp_testvec *ctemplate,
1041 unsigned int i; 1082 unsigned int i;
1042 char result[COMP_BUF_SIZE]; 1083 char result[COMP_BUF_SIZE];
1043 struct crypto_comp *tfm; 1084 struct crypto_comp *tfm;
1044 struct comp_testvec *tv;
1045 unsigned int tsize; 1085 unsigned int tsize;
1046 1086
1047 printk("\ntesting %s compression\n", algo); 1087 printk("\ntesting %s compression\n", algo);
1048 1088
1049 tsize = sizeof(struct comp_testvec);
1050 tsize *= ctcount;
1051 if (tsize > TVMEMSIZE) {
1052 printk("template (%u) too big for tvmem (%u)\n", tsize,
1053 TVMEMSIZE);
1054 return;
1055 }
1056
1057 memcpy(tvmem, ctemplate, tsize);
1058 tv = (void *)tvmem;
1059
1060 tfm = crypto_alloc_comp(algo, 0, CRYPTO_ALG_ASYNC); 1089 tfm = crypto_alloc_comp(algo, 0, CRYPTO_ALG_ASYNC);
1061 if (IS_ERR(tfm)) { 1090 if (IS_ERR(tfm)) {
1062 printk("failed to load transform for %s\n", algo); 1091 printk("failed to load transform for %s\n", algo);
@@ -1069,8 +1098,8 @@ static void test_comp(char *algo, struct comp_testvec *ctemplate,
1069 printk("test %u:\n", i + 1); 1098 printk("test %u:\n", i + 1);
1070 memset(result, 0, sizeof (result)); 1099 memset(result, 0, sizeof (result));
1071 1100
1072 ilen = tv[i].inlen; 1101 ilen = ctemplate[i].inlen;
1073 ret = crypto_comp_compress(tfm, tv[i].input, 1102 ret = crypto_comp_compress(tfm, ctemplate[i].input,
1074 ilen, result, &dlen); 1103 ilen, result, &dlen);
1075 if (ret) { 1104 if (ret) {
1076 printk("fail: ret=%d\n", ret); 1105 printk("fail: ret=%d\n", ret);
@@ -1078,7 +1107,7 @@ static void test_comp(char *algo, struct comp_testvec *ctemplate,
1078 } 1107 }
1079 hexdump(result, dlen); 1108 hexdump(result, dlen);
1080 printk("%s (ratio %d:%d)\n", 1109 printk("%s (ratio %d:%d)\n",
1081 memcmp(result, tv[i].output, dlen) ? "fail" : "pass", 1110 memcmp(result, ctemplate[i].output, dlen) ? "fail" : "pass",
1082 ilen, dlen); 1111 ilen, dlen);
1083 } 1112 }
1084 1113
@@ -1092,17 +1121,14 @@ static void test_comp(char *algo, struct comp_testvec *ctemplate,
1092 goto out; 1121 goto out;
1093 } 1122 }
1094 1123
1095 memcpy(tvmem, dtemplate, tsize);
1096 tv = (void *)tvmem;
1097
1098 for (i = 0; i < dtcount; i++) { 1124 for (i = 0; i < dtcount; i++) {
1099 int ilen, ret, dlen = COMP_BUF_SIZE; 1125 int ilen, ret, dlen = COMP_BUF_SIZE;
1100 1126
1101 printk("test %u:\n", i + 1); 1127 printk("test %u:\n", i + 1);
1102 memset(result, 0, sizeof (result)); 1128 memset(result, 0, sizeof (result));
1103 1129
1104 ilen = tv[i].inlen; 1130 ilen = dtemplate[i].inlen;
1105 ret = crypto_comp_decompress(tfm, tv[i].input, 1131 ret = crypto_comp_decompress(tfm, dtemplate[i].input,
1106 ilen, result, &dlen); 1132 ilen, result, &dlen);
1107 if (ret) { 1133 if (ret) {
1108 printk("fail: ret=%d\n", ret); 1134 printk("fail: ret=%d\n", ret);
@@ -1110,7 +1136,7 @@ static void test_comp(char *algo, struct comp_testvec *ctemplate,
1110 } 1136 }
1111 hexdump(result, dlen); 1137 hexdump(result, dlen);
1112 printk("%s (ratio %d:%d)\n", 1138 printk("%s (ratio %d:%d)\n",
1113 memcmp(result, tv[i].output, dlen) ? "fail" : "pass", 1139 memcmp(result, dtemplate[i].output, dlen) ? "fail" : "pass",
1114 ilen, dlen); 1140 ilen, dlen);
1115 } 1141 }
1116out: 1142out:
@@ -1301,6 +1327,12 @@ static void do_test(void)
1301 test_cipher("ecb(seed)", DECRYPT, seed_dec_tv_template, 1327 test_cipher("ecb(seed)", DECRYPT, seed_dec_tv_template,
1302 SEED_DEC_TEST_VECTORS); 1328 SEED_DEC_TEST_VECTORS);
1303 1329
1330 //CTS
1331 test_cipher("cts(cbc(aes))", ENCRYPT, cts_mode_enc_tv_template,
1332 CTS_MODE_ENC_TEST_VECTORS);
1333 test_cipher("cts(cbc(aes))", DECRYPT, cts_mode_dec_tv_template,
1334 CTS_MODE_DEC_TEST_VECTORS);
1335
1304 test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS); 1336 test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
1305 test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS); 1337 test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
1306 test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS); 1338 test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS);
@@ -1584,6 +1616,13 @@ static void do_test(void)
1584 AES_CCM_DEC_TEST_VECTORS); 1616 AES_CCM_DEC_TEST_VECTORS);
1585 break; 1617 break;
1586 1618
1619 case 38:
1620 test_cipher("cts(cbc(aes))", ENCRYPT, cts_mode_enc_tv_template,
1621 CTS_MODE_ENC_TEST_VECTORS);
1622 test_cipher("cts(cbc(aes))", DECRYPT, cts_mode_dec_tv_template,
1623 CTS_MODE_DEC_TEST_VECTORS);
1624 break;
1625
1587 case 100: 1626 case 100:
1588 test_hash("hmac(md5)", hmac_md5_tv_template, 1627 test_hash("hmac(md5)", hmac_md5_tv_template,
1589 HMAC_MD5_TEST_VECTORS); 1628 HMAC_MD5_TEST_VECTORS);
@@ -1621,89 +1660,85 @@ static void do_test(void)
1621 1660
1622 case 200: 1661 case 200:
1623 test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, 1662 test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
1624 aes_speed_template); 1663 speed_template_16_24_32);
1625 test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0, 1664 test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
1626 aes_speed_template); 1665 speed_template_16_24_32);
1627 test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0, 1666 test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
1628 aes_speed_template); 1667 speed_template_16_24_32);
1629 test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, 1668 test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
1630 aes_speed_template); 1669 speed_template_16_24_32);
1631 test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, 1670 test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
1632 aes_lrw_speed_template); 1671 speed_template_32_40_48);
1633 test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, 1672 test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
1634 aes_lrw_speed_template); 1673 speed_template_32_40_48);
1635 test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0, 1674 test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
1636 aes_xts_speed_template); 1675 speed_template_32_48_64);
1637 test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0, 1676 test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
1638 aes_xts_speed_template); 1677 speed_template_32_48_64);
1639 break; 1678 break;
1640 1679
1641 case 201: 1680 case 201:
1642 test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec, 1681 test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec,
1643 des3_ede_enc_tv_template, 1682 des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS,
1644 DES3_EDE_ENC_TEST_VECTORS, 1683 speed_template_24);
1645 des3_ede_speed_template);
1646 test_cipher_speed("ecb(des3_ede)", DECRYPT, sec, 1684 test_cipher_speed("ecb(des3_ede)", DECRYPT, sec,
1647 des3_ede_dec_tv_template, 1685 des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS,
1648 DES3_EDE_DEC_TEST_VECTORS, 1686 speed_template_24);
1649 des3_ede_speed_template);
1650 test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec, 1687 test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec,
1651 des3_ede_enc_tv_template, 1688 des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS,
1652 DES3_EDE_ENC_TEST_VECTORS, 1689 speed_template_24);
1653 des3_ede_speed_template);
1654 test_cipher_speed("cbc(des3_ede)", DECRYPT, sec, 1690 test_cipher_speed("cbc(des3_ede)", DECRYPT, sec,
1655 des3_ede_dec_tv_template, 1691 des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS,
1656 DES3_EDE_DEC_TEST_VECTORS, 1692 speed_template_24);
1657 des3_ede_speed_template);
1658 break; 1693 break;
1659 1694
1660 case 202: 1695 case 202:
1661 test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0, 1696 test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
1662 twofish_speed_template); 1697 speed_template_16_24_32);
1663 test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0, 1698 test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
1664 twofish_speed_template); 1699 speed_template_16_24_32);
1665 test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0, 1700 test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
1666 twofish_speed_template); 1701 speed_template_16_24_32);
1667 test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0, 1702 test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
1668 twofish_speed_template); 1703 speed_template_16_24_32);
1669 break; 1704 break;
1670 1705
1671 case 203: 1706 case 203:
1672 test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0, 1707 test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
1673 blowfish_speed_template); 1708 speed_template_8_32);
1674 test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0, 1709 test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
1675 blowfish_speed_template); 1710 speed_template_8_32);
1676 test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0, 1711 test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
1677 blowfish_speed_template); 1712 speed_template_8_32);
1678 test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0, 1713 test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
1679 blowfish_speed_template); 1714 speed_template_8_32);
1680 break; 1715 break;
1681 1716
1682 case 204: 1717 case 204:
1683 test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0, 1718 test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
1684 des_speed_template); 1719 speed_template_8);
1685 test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0, 1720 test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
1686 des_speed_template); 1721 speed_template_8);
1687 test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0, 1722 test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
1688 des_speed_template); 1723 speed_template_8);
1689 test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0, 1724 test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
1690 des_speed_template); 1725 speed_template_8);
1691 break; 1726 break;
1692 1727
1693 case 205: 1728 case 205:
1694 test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0, 1729 test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
1695 camellia_speed_template); 1730 speed_template_16_24_32);
1696 test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0, 1731 test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
1697 camellia_speed_template); 1732 speed_template_16_24_32);
1698 test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0, 1733 test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
1699 camellia_speed_template); 1734 speed_template_16_24_32);
1700 test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0, 1735 test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
1701 camellia_speed_template); 1736 speed_template_16_24_32);
1702 break; 1737 break;
1703 1738
1704 case 206: 1739 case 206:
1705 test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0, 1740 test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0,
1706 salsa20_speed_template); 1741 speed_template_16_32);
1707 break; 1742 break;
1708 1743
1709 case 300: 1744 case 300:
@@ -1775,7 +1810,7 @@ static void do_test(void)
1775 } 1810 }
1776} 1811}
1777 1812
1778static int __init init(void) 1813static int __init tcrypt_mod_init(void)
1779{ 1814{
1780 int err = -ENOMEM; 1815 int err = -ENOMEM;
1781 1816
@@ -1814,10 +1849,10 @@ static int __init init(void)
1814 * If an init function is provided, an exit function must also be provided 1849 * If an init function is provided, an exit function must also be provided
1815 * to allow module unload. 1850 * to allow module unload.
1816 */ 1851 */
1817static void __exit fini(void) { } 1852static void __exit tcrypt_mod_fini(void) { }
1818 1853
1819module_init(init); 1854module_init(tcrypt_mod_init);
1820module_exit(fini); 1855module_exit(tcrypt_mod_fini);
1821 1856
1822module_param(mode, int, 0); 1857module_param(mode, int, 0);
1823module_param(sec, uint, 0); 1858module_param(sec, uint, 0);