Deleted Added
full compact
speed.c (63249) speed.c (68654)
1/* apps/speed.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 *

--- 41 unchanged lines hidden (view full) ---

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 *
1/* apps/speed.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 *

--- 41 unchanged lines hidden (view full) ---

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 * $FreeBSD: head/crypto/openssl/apps/speed.c 59194 2000-04-13 07:15:03Z kris $
58 * $FreeBSD: head/crypto/openssl/apps/speed.c 68654 2000-11-13 02:20:29Z kris $
59 */
60
61/* most of this code has been pilfered from my libdes speed.c program */
62
63#undef SECONDS
64#define SECONDS 3
65#define RSA_SECONDS 10
66#define DSA_SECONDS 10

--- 12 unchanged lines hidden (view full) ---

79#include "apps.h"
80#ifdef NO_STDIO
81#define APPS_WIN16
82#endif
83#include <openssl/crypto.h>
84#include <openssl/rand.h>
85#include <openssl/err.h>
86
59 */
60
61/* most of this code has been pilfered from my libdes speed.c program */
62
63#undef SECONDS
64#define SECONDS 3
65#define RSA_SECONDS 10
66#define DSA_SECONDS 10

--- 12 unchanged lines hidden (view full) ---

79#include "apps.h"
80#ifdef NO_STDIO
81#define APPS_WIN16
82#endif
83#include <openssl/crypto.h>
84#include <openssl/rand.h>
85#include <openssl/err.h>
86
87#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC))
88#define TIMES
87#if defined(__FreeBSD__)
88# define USE_TOD
89#elif !defined(MSDOS) && (!defined(VMS) || defined(__DECC))
90# define TIMES
89#endif
91#endif
92#if !defined(_UNICOS) && !defined(__OpenBSD__) && !defined(sgi) && !defined(__FreeBSD__) && !(defined(__bsdi) || defined(__bsdi__)) && !defined(_AIX) && !defined(MPE)
93# define TIMEB
94#endif
90
91#ifndef _IRIX
95
96#ifndef _IRIX
92#include
97# include <time.h>
93#endif
94#ifdef TIMES
98#endif
99#ifdef TIMES
95#include
96#include
100# include <sys/types.h>
101# include <sys/times.h>
97#endif
102#endif
103#ifdef USE_TOD
104# include <sys/time.h>
105# include <sys/resource.h>
106#endif
98
99/* Depending on the VMS version, the tms structure is perhaps defined.
100 The __TMS macro will show if it was. If it wasn't defined, we should
101 undefine TIMES, since that tells the rest of the program how things
102 should be handled. -- Richard Levitte */
103#if defined(VMS) && defined(__DECC) && !defined(__TMS)
104#undef TIMES
105#endif
106
107
108/* Depending on the VMS version, the tms structure is perhaps defined.
109 The __TMS macro will show if it was. If it wasn't defined, we should
110 undefine TIMES, since that tells the rest of the program how things
111 should be handled. -- Richard Levitte */
112#if defined(VMS) && defined(__DECC) && !defined(__TMS)
113#undef TIMES
114#endif
115
107#ifndef TIMES
116#ifdef TIMEB
108#include <sys/timeb.h>
109#endif
110
117#include <sys/timeb.h>
118#endif
119
120#if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD)
121#error "It seems neither struct tms nor struct timeb is supported in this platform!"
122#endif
123
111#if defined(sun) || defined(__ultrix)
112#define _POSIX_SOURCE
113#include <limits.h>
114#include <sys/param.h>
115#endif
116
117#ifndef NO_DES
118#include <openssl/des.h>
119#endif
120#ifndef NO_MD2
121#include <openssl/md2.h>
122#endif
123#ifndef NO_MDC2
124#include <openssl/mdc2.h>
125#endif
124#if defined(sun) || defined(__ultrix)
125#define _POSIX_SOURCE
126#include <limits.h>
127#include <sys/param.h>
128#endif
129
130#ifndef NO_DES
131#include <openssl/des.h>
132#endif
133#ifndef NO_MD2
134#include <openssl/md2.h>
135#endif
136#ifndef NO_MDC2
137#include <openssl/mdc2.h>
138#endif
139#ifndef NO_MD4
140#include <openssl/md4.h>
141#endif
126#ifndef NO_MD5
127#include <openssl/md5.h>
128#endif
129#ifndef NO_HMAC
130#include <openssl/hmac.h>
131#endif
132#include <openssl/evp.h>
133#ifndef NO_SHA

--- 41 unchanged lines hidden (view full) ---

175# define HZ ((double)CLK_TCK)
176# endif
177#endif
178
179#undef BUFSIZE
180#define BUFSIZE ((long)1024*8+1)
181int run=0;
182
142#ifndef NO_MD5
143#include <openssl/md5.h>
144#endif
145#ifndef NO_HMAC
146#include <openssl/hmac.h>
147#endif
148#include <openssl/evp.h>
149#ifndef NO_SHA

--- 41 unchanged lines hidden (view full) ---

191# define HZ ((double)CLK_TCK)
192# endif
193#endif
194
195#undef BUFSIZE
196#define BUFSIZE ((long)1024*8+1)
197int run=0;
198
183static double Time_F(int s);
199static double Time_F(int s, int usertime);
184static void print_message(char *s,long num,int length);
185static void pkey_print_message(char *str,char *str2,long num,int bits,int sec);
186#ifdef SIGALRM
187#if defined(__STDC__) || defined(sgi) || defined(_AIX)
188#define SIGRETTYPE void
189#else
190#define SIGRETTYPE int
191#endif

--- 7 unchanged lines hidden (view full) ---

199 sig=sig;
200#endif
201 }
202#endif
203
204#define START 0
205#define STOP 1
206
200static void print_message(char *s,long num,int length);
201static void pkey_print_message(char *str,char *str2,long num,int bits,int sec);
202#ifdef SIGALRM
203#if defined(__STDC__) || defined(sgi) || defined(_AIX)
204#define SIGRETTYPE void
205#else
206#define SIGRETTYPE int
207#endif

--- 7 unchanged lines hidden (view full) ---

