tcrypt.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144
  1. /*
  2. * Quick & dirty crypto testing module.
  3. *
  4. * This will only exist until we have a better testing mechanism
  5. * (e.g. a char device).
  6. *
  7. * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
  8. * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the Free
  12. * Software Foundation; either version 2 of the License, or (at your option)
  13. * any later version.
  14. *
  15. * 2004-08-09 Added cipher speed tests (Reyk Floeter <reyk@vantronix.net>)
  16. * 2003-09-14 Rewritten by Kartikey Mahendra Bhatt
  17. *
  18. */
  19. #include <linux/init.h>
  20. #include <linux/module.h>
  21. #include <linux/mm.h>
  22. #include <linux/slab.h>
  23. #include <asm/scatterlist.h>
  24. #include <linux/string.h>
  25. #include <linux/crypto.h>
  26. #include <linux/highmem.h>
  27. #include <linux/moduleparam.h>
  28. #include <linux/jiffies.h>
  29. #include <linux/timex.h>
  30. #include <linux/interrupt.h>
  31. #include "tcrypt.h"
  32. /*
  33. * Need to kmalloc() memory for testing kmap().
  34. */
  35. #define TVMEMSIZE 16384
  36. #define XBUFSIZE 32768
  37. /*
  38. * Indexes into the xbuf to simulate cross-page access.
  39. */
  40. #define IDX1 37
  41. #define IDX2 32400
  42. #define IDX3 1
  43. #define IDX4 8193
  44. #define IDX5 22222
  45. #define IDX6 17101
  46. #define IDX7 27333
  47. #define IDX8 3000
  48. /*
  49. * Used by test_cipher()
  50. */
  51. #define ENCRYPT 1
  52. #define DECRYPT 0
  53. #define MODE_ECB 1
  54. #define MODE_CBC 0
  55. static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 };
  56. /*
  57. * Used by test_cipher_speed()
  58. */
  59. static unsigned int sec;
  60. static int mode;
  61. static char *xbuf;
  62. static char *tvmem;
  63. static char *check[] = {
  64. "des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish",
  65. "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6",
  66. "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
  67. "khazad", "wp512", "wp384", "wp256", "tnepres", NULL
  68. };
  69. static void hexdump(unsigned char *buf, unsigned int len)
  70. {
  71. while (len--)
  72. printk("%02x", *buf++);
  73. printk("\n");
  74. }
  75. static void test_hash(char *algo, struct hash_testvec *template,
  76. unsigned int tcount)
  77. {
  78. char *p;
  79. unsigned int i, j, k, temp;
  80. struct scatterlist sg[8];
  81. char result[64];
  82. struct crypto_tfm *tfm;
  83. struct hash_testvec *hash_tv;
  84. unsigned int tsize;
  85. printk("\ntesting %s\n", algo);
  86. tsize = sizeof(struct hash_testvec);
  87. tsize *= tcount;
  88. if (tsize > TVMEMSIZE) {
  89. printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE);
  90. return;
  91. }
  92. memcpy(tvmem, template, tsize);
  93. hash_tv = (void *)tvmem;
  94. tfm = crypto_alloc_tfm(algo, 0);
  95. if (tfm == NULL) {
  96. printk("failed to load transform for %s\n", algo);
  97. return;
  98. }
  99. for (i = 0; i < tcount; i++) {
  100. printk("test %u:\n", i + 1);
  101. memset(result, 0, 64);
  102. p = hash_tv[i].plaintext;
  103. sg[0].page = virt_to_page(p);
  104. sg[0].offset = offset_in_page(p);
  105. sg[0].length = hash_tv[i].psize;
  106. crypto_digest_init(tfm);
  107. if (tfm->crt_u.digest.dit_setkey) {
  108. crypto_digest_setkey(tfm, hash_tv[i].key,
  109. hash_tv[i].ksize);
  110. }
  111. crypto_digest_update(tfm, sg, 1);
  112. crypto_digest_final(tfm, result);
  113. hexdump(result, crypto_tfm_alg_digestsize(tfm));
  114. printk("%s\n",
  115. memcmp(result, hash_tv[i].digest,
  116. crypto_tfm_alg_digestsize(tfm)) ?
  117. "fail" : "pass");
  118. }
  119. printk("testing %s across pages\n", algo);
  120. /* setup the dummy buffer first */
  121. memset(xbuf, 0, XBUFSIZE);
  122. j = 0;
  123. for (i = 0; i < tcount; i++) {
  124. if (hash_tv[i].np) {
  125. j++;
  126. printk("test %u:\n", j);
  127. memset(result, 0, 64);
  128. temp = 0;
  129. for (k = 0; k < hash_tv[i].np; k++) {
  130. memcpy(&xbuf[IDX[k]],
  131. hash_tv[i].plaintext + temp,
  132. hash_tv[i].tap[k]);
  133. temp += hash_tv[i].tap[k];
  134. p = &xbuf[IDX[k]];
  135. sg[k].page = virt_to_page(p);
  136. sg[k].offset = offset_in_page(p);
  137. sg[k].length = hash_tv[i].tap[k];
  138. }
  139. crypto_digest_digest(tfm, sg, hash_tv[i].np, result);
  140. hexdump(result, crypto_tfm_alg_digestsize(tfm));
  141. printk("%s\n",
  142. memcmp(result, hash_tv[i].digest,
  143. crypto_tfm_alg_digestsize(tfm)) ?
  144. "fail" : "pass");
  145. }
  146. }
  147. crypto_free_tfm(tfm);
  148. }
  149. #ifdef CONFIG_CRYPTO_HMAC
  150. static void test_hmac(char *algo, struct hmac_testvec *template,
  151. unsigned int tcount)
  152. {
  153. char *p;
  154. unsigned int i, j, k, temp;
  155. struct scatterlist sg[8];
  156. char result[64];
  157. struct crypto_tfm *tfm;
  158. struct hmac_testvec *hmac_tv;
  159. unsigned int tsize, klen;
  160. tfm = crypto_alloc_tfm(algo, 0);
  161. if (tfm == NULL) {
  162. printk("failed to load transform for %s\n", algo);
  163. return;
  164. }
  165. printk("\ntesting hmac_%s\n", algo);
  166. tsize = sizeof(struct hmac_testvec);
  167. tsize *= tcount;
  168. if (tsize > TVMEMSIZE) {
  169. printk("template (%u) too big for tvmem (%u)\n", tsize,
  170. TVMEMSIZE);
  171. goto out;
  172. }
  173. memcpy(tvmem, template, tsize);
  174. hmac_tv = (void *)tvmem;
  175. for (i = 0; i < tcount; i++) {
  176. printk("test %u:\n", i + 1);
  177. memset(result, 0, sizeof (result));
  178. p = hmac_tv[i].plaintext;
  179. klen = hmac_tv[i].ksize;
  180. sg[0].page = virt_to_page(p);
  181. sg[0].offset = offset_in_page(p);
  182. sg[0].length = hmac_tv[i].psize;
  183. crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, 1, result);
  184. hexdump(result, crypto_tfm_alg_digestsize(tfm));
  185. printk("%s\n",
  186. memcmp(result, hmac_tv[i].digest,
  187. crypto_tfm_alg_digestsize(tfm)) ? "fail" :
  188. "pass");
  189. }
  190. printk("\ntesting hmac_%s across pages\n", algo);
  191. memset(xbuf, 0, XBUFSIZE);
  192. j = 0;
  193. for (i = 0; i < tcount; i++) {
  194. if (hmac_tv[i].np) {
  195. j++;
  196. printk("test %u:\n",j);
  197. memset(result, 0, 64);
  198. temp = 0;
  199. klen = hmac_tv[i].ksize;
  200. for (k = 0; k < hmac_tv[i].np; k++) {
  201. memcpy(&xbuf[IDX[k]],
  202. hmac_tv[i].plaintext + temp,
  203. hmac_tv[i].tap[k]);
  204. temp += hmac_tv[i].tap[k];
  205. p = &xbuf[IDX[k]];
  206. sg[k].page = virt_to_page(p);
  207. sg[k].offset = offset_in_page(p);
  208. sg[k].length = hmac_tv[i].tap[k];
  209. }
  210. crypto_hmac(tfm, hmac_tv[i].key, &klen, sg,
  211. hmac_tv[i].np, result);
  212. hexdump(result, crypto_tfm_alg_digestsize(tfm));
  213. printk("%s\n",
  214. memcmp(result, hmac_tv[i].digest,
  215. crypto_tfm_alg_digestsize(tfm)) ?
  216. "fail" : "pass");
  217. }
  218. }
  219. out:
  220. crypto_free_tfm(tfm);
  221. }
  222. #endif /* CONFIG_CRYPTO_HMAC */
  223. static void test_cipher(char *algo, int mode, int enc,
  224. struct cipher_testvec *template, unsigned int tcount)
  225. {
  226. unsigned int ret, i, j, k, temp;
  227. unsigned int tsize;
  228. char *p, *q;
  229. struct crypto_tfm *tfm;
  230. char *key;
  231. struct cipher_testvec *cipher_tv;
  232. struct scatterlist sg[8];
  233. const char *e, *m;
  234. if (enc == ENCRYPT)
  235. e = "encryption";
  236. else
  237. e = "decryption";
  238. if (mode == MODE_ECB)
  239. m = "ECB";
  240. else
  241. m = "CBC";
  242. printk("\ntesting %s %s %s\n", algo, m, e);
  243. tsize = sizeof (struct cipher_testvec);
  244. tsize *= tcount;
  245. if (tsize > TVMEMSIZE) {
  246. printk("template (%u) too big for tvmem (%u)\n", tsize,
  247. TVMEMSIZE);
  248. return;
  249. }
  250. memcpy(tvmem, template, tsize);
  251. cipher_tv = (void *)tvmem;
  252. if (mode)
  253. tfm = crypto_alloc_tfm(algo, 0);
  254. else
  255. tfm = crypto_alloc_tfm(algo, CRYPTO_TFM_MODE_CBC);
  256. if (tfm == NULL) {
  257. printk("failed to load transform for %s %s\n", algo, m);
  258. return;
  259. }
  260. j = 0;
  261. for (i = 0; i < tcount; i++) {
  262. if (!(cipher_tv[i].np)) {
  263. j++;
  264. printk("test %u (%d bit key):\n",
  265. j, cipher_tv[i].klen * 8);
  266. tfm->crt_flags = 0;
  267. if (cipher_tv[i].wk)
  268. tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY;
  269. key = cipher_tv[i].key;
  270. ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen);
  271. if (ret) {
  272. printk("setkey() failed flags=%x\n", tfm->crt_flags);
  273. if (!cipher_tv[i].fail)
  274. goto out;
  275. }
  276. p = cipher_tv[i].input;
  277. sg[0].page = virt_to_page(p);
  278. sg[0].offset = offset_in_page(p);
  279. sg[0].length = cipher_tv[i].ilen;
  280. if (!mode) {
  281. crypto_cipher_set_iv(tfm, cipher_tv[i].iv,
  282. crypto_tfm_alg_ivsize(tfm));
  283. }
  284. if (enc)
  285. ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen);
  286. else
  287. ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen);
  288. if (ret) {
  289. printk("%s () failed flags=%x\n", e, tfm->crt_flags);
  290. goto out;
  291. }
  292. q = kmap(sg[0].page) + sg[0].offset;
  293. hexdump(q, cipher_tv[i].rlen);
  294. printk("%s\n",
  295. memcmp(q, cipher_tv[i].result,
  296. cipher_tv[i].rlen) ? "fail" : "pass");
  297. }
  298. }
  299. printk("\ntesting %s %s %s across pages (chunking)\n", algo, m, e);
  300. memset(xbuf, 0, XBUFSIZE);
  301. j = 0;
  302. for (i = 0; i < tcount; i++) {
  303. if (cipher_tv[i].np) {
  304. j++;
  305. printk("test %u (%d bit key):\n",
  306. j, cipher_tv[i].klen * 8);
  307. tfm->crt_flags = 0;
  308. if (cipher_tv[i].wk)
  309. tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY;
  310. key = cipher_tv[i].key;
  311. ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen);
  312. if (ret) {
  313. printk("setkey() failed flags=%x\n", tfm->crt_flags);
  314. if (!cipher_tv[i].fail)
  315. goto out;
  316. }
  317. temp = 0;
  318. for (k = 0; k < cipher_tv[i].np; k++) {
  319. memcpy(&xbuf[IDX[k]],
  320. cipher_tv[i].input + temp,
  321. cipher_tv[i].tap[k]);
  322. temp += cipher_tv[i].tap[k];
  323. p = &xbuf[IDX[k]];
  324. sg[k].page = virt_to_page(p);
  325. sg[k].offset = offset_in_page(p);
  326. sg[k].length = cipher_tv[i].tap[k];
  327. }
  328. if (!mode) {
  329. crypto_cipher_set_iv(tfm, cipher_tv[i].iv,
  330. crypto_tfm_alg_ivsize(tfm));
  331. }
  332. if (enc)
  333. ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen);
  334. else
  335. ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen);
  336. if (ret) {
  337. printk("%s () failed flags=%x\n", e, tfm->crt_flags);
  338. goto out;
  339. }
  340. temp = 0;
  341. for (k = 0; k < cipher_tv[i].np; k++) {
  342. printk("page %u\n", k);
  343. q = kmap(sg[k].page) + sg[k].offset;
  344. hexdump(q, cipher_tv[i].tap[k]);
  345. printk("%s\n",
  346. memcmp(q, cipher_tv[i].result + temp,
  347. cipher_tv[i].tap[k]) ? "fail" :
  348. "pass");
  349. temp += cipher_tv[i].tap[k];
  350. }
  351. }
  352. }
  353. out:
  354. crypto_free_tfm(tfm);
  355. }
  356. static int test_cipher_jiffies(struct crypto_tfm *tfm, int enc, char *p,
  357. int blen, int sec)
  358. {
  359. struct scatterlist sg[8];
  360. unsigned long start, end;
  361. int bcount;
  362. int ret;
  363. sg[0].page = virt_to_page(p);
  364. sg[0].offset = offset_in_page(p);
  365. sg[0].length = blen;
  366. for (start = jiffies, end = start + sec * HZ, bcount = 0;
  367. time_before(jiffies, end); bcount++) {
  368. if (enc)
  369. ret = crypto_cipher_encrypt(tfm, sg, sg, blen);
  370. else
  371. ret = crypto_cipher_decrypt(tfm, sg, sg, blen);
  372. if (ret)
  373. return ret;
  374. }
  375. printk("%d operations in %d seconds (%ld bytes)\n",
  376. bcount, sec, (long)bcount * blen);
  377. return 0;
  378. }
  379. static int test_cipher_cycles(struct crypto_tfm *tfm, int enc, char *p,
  380. int blen)
  381. {
  382. struct scatterlist sg[8];
  383. unsigned long cycles = 0;
  384. int ret = 0;
  385. int i;
  386. sg[0].page = virt_to_page(p);
  387. sg[0].offset = offset_in_page(p);
  388. sg[0].length = blen;
  389. local_bh_disable();
  390. local_irq_disable();
  391. /* Warm-up run. */
  392. for (i = 0; i < 4; i++) {
  393. if (enc)
  394. ret = crypto_cipher_encrypt(tfm, sg, sg, blen);
  395. else
  396. ret = crypto_cipher_decrypt(tfm, sg, sg, blen);
  397. if (ret)
  398. goto out;
  399. }
  400. /* The real thing. */
  401. for (i = 0; i < 8; i++) {
  402. cycles_t start, end;
  403. start = get_cycles();
  404. if (enc)
  405. ret = crypto_cipher_encrypt(tfm, sg, sg, blen);
  406. else
  407. ret = crypto_cipher_decrypt(tfm, sg, sg, blen);
  408. end = get_cycles();
  409. if (ret)
  410. goto out;
  411. cycles += end - start;
  412. }
  413. out:
  414. local_irq_enable();
  415. local_bh_enable();
  416. if (ret == 0)
  417. printk("1 operation in %lu cycles (%d bytes)\n",
  418. (cycles + 4) / 8, blen);
  419. return ret;
  420. }
  421. static void test_cipher_speed(char *algo, int mode, int enc, unsigned int sec,
  422. struct cipher_testvec *template,
  423. unsigned int tcount, struct cipher_speed *speed)
  424. {
  425. unsigned int ret, i, j, iv_len;
  426. unsigned char *key, *p, iv[128];
  427. struct crypto_tfm *tfm;
  428. const char *e, *m;
  429. if (enc == ENCRYPT)
  430. e = "encryption";
  431. else
  432. e = "decryption";
  433. if (mode == MODE_ECB)
  434. m = "ECB";
  435. else
  436. m = "CBC";
  437. printk("\ntesting speed of %s %s %s\n", algo, m, e);
  438. if (mode)
  439. tfm = crypto_alloc_tfm(algo, 0);
  440. else
  441. tfm = crypto_alloc_tfm(algo, CRYPTO_TFM_MODE_CBC);
  442. if (tfm == NULL) {
  443. printk("failed to load transform for %s %s\n", algo, m);
  444. return;
  445. }
  446. for (i = 0; speed[i].klen != 0; i++) {
  447. if ((speed[i].blen + speed[i].klen) > TVMEMSIZE) {
  448. printk("template (%u) too big for tvmem (%u)\n",
  449. speed[i].blen + speed[i].klen, TVMEMSIZE);
  450. goto out;
  451. }
  452. printk("test %u (%d bit key, %d byte blocks): ", i,
  453. speed[i].klen * 8, speed[i].blen);
  454. memset(tvmem, 0xff, speed[i].klen + speed[i].blen);
  455. /* set key, plain text and IV */
  456. key = (unsigned char *)tvmem;
  457. for (j = 0; j < tcount; j++) {
  458. if (template[j].klen == speed[i].klen) {
  459. key = template[j].key;
  460. break;
  461. }
  462. }
  463. p = (unsigned char *)tvmem + speed[i].klen;
  464. ret = crypto_cipher_setkey(tfm, key, speed[i].klen);
  465. if (ret) {
  466. printk("setkey() failed flags=%x\n", tfm->crt_flags);
  467. goto out;
  468. }
  469. if (!mode) {
  470. iv_len = crypto_tfm_alg_ivsize(tfm);
  471. memset(&iv, 0xff, iv_len);
  472. crypto_cipher_set_iv(tfm, iv, iv_len);
  473. }
  474. if (sec)
  475. ret = test_cipher_jiffies(tfm, enc, p, speed[i].blen,
  476. sec);
  477. else
  478. ret = test_cipher_cycles(tfm, enc, p, speed[i].blen);
  479. if (ret) {
  480. printk("%s() failed flags=%x\n", e, tfm->crt_flags);
  481. break;
  482. }
  483. }
  484. out:
  485. crypto_free_tfm(tfm);
  486. }
  487. static void test_deflate(void)
  488. {
  489. unsigned int i;
  490. char result[COMP_BUF_SIZE];
  491. struct crypto_tfm *tfm;
  492. struct comp_testvec *tv;
  493. unsigned int tsize;
  494. printk("\ntesting deflate compression\n");
  495. tsize = sizeof (deflate_comp_tv_template);
  496. if (tsize > TVMEMSIZE) {
  497. printk("template (%u) too big for tvmem (%u)\n", tsize,
  498. TVMEMSIZE);
  499. return;
  500. }
  501. memcpy(tvmem, deflate_comp_tv_template, tsize);
  502. tv = (void *)tvmem;
  503. tfm = crypto_alloc_tfm("deflate", 0);
  504. if (tfm == NULL) {
  505. printk("failed to load transform for deflate\n");
  506. return;
  507. }
  508. for (i = 0; i < DEFLATE_COMP_TEST_VECTORS; i++) {
  509. int ilen, ret, dlen = COMP_BUF_SIZE;
  510. printk("test %u:\n", i + 1);
  511. memset(result, 0, sizeof (result));
  512. ilen = tv[i].inlen;
  513. ret = crypto_comp_compress(tfm, tv[i].input,
  514. ilen, result, &dlen);
  515. if (ret) {
  516. printk("fail: ret=%d\n", ret);
  517. continue;
  518. }
  519. hexdump(result, dlen);
  520. printk("%s (ratio %d:%d)\n",
  521. memcmp(result, tv[i].output, dlen) ? "fail" : "pass",
  522. ilen, dlen);
  523. }
  524. printk("\ntesting deflate decompression\n");
  525. tsize = sizeof (deflate_decomp_tv_template);
  526. if (tsize > TVMEMSIZE) {
  527. printk("template (%u) too big for tvmem (%u)\n", tsize,
  528. TVMEMSIZE);
  529. goto out;
  530. }
  531. memcpy(tvmem, deflate_decomp_tv_template, tsize);
  532. tv = (void *)tvmem;
  533. for (i = 0; i < DEFLATE_DECOMP_TEST_VECTORS; i++) {
  534. int ilen, ret, dlen = COMP_BUF_SIZE;
  535. printk("test %u:\n", i + 1);
  536. memset(result, 0, sizeof (result));
  537. ilen = tv[i].inlen;
  538. ret = crypto_comp_decompress(tfm, tv[i].input,
  539. ilen, result, &dlen);
  540. if (ret) {
  541. printk("fail: ret=%d\n", ret);
  542. continue;
  543. }
  544. hexdump(result, dlen);
  545. printk("%s (ratio %d:%d)\n",
  546. memcmp(result, tv[i].output, dlen) ? "fail" : "pass",
  547. ilen, dlen);
  548. }
  549. out:
  550. crypto_free_tfm(tfm);
  551. }
  552. static void test_crc32c(void)
  553. {
  554. #define NUMVEC 6
  555. #define VECSIZE 40
  556. int i, j, pass;
  557. u32 crc;
  558. u8 b, test_vec[NUMVEC][VECSIZE];
  559. static u32 vec_results[NUMVEC] = {
  560. 0x0e2c157f, 0xe980ebf6, 0xde74bded,
  561. 0xd579c862, 0xba979ad0, 0x2b29d913
  562. };
  563. static u32 tot_vec_results = 0x24c5d375;
  564. struct scatterlist sg[NUMVEC];
  565. struct crypto_tfm *tfm;
  566. char *fmtdata = "testing crc32c initialized to %08x: %s\n";
  567. #define SEEDTESTVAL 0xedcba987
  568. u32 seed;
  569. printk("\ntesting crc32c\n");
  570. tfm = crypto_alloc_tfm("crc32c", 0);
  571. if (tfm == NULL) {
  572. printk("failed to load transform for crc32c\n");
  573. return;
  574. }
  575. crypto_digest_init(tfm);
  576. crypto_digest_final(tfm, (u8*)&crc);
  577. printk(fmtdata, crc, (crc == 0) ? "pass" : "ERROR");
  578. /*
  579. * stuff test_vec with known values, simple incrementing
  580. * byte values.
  581. */
  582. b = 0;
  583. for (i = 0; i < NUMVEC; i++) {
  584. for (j = 0; j < VECSIZE; j++)
  585. test_vec[i][j] = ++b;
  586. sg[i].page = virt_to_page(test_vec[i]);
  587. sg[i].offset = offset_in_page(test_vec[i]);
  588. sg[i].length = VECSIZE;
  589. }
  590. seed = SEEDTESTVAL;
  591. (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32));
  592. crypto_digest_final(tfm, (u8*)&crc);
  593. printk("testing crc32c setkey returns %08x : %s\n", crc, (crc == (SEEDTESTVAL ^ ~(u32)0)) ?
  594. "pass" : "ERROR");
  595. printk("testing crc32c using update/final:\n");
  596. pass = 1; /* assume all is well */
  597. for (i = 0; i < NUMVEC; i++) {
  598. seed = ~(u32)0;
  599. (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32));
  600. crypto_digest_update(tfm, &sg[i], 1);
  601. crypto_digest_final(tfm, (u8*)&crc);
  602. if (crc == vec_results[i]) {
  603. printk(" %08x:OK", crc);
  604. } else {
  605. printk(" %08x:BAD, wanted %08x\n", crc, vec_results[i]);
  606. pass = 0;
  607. }
  608. }
  609. printk("\ntesting crc32c using incremental accumulator:\n");
  610. crc = 0;
  611. for (i = 0; i < NUMVEC; i++) {
  612. seed = (crc ^ ~(u32)0);
  613. (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32));
  614. crypto_digest_update(tfm, &sg[i], 1);
  615. crypto_digest_final(tfm, (u8*)&crc);
  616. }
  617. if (crc == tot_vec_results) {
  618. printk(" %08x:OK", crc);
  619. } else {
  620. printk(" %08x:BAD, wanted %08x\n", crc, tot_vec_results);
  621. pass = 0;
  622. }
  623. printk("\ntesting crc32c using digest:\n");
  624. seed = ~(u32)0;
  625. (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32));
  626. crypto_digest_digest(tfm, sg, NUMVEC, (u8*)&crc);
  627. if (crc == tot_vec_results) {
  628. printk(" %08x:OK", crc);
  629. } else {
  630. printk(" %08x:BAD, wanted %08x\n", crc, tot_vec_results);
  631. pass = 0;
  632. }
  633. printk("\n%s\n", pass ? "pass" : "ERROR");
  634. crypto_free_tfm(tfm);
  635. printk("crc32c test complete\n");
  636. }
  637. static void test_available(void)
  638. {
  639. char **name = check;
  640. while (*name) {
  641. printk("alg %s ", *name);
  642. printk((crypto_alg_available(*name, 0)) ?
  643. "found\n" : "not found\n");
  644. name++;
  645. }
  646. }
  647. static void do_test(void)
  648. {
  649. switch (mode) {
  650. case 0:
  651. test_hash("md5", md5_tv_template, MD5_TEST_VECTORS);
  652. test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS);
  653. //DES
  654. test_cipher ("des", MODE_ECB, ENCRYPT, des_enc_tv_template, DES_ENC_TEST_VECTORS);
  655. test_cipher ("des", MODE_ECB, DECRYPT, des_dec_tv_template, DES_DEC_TEST_VECTORS);
  656. test_cipher ("des", MODE_CBC, ENCRYPT, des_cbc_enc_tv_template, DES_CBC_ENC_TEST_VECTORS);
  657. test_cipher ("des", MODE_CBC, DECRYPT, des_cbc_dec_tv_template, DES_CBC_DEC_TEST_VECTORS);
  658. //DES3_EDE
  659. test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS);
  660. test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS);
  661. test_hash("md4", md4_tv_template, MD4_TEST_VECTORS);
  662. test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS);
  663. //BLOWFISH
  664. test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS);
  665. test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS);
  666. test_cipher ("blowfish", MODE_CBC, ENCRYPT, bf_cbc_enc_tv_template, BF_CBC_ENC_TEST_VECTORS);
  667. test_cipher ("blowfish", MODE_CBC, DECRYPT, bf_cbc_dec_tv_template, BF_CBC_DEC_TEST_VECTORS);
  668. //TWOFISH
  669. test_cipher ("twofish", MODE_ECB, ENCRYPT, tf_enc_tv_template, TF_ENC_TEST_VECTORS);
  670. test_cipher ("twofish", MODE_ECB, DECRYPT, tf_dec_tv_template, TF_DEC_TEST_VECTORS);
  671. test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS);
  672. test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS);
  673. //SERPENT
  674. test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS);
  675. test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS);
  676. //TNEPRES
  677. test_cipher ("tnepres", MODE_ECB, ENCRYPT, tnepres_enc_tv_template, TNEPRES_ENC_TEST_VECTORS);
  678. test_cipher ("tnepres", MODE_ECB, DECRYPT, tnepres_dec_tv_template, TNEPRES_DEC_TEST_VECTORS);
  679. //AES
  680. test_cipher ("aes", MODE_ECB, ENCRYPT, aes_enc_tv_template, AES_ENC_TEST_VECTORS);
  681. test_cipher ("aes", MODE_ECB, DECRYPT, aes_dec_tv_template, AES_DEC_TEST_VECTORS);
  682. //CAST5
  683. test_cipher ("cast5", MODE_ECB, ENCRYPT, cast5_enc_tv_template, CAST5_ENC_TEST_VECTORS);
  684. test_cipher ("cast5", MODE_ECB, DECRYPT, cast5_dec_tv_template, CAST5_DEC_TEST_VECTORS);
  685. //CAST6
  686. test_cipher ("cast6", MODE_ECB, ENCRYPT, cast6_enc_tv_template, CAST6_ENC_TEST_VECTORS);
  687. test_cipher ("cast6", MODE_ECB, DECRYPT, cast6_dec_tv_template, CAST6_DEC_TEST_VECTORS);
  688. //ARC4
  689. test_cipher ("arc4", MODE_ECB, ENCRYPT, arc4_enc_tv_template, ARC4_ENC_TEST_VECTORS);
  690. test_cipher ("arc4", MODE_ECB, DECRYPT, arc4_dec_tv_template, ARC4_DEC_TEST_VECTORS);
  691. //TEA
  692. test_cipher ("tea", MODE_ECB, ENCRYPT, tea_enc_tv_template, TEA_ENC_TEST_VECTORS);
  693. test_cipher ("tea", MODE_ECB, DECRYPT, tea_dec_tv_template, TEA_DEC_TEST_VECTORS);
  694. //XTEA
  695. test_cipher ("xtea", MODE_ECB, ENCRYPT, xtea_enc_tv_template, XTEA_ENC_TEST_VECTORS);
  696. test_cipher ("xtea", MODE_ECB, DECRYPT, xtea_dec_tv_template, XTEA_DEC_TEST_VECTORS);
  697. //KHAZAD
  698. test_cipher ("khazad", MODE_ECB, ENCRYPT, khazad_enc_tv_template, KHAZAD_ENC_TEST_VECTORS);
  699. test_cipher ("khazad", MODE_ECB, DECRYPT, khazad_dec_tv_template, KHAZAD_DEC_TEST_VECTORS);
  700. //ANUBIS
  701. test_cipher ("anubis", MODE_ECB, ENCRYPT, anubis_enc_tv_template, ANUBIS_ENC_TEST_VECTORS);
  702. test_cipher ("anubis", MODE_ECB, DECRYPT, anubis_dec_tv_template, ANUBIS_DEC_TEST_VECTORS);
  703. test_cipher ("anubis", MODE_CBC, ENCRYPT, anubis_cbc_enc_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
  704. test_cipher ("anubis", MODE_CBC, DECRYPT, anubis_cbc_dec_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
  705. test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
  706. test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
  707. test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS);
  708. test_hash("wp384", wp384_tv_template, WP384_TEST_VECTORS);
  709. test_hash("wp256", wp256_tv_template, WP256_TEST_VECTORS);
  710. test_hash("tgr192", tgr192_tv_template, TGR192_TEST_VECTORS);
  711. test_hash("tgr160", tgr160_tv_template, TGR160_TEST_VECTORS);
  712. test_hash("tgr128", tgr128_tv_template, TGR128_TEST_VECTORS);
  713. test_deflate();
  714. test_crc32c();
  715. #ifdef CONFIG_CRYPTO_HMAC
  716. test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS);
  717. test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS);
  718. test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS);
  719. #endif
  720. test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS);
  721. break;
  722. case 1:
  723. test_hash("md5", md5_tv_template, MD5_TEST_VECTORS);
  724. break;
  725. case 2:
  726. test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS);
  727. break;
  728. case 3:
  729. test_cipher ("des", MODE_ECB, ENCRYPT, des_enc_tv_template, DES_ENC_TEST_VECTORS);
  730. test_cipher ("des", MODE_ECB, DECRYPT, des_dec_tv_template, DES_DEC_TEST_VECTORS);
  731. test_cipher ("des", MODE_CBC, ENCRYPT, des_cbc_enc_tv_template, DES_CBC_ENC_TEST_VECTORS);
  732. test_cipher ("des", MODE_CBC, DECRYPT, des_cbc_dec_tv_template, DES_CBC_DEC_TEST_VECTORS);
  733. break;
  734. case 4:
  735. test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS);
  736. test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS);
  737. break;
  738. case 5:
  739. test_hash("md4", md4_tv_template, MD4_TEST_VECTORS);
  740. break;
  741. case 6:
  742. test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS);
  743. break;
  744. case 7:
  745. test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS);
  746. test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS);
  747. test_cipher ("blowfish", MODE_CBC, ENCRYPT, bf_cbc_enc_tv_template, BF_CBC_ENC_TEST_VECTORS);
  748. test_cipher ("blowfish", MODE_CBC, DECRYPT, bf_cbc_dec_tv_template, BF_CBC_DEC_TEST_VECTORS);
  749. break;
  750. case 8:
  751. test_cipher ("twofish", MODE_ECB, ENCRYPT, tf_enc_tv_template, TF_ENC_TEST_VECTORS);
  752. test_cipher ("twofish", MODE_ECB, DECRYPT, tf_dec_tv_template, TF_DEC_TEST_VECTORS);
  753. test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS);
  754. test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS);
  755. break;
  756. case 9:
  757. test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS);
  758. test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS);
  759. break;
  760. case 10:
  761. test_cipher ("aes", MODE_ECB, ENCRYPT, aes_enc_tv_template, AES_ENC_TEST_VECTORS);
  762. test_cipher ("aes", MODE_ECB, DECRYPT, aes_dec_tv_template, AES_DEC_TEST_VECTORS);
  763. break;
  764. case 11:
  765. test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
  766. break;
  767. case 12:
  768. test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
  769. break;
  770. case 13:
  771. test_deflate();
  772. break;
  773. case 14:
  774. test_cipher ("cast5", MODE_ECB, ENCRYPT, cast5_enc_tv_template, CAST5_ENC_TEST_VECTORS);
  775. test_cipher ("cast5", MODE_ECB, DECRYPT, cast5_dec_tv_template, CAST5_DEC_TEST_VECTORS);
  776. break;
  777. case 15:
  778. test_cipher ("cast6", MODE_ECB, ENCRYPT, cast6_enc_tv_template, CAST6_ENC_TEST_VECTORS);
  779. test_cipher ("cast6", MODE_ECB, DECRYPT, cast6_dec_tv_template, CAST6_DEC_TEST_VECTORS);
  780. break;
  781. case 16:
  782. test_cipher ("arc4", MODE_ECB, ENCRYPT, arc4_enc_tv_template, ARC4_ENC_TEST_VECTORS);
  783. test_cipher ("arc4", MODE_ECB, DECRYPT, arc4_dec_tv_template, ARC4_DEC_TEST_VECTORS);
  784. break;
  785. case 17:
  786. test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS);
  787. break;
  788. case 18:
  789. test_crc32c();
  790. break;
  791. case 19:
  792. test_cipher ("tea", MODE_ECB, ENCRYPT, tea_enc_tv_template, TEA_ENC_TEST_VECTORS);
  793. test_cipher ("tea", MODE_ECB, DECRYPT, tea_dec_tv_template, TEA_DEC_TEST_VECTORS);
  794. break;
  795. case 20:
  796. test_cipher ("xtea", MODE_ECB, ENCRYPT, xtea_enc_tv_template, XTEA_ENC_TEST_VECTORS);
  797. test_cipher ("xtea", MODE_ECB, DECRYPT, xtea_dec_tv_template, XTEA_DEC_TEST_VECTORS);
  798. break;
  799. case 21:
  800. test_cipher ("khazad", MODE_ECB, ENCRYPT, khazad_enc_tv_template, KHAZAD_ENC_TEST_VECTORS);
  801. test_cipher ("khazad", MODE_ECB, DECRYPT, khazad_dec_tv_template, KHAZAD_DEC_TEST_VECTORS);
  802. break;
  803. case 22:
  804. test_hash("wp512", wp512_tv_template, WP512_TEST_VECTORS);
  805. break;
  806. case 23:
  807. test_hash("wp384", wp384_tv_template, WP384_TEST_VECTORS);
  808. break;
  809. case 24:
  810. test_hash("wp256", wp256_tv_template, WP256_TEST_VECTORS);
  811. break;
  812. case 25:
  813. test_cipher ("tnepres", MODE_ECB, ENCRYPT, tnepres_enc_tv_template, TNEPRES_ENC_TEST_VECTORS);
  814. test_cipher ("tnepres", MODE_ECB, DECRYPT, tnepres_dec_tv_template, TNEPRES_DEC_TEST_VECTORS);
  815. break;
  816. case 26:
  817. test_cipher ("anubis", MODE_ECB, ENCRYPT, anubis_enc_tv_template, ANUBIS_ENC_TEST_VECTORS);
  818. test_cipher ("anubis", MODE_ECB, DECRYPT, anubis_dec_tv_template, ANUBIS_DEC_TEST_VECTORS);
  819. test_cipher ("anubis", MODE_CBC, ENCRYPT, anubis_cbc_enc_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
  820. test_cipher ("anubis", MODE_CBC, DECRYPT, anubis_cbc_dec_tv_template, ANUBIS_CBC_ENC_TEST_VECTORS);
  821. break;
  822. case 27:
  823. test_hash("tgr192", tgr192_tv_template, TGR192_TEST_VECTORS);
  824. break;
  825. case 28:
  826. test_hash("tgr160", tgr160_tv_template, TGR160_TEST_VECTORS);
  827. break;
  828. case 29:
  829. test_hash("tgr128", tgr128_tv_template, TGR128_TEST_VECTORS);
  830. break;
  831. #ifdef CONFIG_CRYPTO_HMAC
  832. case 100:
  833. test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS);
  834. break;
  835. case 101:
  836. test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS);
  837. break;
  838. case 102:
  839. test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS);
  840. break;
  841. #endif
  842. case 200:
  843. test_cipher_speed("aes", MODE_ECB, ENCRYPT, sec, NULL, 0,
  844. aes_speed_template);
  845. test_cipher_speed("aes", MODE_ECB, DECRYPT, sec, NULL, 0,
  846. aes_speed_template);
  847. test_cipher_speed("aes", MODE_CBC, ENCRYPT, sec, NULL, 0,
  848. aes_speed_template);
  849. test_cipher_speed("aes", MODE_CBC, DECRYPT, sec, NULL, 0,
  850. aes_speed_template);
  851. break;
  852. case 201:
  853. test_cipher_speed("des3_ede", MODE_ECB, ENCRYPT, sec,
  854. des3_ede_enc_tv_template,
  855. DES3_EDE_ENC_TEST_VECTORS,
  856. des3_ede_speed_template);
  857. test_cipher_speed("des3_ede", MODE_ECB, DECRYPT, sec,
  858. des3_ede_dec_tv_template,
  859. DES3_EDE_DEC_TEST_VECTORS,
  860. des3_ede_speed_template);
  861. test_cipher_speed("des3_ede", MODE_CBC, ENCRYPT, sec,
  862. des3_ede_enc_tv_template,
  863. DES3_EDE_ENC_TEST_VECTORS,
  864. des3_ede_speed_template);
  865. test_cipher_speed("des3_ede", MODE_CBC, DECRYPT, sec,
  866. des3_ede_dec_tv_template,
  867. DES3_EDE_DEC_TEST_VECTORS,
  868. des3_ede_speed_template);
  869. break;
  870. case 202:
  871. test_cipher_speed("twofish", MODE_ECB, ENCRYPT, sec, NULL, 0,
  872. twofish_speed_template);
  873. test_cipher_speed("twofish", MODE_ECB, DECRYPT, sec, NULL, 0,
  874. twofish_speed_template);
  875. test_cipher_speed("twofish", MODE_CBC, ENCRYPT, sec, NULL, 0,
  876. twofish_speed_template);
  877. test_cipher_speed("twofish", MODE_CBC, DECRYPT, sec, NULL, 0,
  878. twofish_speed_template);
  879. break;
  880. case 203:
  881. test_cipher_speed("blowfish", MODE_ECB, ENCRYPT, sec, NULL, 0,
  882. blowfish_speed_template);
  883. test_cipher_speed("blowfish", MODE_ECB, DECRYPT, sec, NULL, 0,
  884. blowfish_speed_template);
  885. test_cipher_speed("blowfish", MODE_CBC, ENCRYPT, sec, NULL, 0,
  886. blowfish_speed_template);
  887. test_cipher_speed("blowfish", MODE_CBC, DECRYPT, sec, NULL, 0,
  888. blowfish_speed_template);
  889. break;
  890. case 204:
  891. test_cipher_speed("des", MODE_ECB, ENCRYPT, sec, NULL, 0,
  892. des_speed_template);
  893. test_cipher_speed("des", MODE_ECB, DECRYPT, sec, NULL, 0,
  894. des_speed_template);
  895. test_cipher_speed("des", MODE_CBC, ENCRYPT, sec, NULL, 0,
  896. des_speed_template);
  897. test_cipher_speed("des", MODE_CBC, DECRYPT, sec, NULL, 0,
  898. des_speed_template);
  899. break;
  900. case 1000:
  901. test_available();
  902. break;
  903. default:
  904. /* useful for debugging */
  905. printk("not testing anything\n");
  906. break;
  907. }
  908. }
  909. static int __init init(void)
  910. {
  911. tvmem = kmalloc(TVMEMSIZE, GFP_KERNEL);
  912. if (tvmem == NULL)
  913. return -ENOMEM;
  914. xbuf = kmalloc(XBUFSIZE, GFP_KERNEL);
  915. if (xbuf == NULL) {
  916. kfree(tvmem);
  917. return -ENOMEM;
  918. }
  919. do_test();
  920. kfree(xbuf);
  921. kfree(tvmem);
  922. return 0;
  923. }
  924. /*
  925. * If an init function is provided, an exit function must also be provided
  926. * to allow module unload.
  927. */
  928. static void __exit fini(void) { }
  929. module_init(init);
  930. module_exit(fini);
  931. module_param(mode, int, 0);
  932. module_param(sec, uint, 0);
  933. MODULE_PARM_DESC(sec, "Length in seconds of speed tests "
  934. "(defaults to zero which uses CPU cycles instead)");
  935. MODULE_LICENSE("GPL");
  936. MODULE_DESCRIPTION("Quick & dirty crypto testing module");
  937. MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");