x86_prof.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208
  1. #include <tomcrypt_test.h>
  2. prng_state yarrow_prng;
  3. struct list results[100];
  4. int no_results;
  5. int sorter(const void *a, const void *b)
  6. {
  7. const struct list *A, *B;
  8. A = a;
  9. B = b;
  10. if (A->avg < B->avg) return -1;
  11. if (A->avg > B->avg) return 1;
  12. return 0;
  13. }
  14. void tally_results(int type)
  15. {
  16. int x;
  17. // qsort the results
  18. qsort(results, no_results, sizeof(struct list), &sorter);
  19. fprintf(stderr, "\n");
  20. if (type == 0) {
  21. for (x = 0; x < no_results; x++) {
  22. fprintf(stderr, "%-20s: Schedule at %6lu\n", cipher_descriptor[results[x].id].name, (unsigned long)results[x].spd1);
  23. }
  24. } else if (type == 1) {
  25. for (x = 0; x < no_results; x++) {
  26. printf
  27. ("%-20s[%3d]: Encrypt at %5lu, Decrypt at %5lu\n", cipher_descriptor[results[x].id].name, cipher_descriptor[results[x].id].ID, results[x].spd1, results[x].spd2);
  28. }
  29. } else {
  30. for (x = 0; x < no_results; x++) {
  31. printf
  32. ("%-20s: Process at %5lu\n", hash_descriptor[results[x].id].name, results[x].spd1 / 1000);
  33. }
  34. }
  35. }
  36. /* RDTSC from Scott Duplichan */
  37. ulong64 rdtsc (void)
  38. {
  39. #if defined __GNUC__ && !defined(LTC_NO_ASM)
  40. #ifdef INTEL_CC
  41. ulong64 a;
  42. asm ( " rdtsc ":"=A"(a));
  43. return a;
  44. #elif defined(__i386__) || defined(__x86_64__)
  45. ulong64 a;
  46. asm __volatile__ ("rdtsc\nmovl %%eax,(%0)\nmovl %%edx,4(%0)\n"::"r"(&a):"%eax","%edx");
  47. return a;
  48. #elif defined(LTC_PPC32) || defined(TFM_PPC32)
  49. unsigned long a, b;
  50. __asm__ __volatile__ ("mftbu %1 \nmftb %0\n":"=r"(a), "=r"(b));
  51. return (((ulong64)b) << 32ULL) | ((ulong64)a);
  52. #elif defined(__ia64__) /* gcc-IA64 version */
  53. unsigned long result;
  54. __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
  55. while (__builtin_expect ((int) result == -1, 0))
  56. __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
  57. return result;
  58. #elif defined(__sparc__)
  59. #if defined(__arch64__)
  60. ulong64 a;
  61. asm volatile("rd %%tick,%0" : "=r" (a));
  62. return a;
  63. #else
  64. register unsigned long x, y;
  65. __asm__ __volatile__ ("rd %%tick, %0; clruw %0, %1; srlx %0, 32, %0" : "=r" (x), "=r" (y) : "0" (x), "1" (y));
  66. return ((unsigned long long) x << 32) | y;
  67. #endif
  68. #else
  69. return XCLOCK();
  70. #endif
  71. // Microsoft and Intel Windows compilers
  72. #elif defined _M_IX86 && !defined(LTC_NO_ASM)
  73. __asm rdtsc
  74. #elif defined _M_AMD64 && !defined(LTC_NO_ASM)
  75. return __rdtsc ();
  76. #elif defined _M_IA64 && !defined(LTC_NO_ASM)
  77. #if defined __INTEL_COMPILER
  78. #include <ia64intrin.h>
  79. #endif
  80. return __getReg (3116);
  81. #else
  82. return XCLOCK();
  83. #endif
  84. }
  85. static ulong64 timer, skew = 0;
  86. void t_start(void)
  87. {
  88. timer = rdtsc();
  89. }
  90. ulong64 t_read(void)
  91. {
  92. return rdtsc() - timer;
  93. }
  94. void init_timer(void)
  95. {
  96. ulong64 c1, c2, t1, t2, t3;
  97. unsigned long y1;
  98. c1 = c2 = (ulong64)-1;
  99. for (y1 = 0; y1 < TIMES*100; y1++) {
  100. t_start();
  101. t1 = t_read();
  102. t3 = t_read();
  103. t2 = (t_read() - t1)>>1;
  104. c1 = (t1 > c1) ? t1 : c1;
  105. c2 = (t2 > c2) ? t2 : c2;
  106. }
  107. skew = c2 - c1;
  108. fprintf(stderr, "Clock Skew: %lu\n", (unsigned long)skew);
  109. }
  110. void reg_algs(void)
  111. {
  112. int err;
  113. #ifdef RIJNDAEL
  114. register_cipher (&aes_desc);
  115. #endif
  116. #ifdef BLOWFISH
  117. register_cipher (&blowfish_desc);
  118. #endif
  119. #ifdef XTEA
  120. register_cipher (&xtea_desc);
  121. #endif
  122. #ifdef RC5
  123. register_cipher (&rc5_desc);
  124. #endif
  125. #ifdef RC6
  126. register_cipher (&rc6_desc);
  127. #endif
  128. #ifdef SAFERP
  129. register_cipher (&saferp_desc);
  130. #endif
  131. #ifdef TWOFISH
  132. register_cipher (&twofish_desc);
  133. #endif
  134. #ifdef SAFER
  135. register_cipher (&safer_k64_desc);
  136. register_cipher (&safer_sk64_desc);
  137. register_cipher (&safer_k128_desc);
  138. register_cipher (&safer_sk128_desc);
  139. #endif
  140. #ifdef RC2
  141. register_cipher (&rc2_desc);
  142. #endif
  143. #ifdef DES
  144. register_cipher (&des_desc);
  145. register_cipher (&des3_desc);
  146. #endif
  147. #ifdef CAST5
  148. register_cipher (&cast5_desc);
  149. #endif
  150. #ifdef NOEKEON
  151. register_cipher (&noekeon_desc);
  152. #endif
  153. #ifdef SKIPJACK
  154. register_cipher (&skipjack_desc);
  155. #endif
  156. #ifdef KHAZAD
  157. register_cipher (&khazad_desc);
  158. #endif
  159. #ifdef ANUBIS
  160. register_cipher (&anubis_desc);
  161. #endif
  162. #ifdef TIGER
  163. register_hash (&tiger_desc);
  164. #endif
  165. #ifdef MD2
  166. register_hash (&md2_desc);
  167. #endif
  168. #ifdef MD4
  169. register_hash (&md4_desc);
  170. #endif
  171. #ifdef MD5
  172. register_hash (&md5_desc);
  173. #endif
  174. #ifdef SHA1
  175. register_hash (&sha1_desc);
  176. #endif
  177. #ifdef SHA224
  178. register_hash (&sha224_desc);
  179. #endif
  180. #ifdef SHA256
  181. register_hash (&sha256_desc);
  182. #endif
  183. #ifdef SHA384
  184. register_hash (&sha384_desc);
  185. #endif
  186. #ifdef SHA512
  187. register_hash (&sha512_desc);
  188. #endif
  189. #ifdef RIPEMD128
  190. register_hash (&rmd128_desc);
  191. #endif
  192. #ifdef RIPEMD160
  193. register_hash (&rmd160_desc);
  194. #endif
  195. #ifdef WHIRLPOOL
  196. register_hash (&whirlpool_desc);
  197. #endif
  198. #ifdef CHC_HASH
  199. register_hash(&chc_desc);
  200. if ((err = chc_register(register_cipher(&aes_desc))) != CRYPT_OK) {
  201. fprintf(stderr, "chc_register error: %s\n", error_to_string(err));
  202. exit(EXIT_FAILURE);
  203. }
  204. #endif
  205. #ifndef YARROW
  206. #error This demo requires Yarrow.
  207. #endif
  208. register_prng(&yarrow_desc);
  209. #ifdef FORTUNA
  210. register_prng(&fortuna_desc);
  211. #endif
  212. #ifdef RC4
  213. register_prng(&rc4_desc);
  214. #endif
  215. #ifdef SOBER128
  216. register_prng(&sober128_desc);
  217. #endif
  218. if ((err = rng_make_prng(128, find_prng("yarrow"), &yarrow_prng, NULL)) != CRYPT_OK) {
  219. fprintf(stderr, "rng_make_prng failed: %s\n", error_to_string(err));
  220. exit(EXIT_FAILURE);
  221. }
  222. }
  223. int time_keysched(void)
  224. {
  225. unsigned long x, y1;
  226. ulong64 t1, c1;
  227. symmetric_key skey;
  228. int kl;
  229. int (*func) (const unsigned char *, int , int , symmetric_key *);
  230. unsigned char key[MAXBLOCKSIZE];
  231. fprintf(stderr, "\n\nKey Schedule Time Trials for the Symmetric Ciphers:\n(Times are cycles per key)\n");
  232. no_results = 0;
  233. for (x = 0; cipher_descriptor[x].name != NULL; x++) {
  234. #define DO1(k) func(k, kl, 0, &skey);
  235. func = cipher_descriptor[x].setup;
  236. kl = cipher_descriptor[x].min_key_length;
  237. c1 = (ulong64)-1;
  238. for (y1 = 0; y1 < KTIMES; y1++) {
  239. yarrow_read(key, kl, &yarrow_prng);
  240. t_start();
  241. DO1(key);
  242. t1 = t_read();
  243. c1 = (t1 > c1) ? c1 : t1;
  244. }
  245. t1 = c1 - skew;
  246. results[no_results].spd1 = results[no_results].avg = t1;
  247. results[no_results++].id = x;
  248. fprintf(stderr, "."); fflush(stdout);
  249. #undef DO1
  250. }
  251. tally_results(0);
  252. return 0;
  253. }
  254. int time_cipher(void)
  255. {
  256. unsigned long x, y1;
  257. ulong64 t1, t2, c1, c2, a1, a2;
  258. symmetric_ECB ecb;
  259. unsigned char key[MAXBLOCKSIZE], pt[4096];
  260. int err;
  261. fprintf(stderr, "\n\nECB Time Trials for the Symmetric Ciphers:\n");
  262. no_results = 0;
  263. for (x = 0; cipher_descriptor[x].name != NULL; x++) {
  264. ecb_start(x, key, cipher_descriptor[x].min_key_length, 0, &ecb);
  265. /* sanity check on cipher */
  266. if ((err = cipher_descriptor[x].test()) != CRYPT_OK) {
  267. fprintf(stderr, "\n\nERROR: Cipher %s failed self-test %s\n", cipher_descriptor[x].name, error_to_string(err));
  268. exit(EXIT_FAILURE);
  269. }
  270. #define DO1 ecb_encrypt(pt, pt, sizeof(pt), &ecb);
  271. #define DO2 DO1 DO1
  272. c1 = c2 = (ulong64)-1;
  273. for (y1 = 0; y1 < 100; y1++) {
  274. t_start();
  275. DO1;
  276. t1 = t_read();
  277. DO2;
  278. t2 = t_read();
  279. t2 -= t1;
  280. c1 = (t1 > c1 ? c1 : t1);
  281. c2 = (t2 > c2 ? c2 : t2);
  282. }
  283. a1 = c2 - c1 - skew;
  284. #undef DO1
  285. #undef DO2
  286. #define DO1 ecb_decrypt(pt, pt, sizeof(pt), &ecb);
  287. #define DO2 DO1 DO1
  288. c1 = c2 = (ulong64)-1;
  289. for (y1 = 0; y1 < 100; y1++) {
  290. t_start();
  291. DO1;
  292. t1 = t_read();
  293. DO2;
  294. t2 = t_read();
  295. t2 -= t1;
  296. c1 = (t1 > c1 ? c1 : t1);
  297. c2 = (t2 > c2 ? c2 : t2);
  298. }
  299. a2 = c2 - c1 - skew;
  300. ecb_done(&ecb);
  301. results[no_results].id = x;
  302. results[no_results].spd1 = a1/(sizeof(pt)/cipher_descriptor[x].block_length);
  303. results[no_results].spd2 = a2/(sizeof(pt)/cipher_descriptor[x].block_length);
  304. results[no_results].avg = (results[no_results].spd1 + results[no_results].spd2+1)/2;
  305. ++no_results;
  306. fprintf(stderr, "."); fflush(stdout);
  307. #undef DO2
  308. #undef DO1
  309. }
  310. tally_results(1);
  311. return 0;
  312. }
  313. #ifdef CBC
  314. int time_cipher2(void)
  315. {
  316. unsigned long x, y1;
  317. ulong64 t1, t2, c1, c2, a1, a2;
  318. symmetric_CBC cbc;
  319. unsigned char key[MAXBLOCKSIZE], pt[4096];
  320. int err;
  321. fprintf(stderr, "\n\nCBC Time Trials for the Symmetric Ciphers:\n");
  322. no_results = 0;
  323. for (x = 0; cipher_descriptor[x].name != NULL; x++) {
  324. cbc_start(x, pt, key, cipher_descriptor[x].min_key_length, 0, &cbc);
  325. /* sanity check on cipher */
  326. if ((err = cipher_descriptor[x].test()) != CRYPT_OK) {
  327. fprintf(stderr, "\n\nERROR: Cipher %s failed self-test %s\n", cipher_descriptor[x].name, error_to_string(err));
  328. exit(EXIT_FAILURE);
  329. }
  330. #define DO1 cbc_encrypt(pt, pt, sizeof(pt), &cbc);
  331. #define DO2 DO1 DO1
  332. c1 = c2 = (ulong64)-1;
  333. for (y1 = 0; y1 < 100; y1++) {
  334. t_start();
  335. DO1;
  336. t1 = t_read();
  337. DO2;
  338. t2 = t_read();
  339. t2 -= t1;
  340. c1 = (t1 > c1 ? c1 : t1);
  341. c2 = (t2 > c2 ? c2 : t2);
  342. }
  343. a1 = c2 - c1 - skew;
  344. #undef DO1
  345. #undef DO2
  346. #define DO1 cbc_decrypt(pt, pt, sizeof(pt), &cbc);
  347. #define DO2 DO1 DO1
  348. c1 = c2 = (ulong64)-1;
  349. for (y1 = 0; y1 < 100; y1++) {
  350. t_start();
  351. DO1;
  352. t1 = t_read();
  353. DO2;
  354. t2 = t_read();
  355. t2 -= t1;
  356. c1 = (t1 > c1 ? c1 : t1);
  357. c2 = (t2 > c2 ? c2 : t2);
  358. }
  359. a2 = c2 - c1 - skew;
  360. cbc_done(&cbc);
  361. results[no_results].id = x;
  362. results[no_results].spd1 = a1/(sizeof(pt)/cipher_descriptor[x].block_length);
  363. results[no_results].spd2 = a2/(sizeof(pt)/cipher_descriptor[x].block_length);
  364. results[no_results].avg = (results[no_results].spd1 + results[no_results].spd2+1)/2;
  365. ++no_results;
  366. fprintf(stderr, "."); fflush(stdout);
  367. #undef DO2
  368. #undef DO1
  369. }
  370. tally_results(1);
  371. return 0;
  372. }
  373. #else
  374. int time_cipher2(void) { fprintf(stderr, "NO CBC\n"); return 0; }
  375. #endif
  376. #ifdef CTR
  377. int time_cipher3(void)
  378. {
  379. unsigned long x, y1;
  380. ulong64 t1, t2, c1, c2, a1, a2;
  381. symmetric_CTR ctr;
  382. unsigned char key[MAXBLOCKSIZE], pt[4096];
  383. int err;
  384. fprintf(stderr, "\n\nCTR Time Trials for the Symmetric Ciphers:\n");
  385. no_results = 0;
  386. for (x = 0; cipher_descriptor[x].name != NULL; x++) {
  387. ctr_start(x, pt, key, cipher_descriptor[x].min_key_length, 0, CTR_COUNTER_LITTLE_ENDIAN, &ctr);
  388. /* sanity check on cipher */
  389. if ((err = cipher_descriptor[x].test()) != CRYPT_OK) {
  390. fprintf(stderr, "\n\nERROR: Cipher %s failed self-test %s\n", cipher_descriptor[x].name, error_to_string(err));
  391. exit(EXIT_FAILURE);
  392. }
  393. #define DO1 ctr_encrypt(pt, pt, sizeof(pt), &ctr);
  394. #define DO2 DO1 DO1
  395. c1 = c2 = (ulong64)-1;
  396. for (y1 = 0; y1 < 100; y1++) {
  397. t_start();
  398. DO1;
  399. t1 = t_read();
  400. DO2;
  401. t2 = t_read();
  402. t2 -= t1;
  403. c1 = (t1 > c1 ? c1 : t1);
  404. c2 = (t2 > c2 ? c2 : t2);
  405. }
  406. a1 = c2 - c1 - skew;
  407. #undef DO1
  408. #undef DO2
  409. #define DO1 ctr_decrypt(pt, pt, sizeof(pt), &ctr);
  410. #define DO2 DO1 DO1
  411. c1 = c2 = (ulong64)-1;
  412. for (y1 = 0; y1 < 100; y1++) {
  413. t_start();
  414. DO1;
  415. t1 = t_read();
  416. DO2;
  417. t2 = t_read();
  418. t2 -= t1;
  419. c1 = (t1 > c1 ? c1 : t1);
  420. c2 = (t2 > c2 ? c2 : t2);
  421. }
  422. a2 = c2 - c1 - skew;
  423. ctr_done(&ctr);
  424. results[no_results].id = x;
  425. results[no_results].spd1 = a1/(sizeof(pt)/cipher_descriptor[x].block_length);
  426. results[no_results].spd2 = a2/(sizeof(pt)/cipher_descriptor[x].block_length);
  427. results[no_results].avg = (results[no_results].spd1 + results[no_results].spd2+1)/2;
  428. ++no_results;
  429. fprintf(stderr, "."); fflush(stdout);
  430. #undef DO2
  431. #undef DO1
  432. }
  433. tally_results(1);
  434. return 0;
  435. }
  436. #else
  437. int time_cipher3(void) { fprintf(stderr, "NO CTR\n"); return 0; }
  438. #endif
  439. #ifdef LRW_MODE
  440. int time_cipher4(void)
  441. {
  442. unsigned long x, y1;
  443. ulong64 t1, t2, c1, c2, a1, a2;
  444. symmetric_LRW lrw;
  445. unsigned char key[MAXBLOCKSIZE], pt[4096];
  446. int err;
  447. fprintf(stderr, "\n\nLRW Time Trials for the Symmetric Ciphers:\n");
  448. no_results = 0;
  449. for (x = 0; cipher_descriptor[x].name != NULL; x++) {
  450. if (cipher_descriptor[x].block_length != 16) continue;
  451. lrw_start(x, pt, key, cipher_descriptor[x].min_key_length, key, 0, &lrw);
  452. /* sanity check on cipher */
  453. if ((err = cipher_descriptor[x].test()) != CRYPT_OK) {
  454. fprintf(stderr, "\n\nERROR: Cipher %s failed self-test %s\n", cipher_descriptor[x].name, error_to_string(err));
  455. exit(EXIT_FAILURE);
  456. }
  457. #define DO1 lrw_encrypt(pt, pt, sizeof(pt), &lrw);
  458. #define DO2 DO1 DO1
  459. c1 = c2 = (ulong64)-1;
  460. for (y1 = 0; y1 < 100; y1++) {
  461. t_start();
  462. DO1;
  463. t1 = t_read();
  464. DO2;
  465. t2 = t_read();
  466. t2 -= t1;
  467. c1 = (t1 > c1 ? c1 : t1);
  468. c2 = (t2 > c2 ? c2 : t2);
  469. }
  470. a1 = c2 - c1 - skew;
  471. #undef DO1
  472. #undef DO2
  473. #define DO1 lrw_decrypt(pt, pt, sizeof(pt), &lrw);
  474. #define DO2 DO1 DO1
  475. c1 = c2 = (ulong64)-1;
  476. for (y1 = 0; y1 < 100; y1++) {
  477. t_start();
  478. DO1;
  479. t1 = t_read();
  480. DO2;
  481. t2 = t_read();
  482. t2 -= t1;
  483. c1 = (t1 > c1 ? c1 : t1);
  484. c2 = (t2 > c2 ? c2 : t2);
  485. }
  486. a2 = c2 - c1 - skew;
  487. lrw_done(&lrw);
  488. results[no_results].id = x;
  489. results[no_results].spd1 = a1/(sizeof(pt)/cipher_descriptor[x].block_length);
  490. results[no_results].spd2 = a2/(sizeof(pt)/cipher_descriptor[x].block_length);
  491. results[no_results].avg = (results[no_results].spd1 + results[no_results].spd2+1)/2;
  492. ++no_results;
  493. fprintf(stderr, "."); fflush(stdout);
  494. #undef DO2
  495. #undef DO1
  496. }
  497. tally_results(1);
  498. return 0;
  499. }
  500. #else
  501. int time_cipher4(void) { fprintf(stderr, "NO LRW\n"); return 0; }
  502. #endif
  503. int time_hash(void)
  504. {
  505. unsigned long x, y1, len;
  506. ulong64 t1, t2, c1, c2;
  507. hash_state md;
  508. int (*func)(hash_state *, const unsigned char *, unsigned long), err;
  509. unsigned char pt[MAXBLOCKSIZE];
  510. fprintf(stderr, "\n\nHASH Time Trials for:\n");
  511. no_results = 0;
  512. for (x = 0; hash_descriptor[x].name != NULL; x++) {
  513. /* sanity check on hash */
  514. if ((err = hash_descriptor[x].test()) != CRYPT_OK) {
  515. fprintf(stderr, "\n\nERROR: Hash %s failed self-test %s\n", hash_descriptor[x].name, error_to_string(err));
  516. exit(EXIT_FAILURE);
  517. }
  518. hash_descriptor[x].init(&md);
  519. #define DO1 func(&md,pt,len);
  520. #define DO2 DO1 DO1
  521. func = hash_descriptor[x].process;
  522. len = hash_descriptor[x].blocksize;
  523. c1 = c2 = (ulong64)-1;
  524. for (y1 = 0; y1 < TIMES; y1++) {
  525. t_start();
  526. DO1;
  527. t1 = t_read();
  528. DO2;
  529. t2 = t_read() - t1;
  530. c1 = (t1 > c1) ? c1 : t1;
  531. c2 = (t2 > c2) ? c2 : t2;
  532. }
  533. t1 = c2 - c1 - skew;
  534. t1 = ((t1 * CONST64(1000))) / ((ulong64)hash_descriptor[x].blocksize);
  535. results[no_results].id = x;
  536. results[no_results].spd1 = results[no_results].avg = t1;
  537. ++no_results;
  538. fprintf(stderr, "."); fflush(stdout);
  539. #undef DO2
  540. #undef DO1
  541. }
  542. tally_results(2);
  543. return 0;
  544. }
  545. #undef MPI
  546. //#warning you need an mp_rand!!!
  547. #ifdef MPI
  548. void time_mult(void)
  549. {
  550. ulong64 t1, t2;
  551. unsigned long x, y;
  552. void *a, *b, *c;
  553. fprintf(stderr, "Timing Multiplying:\n");
  554. mp_init_multi(&a,&b,&c,NULL);
  555. for (x = 128/DIGIT_BIT; x <= 1536/DIGIT_BIT; x += 128/DIGIT_BIT) {
  556. mp_rand(&a, x);
  557. mp_rand(&b, x);
  558. #define DO1 mp_mul(&a, &b, &c);
  559. #define DO2 DO1; DO1;
  560. t2 = -1;
  561. for (y = 0; y < TIMES; y++) {
  562. t_start();
  563. t1 = t_read();
  564. DO2;
  565. t1 = (t_read() - t1)>>1;
  566. if (t1 < t2) t2 = t1;
  567. }
  568. fprintf(stderr, "%4lu bits: %9llu cycles\n", x*DIGIT_BIT, t2);
  569. }
  570. mp_clear_multi(&a,&b,&c,NULL);
  571. #undef DO1
  572. #undef DO2
  573. }
  574. void time_sqr(void)
  575. {
  576. ulong64 t1, t2;
  577. unsigned long x, y;
  578. mp_int a, b;
  579. fprintf(stderr, "Timing Squaring:\n");
  580. mp_init_multi(&a,&b,NULL);
  581. for (x = 128/DIGIT_BIT; x <= 1536/DIGIT_BIT; x += 128/DIGIT_BIT) {
  582. mp_rand(&a, x);
  583. #define DO1 mp_sqr(&a, &b);
  584. #define DO2 DO1; DO1;
  585. t2 = -1;
  586. for (y = 0; y < TIMES; y++) {
  587. t_start();
  588. t1 = t_read();
  589. DO2;
  590. t1 = (t_read() - t1)>>1;
  591. if (t1 < t2) t2 = t1;
  592. }
  593. fprintf(stderr, "%4lu bits: %9llu cycles\n", x*DIGIT_BIT, t2);
  594. }
  595. mp_clear_multi(&a,&b,NULL);
  596. #undef DO1
  597. #undef DO2
  598. }
  599. #else
  600. void time_mult(void) { fprintf(stderr, "NO MULT\n"); }
  601. void time_sqr(void) { fprintf(stderr, "NO SQR\n"); }
  602. #endif
  603. void time_prng(void)
  604. {
  605. ulong64 t1, t2;
  606. unsigned char buf[4096];
  607. prng_state tprng;
  608. unsigned long x, y;
  609. int err;
  610. fprintf(stderr, "Timing PRNGs (cycles/byte output, cycles add_entropy (32 bytes) :\n");
  611. for (x = 0; prng_descriptor[x].name != NULL; x++) {
  612. /* sanity check on prng */
  613. if ((err = prng_descriptor[x].test()) != CRYPT_OK) {
  614. fprintf(stderr, "\n\nERROR: PRNG %s failed self-test %s\n", prng_descriptor[x].name, error_to_string(err));
  615. exit(EXIT_FAILURE);
  616. }
  617. prng_descriptor[x].start(&tprng);
  618. zeromem(buf, 256);
  619. prng_descriptor[x].add_entropy(buf, 256, &tprng);
  620. prng_descriptor[x].ready(&tprng);
  621. t2 = -1;
  622. #define DO1 if (prng_descriptor[x].read(buf, 4096, &tprng) != 4096) { fprintf(stderr, "\n\nERROR READ != 4096\n\n"); exit(EXIT_FAILURE); }
  623. #define DO2 DO1 DO1
  624. for (y = 0; y < 10000; y++) {
  625. t_start();
  626. t1 = t_read();
  627. DO2;
  628. t1 = (t_read() - t1)>>1;
  629. if (t1 < t2) t2 = t1;
  630. }
  631. fprintf(stderr, "%20s: %5llu ", prng_descriptor[x].name, t2>>12);
  632. #undef DO2
  633. #undef DO1
  634. #define DO1 prng_descriptor[x].start(&tprng); prng_descriptor[x].add_entropy(buf, 32, &tprng); prng_descriptor[x].ready(&tprng); prng_descriptor[x].done(&tprng);
  635. #define DO2 DO1 DO1
  636. for (y = 0; y < 10000; y++) {
  637. t_start();
  638. t1 = t_read();
  639. DO2;
  640. t1 = (t_read() - t1)>>1;
  641. if (t1 < t2) t2 = t1;
  642. }
  643. fprintf(stderr, "%5llu\n", t2);
  644. #undef DO2
  645. #undef DO1
  646. }
  647. }
  648. #ifdef MRSA
  649. /* time various RSA operations */
  650. void time_rsa(void)
  651. {
  652. rsa_key key;
  653. ulong64 t1, t2;
  654. unsigned char buf[2][4096];
  655. unsigned long x, y, z, zzz;
  656. int err, zz;
  657. for (x = 1024; x <= 2048; x += 256) {
  658. t2 = 0;
  659. for (y = 0; y < 4; y++) {
  660. t_start();
  661. t1 = t_read();
  662. if ((err = rsa_make_key(&yarrow_prng, find_prng("yarrow"), x/8, 65537, &key)) != CRYPT_OK) {
  663. fprintf(stderr, "\n\nrsa_make_key says %s, wait...no it should say %s...damn you!\n", error_to_string(err), error_to_string(CRYPT_OK));
  664. exit(EXIT_FAILURE);
  665. }
  666. t1 = t_read() - t1;
  667. t2 += t1;
  668. if (y < 3) {
  669. rsa_free(&key);
  670. }
  671. }
  672. t2 >>= 2;
  673. fprintf(stderr, "RSA-%lu make_key took %15llu cycles\n", x, t2);
  674. t2 = 0;
  675. for (y = 0; y < 16; y++) {
  676. t_start();
  677. t1 = t_read();
  678. z = sizeof(buf[1]);
  679. if ((err = rsa_encrypt_key(buf[0], 32, buf[1], &z, "testprog", 8, &yarrow_prng,
  680. find_prng("yarrow"), find_hash("sha1"),
  681. &key)) != CRYPT_OK) {
  682. fprintf(stderr, "\n\nrsa_encrypt_key says %s, wait...no it should say %s...damn you!\n", error_to_string(err), error_to_string(CRYPT_OK));
  683. exit(EXIT_FAILURE);
  684. }
  685. t1 = t_read() - t1;
  686. t2 += t1;
  687. }
  688. t2 >>= 4;
  689. fprintf(stderr, "RSA-%lu encrypt_key took %15llu cycles\n", x, t2);
  690. t2 = 0;
  691. for (y = 0; y < 2048; y++) {
  692. t_start();
  693. t1 = t_read();
  694. zzz = sizeof(buf[0]);
  695. if ((err = rsa_decrypt_key(buf[1], z, buf[0], &zzz, "testprog", 8, find_hash("sha1"),
  696. &zz, &key)) != CRYPT_OK) {
  697. fprintf(stderr, "\n\nrsa_decrypt_key says %s, wait...no it should say %s...damn you!\n", error_to_string(err), error_to_string(CRYPT_OK));
  698. exit(EXIT_FAILURE);
  699. }
  700. t1 = t_read() - t1;
  701. t2 += t1;
  702. }
  703. t2 >>= 11;
  704. fprintf(stderr, "RSA-%lu decrypt_key took %15llu cycles\n", x, t2);
  705. rsa_free(&key);
  706. }
  707. }
  708. #else
  709. void time_rsa(void) { fprintf(stderr, "NO RSA\n"); }
  710. #endif
  711. #ifdef MKAT
  712. /* time various KAT operations */
  713. void time_katja(void)
  714. {
  715. katja_key key;
  716. ulong64 t1, t2;
  717. unsigned char buf[2][4096];
  718. unsigned long x, y, z, zzz;
  719. int err, zz;
  720. for (x = 1024; x <= 2048; x += 256) {
  721. t2 = 0;
  722. for (y = 0; y < 4; y++) {
  723. t_start();
  724. t1 = t_read();
  725. if ((err = katja_make_key(&yarrow_prng, find_prng("yarrow"), x/8, &key)) != CRYPT_OK) {
  726. fprintf(stderr, "\n\nkatja_make_key says %s, wait...no it should say %s...damn you!\n", error_to_string(err), error_to_string(CRYPT_OK));
  727. exit(EXIT_FAILURE);
  728. }
  729. t1 = t_read() - t1;
  730. t2 += t1;
  731. if (y < 3) {
  732. rsa_free(&key);
  733. }
  734. }
  735. t2 >>= 2;
  736. fprintf(stderr, "Katja-%lu make_key took %15llu cycles\n", x, t2);
  737. t2 = 0;
  738. for (y = 0; y < 16; y++) {
  739. t_start();
  740. t1 = t_read();
  741. z = sizeof(buf[1]);
  742. if ((err = katja_encrypt_key(buf[0], 32, buf[1], &z, "testprog", 8, &yarrow_prng,
  743. find_prng("yarrow"), find_hash("sha1"),
  744. &key)) != CRYPT_OK) {
  745. fprintf(stderr, "\n\nkatja_encrypt_key says %s, wait...no it should say %s...damn you!\n", error_to_string(err), error_to_string(CRYPT_OK));
  746. exit(EXIT_FAILURE);
  747. }
  748. t1 = t_read() - t1;
  749. t2 += t1;
  750. }
  751. t2 >>= 4;
  752. fprintf(stderr, "Katja-%lu encrypt_key took %15llu cycles\n", x, t2);
  753. t2 = 0;
  754. for (y = 0; y < 2048; y++) {
  755. t_start();
  756. t1 = t_read();
  757. zzz = sizeof(buf[0]);
  758. if ((err = katja_decrypt_key(buf[1], z, buf[0], &zzz, "testprog", 8, find_hash("sha1"),
  759. &zz, &key)) != CRYPT_OK) {
  760. fprintf(stderr, "\n\nkatja_decrypt_key says %s, wait...no it should say %s...damn you!\n", error_to_string(err), error_to_string(CRYPT_OK));
  761. exit(EXIT_FAILURE);
  762. }
  763. t1 = t_read() - t1;
  764. t2 += t1;
  765. }
  766. t2 >>= 11;
  767. fprintf(stderr, "Katja-%lu decrypt_key took %15llu cycles\n", x, t2);
  768. katja_free(&key);
  769. }
  770. }
  771. #else
  772. void time_katja(void) { fprintf(stderr, "NO Katja\n"); }
  773. #endif
  774. #ifdef MECC
  775. /* time various ECC operations */
  776. void time_ecc(void)
  777. {
  778. ecc_key key;
  779. ulong64 t1, t2;
  780. unsigned char buf[2][4096];
  781. unsigned long i, x, y, z;
  782. int err;
  783. static unsigned long sizes[] = {
  784. #ifdef ECC192
  785. 192/8,
  786. #endif
  787. #ifdef ECC224
  788. 224/8,
  789. #endif
  790. #ifdef ECC256
  791. 256/8,
  792. #endif
  793. #ifdef ECC384
  794. 384/8,
  795. #endif
  796. #ifdef ECC521
  797. 521/8,
  798. #endif
  799. 100000};
  800. for (x = sizes[i=0]; x < 100000; x = sizes[++i]) {
  801. t2 = 0;
  802. for (y = 0; y < 64; y++) {
  803. t_start();
  804. t1 = t_read();
  805. if ((err = ecc_make_key(&yarrow_prng, find_prng("yarrow"), x, &key)) != CRYPT_OK) {
  806. fprintf(stderr, "\n\necc_make_key says %s, wait...no it should say %s...damn you!\n", error_to_string(err), error_to_string(CRYPT_OK));
  807. exit(EXIT_FAILURE);
  808. }
  809. t1 = t_read() - t1;
  810. t2 += t1;
  811. if (y < 63) {
  812. ecc_free(&key);
  813. }
  814. }
  815. t2 >>= 6;
  816. fprintf(stderr, "ECC-%lu make_key took %15llu cycles\n", x*8, t2);
  817. t2 = 0;
  818. for (y = 0; y < 16; y++) {
  819. t_start();
  820. t1 = t_read();
  821. z = sizeof(buf[1]);
  822. if ((err = ecc_encrypt_key(buf[0], 20, buf[1], &z, &yarrow_prng, find_prng("yarrow"), find_hash("sha1"),
  823. &key)) != CRYPT_OK) {
  824. fprintf(stderr, "\n\necc_encrypt_key says %s, wait...no it should say %s...damn you!\n", error_to_string(err), error_to_string(CRYPT_OK));
  825. exit(EXIT_FAILURE);
  826. }
  827. t1 = t_read() - t1;
  828. t2 += t1;
  829. }
  830. t2 >>= 4;
  831. fprintf(stderr, "ECC-%lu encrypt_key took %15llu cycles\n", x*8, t2);
  832. ecc_free(&key);
  833. }
  834. }
  835. #else
  836. void time_ecc(void) { fprintf(stderr, "NO ECC\n"); }
  837. #endif
  838. void time_macs_(unsigned long MAC_SIZE)
  839. {
  840. unsigned char *buf, key[16], tag[16];
  841. ulong64 t1, t2;
  842. unsigned long x, z;
  843. int err, cipher_idx, hash_idx;
  844. fprintf(stderr, "\nMAC Timings (cycles/byte on %luKB blocks):\n", MAC_SIZE);
  845. buf = XMALLOC(MAC_SIZE*1024);
  846. if (buf == NULL) {
  847. fprintf(stderr, "\n\nout of heap yo\n\n");
  848. exit(EXIT_FAILURE);
  849. }
  850. cipher_idx = find_cipher("aes");
  851. hash_idx = find_hash("sha1");
  852. if (cipher_idx == -1 || hash_idx == -1) {
  853. fprintf(stderr, "Warning the MAC tests requires AES and SHA1 to operate... so sorry\n");
  854. return;
  855. }
  856. yarrow_read(buf, MAC_SIZE*1024, &yarrow_prng);
  857. yarrow_read(key, 16, &yarrow_prng);
  858. #ifdef OMAC
  859. t2 = -1;
  860. for (x = 0; x < 10000; x++) {
  861. t_start();
  862. t1 = t_read();
  863. z = 16;
  864. if ((err = omac_memory(cipher_idx, key, 16, buf, MAC_SIZE*1024, tag, &z)) != CRYPT_OK) {
  865. fprintf(stderr, "\n\nomac error... %s\n", error_to_string(err));
  866. exit(EXIT_FAILURE);
  867. }
  868. t1 = t_read() - t1;
  869. if (t1 < t2) t2 = t1;
  870. }
  871. fprintf(stderr, "OMAC-%s\t\t%9llu\n", cipher_descriptor[cipher_idx].name, t2/(ulong64)(MAC_SIZE*1024));
  872. #endif
  873. #ifdef PMAC
  874. t2 = -1;
  875. for (x = 0; x < 10000; x++) {
  876. t_start();
  877. t1 = t_read();
  878. z = 16;
  879. if ((err = pmac_memory(cipher_idx, key, 16, buf, MAC_SIZE*1024, tag, &z)) != CRYPT_OK) {
  880. fprintf(stderr, "\n\npmac error... %s\n", error_to_string(err));
  881. exit(EXIT_FAILURE);
  882. }
  883. t1 = t_read() - t1;
  884. if (t1 < t2) t2 = t1;
  885. }
  886. fprintf(stderr, "PMAC-AES\t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
  887. #endif
  888. #ifdef PELICAN
  889. t2 = -1;
  890. for (x = 0; x < 10000; x++) {
  891. t_start();
  892. t1 = t_read();
  893. z = 16;
  894. if ((err = pelican_memory(key, 16, buf, MAC_SIZE*1024, tag)) != CRYPT_OK) {
  895. fprintf(stderr, "\n\npelican error... %s\n", error_to_string(err));
  896. exit(EXIT_FAILURE);
  897. }
  898. t1 = t_read() - t1;
  899. if (t1 < t2) t2 = t1;
  900. }
  901. fprintf(stderr, "PELICAN \t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
  902. #endif
  903. #ifdef HMAC
  904. t2 = -1;
  905. for (x = 0; x < 10000; x++) {
  906. t_start();
  907. t1 = t_read();
  908. z = 16;
  909. if ((err = hmac_memory(hash_idx, key, 16, buf, MAC_SIZE*1024, tag, &z)) != CRYPT_OK) {
  910. fprintf(stderr, "\n\nhmac error... %s\n", error_to_string(err));
  911. exit(EXIT_FAILURE);
  912. }
  913. t1 = t_read() - t1;
  914. if (t1 < t2) t2 = t1;
  915. }
  916. fprintf(stderr, "HMAC-%s\t\t%9llu\n", hash_descriptor[hash_idx].name, t2/(ulong64)(MAC_SIZE*1024));
  917. #endif
  918. XFREE(buf);
  919. }
  920. void time_macs(void)
  921. {
  922. time_macs_(1);
  923. time_macs_(4);
  924. time_macs_(32);
  925. }
  926. void time_encmacs_(unsigned long MAC_SIZE)
  927. {
  928. unsigned char *buf, IV[16], key[16], tag[16];
  929. ulong64 t1, t2;
  930. unsigned long x, z;
  931. int err, cipher_idx;
  932. symmetric_key skey;
  933. fprintf(stderr, "\nENC+MAC Timings (zero byte AAD, 16 byte IV, cycles/byte on %luKB blocks):\n", MAC_SIZE);
  934. buf = XMALLOC(MAC_SIZE*1024);
  935. if (buf == NULL) {
  936. fprintf(stderr, "\n\nout of heap yo\n\n");
  937. exit(EXIT_FAILURE);
  938. }
  939. cipher_idx = find_cipher("aes");
  940. yarrow_read(buf, MAC_SIZE*1024, &yarrow_prng);
  941. yarrow_read(key, 16, &yarrow_prng);
  942. yarrow_read(IV, 16, &yarrow_prng);
  943. #ifdef EAX_MODE
  944. t2 = -1;
  945. for (x = 0; x < 10000; x++) {
  946. t_start();
  947. t1 = t_read();
  948. z = 16;
  949. if ((err = eax_encrypt_authenticate_memory(cipher_idx, key, 16, IV, 16, NULL, 0, buf, MAC_SIZE*1024, buf, tag, &z)) != CRYPT_OK) {
  950. fprintf(stderr, "\nEAX error... %s\n", error_to_string(err));
  951. exit(EXIT_FAILURE);
  952. }
  953. t1 = t_read() - t1;
  954. if (t1 < t2) t2 = t1;
  955. }
  956. fprintf(stderr, "EAX \t\t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
  957. #endif
  958. #ifdef OCB_MODE
  959. t2 = -1;
  960. for (x = 0; x < 10000; x++) {
  961. t_start();
  962. t1 = t_read();
  963. z = 16;
  964. if ((err = ocb_encrypt_authenticate_memory(cipher_idx, key, 16, IV, buf, MAC_SIZE*1024, buf, tag, &z)) != CRYPT_OK) {
  965. fprintf(stderr, "\nOCB error... %s\n", error_to_string(err));
  966. exit(EXIT_FAILURE);
  967. }
  968. t1 = t_read() - t1;
  969. if (t1 < t2) t2 = t1;
  970. }
  971. fprintf(stderr, "OCB \t\t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
  972. #endif
  973. #ifdef CCM_MODE
  974. t2 = -1;
  975. for (x = 0; x < 10000; x++) {
  976. t_start();
  977. t1 = t_read();
  978. z = 16;
  979. if ((err = ccm_memory(cipher_idx, key, 16, NULL, IV, 16, NULL, 0, buf, MAC_SIZE*1024, buf, tag, &z, CCM_ENCRYPT)) != CRYPT_OK) {
  980. fprintf(stderr, "\nCCM error... %s\n", error_to_string(err));
  981. exit(EXIT_FAILURE);
  982. }
  983. t1 = t_read() - t1;
  984. if (t1 < t2) t2 = t1;
  985. }
  986. fprintf(stderr, "CCM (no-precomp) \t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
  987. cipher_descriptor[cipher_idx].setup(key, 16, 0, &skey);
  988. t2 = -1;
  989. for (x = 0; x < 10000; x++) {
  990. t_start();
  991. t1 = t_read();
  992. z = 16;
  993. if ((err = ccm_memory(cipher_idx, key, 16, &skey, IV, 16, NULL, 0, buf, MAC_SIZE*1024, buf, tag, &z, CCM_ENCRYPT)) != CRYPT_OK) {
  994. fprintf(stderr, "\nCCM error... %s\n", error_to_string(err));
  995. exit(EXIT_FAILURE);
  996. }
  997. t1 = t_read() - t1;
  998. if (t1 < t2) t2 = t1;
  999. }
  1000. fprintf(stderr, "CCM (precomp) \t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
  1001. cipher_descriptor[cipher_idx].done(&skey);
  1002. #endif
  1003. #ifdef GCM_MODE
  1004. t2 = -1;
  1005. for (x = 0; x < 100; x++) {
  1006. t_start();
  1007. t1 = t_read();
  1008. z = 16;
  1009. if ((err = gcm_memory(cipher_idx, key, 16, IV, 16, NULL, 0, buf, MAC_SIZE*1024, buf, tag, &z, GCM_ENCRYPT)) != CRYPT_OK) {
  1010. fprintf(stderr, "\nGCM error... %s\n", error_to_string(err));
  1011. exit(EXIT_FAILURE);
  1012. }
  1013. t1 = t_read() - t1;
  1014. if (t1 < t2) t2 = t1;
  1015. }
  1016. fprintf(stderr, "GCM (no-precomp)\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
  1017. {
  1018. gcm_state gcm;
  1019. if ((err = gcm_init(&gcm, cipher_idx, key, 16)) != CRYPT_OK) { fprintf(stderr, "gcm_init: %s\n", error_to_string(err)); exit(EXIT_FAILURE); }
  1020. t2 = -1;
  1021. for (x = 0; x < 10000; x++) {
  1022. t_start();
  1023. t1 = t_read();
  1024. z = 16;
  1025. if ((err = gcm_reset(&gcm)) != CRYPT_OK) {
  1026. fprintf(stderr, "\nGCM error[%d]... %s\n", __LINE__, error_to_string(err));
  1027. exit(EXIT_FAILURE);
  1028. }
  1029. if ((err = gcm_add_iv(&gcm, IV, 16)) != CRYPT_OK) {
  1030. fprintf(stderr, "\nGCM error[%d]... %s\n", __LINE__, error_to_string(err));
  1031. exit(EXIT_FAILURE);
  1032. }
  1033. if ((err = gcm_add_aad(&gcm, NULL, 0)) != CRYPT_OK) {
  1034. fprintf(stderr, "\nGCM error[%d]... %s\n", __LINE__, error_to_string(err));
  1035. exit(EXIT_FAILURE);
  1036. }
  1037. if ((err = gcm_process(&gcm, buf, MAC_SIZE*1024, buf, GCM_ENCRYPT)) != CRYPT_OK) {
  1038. fprintf(stderr, "\nGCM error[%d]... %s\n", __LINE__, error_to_string(err));
  1039. exit(EXIT_FAILURE);
  1040. }
  1041. if ((err = gcm_done(&gcm, tag, &z)) != CRYPT_OK) {
  1042. fprintf(stderr, "\nGCM error[%d]... %s\n", __LINE__, error_to_string(err));
  1043. exit(EXIT_FAILURE);
  1044. }
  1045. t1 = t_read() - t1;
  1046. if (t1 < t2) t2 = t1;
  1047. }
  1048. fprintf(stderr, "GCM (precomp)\t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
  1049. }
  1050. #endif
  1051. }
  1052. void time_encmacs(void)
  1053. {
  1054. time_encmacs_(1);
  1055. time_encmacs_(4);
  1056. time_encmacs_(32);
  1057. }
  1058. /* $Source$ */
  1059. /* $Revision$ */
  1060. /* $Date$ */