215 sig=sig;
216#endif
217 }
218#endif
219
220#define START 0
221#define STOP 1
222
207static double Time_F(int s)
223static double Time_F(int s, int usertime)
208 {
209 double ret;
224 {
225 double ret;
210#ifdef TIMES
211 static struct tms tstart,tend;
212
226
213 if (s == START)
214 {
215 times(&tstart);
216 return(0);
227#ifdef USE_TOD
228 if(usertime)
229 {
230 static struct rusage tstart,tend;
231
232 if (s == START)
233 {
234 getrusage(RUSAGE_SELF,&tstart);
235 return(0);
236 }
237 else
238 {
239 long i;
240
241 getrusage(RUSAGE_SELF,&tend);
242 i=(long)tend.ru_utime.tv_usec-(long)tstart.ru_utime.tv_usec;
243 ret=((double)(tend.ru_utime.tv_sec-tstart.ru_utime.tv_sec))
244 +((double)i)/1000000.0;
245 return((ret < 0.001)?0.001:ret);
246 }
217 }
218 else
219 {
247 }
248 else
249 {
220 times(&tend);
221 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
222 return((ret < 1e-3)?1e-3:ret);
223 }
224#else /* !times() */
225 static struct timeb tstart,tend;
226 long i;
250 static struct timeval tstart,tend;
251 long i;
227
252
228 if (s == START)
253 if (s == START)
254 {
255 gettimeofday(&tstart,NULL);
256 return(0);
257 }
258 else
259 {
260 gettimeofday(&tend,NULL);
261 i=(long)tend.tv_usec-(long)tstart.tv_usec;
262 ret=((double)(tend.tv_sec-tstart.tv_sec))+((double)i)/1000000.0;
263 return((ret < 0.001)?0.001:ret);
264 }
265 }
266#else /* ndef USE_TOD */
267
268# ifdef TIMES
269 if (usertime)
229 {
270 {
230 ftime(&tstart);
231 return(0);
271 static struct tms tstart,tend;
272
273 if (s == START)
274 {
275 times(&tstart);
276 return(0);
277 }
278 else
279 {
280 times(&tend);
281 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
282 return((ret < 1e-3)?1e-3:ret);
283 }
232 }
284 }
285# endif /* times() */
286# if defined(TIMES) && defined(TIMEB)
233 else
287 else
288# endif
289# ifdef TIMEB
234 {
290 {
235 ftime(&tend);
236 i=(long)tend.millitm-(long)tstart.millitm;
237 ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
238 return((ret < 0.001)?0.001:ret);
291 static struct timeb tstart,tend;
292 long i;
293
294 if (s == START)
295 {
296 ftime(&tstart);
297 return(0);
298 }
299 else
300 {
301 ftime(&tend);
302 i=(long)tend.millitm-(long)tstart.millitm;
303 ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
304 return((ret < 0.001)?0.001:ret);
305 }
239 }
306 }
307# endif
240#endif
241 }
242
243int MAIN(int, char **);
244
245int MAIN(int argc, char **argv)
246 {
247 unsigned char *buf=NULL,*buf2=NULL;
248 int mret=1;
308#endif
309 }
310
311int MAIN(int, char **);
312
313int MAIN(int argc, char **argv)
314 {
315 unsigned char *buf=NULL,*buf2=NULL;
316 int mret=1;
249#define ALGOR_NUM 14
317#define ALGOR_NUM 15
250#define SIZE_NUM 5
251#define RSA_NUM 4
252#define DSA_NUM 3
253 long count,rsa_count;
254 int i,j,k;
318#define SIZE_NUM 5
319#define RSA_NUM 4
320#define DSA_NUM 3
321 long count,rsa_count;
322 int i,j,k;
255 unsigned rsa_num,rsa_num2;
323 unsigned rsa_num;
256#ifndef NO_MD2
257 unsigned char md2[MD2_DIGEST_LENGTH];
258#endif
259#ifndef NO_MDC2
260 unsigned char mdc2[MDC2_DIGEST_LENGTH];
261#endif
324#ifndef NO_MD2
325 unsigned char md2[MD2_DIGEST_LENGTH];
326#endif
327#ifndef NO_MDC2
328 unsigned char mdc2[MDC2_DIGEST_LENGTH];
329#endif
330#ifndef NO_MD4
331 unsigned char md4[MD4_DIGEST_LENGTH];
332#endif
262#ifndef NO_MD5
263 unsigned char md5[MD5_DIGEST_LENGTH];
264 unsigned char hmac[MD5_DIGEST_LENGTH];
265#endif
266#ifndef NO_SHA
267 unsigned char sha[SHA_DIGEST_LENGTH];
268#endif
269#ifndef NO_RIPEMD

--- 25 unchanged lines hidden (view full) ---

295 des_cblock *buf_as_des_cblock = NULL;
296 static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
297 static des_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
298 static des_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
299 des_key_schedule sch,sch2,sch3;
300#endif
301#define D_MD2 0
302#define D_MDC2 1
333#ifndef NO_MD5
334 unsigned char md5[MD5_DIGEST_LENGTH];
335 unsigned char hmac[MD5_DIGEST_LENGTH];
336#endif
337#ifndef NO_SHA
338 unsigned char sha[SHA_DIGEST_LENGTH];
339#endif
340#ifndef NO_RIPEMD

--- 25 unchanged lines hidden (view full) ---

366 des_cblock *buf_as_des_cblock = NULL;
367 static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
368 static des_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
369 static des_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
370 des_key_schedule sch,sch2,sch3;
371#endif
372#define D_MD2 0
373#define D_MDC2 1
303#define D_MD5 2
304#define D_HMAC 3
305#define D_SHA1 4
306#define D_RMD160 5
307#define D_RC4 6
308#define D_CBC_DES 7
309#define D_EDE3_DES 8
310#define D_CBC_IDEA 9
311#define D_CBC_RC2 10
312#define D_CBC_RC5 11
313#define D_CBC_BF 12
314#define D_CBC_CAST 13
374#define D_MD4 2
375#define D_MD5 3
376#define D_HMAC 4
377#define D_SHA1 5
378#define D_RMD160 6
379#define D_RC4 7
380#define D_CBC_DES 8
381#define D_EDE3_DES 9
382#define D_CBC_IDEA 10
383#define D_CBC_RC2 11
384#define D_CBC_RC5 12
385#define D_CBC_BF 13
386#define D_CBC_CAST 14
315 double d,results[ALGOR_NUM][SIZE_NUM];
316 static int lengths[SIZE_NUM]={8,64,256,1024,8*1024};
317 long c[ALGOR_NUM][SIZE_NUM];
318 static char *names[ALGOR_NUM]={
387 double d,results[ALGOR_NUM][SIZE_NUM];
388 static int lengths[SIZE_NUM]={8,64,256,1024,8*1024};
389 long c[ALGOR_NUM][SIZE_NUM];
390 static char *names[ALGOR_NUM]={
319 "md2","mdc2","md5","hmac(md5)","sha1","rmd160","rc4",
391 "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4",
320 "des cbc","des ede3","idea cbc",
321 "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc"};
322#define R_DSA_512 0
323#define R_DSA_1024 1
324#define R_DSA_2048 2
325#define R_RSA_512 0
326#define R_RSA_1024 1
327#define R_RSA_2048 2

--- 14 unchanged lines hidden (view full) ---

342 long dsa_c[DSA_NUM][2];
343 double dsa_results[DSA_NUM][2];
344 static unsigned int dsa_bits[DSA_NUM]={512,1024,2048};
345#endif
346 int rsa_doit[RSA_NUM];
347 int dsa_doit[DSA_NUM];
348 int doit[ALGOR_NUM];
349 int pr_header=0;
392 "des cbc","des ede3","idea cbc",
393 "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc"};
394#define R_DSA_512 0
395#define R_DSA_1024 1
396#define R_DSA_2048 2
397#define R_RSA_512 0
398#define R_RSA_1024 1
399#define R_RSA_2048 2

--- 14 unchanged lines hidden (view full) ---

414 long dsa_c[DSA_NUM][2];
415 double dsa_results[DSA_NUM][2];
416 static unsigned int dsa_bits[DSA_NUM]={512,1024,2048};
417#endif
418 int rsa_doit[RSA_NUM];
419 int dsa_doit[DSA_NUM];
420 int doit[ALGOR_NUM];
421 int pr_header=0;
422 int usertime=1;
350
423
424#ifndef TIMES
425 usertime=-1;
426#endif
427
351 apps_startup();
352 memset(results, 0, sizeof(results));
353#ifndef NO_DSA
354 memset(dsa_key,0,sizeof(dsa_key));
355#endif
356
357 if (bio_err == NULL)
358 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
359 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
360
361#ifndef NO_RSA
362 memset(rsa_key,0,sizeof(rsa_key));
363 for (i=0; i<RSA_NUM; i++)
364 rsa_key[i]=NULL;
365#endif
366
428 apps_startup();
429 memset(results, 0, sizeof(results));
430#ifndef NO_DSA
431 memset(dsa_key,0,sizeof(dsa_key));
432#endif
433
434 if (bio_err == NULL)
435 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
436 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
437
438#ifndef NO_RSA
439 memset(rsa_key,0,sizeof(rsa_key));
440 for (i=0; i<RSA_NUM; i++)
441 rsa_key[i]=NULL;
442#endif
443
367 if ((buf=(unsigned char *)Malloc((int)BUFSIZE)) == NULL)
444 if ((buf=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
368 {
369 BIO_printf(bio_err,"out of memory\n");
370 goto end;
371 }
372#ifndef NO_DES
373 buf_as_des_cblock = (des_cblock *)buf;
374#endif
445 {
446 BIO_printf(bio_err,"out of memory\n");
447 goto end;
448 }
449#ifndef NO_DES
450 buf_as_des_cblock = (des_cblock *)buf;
451#endif
375 if ((buf2=(unsigned char *)Malloc((int)BUFSIZE)) == NULL)
452 if ((buf2=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
376 {
377 BIO_printf(bio_err,"out of memory\n");
378 goto end;
379 }
380
381 memset(c,0,sizeof(c));
382 memset(iv,0,sizeof(iv));
383

--- 4 unchanged lines hidden (view full) ---

388 for (i=0; i<DSA_NUM; i++)
389 dsa_doit[i]=0;
390
391 j=0;
392 argc--;
393 argv++;
394 while (argc)
395 {
453 {
454 BIO_printf(bio_err,"out of memory\n");
455 goto end;
456 }
457
458 memset(c,0,sizeof(c));
459 memset(iv,0,sizeof(iv));
460

--- 4 unchanged lines hidden (view full) ---

465 for (i=0; i<DSA_NUM; i++)
466 dsa_doit[i]=0;
467
468 j=0;
469 argc--;
470 argv++;
471 while (argc)
472 {
473 if ((argc > 0) && (strcmp(*argv,"-elapsed") == 0))
474 usertime = 0;
396#ifndef NO_MD2
397 if (strcmp(*argv,"md2") == 0) doit[D_MD2]=1;
398 else
399#endif
400#ifndef NO_MDC2
401 if (strcmp(*argv,"mdc2") == 0) doit[D_MDC2]=1;
402 else
403#endif
475#ifndef NO_MD2
476 if (strcmp(*argv,"md2") == 0) doit[D_MD2]=1;
477 else
478#endif
479#ifndef NO_MDC2
480 if (strcmp(*argv,"mdc2") == 0) doit[D_MDC2]=1;
481 else
482#endif
483#ifndef NO_MD4
484 if (strcmp(*argv,"md4") == 0) doit[D_MD4]=1;
485 else
486#endif
404#ifndef NO_MD5
405 if (strcmp(*argv,"md5") == 0) doit[D_MD5]=1;
406 else
407#endif
408#ifndef NO_MD5
409 if (strcmp(*argv,"hmac") == 0) doit[D_HMAC]=1;
410 else
411#endif

--- 16 unchanged lines hidden (view full) ---

428 else
429#endif
430#ifndef NO_DES
431 if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1;
432 else if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1;
433 else
434#endif
435#ifndef NO_RSA
487#ifndef NO_MD5
488 if (strcmp(*argv,"md5") == 0) doit[D_MD5]=1;
489 else
490#endif
491#ifndef NO_MD5
492 if (strcmp(*argv,"hmac") == 0) doit[D_HMAC]=1;
493 else
494#endif

--- 16 unchanged lines hidden (view full) ---

511 else
512#endif
513#ifndef NO_DES
514 if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1;
515 else if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1;
516 else
517#endif
518#ifndef NO_RSA
519#ifdef RSAref
520 if (strcmp(*argv,"rsaref") == 0)
521 {
522 RSA_set_default_method(RSA_PKCS1_RSAref());
523 j--;
524 }
525 else
526#endif
436#ifndef RSA_NULL
437 if (strcmp(*argv,"openssl") == 0)
438 {
527#ifndef RSA_NULL
528 if (strcmp(*argv,"openssl") == 0)
529 {
439 RSA_set_default_method(RSA_PKCS1());
530 RSA_set_default_method(RSA_PKCS1_SSLeay());
440 j--;
441 }
442 else
443#endif
444#endif /* !NO_RSA */
445 if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2;
446 else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2;
447 else if (strcmp(*argv,"dsa2048") == 0) dsa_doit[R_DSA_2048]=2;

--- 51 unchanged lines hidden (view full) ---

499 if (strcmp(*argv,"dsa") == 0)
500 {
501 dsa_doit[R_DSA_512]=1;
502 dsa_doit[R_DSA_1024]=1;
503 }
504 else
505#endif
506 {
531 j--;
532 }
533 else
534#endif
535#endif /* !NO_RSA */
536 if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2;
537 else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2;
538 else if (strcmp(*argv,"dsa2048") == 0) dsa_doit[R_DSA_2048]=2;

--- 51 unchanged lines hidden (view full) ---

590 if (strcmp(*argv,"dsa") == 0)
591 {
592 dsa_doit[R_DSA_512]=1;
593 dsa_doit[R_DSA_1024]=1;
594 }
595 else
596#endif
597 {
507 BIO_printf(bio_err,"bad value, pick one of\n");
508 BIO_printf(bio_err,"md2 mdc2 md5 hmac sha1 rmd160\n");
598 BIO_printf(bio_err,"Error: bad option or value\n");
599 BIO_printf(bio_err,"\n");
600 BIO_printf(bio_err,"Available values:\n");
601#ifndef NO_MD2
602 BIO_printf(bio_err,"md2 ");
603#endif
604#ifndef NO_MDC2
605 BIO_printf(bio_err,"mdc2 ");
606#endif
607#ifndef NO_MD4
608 BIO_printf(bio_err,"md4 ");
609#endif
610#ifndef NO_MD5
611 BIO_printf(bio_err,"md5 ");
612#ifndef NO_HMAC
613 BIO_printf(bio_err,"hmac ");
614#endif
615#endif
616#ifndef NO_SHA1
617 BIO_printf(bio_err,"sha1 ");
618#endif
619#ifndef NO_RIPEMD160
620 BIO_printf(bio_err,"rmd160");
621#endif
622#if !defined(NO_MD2) || !defined(NO_MDC2) || !defined(NO_MD4) || !defined(NO_MD5) || !defined(NO_SHA1) || !defined(NO_RIPEMD160)
623 BIO_printf(bio_err,"\n");
624#endif
625
509#ifndef NO_IDEA
510 BIO_printf(bio_err,"idea-cbc ");
511#endif
512#ifndef NO_RC2
513 BIO_printf(bio_err,"rc2-cbc ");
514#endif
515#ifndef NO_RC5
516 BIO_printf(bio_err,"rc5-cbc ");
517#endif
518#ifndef NO_BF
519 BIO_printf(bio_err,"bf-cbc");
520#endif
626#ifndef NO_IDEA
627 BIO_printf(bio_err,"idea-cbc ");
628#endif
629#ifndef NO_RC2
630 BIO_printf(bio_err,"rc2-cbc ");
631#endif
632#ifndef NO_RC5
633 BIO_printf(bio_err,"rc5-cbc ");
634#endif
635#ifndef NO_BF
636 BIO_printf(bio_err,"bf-cbc");
637#endif
521#if !defined(NO_IDEA) && !defined(NO_RC2) && !defined(NO_BF) && !defined(NO_RC5)
638#if !defined(NO_IDEA) || !defined(NO_RC2) || !defined(NO_BF) || !defined(NO_RC5)
522 BIO_printf(bio_err,"\n");
523#endif
639 BIO_printf(bio_err,"\n");
640#endif
641
524 BIO_printf(bio_err,"des-cbc des-ede3 ");
525#ifndef NO_RC4
526 BIO_printf(bio_err,"rc4");
527#endif
642 BIO_printf(bio_err,"des-cbc des-ede3 ");
643#ifndef NO_RC4
644 BIO_printf(bio_err,"rc4");
645#endif
646 BIO_printf(bio_err,"\n");
647
528#ifndef NO_RSA
648#ifndef NO_RSA
529 BIO_printf(bio_err,"\nrsa512 rsa1024 rsa2048 rsa4096\n");
649 BIO_printf(bio_err,"rsa512 rsa1024 rsa2048 rsa4096\n");
530#endif
650#endif
651
531#ifndef NO_DSA
652#ifndef NO_DSA
532 BIO_printf(bio_err,"\ndsa512 dsa1024 dsa2048\n");
653 BIO_printf(bio_err,"dsa512 dsa1024 dsa2048\n");
533#endif
654#endif
534 BIO_printf(bio_err,"idea rc2 des rsa blowfish\n");
655
656#ifndef NO_IDEA
657 BIO_printf(bio_err,"idea ");
658#endif
659#ifndef NO_RC2
660 BIO_printf(bio_err,"rc2 ");
661#endif
662#ifndef NO_DES
663 BIO_printf(bio_err,"des ");
664#endif
665#ifndef NO_RSA
666 BIO_printf(bio_err,"rsa ");
667#endif
668#ifndef NO_BF
669 BIO_printf(bio_err,"blowfish");
670#endif
671#if !defined(NO_IDEA) || !defined(NO_RC2) || !defined(NO_DES) || !defined(NO_RSA) || !defined(NO_BF)
672 BIO_printf(bio_err,"\n");
673#endif
674
675#ifdef TIMES
676 BIO_printf(bio_err,"\n");
677 BIO_printf(bio_err,"Available options:\n");
678 BIO_printf(bio_err,"-elapsed measure time in real time instead of CPU user time.\n");
679#endif
535 goto end;
536 }
537 argc--;
538 argv++;
539 j++;
540 }
541
542 if (j == 0)
543 {
544 for (i=0; i<ALGOR_NUM; i++)
545 doit[i]=1;
546 for (i=0; i<RSA_NUM; i++)
547 rsa_doit[i]=1;
548 for (i=0; i<DSA_NUM; i++)
549 dsa_doit[i]=1;
550 }
551 for (i=0; i<ALGOR_NUM; i++)
552 if (doit[i]) pr_header++;
553
680 goto end;
681 }
682 argc--;
683 argv++;
684 j++;
685 }
686
687 if (j == 0)
688 {
689 for (i=0; i<ALGOR_NUM; i++)
690 doit[i]=1;
691 for (i=0; i<RSA_NUM; i++)
692 rsa_doit[i]=1;
693 for (i=0; i<DSA_NUM; i++)
694 dsa_doit[i]=1;
695 }
696 for (i=0; i<ALGOR_NUM; i++)
697 if (doit[i]) pr_header++;
698
554#ifndef TIMES
555 BIO_printf(bio_err,"To get the most accurate results, try to run this\n");
556 BIO_printf(bio_err,"program when this computer is idle.\n");
557#endif
699 if (usertime == 0)
700 BIO_printf(bio_err,"You have chosen to measure elapsed time instead of user CPU time.\n");
701 if (usertime <= 0)
702 {
703 BIO_printf(bio_err,"To get the most accurate results, try to run this\n");
704 BIO_printf(bio_err,"program when this computer is idle.\n");
705 }
558
559#ifndef NO_RSA
560 for (i=0; i<RSA_NUM; i++)
561 {
562 unsigned char *p;
563
564 p=rsa_data[i];
565 rsa_key[i]=d2i_RSAPrivateKey(NULL,&p,rsa_data_length[i]);

--- 47 unchanged lines hidden (view full) ---

613#endif
614#ifndef SIGALRM
615#ifndef NO_DES
616 BIO_printf(bio_err,"First we calculate the approximate speed ...\n");
617 count=10;
618 do {
619 long i;
620 count*=2;
706
707#ifndef NO_RSA
708 for (i=0; i<RSA_NUM; i++)
709 {
710 unsigned char *p;
711
712 p=rsa_data[i];
713 rsa_key[i]=d2i_RSAPrivateKey(NULL,&p,rsa_data_length[i]);

--- 47 unchanged lines hidden (view full) ---

761#endif
762#ifndef SIGALRM
763#ifndef NO_DES
764 BIO_printf(bio_err,"First we calculate the approximate speed ...\n");
765 count=10;
766 do {
767 long i;
768 count*=2;
621 Time_F(START);
769 Time_F(START,usertime);
622 for (i=count; i; i--)
623 des_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock,
624 &(sch[0]),DES_ENCRYPT);
770 for (i=count; i; i--)
771 des_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock,
772 &(sch[0]),DES_ENCRYPT);
625 d=Time_F(STOP);
773 d=Time_F(STOP,usertime);
626 } while (d <3);
627 c[D_MD2][0]=count/10;
628 c[D_MDC2][0]=count/10;
774 } while (d <3);
775 c[D_MD2][0]=count/10;
776 c[D_MDC2][0]=count/10;
777 c[D_MD4][0]=count;
629 c[D_MD5][0]=count;
630 c[D_HMAC][0]=count;
631 c[D_SHA1][0]=count;
632 c[D_RMD160][0]=count;
633 c[D_RC4][0]=count*5;
634 c[D_CBC_DES][0]=count;
635 c[D_EDE3_DES][0]=count/3;
636 c[D_CBC_IDEA][0]=count;
637 c[D_CBC_RC2][0]=count;
638 c[D_CBC_RC5][0]=count;
639 c[D_CBC_BF][0]=count;
640 c[D_CBC_CAST][0]=count;
641
642 for (i=1; i<SIZE_NUM; i++)
643 {
644 c[D_MD2][i]=c[D_MD2][0]*4*lengths[0]/lengths[i];
645 c[D_MDC2][i]=c[D_MDC2][0]*4*lengths[0]/lengths[i];
778 c[D_MD5][0]=count;
779 c[D_HMAC][0]=count;
780 c[D_SHA1][0]=count;
781 c[D_RMD160][0]=count;
782 c[D_RC4][0]=count*5;
783 c[D_CBC_DES][0]=count;
784 c[D_EDE3_DES][0]=count/3;
785 c[D_CBC_IDEA][0]=count;
786 c[D_CBC_RC2][0]=count;
787 c[D_CBC_RC5][0]=count;
788 c[D_CBC_BF][0]=count;
789 c[D_CBC_CAST][0]=count;
790
791 for (i=1; i<SIZE_NUM; i++)
792 {
793 c[D_MD2][i]=c[D_MD2][0]*4*lengths[0]/lengths[i];
794 c[D_MDC2][i]=c[D_MDC2][0]*4*lengths[0]/lengths[i];
795 c[D_MD4][i]=c[D_MD4][0]*4*lengths[0]/lengths[i];
646 c[D_MD5][i]=c[D_MD5][0]*4*lengths[0]/lengths[i];
647 c[D_HMAC][i]=c[D_HMAC][0]*4*lengths[0]/lengths[i];
648 c[D_SHA1][i]=c[D_SHA1][0]*4*lengths[0]/lengths[i];
649 c[D_RMD160][i]=c[D_RMD160][0]*4*lengths[0]/lengths[i];
650 }
651 for (i=1; i<SIZE_NUM; i++)
652 {
653 long l0,l1;

--- 60 unchanged lines hidden (view full) ---

714#endif /* SIGALRM */
715
716#ifndef NO_MD2
717 if (doit[D_MD2])
718 {
719 for (j=0; j<SIZE_NUM; j++)
720 {
721 print_message(names[D_MD2],c[D_MD2][j],lengths[j]);
796 c[D_MD5][i]=c[D_MD5][0]*4*lengths[0]/lengths[i];
797 c[D_HMAC][i]=c[D_HMAC][0]*4*lengths[0]/lengths[i];
798 c[D_SHA1][i]=c[D_SHA1][0]*4*lengths[0]/lengths[i];
799 c[D_RMD160][i]=c[D_RMD160][0]*4*lengths[0]/lengths[i];
800 }
801 for (i=1; i<SIZE_NUM; i++)
802 {
803 long l0,l1;

--- 60 unchanged lines hidden (view full) ---

864#endif /* SIGALRM */
865
866#ifndef NO_MD2
867 if (doit[D_MD2])
868 {
869 for (j=0; j<SIZE_NUM; j++)
870 {
871 print_message(names[D_MD2],c[D_MD2][j],lengths[j]);
722 Time_F(START);
872 Time_F(START,usertime);
723 for (count=0,run=1; COND(c[D_MD2][j]); count++)
724 MD2(buf,(unsigned long)lengths[j],&(md2[0]));
873 for (count=0,run=1; COND(c[D_MD2][j]); count++)
874 MD2(buf,(unsigned long)lengths[j],&(md2[0]));
725 d=Time_F(STOP);
875 d=Time_F(STOP,usertime);
726 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
727 count,names[D_MD2],d);
728 results[D_MD2][j]=((double)count)/d*lengths[j];
729 }
730 }
731#endif
732#ifndef NO_MDC2
733 if (doit[D_MDC2])
734 {
735 for (j=0; j<SIZE_NUM; j++)
736 {
737 print_message(names[D_MDC2],c[D_MDC2][j],lengths[j]);
876 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
877 count,names[D_MD2],d);
878 results[D_MD2][j]=((double)count)/d*lengths[j];
879 }
880 }
881#endif
882#ifndef NO_MDC2
883 if (doit[D_MDC2])
884 {
885 for (j=0; j<SIZE_NUM; j++)
886 {
887 print_message(names[D_MDC2],c[D_MDC2][j],lengths[j]);
738 Time_F(START);
888 Time_F(START,usertime);
739 for (count=0,run=1; COND(c[D_MDC2][j]); count++)
740 MDC2(buf,(unsigned long)lengths[j],&(mdc2[0]));
889 for (count=0,run=1; COND(c[D_MDC2][j]); count++)
890 MDC2(buf,(unsigned long)lengths[j],&(mdc2[0]));
741 d=Time_F(STOP);
891 d=Time_F(STOP,usertime);
742 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
743 count,names[D_MDC2],d);
744 results[D_MDC2][j]=((double)count)/d*lengths[j];
745 }
746 }
747#endif
748
892 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
893 count,names[D_MDC2],d);
894 results[D_MDC2][j]=((double)count)/d*lengths[j];
895 }
896 }
897#endif
898
899#ifndef NO_MD4
900 if (doit[D_MD4])
901 {
902 for (j=0; j<SIZE_NUM; j++)
903 {
904 print_message(names[D_MD4],c[D_MD4][j],lengths[j]);
905 Time_F(START,usertime);
906 for (count=0,run=1; COND(c[D_MD4][j]); count++)
907 MD4(&(buf[0]),(unsigned long)lengths[j],&(md4[0]));
908 d=Time_F(STOP,usertime);
909 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
910 count,names[D_MD4],d);
911 results[D_MD4][j]=((double)count)/d*lengths[j];
912 }
913 }
914#endif
915
749#ifndef NO_MD5
750 if (doit[D_MD5])
751 {
752 for (j=0; j<SIZE_NUM; j++)
753 {
754 print_message(names[D_MD5],c[D_MD5][j],lengths[j]);
916#ifndef NO_MD5
917 if (doit[D_MD5])
918 {
919 for (j=0; j<SIZE_NUM; j++)
920 {
921 print_message(names[D_MD5],c[D_MD5][j],lengths[j]);
755 Time_F(START);
922 Time_F(START,usertime);
756 for (count=0,run=1; COND(c[D_MD5][j]); count++)
757 MD5(&(buf[0]),(unsigned long)lengths[j],&(md5[0]));
923 for (count=0,run=1; COND(c[D_MD5][j]); count++)
924 MD5(&(buf[0]),(unsigned long)lengths[j],&(md5[0]));
758 d=Time_F(STOP);
925 d=Time_F(STOP,usertime);
759 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
760 count,names[D_MD5],d);
761 results[D_MD5][j]=((double)count)/d*lengths[j];
762 }
763 }
764#endif
765
766#if !defined(NO_MD5) && !defined(NO_HMAC)
767 if (doit[D_HMAC])
768 {
769 HMAC_CTX hctx;
770 HMAC_Init(&hctx,(unsigned char *)"This is a key...",
771 16,EVP_md5());
772
773 for (j=0; j<SIZE_NUM; j++)
774 {
775 print_message(names[D_HMAC],c[D_HMAC][j],lengths[j]);
926 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
927 count,names[D_MD5],d);
928 results[D_MD5][j]=((double)count)/d*lengths[j];
929 }
930 }
931#endif
932
933#if !defined(NO_MD5) && !defined(NO_HMAC)
934 if (doit[D_HMAC])
935 {
936 HMAC_CTX hctx;
937 HMAC_Init(&hctx,(unsigned char *)"This is a key...",
938 16,EVP_md5());
939
940 for (j=0; j<SIZE_NUM; j++)
941 {
942 print_message(names[D_HMAC],c[D_HMAC][j],lengths[j]);
776 Time_F(START);
943 Time_F(START,usertime);
777 for (count=0,run=1; COND(c[D_HMAC][j]); count++)
778 {
779 HMAC_Init(&hctx,NULL,0,NULL);
780 HMAC_Update(&hctx,buf,lengths[j]);
781 HMAC_Final(&hctx,&(hmac[0]),NULL);
782 }
944 for (count=0,run=1; COND(c[D_HMAC][j]); count++)
945 {
946 HMAC_Init(&hctx,NULL,0,NULL);
947 HMAC_Update(&hctx,buf,lengths[j]);
948 HMAC_Final(&hctx,&(hmac[0]),NULL);
949 }
783 d=Time_F(STOP);
950 d=Time_F(STOP,usertime);
784 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
785 count,names[D_HMAC],d);
786 results[D_HMAC][j]=((double)count)/d*lengths[j];
787 }
788 }
789#endif
790#ifndef NO_SHA
791 if (doit[D_SHA1])
792 {
793 for (j=0; j<SIZE_NUM; j++)
794 {
795 print_message(names[D_SHA1],c[D_SHA1][j],lengths[j]);
951 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
952 count,names[D_HMAC],d);
953 results[D_HMAC][j]=((double)count)/d*lengths[j];
954 }
955 }
956#endif
957#ifndef NO_SHA
958 if (doit[D_SHA1])
959 {
960 for (j=0; j<SIZE_NUM; j++)
961 {
962 print_message(names[D_SHA1],c[D_SHA1][j],lengths[j]);
796 Time_F(START);
963 Time_F(START,usertime);
797 for (count=0,run=1; COND(c[D_SHA1][j]); count++)
798 SHA1(buf,(unsigned long)lengths[j],&(sha[0]));
964 for (count=0,run=1; COND(c[D_SHA1][j]); count++)
965 SHA1(buf,(unsigned long)lengths[j],&(sha[0]));
799 d=Time_F(STOP);
966 d=Time_F(STOP,usertime);
800 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
801 count,names[D_SHA1],d);
802 results[D_SHA1][j]=((double)count)/d*lengths[j];
803 }
804 }
805#endif
806#ifndef NO_RIPEMD
807 if (doit[D_RMD160])
808 {
809 for (j=0; j<SIZE_NUM; j++)
810 {
811 print_message(names[D_RMD160],c[D_RMD160][j],lengths[j]);
967 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
968 count,names[D_SHA1],d);
969 results[D_SHA1][j]=((double)count)/d*lengths[j];
970 }
971 }
972#endif
973#ifndef NO_RIPEMD
974 if (doit[D_RMD160])
975 {
976 for (j=0; j<SIZE_NUM; j++)
977 {
978 print_message(names[D_RMD160],c[D_RMD160][j],lengths[j]);
812 Time_F(START);
979 Time_F(START,usertime);
813 for (count=0,run=1; COND(c[D_RMD160][j]); count++)
814 RIPEMD160(buf,(unsigned long)lengths[j],&(rmd160[0]));
980 for (count=0,run=1; COND(c[D_RMD160][j]); count++)
981 RIPEMD160(buf,(unsigned long)lengths[j],&(rmd160[0]));
815 d=Time_F(STOP);
982 d=Time_F(STOP,usertime);
816 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
817 count,names[D_RMD160],d);
818 results[D_RMD160][j]=((double)count)/d*lengths[j];
819 }
820 }
821#endif
822#ifndef NO_RC4
823 if (doit[D_RC4])
824 {
825 for (j=0; j<SIZE_NUM; j++)
826 {
827 print_message(names[D_RC4],c[D_RC4][j],lengths[j]);
983 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
984 count,names[D_RMD160],d);
985 results[D_RMD160][j]=((double)count)/d*lengths[j];
986 }
987 }
988#endif
989#ifndef NO_RC4
990 if (doit[D_RC4])
991 {
992 for (j=0; j<SIZE_NUM; j++)
993 {
994 print_message(names[D_RC4],c[D_RC4][j],lengths[j]);
828 Time_F(START);
995 Time_F(START,usertime);
829 for (count=0,run=1; COND(c[D_RC4][j]); count++)
830 RC4(&rc4_ks,(unsigned int)lengths[j],
831 buf,buf);
996 for (count=0,run=1; COND(c[D_RC4][j]); count++)
997 RC4(&rc4_ks,(unsigned int)lengths[j],
998 buf,buf);
832 d=Time_F(STOP);
999 d=Time_F(STOP,usertime);
833 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
834 count,names[D_RC4],d);
835 results[D_RC4][j]=((double)count)/d*lengths[j];
836 }
837 }
838#endif
839#ifndef NO_DES
840 if (doit[D_CBC_DES])
841 {
842 for (j=0; j<SIZE_NUM; j++)
843 {
844 print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
1000 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
1001 count,names[D_RC4],d);
1002 results[D_RC4][j]=((double)count)/d*lengths[j];
1003 }
1004 }
1005#endif
1006#ifndef NO_DES
1007 if (doit[D_CBC_DES])
1008 {
1009 for (j=0; j<SIZE_NUM; j++)
1010 {
1011 print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
845 Time_F(START);
1012 Time_F(START,usertime);
846 for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
847 des_ncbc_encrypt(buf,buf,lengths[j],sch,
848 &iv,DES_ENCRYPT);
1013 for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
1014 des_ncbc_encrypt(buf,buf,lengths[j],sch,
1015 &iv,DES_ENCRYPT);
849 d=Time_F(STOP);
1016 d=Time_F(STOP,usertime);
850 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
851 count,names[D_CBC_DES],d);
852 results[D_CBC_DES][j]=((double)count)/d*lengths[j];
853 }
854 }
855
856 if (doit[D_EDE3_DES])
857 {
858 for (j=0; j<SIZE_NUM; j++)
859 {
860 print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
1017 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
1018 count,names[D_CBC_DES],d);
1019 results[D_CBC_DES][j]=((double)count)/d*lengths[j];
1020 }
1021 }
1022
1023 if (doit[D_EDE3_DES])
1024 {
1025 for (j=0; j<SIZE_NUM; j++)
1026 {
1027 print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
861 Time_F(START);
1028 Time_F(START,usertime);
862 for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
863 des_ede3_cbc_encrypt(buf,buf,lengths[j],
864 sch,sch2,sch3,
865 &iv,DES_ENCRYPT);
1029 for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
1030 des_ede3_cbc_encrypt(buf,buf,lengths[j],
1031 sch,sch2,sch3,
1032 &iv,DES_ENCRYPT);
866 d=Time_F(STOP);
1033 d=Time_F(STOP,usertime);
867 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
868 count,names[D_EDE3_DES],d);
869 results[D_EDE3_DES][j]=((double)count)/d*lengths[j];
870 }
871 }
872#endif
873#ifndef NO_IDEA
874 if (doit[D_CBC_IDEA])
875 {
876 for (j=0; j<SIZE_NUM; j++)
877 {
878 print_message(names[D_CBC_IDEA],c[D_CBC_IDEA][j],lengths[j]);
1034 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
1035 count,names[D_EDE3_DES],d);
1036 results[D_EDE3_DES][j]=((double)count)/d*lengths[j];
1037 }
1038 }
1039#endif
1040#ifndef NO_IDEA
1041 if (doit[D_CBC_IDEA])
1042 {
1043 for (j=0; j<SIZE_NUM; j++)
1044 {
1045 print_message(names[D_CBC_IDEA],c[D_CBC_IDEA][j],lengths[j]);
879 Time_F(START);
1046 Time_F(START,usertime);
880 for (count=0,run=1; COND(c[D_CBC_IDEA][j]); count++)
881 idea_cbc_encrypt(buf,buf,
882 (unsigned long)lengths[j],&idea_ks,
883 iv,IDEA_ENCRYPT);
1047 for (count=0,run=1; COND(c[D_CBC_IDEA][j]); count++)
1048 idea_cbc_encrypt(buf,buf,
1049 (unsigned long)lengths[j],&idea_ks,
1050 iv,IDEA_ENCRYPT);
884 d=Time_F(STOP);
1051 d=Time_F(STOP,usertime);
885 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
886 count,names[D_CBC_IDEA],d);
887 results[D_CBC_IDEA][j]=((double)count)/d*lengths[j];
888 }
889 }
890#endif
891#ifndef NO_RC2
892 if (doit[D_CBC_RC2])
893 {
894 for (j=0; j<SIZE_NUM; j++)
895 {
896 print_message(names[D_CBC_RC2],c[D_CBC_RC2][j],lengths[j]);
1052 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
1053 count,names[D_CBC_IDEA],d);
1054 results[D_CBC_IDEA][j]=((double)count)/d*lengths[j];
1055 }
1056 }
1057#endif
1058#ifndef NO_RC2
1059 if (doit[D_CBC_RC2])
1060 {
1061 for (j=0; j<SIZE_NUM; j++)
1062 {
1063 print_message(names[D_CBC_RC2],c[D_CBC_RC2][j],lengths[j]);
897 Time_F(START);
1064 Time_F(START,usertime);
898 for (count=0,run=1; COND(c[D_CBC_RC2][j]); count++)
899 RC2_cbc_encrypt(buf,buf,
900 (unsigned long)lengths[j],&rc2_ks,
901 iv,RC2_ENCRYPT);
1065 for (count=0,run=1; COND(c[D_CBC_RC2][j]); count++)
1066 RC2_cbc_encrypt(buf,buf,
1067 (unsigned long)lengths[j],&rc2_ks,
1068 iv,RC2_ENCRYPT);
902 d=Time_F(STOP);
1069 d=Time_F(STOP,usertime);
903 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
904 count,names[D_CBC_RC2],d);
905 results[D_CBC_RC2][j]=((double)count)/d*lengths[j];
906 }
907 }
908#endif
909#ifndef NO_RC5
910 if (doit[D_CBC_RC5])
911 {
912 for (j=0; j<SIZE_NUM; j++)
913 {
914 print_message(names[D_CBC_RC5],c[D_CBC_RC5][j],lengths[j]);
1070 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
1071 count,names[D_CBC_RC2],d);
1072 results[D_CBC_RC2][j]=((double)count)/d*lengths[j];
1073 }
1074 }
1075#endif
1076#ifndef NO_RC5
1077 if (doit[D_CBC_RC5])
1078 {
1079 for (j=0; j<SIZE_NUM; j++)
1080 {
1081 print_message(names[D_CBC_RC5],c[D_CBC_RC5][j],lengths[j]);
915 Time_F(START);
1082 Time_F(START,usertime);
916 for (count=0,run=1; COND(c[D_CBC_RC5][j]); count++)
917 RC5_32_cbc_encrypt(buf,buf,
918 (unsigned long)lengths[j],&rc5_ks,
919 iv,RC5_ENCRYPT);
1083 for (count=0,run=1; COND(c[D_CBC_RC5][j]); count++)
1084 RC5_32_cbc_encrypt(buf,buf,
1085 (unsigned long)lengths[j],&rc5_ks,
1086 iv,RC5_ENCRYPT);
920 d=Time_F(STOP);
1087 d=Time_F(STOP,usertime);
921 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
922 count,names[D_CBC_RC5],d);
923 results[D_CBC_RC5][j]=((double)count)/d*lengths[j];
924 }
925 }
926#endif
927#ifndef NO_BF
928 if (doit[D_CBC_BF])
929 {
930 for (j=0; j<SIZE_NUM; j++)
931 {
932 print_message(names[D_CBC_BF],c[D_CBC_BF][j],lengths[j]);
1088 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
1089 count,names[D_CBC_RC5],d);
1090 results[D_CBC_RC5][j]=((double)count)/d*lengths[j];
1091 }
1092 }
1093#endif
1094#ifndef NO_BF
1095 if (doit[D_CBC_BF])
1096 {
1097 for (j=0; j<SIZE_NUM; j++)
1098 {
1099 print_message(names[D_CBC_BF],c[D_CBC_BF][j],lengths[j]);
933 Time_F(START);
1100 Time_F(START,usertime);
934 for (count=0,run=1; COND(c[D_CBC_BF][j]); count++)
935 BF_cbc_encrypt(buf,buf,
936 (unsigned long)lengths[j],&bf_ks,
937 iv,BF_ENCRYPT);
1101 for (count=0,run=1; COND(c[D_CBC_BF][j]); count++)
1102 BF_cbc_encrypt(buf,buf,
1103 (unsigned long)lengths[j],&bf_ks,
1104 iv,BF_ENCRYPT);
938 d=Time_F(STOP);
1105 d=Time_F(STOP,usertime);
939 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
940 count,names[D_CBC_BF],d);
941 results[D_CBC_BF][j]=((double)count)/d*lengths[j];
942 }
943 }
944#endif
945#ifndef NO_CAST
946 if (doit[D_CBC_CAST])
947 {
948 for (j=0; j<SIZE_NUM; j++)
949 {
950 print_message(names[D_CBC_CAST],c[D_CBC_CAST][j],lengths[j]);
1106 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
1107 count,names[D_CBC_BF],d);
1108 results[D_CBC_BF][j]=((double)count)/d*lengths[j];
1109 }
1110 }
1111#endif
1112#ifndef NO_CAST
1113 if (doit[D_CBC_CAST])
1114 {
1115 for (j=0; j<SIZE_NUM; j++)
1116 {
1117 print_message(names[D_CBC_CAST],c[D_CBC_CAST][j],lengths[j]);
951 Time_F(START);
1118 Time_F(START,usertime);
952 for (count=0,run=1; COND(c[D_CBC_CAST][j]); count++)
953 CAST_cbc_encrypt(buf,buf,
954 (unsigned long)lengths[j],&cast_ks,
955 iv,CAST_ENCRYPT);
1119 for (count=0,run=1; COND(c[D_CBC_CAST][j]); count++)
1120 CAST_cbc_encrypt(buf,buf,
1121 (unsigned long)lengths[j],&cast_ks,
1122 iv,CAST_ENCRYPT);
956 d=Time_F(STOP);
1123 d=Time_F(STOP,usertime);
957 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
958 count,names[D_CBC_CAST],d);
959 results[D_CBC_CAST][j]=((double)count)/d*lengths[j];
960 }
961 }
962#endif
963
964 RAND_pseudo_bytes(buf,36);
965#ifndef NO_RSA
966 for (j=0; j<RSA_NUM; j++)
967 {
968 int ret;
969 if (!rsa_doit[j]) continue;
970 ret=RSA_sign(NID_md5_sha1, buf,36, buf2, &rsa_num, rsa_key[j]);
1124 BIO_printf(bio_err,"%ld %s's in %.2fs\n",
1125 count,names[D_CBC_CAST],d);
1126 results[D_CBC_CAST][j]=((double)count)/d*lengths[j];
1127 }
1128 }
1129#endif
1130
1131 RAND_pseudo_bytes(buf,36);
1132#ifndef NO_RSA
1133 for (j=0; j<RSA_NUM; j++)
1134 {
1135 int ret;
1136 if (!rsa_doit[j]) continue;
1137 ret=RSA_sign(NID_md5_sha1, buf,36, buf2, &rsa_num, rsa_key[j]);
971 pkey_print_message("private","rsa",rsa_c[j][0],rsa_bits[j],
972 RSA_SECONDS);
973/* RSA_blinding_on(rsa_key[j],NULL); */
974 Time_F(START);
975 for (count=0,run=1; COND(rsa_c[j][0]); count++)
1138 if (ret == 0)
976 {
1139 {
977 ret=RSA_sign(NID_md5_sha1, buf,36, buf2, &rsa_num,
978 rsa_key[j]);
979 if (ret <= 0)
1140 BIO_printf(bio_err,"RSA sign failure. No RSA sign will be done.\n");
1141 ERR_print_errors(bio_err);
1142 rsa_count=1;
1143 }
1144 else
1145 {
1146 pkey_print_message("private","rsa",
1147 rsa_c[j][0],rsa_bits[j],
1148 RSA_SECONDS);
1149/* RSA_blinding_on(rsa_key[j],NULL); */
1150 Time_F(START,usertime);
1151 for (count=0,run=1; COND(rsa_c[j][0]); count++)
980 {
1152 {
981 BIO_printf(bio_err,"RSA private encrypt failure\n");
982 ERR_print_errors(bio_err);
983 count=1;
984 break;
1153 ret=RSA_sign(NID_md5_sha1, buf,36, buf2,
1154 &rsa_num, rsa_key[j]);
1155 if (ret == 0)
1156 {
1157 BIO_printf(bio_err,
1158 "RSA sign failure\n");
1159 ERR_print_errors(bio_err);
1160 count=1;
1161 break;
1162 }
985 }
1163 }
1164 d=Time_F(STOP,usertime);
1165 BIO_printf(bio_err,
1166 "%ld %d bit private RSA's in %.2fs\n",
1167 count,rsa_bits[j],d);
1168 rsa_results[j][0]=d/(double)count;
1169 rsa_count=count;
986 }
1170 }
987 d=Time_F(STOP);
988 BIO_printf(bio_err,"%ld %d bit private RSA's in %.2fs\n",
989 count,rsa_bits[j],d);
990 rsa_results[j][0]=d/(double)count;
991 rsa_count=count;
992
993#if 1
994 ret=RSA_verify(NID_md5_sha1, buf,36, buf2, rsa_num, rsa_key[j]);
1171
1172#if 1
1173 ret=RSA_verify(NID_md5_sha1, buf,36, buf2, rsa_num, rsa_key[j]);
995 pkey_print_message("public","rsa",rsa_c[j][1],rsa_bits[j],
996 RSA_SECONDS);
997 Time_F(START);
998 for (count=0,run=1; COND(rsa_c[j][1]); count++)
1174 if (ret <= 0)
999 {
1175 {
1000 ret=RSA_verify(NID_md5_sha1, buf,36, buf2, rsa_num,
1001 rsa_key[j]);
1002 if (ret <= 0)
1176 BIO_printf(bio_err,"RSA verify failure. No RSA verify will be done.\n");
1177 ERR_print_errors(bio_err);
1178 dsa_doit[j] = 0;
1179 }
1180 else
1181 {
1182 pkey_print_message("public","rsa",
1183 rsa_c[j][1],rsa_bits[j],
1184 RSA_SECONDS);
1185 Time_F(START,usertime);
1186 for (count=0,run=1; COND(rsa_c[j][1]); count++)
1003 {
1187 {
1004 BIO_printf(bio_err,"RSA verify failure\n");
1005 ERR_print_errors(bio_err);
1006 count=1;
1007 break;
1188 ret=RSA_verify(NID_md5_sha1, buf,36, buf2,
1189 rsa_num, rsa_key[j]);
1190 if (ret == 0)
1191 {
1192 BIO_printf(bio_err,
1193 "RSA verify failure\n");
1194 ERR_print_errors(bio_err);
1195 count=1;
1196 break;
1197 }
1008 }
1198 }
1199 d=Time_F(STOP,usertime);
1200 BIO_printf(bio_err,
1201 "%ld %d bit public RSA's in %.2fs\n",
1202 count,rsa_bits[j],d);
1203 rsa_results[j][1]=d/(double)count;
1009 }
1204 }
1010 d=Time_F(STOP);
1011 BIO_printf(bio_err,"%ld %d bit public RSA's in %.2fs\n",
1012 count,rsa_bits[j],d);
1013 rsa_results[j][1]=d/(double)count;
1014#endif
1015
1016 if (rsa_count <= 1)
1017 {
1018 /* if longer than 10s, don't do any more */
1019 for (j++; j<RSA_NUM; j++)
1020 rsa_doit[j]=0;
1021 }

--- 5 unchanged lines hidden (view full) ---

1027 if (RAND_status() != 1)
1028 {
1029 RAND_seed(rnd_seed, sizeof rnd_seed);
1030 rnd_fake = 1;
1031 }
1032 for (j=0; j<DSA_NUM; j++)
1033 {
1034 unsigned int kk;
1205#endif
1206
1207 if (rsa_count <= 1)
1208 {
1209 /* if longer than 10s, don't do any more */
1210 for (j++; j<RSA_NUM; j++)
1211 rsa_doit[j]=0;
1212 }

--- 5 unchanged lines hidden (view full) ---

1218 if (RAND_status() != 1)
1219 {
1220 RAND_seed(rnd_seed, sizeof rnd_seed);
1221 rnd_fake = 1;
1222 }
1223 for (j=0; j<DSA_NUM; j++)
1224 {
1225 unsigned int kk;
1226 int ret;
1035
1036 if (!dsa_doit[j]) continue;
1037 DSA_generate_key(dsa_key[j]);
1038/* DSA_sign_setup(dsa_key[j],NULL); */
1227
1228 if (!dsa_doit[j]) continue;
1229 DSA_generate_key(dsa_key[j]);
1230/* DSA_sign_setup(dsa_key[j],NULL); */
1039 rsa_num=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1231 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1040 &kk,dsa_key[j]);
1232 &kk,dsa_key[j]);
1041 pkey_print_message("sign","dsa",dsa_c[j][0],dsa_bits[j],
1042 DSA_SECONDS);
1043 Time_F(START);
1044 for (count=0,run=1; COND(dsa_c[j][0]); count++)
1233 if (ret == 0)
1045 {
1234 {
1046 rsa_num=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1047 &kk,dsa_key[j]);
1048 if (rsa_num == 0)
1235 BIO_printf(bio_err,"DSA sign failure. No DSA sign will be done.\n");
1236 ERR_print_errors(bio_err);
1237 rsa_count=1;
1238 }
1239 else
1240 {
1241 pkey_print_message("sign","dsa",
1242 dsa_c[j][0],dsa_bits[j],
1243 DSA_SECONDS);
1244 Time_F(START,usertime);
1245 for (count=0,run=1; COND(dsa_c[j][0]); count++)
1049 {
1246 {
1050 BIO_printf(bio_err,"DSA sign failure\n");
1051 ERR_print_errors(bio_err);
1052 count=1;
1053 break;
1247 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1248 &kk,dsa_key[j]);
1249 if (ret == 0)
1250 {
1251 BIO_printf(bio_err,
1252 "DSA sign failure\n");
1253 ERR_print_errors(bio_err);
1254 count=1;
1255 break;
1256 }
1054 }
1257 }
1258 d=Time_F(STOP,usertime);
1259 BIO_printf(bio_err,"%ld %d bit DSA signs in %.2fs\n",
1260 count,dsa_bits[j],d);
1261 dsa_results[j][0]=d/(double)count;
1262 rsa_count=count;
1055 }
1263 }
1056 d=Time_F(STOP);
1057 BIO_printf(bio_err,"%ld %d bit DSA signs in %.2fs\n",
1058 count,dsa_bits[j],d);
1059 dsa_results[j][0]=d/(double)count;
1060 rsa_count=count;
1061
1264
1062 rsa_num2=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1265 ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1063 kk,dsa_key[j]);
1266 kk,dsa_key[j]);
1064 pkey_print_message("verify","dsa",dsa_c[j][1],dsa_bits[j],
1065 DSA_SECONDS);
1066 Time_F(START);
1067 for (count=0,run=1; COND(dsa_c[j][1]); count++)
1267 if (ret <= 0)
1068 {
1268 {
1069 rsa_num2=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1070 kk,dsa_key[j]);
1071 if (rsa_num2 == 0)
1269 BIO_printf(bio_err,"DSA verify failure. No DSA verify will be done.\n");
1270 ERR_print_errors(bio_err);
1271 dsa_doit[j] = 0;
1272 }
1273 else
1274 {
1275 pkey_print_message("verify","dsa",
1276 dsa_c[j][1],dsa_bits[j],
1277 DSA_SECONDS);
1278 Time_F(START,usertime);
1279 for (count=0,run=1; COND(dsa_c[j][1]); count++)
1072 {
1280 {
1073 BIO_printf(bio_err,"DSA verify failure\n");
1074 ERR_print_errors(bio_err);
1075 count=1;
1076 break;
1281 ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1282 kk,dsa_key[j]);
1283 if (ret <= 0)
1284 {
1285 BIO_printf(bio_err,
1286 "DSA verify failure\n");
1287 ERR_print_errors(bio_err);
1288 count=1;
1289 break;
1290 }
1077 }
1291 }
1292 d=Time_F(STOP,usertime);
1293 BIO_printf(bio_err,"%ld %d bit DSA verify in %.2fs\n",
1294 count,dsa_bits[j],d);
1295 dsa_results[j][1]=d/(double)count;
1078 }
1296 }
1079 d=Time_F(STOP);
1080 BIO_printf(bio_err,"%ld %d bit DSA verify in %.2fs\n",
1081 count,dsa_bits[j],d);
1082 dsa_results[j][1]=d/(double)count;
1083
1084 if (rsa_count <= 1)
1085 {
1086 /* if longer than 10s, don't do any more */
1087 for (j++; j<DSA_NUM; j++)
1088 dsa_doit[j]=0;
1089 }
1090 }

