des_opts.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  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. /*
  59. * define PART1, PART2, PART3 or PART4 to build only with a few of the
  60. * options. This is for machines with 64k code segment size restrictions.
  61. */
  62. #if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
  63. # define TIMES
  64. #endif
  65. #include <stdio.h>
  66. #ifndef OPENSSL_SYS_MSDOS
  67. # include <openssl/e_os2.h>
  68. # include OPENSSL_UNISTD
  69. #else
  70. # include <io.h>
  71. extern void exit();
  72. #endif
  73. #ifndef OPENSSL_SYS_NETWARE
  74. # include <signal.h>
  75. #endif
  76. #ifndef _IRIX
  77. # include <time.h>
  78. #endif
  79. #ifdef TIMES
  80. # include <sys/types.h>
  81. # include <sys/times.h>
  82. #endif
  83. /*
  84. * Depending on the VMS version, the tms structure is perhaps defined. The
  85. * __TMS macro will show if it was. If it wasn't defined, we should undefine
  86. * TIMES, since that tells the rest of the program how things should be
  87. * handled. -- Richard Levitte
  88. */
  89. #if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
  90. # undef TIMES
  91. #endif
  92. #ifndef TIMES
  93. # include <sys/timeb.h>
  94. #endif
  95. #if defined(sun) || defined(__ultrix)
  96. # define _POSIX_SOURCE
  97. # include <limits.h>
  98. # include <sys/param.h>
  99. #endif
  100. #include <openssl/des.h>
  101. #include "spr.h"
  102. #define DES_DEFAULT_OPTIONS
  103. #if !defined(PART1) && !defined(PART2) && !defined(PART3) && !defined(PART4)
  104. # define PART1
  105. # define PART2
  106. # define PART3
  107. # define PART4
  108. #endif
  109. #ifdef PART1
  110. # undef DES_UNROLL
  111. # undef DES_RISC1
  112. # undef DES_RISC2
  113. # undef DES_PTR
  114. # undef D_ENCRYPT
  115. # define DES_encrypt1 des_encrypt_u4_cisc_idx
  116. # define DES_encrypt2 des_encrypt2_u4_cisc_idx
  117. # define DES_encrypt3 des_encrypt3_u4_cisc_idx
  118. # define DES_decrypt3 des_decrypt3_u4_cisc_idx
  119. # undef HEADER_DES_LOCL_H
  120. # include "des_enc.c"
  121. # define DES_UNROLL
  122. # undef DES_RISC1
  123. # undef DES_RISC2
  124. # undef DES_PTR
  125. # undef D_ENCRYPT
  126. # undef DES_encrypt1
  127. # undef DES_encrypt2
  128. # undef DES_encrypt3
  129. # undef DES_decrypt3
  130. # define DES_encrypt1 des_encrypt_u16_cisc_idx
  131. # define DES_encrypt2 des_encrypt2_u16_cisc_idx
  132. # define DES_encrypt3 des_encrypt3_u16_cisc_idx
  133. # define DES_decrypt3 des_decrypt3_u16_cisc_idx
  134. # undef HEADER_DES_LOCL_H
  135. # include "des_enc.c"
  136. # undef DES_UNROLL
  137. # define DES_RISC1
  138. # undef DES_RISC2
  139. # undef DES_PTR
  140. # undef D_ENCRYPT
  141. # undef DES_encrypt1
  142. # undef DES_encrypt2
  143. # undef DES_encrypt3
  144. # undef DES_decrypt3
  145. # define DES_encrypt1 des_encrypt_u4_risc1_idx
  146. # define DES_encrypt2 des_encrypt2_u4_risc1_idx
  147. # define DES_encrypt3 des_encrypt3_u4_risc1_idx
  148. # define DES_decrypt3 des_decrypt3_u4_risc1_idx
  149. # undef HEADER_DES_LOCL_H
  150. # include "des_enc.c"
  151. #endif
  152. #ifdef PART2
  153. # undef DES_UNROLL
  154. # undef DES_RISC1
  155. # define DES_RISC2
  156. # undef DES_PTR
  157. # undef D_ENCRYPT
  158. # undef DES_encrypt1
  159. # undef DES_encrypt2
  160. # undef DES_encrypt3
  161. # undef DES_decrypt3
  162. # define DES_encrypt1 des_encrypt_u4_risc2_idx
  163. # define DES_encrypt2 des_encrypt2_u4_risc2_idx
  164. # define DES_encrypt3 des_encrypt3_u4_risc2_idx
  165. # define DES_decrypt3 des_decrypt3_u4_risc2_idx
  166. # undef HEADER_DES_LOCL_H
  167. # include "des_enc.c"
  168. # define DES_UNROLL
  169. # define DES_RISC1
  170. # undef DES_RISC2
  171. # undef DES_PTR
  172. # undef D_ENCRYPT
  173. # undef DES_encrypt1
  174. # undef DES_encrypt2
  175. # undef DES_encrypt3
  176. # undef DES_decrypt3
  177. # define DES_encrypt1 des_encrypt_u16_risc1_idx
  178. # define DES_encrypt2 des_encrypt2_u16_risc1_idx
  179. # define DES_encrypt3 des_encrypt3_u16_risc1_idx
  180. # define DES_decrypt3 des_decrypt3_u16_risc1_idx
  181. # undef HEADER_DES_LOCL_H
  182. # include "des_enc.c"
  183. # define DES_UNROLL
  184. # undef DES_RISC1
  185. # define DES_RISC2
  186. # undef DES_PTR
  187. # undef D_ENCRYPT
  188. # undef DES_encrypt1
  189. # undef DES_encrypt2
  190. # undef DES_encrypt3
  191. # undef DES_decrypt3
  192. # define DES_encrypt1 des_encrypt_u16_risc2_idx
  193. # define DES_encrypt2 des_encrypt2_u16_risc2_idx
  194. # define DES_encrypt3 des_encrypt3_u16_risc2_idx
  195. # define DES_decrypt3 des_decrypt3_u16_risc2_idx
  196. # undef HEADER_DES_LOCL_H
  197. # include "des_enc.c"
  198. #endif
  199. #ifdef PART3
  200. # undef DES_UNROLL
  201. # undef DES_RISC1
  202. # undef DES_RISC2
  203. # define DES_PTR
  204. # undef D_ENCRYPT
  205. # undef DES_encrypt1
  206. # undef DES_encrypt2
  207. # undef DES_encrypt3
  208. # undef DES_decrypt3
  209. # define DES_encrypt1 des_encrypt_u4_cisc_ptr
  210. # define DES_encrypt2 des_encrypt2_u4_cisc_ptr
  211. # define DES_encrypt3 des_encrypt3_u4_cisc_ptr
  212. # define DES_decrypt3 des_decrypt3_u4_cisc_ptr
  213. # undef HEADER_DES_LOCL_H
  214. # include "des_enc.c"
  215. # define DES_UNROLL
  216. # undef DES_RISC1
  217. # undef DES_RISC2
  218. # define DES_PTR
  219. # undef D_ENCRYPT
  220. # undef DES_encrypt1
  221. # undef DES_encrypt2
  222. # undef DES_encrypt3
  223. # undef DES_decrypt3
  224. # define DES_encrypt1 des_encrypt_u16_cisc_ptr
  225. # define DES_encrypt2 des_encrypt2_u16_cisc_ptr
  226. # define DES_encrypt3 des_encrypt3_u16_cisc_ptr
  227. # define DES_decrypt3 des_decrypt3_u16_cisc_ptr
  228. # undef HEADER_DES_LOCL_H
  229. # include "des_enc.c"
  230. # undef DES_UNROLL
  231. # define DES_RISC1
  232. # undef DES_RISC2
  233. # define DES_PTR
  234. # undef D_ENCRYPT
  235. # undef DES_encrypt1
  236. # undef DES_encrypt2
  237. # undef DES_encrypt3
  238. # undef DES_decrypt3
  239. # define DES_encrypt1 des_encrypt_u4_risc1_ptr
  240. # define DES_encrypt2 des_encrypt2_u4_risc1_ptr
  241. # define DES_encrypt3 des_encrypt3_u4_risc1_ptr
  242. # define DES_decrypt3 des_decrypt3_u4_risc1_ptr
  243. # undef HEADER_DES_LOCL_H
  244. # include "des_enc.c"
  245. #endif
  246. #ifdef PART4
  247. # undef DES_UNROLL
  248. # undef DES_RISC1
  249. # define DES_RISC2
  250. # define DES_PTR
  251. # undef D_ENCRYPT
  252. # undef DES_encrypt1
  253. # undef DES_encrypt2
  254. # undef DES_encrypt3
  255. # undef DES_decrypt3
  256. # define DES_encrypt1 des_encrypt_u4_risc2_ptr
  257. # define DES_encrypt2 des_encrypt2_u4_risc2_ptr
  258. # define DES_encrypt3 des_encrypt3_u4_risc2_ptr
  259. # define DES_decrypt3 des_decrypt3_u4_risc2_ptr
  260. # undef HEADER_DES_LOCL_H
  261. # include "des_enc.c"
  262. # define DES_UNROLL
  263. # define DES_RISC1
  264. # undef DES_RISC2
  265. # define DES_PTR
  266. # undef D_ENCRYPT
  267. # undef DES_encrypt1
  268. # undef DES_encrypt2
  269. # undef DES_encrypt3
  270. # undef DES_decrypt3
  271. # define DES_encrypt1 des_encrypt_u16_risc1_ptr
  272. # define DES_encrypt2 des_encrypt2_u16_risc1_ptr
  273. # define DES_encrypt3 des_encrypt3_u16_risc1_ptr
  274. # define DES_decrypt3 des_decrypt3_u16_risc1_ptr
  275. # undef HEADER_DES_LOCL_H
  276. # include "des_enc.c"
  277. # define DES_UNROLL
  278. # undef DES_RISC1
  279. # define DES_RISC2
  280. # define DES_PTR
  281. # undef D_ENCRYPT
  282. # undef DES_encrypt1
  283. # undef DES_encrypt2
  284. # undef DES_encrypt3
  285. # undef DES_decrypt3
  286. # define DES_encrypt1 des_encrypt_u16_risc2_ptr
  287. # define DES_encrypt2 des_encrypt2_u16_risc2_ptr
  288. # define DES_encrypt3 des_encrypt3_u16_risc2_ptr
  289. # define DES_decrypt3 des_decrypt3_u16_risc2_ptr
  290. # undef HEADER_DES_LOCL_H
  291. # include "des_enc.c"
  292. #endif
  293. /* The following if from times(3) man page. It may need to be changed */
  294. #ifndef HZ
  295. # ifndef CLK_TCK
  296. # ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
  297. # define HZ 100.0
  298. # else /* _BSD_CLK_TCK_ */
  299. # define HZ ((double)_BSD_CLK_TCK_)
  300. # endif
  301. # else /* CLK_TCK */
  302. # define HZ ((double)CLK_TCK)
  303. # endif
  304. #endif
  305. #define BUFSIZE ((long)1024)
  306. long run = 0;
  307. double Time_F(int s);
  308. #ifdef SIGALRM
  309. # if defined(__STDC__) || defined(sgi)
  310. # define SIGRETTYPE void
  311. # else
  312. # define SIGRETTYPE int
  313. # endif
  314. SIGRETTYPE sig_done(int sig);
  315. SIGRETTYPE sig_done(int sig)
  316. {
  317. signal(SIGALRM, sig_done);
  318. run = 0;
  319. # ifdef LINT
  320. sig = sig;
  321. # endif
  322. }
  323. #endif
  324. #define START 0
  325. #define STOP 1
  326. double Time_F(int s)
  327. {
  328. double ret;
  329. #ifdef TIMES
  330. static struct tms tstart, tend;
  331. if (s == START) {
  332. times(&tstart);
  333. return (0);
  334. } else {
  335. times(&tend);
  336. ret = ((double)(tend.tms_utime - tstart.tms_utime)) / HZ;
  337. return ((ret == 0.0) ? 1e-6 : ret);
  338. }
  339. #else /* !times() */
  340. static struct timeb tstart, tend;
  341. long i;
  342. if (s == START) {
  343. ftime(&tstart);
  344. return (0);
  345. } else {
  346. ftime(&tend);
  347. i = (long)tend.millitm - (long)tstart.millitm;
  348. ret = ((double)(tend.time - tstart.time)) + ((double)i) / 1000.0;
  349. return ((ret == 0.0) ? 1e-6 : ret);
  350. }
  351. #endif
  352. }
  353. #ifdef SIGALRM
  354. # define print_name(name) fprintf(stderr,"Doing %s's for 10 seconds\n",name); alarm(10);
  355. #else
  356. # define print_name(name) fprintf(stderr,"Doing %s %ld times\n",name,cb);
  357. #endif
  358. #define time_it(func,name,index) \
  359. print_name(name); \
  360. Time_F(START); \
  361. for (count=0,run=1; COND(cb); count++) \
  362. { \
  363. unsigned long d[2]; \
  364. func(d,&sch,DES_ENCRYPT); \
  365. } \
  366. tm[index]=Time_F(STOP); \
  367. fprintf(stderr,"%ld %s's in %.2f second\n",count,name,tm[index]); \
  368. tm[index]=((double)COUNT(cb))/tm[index];
  369. #define print_it(name,index) \
  370. fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \
  371. tm[index]*8,1.0e6/tm[index]);
  372. int main(int argc, char **argv)
  373. {
  374. long count;
  375. static unsigned char buf[BUFSIZE];
  376. static DES_cblock key =
  377. { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 };
  378. static DES_cblock key2 =
  379. { 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12 };
  380. static DES_cblock key3 =
  381. { 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34 };
  382. DES_key_schedule sch, sch2, sch3;
  383. double d, tm[16], max = 0;
  384. int rank[16];
  385. char *str[16];
  386. int max_idx = 0, i, num = 0, j;
  387. #ifndef SIGALARM
  388. long ca, cb, cc, cd, ce;
  389. #endif
  390. for (i = 0; i < 12; i++) {
  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]) {
  459. max = tm[1];
  460. max_idx = 1;
  461. }
  462. str[2] = " 4 r1 i";
  463. print_it("des_encrypt_u4_risc1_idx ", 2);
  464. if (max < tm[2]) {
  465. max = tm[2];
  466. max_idx = 2;
  467. }
  468. #endif
  469. #ifdef PART2
  470. str[3] = "16 r1 i";
  471. print_it("des_encrypt_u16_risc1_idx", 3);
  472. if (max < tm[3]) {
  473. max = tm[3];
  474. max_idx = 3;
  475. }
  476. str[4] = " 4 r2 i";
  477. print_it("des_encrypt_u4_risc2_idx ", 4);
  478. if (max < tm[4]) {
  479. max = tm[4];
  480. max_idx = 4;
  481. }
  482. str[5] = "16 r2 i";
  483. print_it("des_encrypt_u16_risc2_idx", 5);
  484. if (max < tm[5]) {
  485. max = tm[5];
  486. max_idx = 5;
  487. }
  488. #endif
  489. #ifdef PART3
  490. str[6] = " 4 c p";
  491. print_it("des_encrypt_u4_cisc_ptr ", 6);
  492. if (max < tm[6]) {
  493. max = tm[6];
  494. max_idx = 6;
  495. }
  496. str[7] = "16 c p";
  497. print_it("des_encrypt_u16_cisc_ptr ", 7);
  498. if (max < tm[7]) {
  499. max = tm[7];
  500. max_idx = 7;
  501. }
  502. str[8] = " 4 r1 p";
  503. print_it("des_encrypt_u4_risc1_ptr ", 8);
  504. if (max < tm[8]) {
  505. max = tm[8];
  506. max_idx = 8;
  507. }
  508. #endif
  509. #ifdef PART4
  510. str[9] = "16 r1 p";
  511. print_it("des_encrypt_u16_risc1_ptr", 9);
  512. if (max < tm[9]) {
  513. max = tm[9];
  514. max_idx = 9;
  515. }
  516. str[10] = " 4 r2 p";
  517. print_it("des_encrypt_u4_risc2_ptr ", 10);
  518. if (max < tm[10]) {
  519. max = tm[10];
  520. max_idx = 10;
  521. }
  522. str[11] = "16 r2 p";
  523. print_it("des_encrypt_u16_risc2_ptr", 11);
  524. if (max < tm[11]) {
  525. max = tm[11];
  526. max_idx = 11;
  527. }
  528. #endif
  529. printf("options des ecb/s\n");
  530. printf("%s %12.2f 100.0%%\n", str[max_idx], tm[max_idx]);
  531. d = tm[max_idx];
  532. tm[max_idx] = -2.0;
  533. max = -1.0;
  534. for (;;) {
  535. for (i = 0; i < 12; i++) {
  536. if (max < tm[i]) {
  537. max = tm[i];
  538. j = i;
  539. }
  540. }
  541. if (max < 0.0)
  542. break;
  543. printf("%s %12.2f %4.1f%%\n", str[j], tm[j], tm[j] / d * 100.0);
  544. tm[j] = -2.0;
  545. max = -1.0;
  546. }
  547. switch (max_idx) {
  548. case 0:
  549. printf("-DDES_DEFAULT_OPTIONS\n");
  550. break;
  551. case 1:
  552. printf("-DDES_UNROLL\n");
  553. break;
  554. case 2:
  555. printf("-DDES_RISC1\n");
  556. break;
  557. case 3:
  558. printf("-DDES_UNROLL -DDES_RISC1\n");
  559. break;
  560. case 4:
  561. printf("-DDES_RISC2\n");
  562. break;
  563. case 5:
  564. printf("-DDES_UNROLL -DDES_RISC2\n");
  565. break;
  566. case 6:
  567. printf("-DDES_PTR\n");
  568. break;
  569. case 7:
  570. printf("-DDES_UNROLL -DDES_PTR\n");
  571. break;
  572. case 8:
  573. printf("-DDES_RISC1 -DDES_PTR\n");
  574. break;
  575. case 9:
  576. printf("-DDES_UNROLL -DDES_RISC1 -DDES_PTR\n");
  577. break;
  578. case 10:
  579. printf("-DDES_RISC2 -DDES_PTR\n");
  580. break;
  581. case 11:
  582. printf("-DDES_UNROLL -DDES_RISC2 -DDES_PTR\n");
  583. break;
  584. }
  585. exit(0);
  586. #if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
  587. return (0);
  588. #endif
  589. }