des_opts.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. /* crypto/des/des_opts.c */
  2. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  3. * All rights reserved.
  4. *
  5. * This package is an SSL implementation written
  6. * by Eric Young (eay@cryptsoft.com).
  7. * The implementation was written so as to conform with Netscapes SSL.
  8. *
  9. * This library is free for commercial and non-commercial use as long as
  10. * the following conditions are aheared to. The following conditions
  11. * apply to all code found in this distribution, be it the RC4, RSA,
  12. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  13. * included with this distribution is covered by the same copyright terms
  14. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  15. *
  16. * Copyright remains Eric Young's, and as such any Copyright notices in
  17. * the code are not to be removed.
  18. * If this package is used in a product, Eric Young should be given attribution
  19. * as the author of the parts of the library used.
  20. * This can be in the form of a textual message at program startup or
  21. * in documentation (online or textual) provided with the package.
  22. *
  23. * Redistribution and use in source and binary forms, with or without
  24. * modification, are permitted provided that the following conditions
  25. * are met:
  26. * 1. Redistributions of source code must retain the copyright
  27. * notice, this list of conditions and the following disclaimer.
  28. * 2. Redistributions in binary form must reproduce the above copyright
  29. * notice, this list of conditions and the following disclaimer in the
  30. * documentation and/or other materials provided with the distribution.
  31. * 3. All advertising materials mentioning features or use of this software
  32. * must display the following acknowledgement:
  33. * "This product includes cryptographic software written by
  34. * Eric Young (eay@cryptsoft.com)"
  35. * The word 'cryptographic' can be left out if the rouines from the library
  36. * being used are not cryptographic related :-).
  37. * 4. If you include any Windows specific code (or a derivative thereof) from
  38. * the apps directory (application code) you must include an acknowledgement:
  39. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  40. *
  41. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  42. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  43. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  44. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  45. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  46. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  47. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  48. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  49. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  50. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  51. * SUCH DAMAGE.
  52. *
  53. * The licence and distribution terms for any publically available version or
  54. * derivative of this code cannot be changed. i.e. this code cannot simply be
  55. * copied and put under another distribution licence
  56. * [including the GNU Public Licence.]
  57. */
  58. /* define PART1, PART2, PART3 or PART4 to build only with a few of the options.
  59. * This is for machines with 64k code segment size restrictions. */
  60. #if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
  61. #define TIMES
  62. #endif
  63. #include <stdio.h>
  64. #ifndef OPENSSL_SYS_MSDOS
  65. #include <openssl/e_os2.h>
  66. #include OPENSSL_UNISTD
  67. #else
  68. #include <io.h>
  69. extern void exit();
  70. #endif
  71. #ifndef OPENSSL_SYS_NETWARE
  72. #include <signal.h>
  73. #endif
  74. #ifndef _IRIX
  75. #include <time.h>
  76. #endif
  77. #ifdef TIMES
  78. #include <sys/types.h>
  79. #include <sys/times.h>
  80. #endif
  81. /* Depending on the VMS version, the tms structure is perhaps defined.
  82. The __TMS macro will show if it was. If it wasn't defined, we should
  83. undefine TIMES, since that tells the rest of the program how things
  84. should be handled. -- Richard Levitte */
  85. #if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
  86. #undef TIMES
  87. #endif
  88. #ifndef TIMES
  89. #include <sys/timeb.h>
  90. #endif
  91. #if defined(sun) || defined(__ultrix)
  92. #define _POSIX_SOURCE
  93. #include <limits.h>
  94. #include <sys/param.h>
  95. #endif
  96. #include <openssl/des.h>
  97. #include "spr.h"
  98. #define DES_DEFAULT_OPTIONS
  99. #if !defined(PART1) && !defined(PART2) && !defined(PART3) && !defined(PART4)
  100. #define PART1
  101. #define PART2
  102. #define PART3
  103. #define PART4
  104. #endif
  105. #ifdef PART1
  106. #undef DES_UNROLL
  107. #undef DES_RISC1
  108. #undef DES_RISC2
  109. #undef DES_PTR
  110. #undef D_ENCRYPT
  111. #define DES_encrypt1 des_encrypt_u4_cisc_idx
  112. #define DES_encrypt2 des_encrypt2_u4_cisc_idx
  113. #define DES_encrypt3 des_encrypt3_u4_cisc_idx
  114. #define DES_decrypt3 des_decrypt3_u4_cisc_idx
  115. #undef HEADER_DES_LOCL_H
  116. #include "des_enc.c"
  117. #define DES_UNROLL
  118. #undef DES_RISC1
  119. #undef DES_RISC2
  120. #undef DES_PTR
  121. #undef D_ENCRYPT
  122. #undef DES_encrypt1
  123. #undef DES_encrypt2
  124. #undef DES_encrypt3
  125. #undef DES_decrypt3
  126. #define DES_encrypt1 des_encrypt_u16_cisc_idx
  127. #define DES_encrypt2 des_encrypt2_u16_cisc_idx
  128. #define DES_encrypt3 des_encrypt3_u16_cisc_idx
  129. #define DES_decrypt3 des_decrypt3_u16_cisc_idx
  130. #undef HEADER_DES_LOCL_H
  131. #include "des_enc.c"
  132. #undef DES_UNROLL
  133. #define DES_RISC1
  134. #undef DES_RISC2
  135. #undef DES_PTR
  136. #undef D_ENCRYPT
  137. #undef DES_encrypt1
  138. #undef DES_encrypt2
  139. #undef DES_encrypt3
  140. #undef DES_decrypt3
  141. #define DES_encrypt1 des_encrypt_u4_risc1_idx
  142. #define DES_encrypt2 des_encrypt2_u4_risc1_idx
  143. #define DES_encrypt3 des_encrypt3_u4_risc1_idx
  144. #define DES_decrypt3 des_decrypt3_u4_risc1_idx
  145. #undef HEADER_DES_LOCL_H
  146. #include "des_enc.c"
  147. #endif
  148. #ifdef PART2
  149. #undef DES_UNROLL
  150. #undef DES_RISC1
  151. #define DES_RISC2
  152. #undef DES_PTR
  153. #undef D_ENCRYPT
  154. #undef DES_encrypt1
  155. #undef DES_encrypt2
  156. #undef DES_encrypt3
  157. #undef DES_decrypt3
  158. #define DES_encrypt1 des_encrypt_u4_risc2_idx
  159. #define DES_encrypt2 des_encrypt2_u4_risc2_idx
  160. #define DES_encrypt3 des_encrypt3_u4_risc2_idx
  161. #define DES_decrypt3 des_decrypt3_u4_risc2_idx
  162. #undef HEADER_DES_LOCL_H
  163. #include "des_enc.c"
  164. #define DES_UNROLL
  165. #define DES_RISC1
  166. #undef DES_RISC2
  167. #undef DES_PTR
  168. #undef D_ENCRYPT
  169. #undef DES_encrypt1
  170. #undef DES_encrypt2
  171. #undef DES_encrypt3
  172. #undef DES_decrypt3
  173. #define DES_encrypt1 des_encrypt_u16_risc1_idx
  174. #define DES_encrypt2 des_encrypt2_u16_risc1_idx
  175. #define DES_encrypt3 des_encrypt3_u16_risc1_idx
  176. #define DES_decrypt3 des_decrypt3_u16_risc1_idx
  177. #undef HEADER_DES_LOCL_H
  178. #include "des_enc.c"
  179. #define DES_UNROLL
  180. #undef DES_RISC1
  181. #define DES_RISC2
  182. #undef DES_PTR
  183. #undef D_ENCRYPT
  184. #undef DES_encrypt1
  185. #undef DES_encrypt2
  186. #undef DES_encrypt3
  187. #undef DES_decrypt3
  188. #define DES_encrypt1 des_encrypt_u16_risc2_idx
  189. #define DES_encrypt2 des_encrypt2_u16_risc2_idx
  190. #define DES_encrypt3 des_encrypt3_u16_risc2_idx
  191. #define DES_decrypt3 des_decrypt3_u16_risc2_idx
  192. #undef HEADER_DES_LOCL_H
  193. #include "des_enc.c"
  194. #endif
  195. #ifdef PART3
  196. #undef DES_UNROLL
  197. #undef DES_RISC1
  198. #undef DES_RISC2
  199. #define DES_PTR
  200. #undef D_ENCRYPT
  201. #undef DES_encrypt1
  202. #undef DES_encrypt2
  203. #undef DES_encrypt3
  204. #undef DES_decrypt3
  205. #define DES_encrypt1 des_encrypt_u4_cisc_ptr
  206. #define DES_encrypt2 des_encrypt2_u4_cisc_ptr
  207. #define DES_encrypt3 des_encrypt3_u4_cisc_ptr
  208. #define DES_decrypt3 des_decrypt3_u4_cisc_ptr
  209. #undef HEADER_DES_LOCL_H
  210. #include "des_enc.c"
  211. #define DES_UNROLL
  212. #undef DES_RISC1
  213. #undef DES_RISC2
  214. #define DES_PTR
  215. #undef D_ENCRYPT
  216. #undef DES_encrypt1
  217. #undef DES_encrypt2
  218. #undef DES_encrypt3
  219. #undef DES_decrypt3
  220. #define DES_encrypt1 des_encrypt_u16_cisc_ptr
  221. #define DES_encrypt2 des_encrypt2_u16_cisc_ptr
  222. #define DES_encrypt3 des_encrypt3_u16_cisc_ptr
  223. #define DES_decrypt3 des_decrypt3_u16_cisc_ptr
  224. #undef HEADER_DES_LOCL_H
  225. #include "des_enc.c"
  226. #undef DES_UNROLL
  227. #define DES_RISC1
  228. #undef DES_RISC2
  229. #define DES_PTR
  230. #undef D_ENCRYPT
  231. #undef DES_encrypt1
  232. #undef DES_encrypt2
  233. #undef DES_encrypt3
  234. #undef DES_decrypt3
  235. #define DES_encrypt1 des_encrypt_u4_risc1_ptr
  236. #define DES_encrypt2 des_encrypt2_u4_risc1_ptr
  237. #define DES_encrypt3 des_encrypt3_u4_risc1_ptr
  238. #define DES_decrypt3 des_decrypt3_u4_risc1_ptr
  239. #undef HEADER_DES_LOCL_H
  240. #include "des_enc.c"
  241. #endif
  242. #ifdef PART4
  243. #undef DES_UNROLL
  244. #undef DES_RISC1
  245. #define DES_RISC2
  246. #define DES_PTR
  247. #undef D_ENCRYPT
  248. #undef DES_encrypt1
  249. #undef DES_encrypt2
  250. #undef DES_encrypt3
  251. #undef DES_decrypt3
  252. #define DES_encrypt1 des_encrypt_u4_risc2_ptr
  253. #define DES_encrypt2 des_encrypt2_u4_risc2_ptr
  254. #define DES_encrypt3 des_encrypt3_u4_risc2_ptr
  255. #define DES_decrypt3 des_decrypt3_u4_risc2_ptr
  256. #undef HEADER_DES_LOCL_H
  257. #include "des_enc.c"
  258. #define DES_UNROLL
  259. #define DES_RISC1
  260. #undef DES_RISC2
  261. #define DES_PTR
  262. #undef D_ENCRYPT
  263. #undef DES_encrypt1
  264. #undef DES_encrypt2
  265. #undef DES_encrypt3
  266. #undef DES_decrypt3
  267. #define DES_encrypt1 des_encrypt_u16_risc1_ptr
  268. #define DES_encrypt2 des_encrypt2_u16_risc1_ptr
  269. #define DES_encrypt3 des_encrypt3_u16_risc1_ptr
  270. #define DES_decrypt3 des_decrypt3_u16_risc1_ptr
  271. #undef HEADER_DES_LOCL_H
  272. #include "des_enc.c"
  273. #define DES_UNROLL
  274. #undef DES_RISC1
  275. #define DES_RISC2
  276. #define DES_PTR
  277. #undef D_ENCRYPT
  278. #undef DES_encrypt1
  279. #undef DES_encrypt2
  280. #undef DES_encrypt3
  281. #undef DES_decrypt3
  282. #define DES_encrypt1 des_encrypt_u16_risc2_ptr
  283. #define DES_encrypt2 des_encrypt2_u16_risc2_ptr
  284. #define DES_encrypt3 des_encrypt3_u16_risc2_ptr
  285. #define DES_decrypt3 des_decrypt3_u16_risc2_ptr
  286. #undef HEADER_DES_LOCL_H
  287. #include "des_enc.c"
  288. #endif
  289. /* The following if from times(3) man page. It may need to be changed */
  290. #ifndef HZ
  291. # ifndef CLK_TCK
  292. # ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
  293. # define HZ 100.0
  294. # else /* _BSD_CLK_TCK_ */
  295. # define HZ ((double)_BSD_CLK_TCK_)
  296. # endif
  297. # else /* CLK_TCK */
  298. # define HZ ((double)CLK_TCK)
  299. # endif
  300. #endif
  301. #define BUFSIZE ((long)1024)
  302. long run=0;
  303. double Time_F(int s);
  304. #ifdef SIGALRM
  305. #if defined(__STDC__) || defined(sgi)
  306. #define SIGRETTYPE void
  307. #else
  308. #define SIGRETTYPE int
  309. #endif
  310. SIGRETTYPE sig_done(int sig);
  311. SIGRETTYPE sig_done(int sig)
  312. {
  313. signal(SIGALRM,sig_done);
  314. run=0;
  315. #ifdef LINT
  316. sig=sig;
  317. #endif
  318. }
  319. #endif
  320. #define START 0
  321. #define STOP 1
  322. double Time_F(int s)
  323. {
  324. double ret;
  325. #ifdef TIMES
  326. static struct tms tstart,tend;
  327. if (s == START)
  328. {
  329. times(&tstart);
  330. return(0);
  331. }
  332. else
  333. {
  334. times(&tend);
  335. ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
  336. return((ret == 0.0)?1e-6:ret);
  337. }
  338. #else /* !times() */
  339. static struct timeb tstart,tend;
  340. long i;
  341. if (s == START)
  342. {
  343. ftime(&tstart);
  344. return(0);
  345. }
  346. else
  347. {
  348. ftime(&tend);
  349. i=(long)tend.millitm-(long)tstart.millitm;
  350. ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
  351. return((ret == 0.0)?1e-6:ret);
  352. }
  353. #endif
  354. }
  355. #ifdef SIGALRM
  356. #define print_name(name) fprintf(stderr,"Doing %s's for 10 seconds\n",name); alarm(10);
  357. #else
  358. #define print_name(name) fprintf(stderr,"Doing %s %ld times\n",name,cb);
  359. #endif
  360. #define time_it(func,name,index) \
  361. print_name(name); \
  362. Time_F(START); \
  363. for (count=0,run=1; COND(cb); count++) \
  364. { \
  365. unsigned long d[2]; \
  366. func(d,&sch,DES_ENCRYPT); \
  367. } \
  368. tm[index]=Time_F(STOP); \
  369. fprintf(stderr,"%ld %s's in %.2f second\n",count,name,tm[index]); \
  370. tm[index]=((double)COUNT(cb))/tm[index];
  371. #define print_it(name,index) \
  372. fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \
  373. tm[index]*8,1.0e6/tm[index]);
  374. int main(int argc, char **argv)
  375. {
  376. long count;
  377. static unsigned char buf[BUFSIZE];
  378. static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
  379. static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
  380. static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
  381. DES_key_schedule sch,sch2,sch3;
  382. double d,tm[16],max=0;
  383. int rank[16];
  384. char *str[16];
  385. int max_idx=0,i,num=0,j;
  386. #ifndef SIGALARM
  387. long ca,cb,cc,cd,ce;
  388. #endif
  389. for (i=0; i<12; i++)
  390. {
  391. tm[i]=0.0;
  392. rank[i]=0;
  393. }
  394. #ifndef TIMES
  395. fprintf(stderr,"To get the most accurate results, try to run this\n");
  396. fprintf(stderr,"program when this computer is idle.\n");
  397. #endif
  398. DES_set_key_unchecked(&key,&sch);
  399. DES_set_key_unchecked(&key2,&sch2);
  400. DES_set_key_unchecked(&key3,&sch3);
  401. #ifndef SIGALRM
  402. fprintf(stderr,"First we calculate the approximate speed ...\n");
  403. DES_set_key_unchecked(&key,sch);
  404. count=10;
  405. do {
  406. long i;
  407. unsigned long data[2];
  408. count*=2;
  409. Time_F(START);
  410. for (i=count; i; i--)
  411. DES_encrypt1(data,&(sch[0]),DES_ENCRYPT);
  412. d=Time_F(STOP);
  413. } while (d < 3.0);
  414. ca=count;
  415. cb=count*3;
  416. cc=count*3*8/BUFSIZE+1;
  417. cd=count*8/BUFSIZE+1;
  418. ce=count/20+1;
  419. #define COND(d) (count != (d))
  420. #define COUNT(d) (d)
  421. #else
  422. #define COND(c) (run)
  423. #define COUNT(d) (count)
  424. signal(SIGALRM,sig_done);
  425. alarm(10);
  426. #endif
  427. #ifdef PART1
  428. time_it(des_encrypt_u4_cisc_idx, "des_encrypt_u4_cisc_idx ", 0);
  429. time_it(des_encrypt_u16_cisc_idx, "des_encrypt_u16_cisc_idx ", 1);
  430. time_it(des_encrypt_u4_risc1_idx, "des_encrypt_u4_risc1_idx ", 2);
  431. num+=3;
  432. #endif
  433. #ifdef PART2
  434. time_it(des_encrypt_u16_risc1_idx,"des_encrypt_u16_risc1_idx", 3);
  435. time_it(des_encrypt_u4_risc2_idx, "des_encrypt_u4_risc2_idx ", 4);
  436. time_it(des_encrypt_u16_risc2_idx,"des_encrypt_u16_risc2_idx", 5);
  437. num+=3;
  438. #endif
  439. #ifdef PART3
  440. time_it(des_encrypt_u4_cisc_ptr, "des_encrypt_u4_cisc_ptr ", 6);
  441. time_it(des_encrypt_u16_cisc_ptr, "des_encrypt_u16_cisc_ptr ", 7);
  442. time_it(des_encrypt_u4_risc1_ptr, "des_encrypt_u4_risc1_ptr ", 8);
  443. num+=3;
  444. #endif
  445. #ifdef PART4
  446. time_it(des_encrypt_u16_risc1_ptr,"des_encrypt_u16_risc1_ptr", 9);
  447. time_it(des_encrypt_u4_risc2_ptr, "des_encrypt_u4_risc2_ptr ",10);
  448. time_it(des_encrypt_u16_risc2_ptr,"des_encrypt_u16_risc2_ptr",11);
  449. num+=3;
  450. #endif
  451. #ifdef PART1
  452. str[0]=" 4 c i";
  453. print_it("des_encrypt_u4_cisc_idx ",0);
  454. max=tm[0];
  455. max_idx=0;
  456. str[1]="16 c i";
  457. print_it("des_encrypt_u16_cisc_idx ",1);
  458. if (max < tm[1]) { max=tm[1]; max_idx=1; }
  459. str[2]=" 4 r1 i";
  460. print_it("des_encrypt_u4_risc1_idx ",2);
  461. if (max < tm[2]) { max=tm[2]; max_idx=2; }
  462. #endif
  463. #ifdef PART2
  464. str[3]="16 r1 i";
  465. print_it("des_encrypt_u16_risc1_idx",3);
  466. if (max < tm[3]) { max=tm[3]; max_idx=3; }
  467. str[4]=" 4 r2 i";
  468. print_it("des_encrypt_u4_risc2_idx ",4);
  469. if (max < tm[4]) { max=tm[4]; max_idx=4; }
  470. str[5]="16 r2 i";
  471. print_it("des_encrypt_u16_risc2_idx",5);
  472. if (max < tm[5]) { max=tm[5]; max_idx=5; }
  473. #endif
  474. #ifdef PART3
  475. str[6]=" 4 c p";
  476. print_it("des_encrypt_u4_cisc_ptr ",6);
  477. if (max < tm[6]) { max=tm[6]; max_idx=6; }
  478. str[7]="16 c p";
  479. print_it("des_encrypt_u16_cisc_ptr ",7);
  480. if (max < tm[7]) { max=tm[7]; max_idx=7; }
  481. str[8]=" 4 r1 p";
  482. print_it("des_encrypt_u4_risc1_ptr ",8);
  483. if (max < tm[8]) { max=tm[8]; max_idx=8; }
  484. #endif
  485. #ifdef PART4
  486. str[9]="16 r1 p";
  487. print_it("des_encrypt_u16_risc1_ptr",9);
  488. if (max < tm[9]) { max=tm[9]; max_idx=9; }
  489. str[10]=" 4 r2 p";
  490. print_it("des_encrypt_u4_risc2_ptr ",10);
  491. if (max < tm[10]) { max=tm[10]; max_idx=10; }
  492. str[11]="16 r2 p";
  493. print_it("des_encrypt_u16_risc2_ptr",11);
  494. if (max < tm[11]) { max=tm[11]; max_idx=11; }
  495. #endif
  496. printf("options des ecb/s\n");
  497. printf("%s %12.2f 100.0%%\n",str[max_idx],tm[max_idx]);
  498. d=tm[max_idx];
  499. tm[max_idx]= -2.0;
  500. max= -1.0;
  501. for (;;)
  502. {
  503. for (i=0; i<12; i++)
  504. {
  505. if (max < tm[i]) { max=tm[i]; j=i; }
  506. }
  507. if (max < 0.0) break;
  508. printf("%s %12.2f %4.1f%%\n",str[j],tm[j],tm[j]/d*100.0);
  509. tm[j]= -2.0;
  510. max= -1.0;
  511. }
  512. switch (max_idx)
  513. {
  514. case 0:
  515. printf("-DDES_DEFAULT_OPTIONS\n");
  516. break;
  517. case 1:
  518. printf("-DDES_UNROLL\n");
  519. break;
  520. case 2:
  521. printf("-DDES_RISC1\n");
  522. break;
  523. case 3:
  524. printf("-DDES_UNROLL -DDES_RISC1\n");
  525. break;
  526. case 4:
  527. printf("-DDES_RISC2\n");
  528. break;
  529. case 5:
  530. printf("-DDES_UNROLL -DDES_RISC2\n");
  531. break;
  532. case 6:
  533. printf("-DDES_PTR\n");
  534. break;
  535. case 7:
  536. printf("-DDES_UNROLL -DDES_PTR\n");
  537. break;
  538. case 8:
  539. printf("-DDES_RISC1 -DDES_PTR\n");
  540. break;
  541. case 9:
  542. printf("-DDES_UNROLL -DDES_RISC1 -DDES_PTR\n");
  543. break;
  544. case 10:
  545. printf("-DDES_RISC2 -DDES_PTR\n");
  546. break;
  547. case 11:
  548. printf("-DDES_UNROLL -DDES_RISC2 -DDES_PTR\n");
  549. break;
  550. }
  551. exit(0);
  552. #if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
  553. return(0);
  554. #endif
  555. }