--- 71 unchanged lines hidden (view full) ---

1162 fprintf(stdout,"dsa %4u bits %8.4fs %8.4fs %8.1f %8.1f",
1163 dsa_bits[k],dsa_results[k][0],dsa_results[k][1],
1164 1.0/dsa_results[k][0],1.0/dsa_results[k][1]);
1165 fprintf(stdout,"\n");
1166 }
1167#endif
1168 mret=0;
1169end:
1297
1298 if (rsa_count <= 1)
1299 {
1300 /* if longer than 10s, don't do any more */
1301 for (j++; j<DSA_NUM; j++)
1302 dsa_doit[j]=0;
1303 }
1304 }

--- 71 unchanged lines hidden (view full) ---

1376 fprintf(stdout,"dsa %4u bits %8.4fs %8.4fs %8.1f %8.1f",
1377 dsa_bits[k],dsa_results[k][0],dsa_results[k][1],
1378 1.0/dsa_results[k][0],1.0/dsa_results[k][1]);
1379 fprintf(stdout,"\n");
1380 }
1381#endif
1382 mret=0;
1383end:
1170 if (buf != NULL) Free(buf);
1171 if (buf2 != NULL) Free(buf2);
1384 if (buf != NULL) OPENSSL_free(buf);
1385 if (buf2 != NULL) OPENSSL_free(buf2);
1172#ifndef NO_RSA
1173 for (i=0; i<RSA_NUM; i++)
1174 if (rsa_key[i] != NULL)
1175 RSA_free(rsa_key[i]);
1176#endif
1177#ifndef NO_DSA
1178 for (i=0; i<DSA_NUM; i++)
1179 if (dsa_key[i] != NULL)

--- 36 unchanged lines hidden ---
1386#ifndef NO_RSA
1387 for (i=0; i<RSA_NUM; i++)
1388 if (rsa_key[i] != NULL)
1389 RSA_free(rsa_key[i]);
1390#endif
1391#ifndef NO_DSA
1392 for (i=0; i<DSA_NUM; i++)
1393 if (dsa_key[i] != NULL)

--- 36 unchanged lines hidden ---