tcrypt.c 30 KB

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