1 /* apps/speed.c -*- mode:C; c-file-style: "eay" -*- */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
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.
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).
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.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
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)"
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
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.]
59 /* most of this code has been pilfered from my libdes speed.c program */
63 #define RSA_SECONDS 10
64 #define DSA_SECONDS 10
66 /* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
67 /* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
70 #define PROG speed_main
78 #ifdef OPENSSL_NO_STDIO
81 #include <openssl/crypto.h>
82 #include <openssl/rand.h>
83 #include <openssl/err.h>
84 #include <openssl/evp.h>
85 #include <openssl/objects.h>
86 #if !defined(OPENSSL_SYS_MSDOS)
87 #include OPENSSL_UNISTD
90 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(OPENSSL_SYS_MACOSX)
92 #elif !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
95 #if !defined(_UNICOS) && !defined(__OpenBSD__) && !defined(sgi) && !defined(__FreeBSD__) && !(defined(__bsdi) || defined(__bsdi__)) && !defined(_AIX) && !defined(OPENSSL_SYS_MPE) && !defined(__NetBSD__) /* FIXME */
103 # include <sys/types.h>
104 # include <sys/times.h>
107 # include <sys/time.h>
108 # include <sys/resource.h>
111 /* Depending on the VMS version, the tms structure is perhaps defined.
112 The __TMS macro will show if it was. If it wasn't defined, we should
113 undefine TIMES, since that tells the rest of the program how things
114 should be handled. -- Richard Levitte */
115 #if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
120 #include <sys/timeb.h>
123 #if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD)
124 #error "It seems neither struct tms nor struct timeb is supported in this platform!"
127 #if defined(sun) || defined(__ultrix)
128 #define _POSIX_SOURCE
130 #include <sys/param.h>
133 #ifndef OPENSSL_NO_DES
134 #include <openssl/des_old.h>
136 #ifndef OPENSSL_NO_MD2
137 #include <openssl/md2.h>
139 #ifndef OPENSSL_NO_MDC2
140 #include <openssl/mdc2.h>
142 #ifndef OPENSSL_NO_MD4
143 #include <openssl/md4.h>
145 #ifndef OPENSSL_NO_MD5
146 #include <openssl/md5.h>
148 #ifndef OPENSSL_NO_HMAC
149 #include <openssl/hmac.h>
151 #include <openssl/evp.h>
152 #ifndef OPENSSL_NO_SHA
153 #include <openssl/sha.h>
155 #ifndef OPENSSL_NO_RIPEMD
156 #include <openssl/ripemd.h>
158 #ifndef OPENSSL_NO_RC4
159 #include <openssl/rc4.h>
161 #ifndef OPENSSL_NO_RC5
162 #include <openssl/rc5.h>
164 #ifndef OPENSSL_NO_RC2
165 #include <openssl/rc2.h>
167 #ifndef OPENSSL_NO_IDEA
168 #include <openssl/idea.h>
170 #ifndef OPENSSL_NO_BF
171 #include <openssl/blowfish.h>
173 #ifndef OPENSSL_NO_CAST
174 #include <openssl/cast.h>
176 #ifndef OPENSSL_NO_RSA
177 #include <openssl/rsa.h>
178 #include "./testrsa.h"
180 #include <openssl/x509.h>
181 #ifndef OPENSSL_NO_DSA
182 #include "./testdsa.h"
185 /* The following if from times(3) man page. It may need to be changed */
188 # define HZ ((double)sysconf(_SC_CLK_TCK))
191 # ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
193 # else /* _BSD_CLK_TCK_ */
194 # define HZ ((double)_BSD_CLK_TCK_)
197 # define HZ ((double)CLK_TCK)
202 #if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2)
207 #define BUFSIZE ((long)1024*8+1)
210 static char ftime_used = 0, times_used = 0, gettimeofday_used = 0, getrusage_used = 0;
212 static int usertime=1;
214 static double Time_F(int s);
215 static void print_message(const char *s,long num,int length);
216 static void pkey_print_message(char *str,char *str2,long num,int bits,int sec);
217 static void print_result(int alg,int run_no,int count,double time_used);
219 static int do_multi(int multi);
222 #if defined(__STDC__) || defined(sgi) || defined(_AIX)
223 #define SIGRETTYPE void
225 #define SIGRETTYPE int
232 static const char *names[ALGOR_NUM]={
233 "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4",
234 "des cbc","des ede3","idea cbc",
235 "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc"};
236 static double results[ALGOR_NUM][SIZE_NUM];
237 static int lengths[SIZE_NUM]={8,64,256,1024,8*1024};
238 static double rsa_results[RSA_NUM][2];
239 static double dsa_results[DSA_NUM][2];
241 static SIGRETTYPE sig_done(int sig);
242 static SIGRETTYPE sig_done(int sig)
244 signal(SIGALRM,sig_done);
255 static double Time_F(int s)
262 static struct rusage tstart,tend;
267 getrusage(RUSAGE_SELF,&tstart);
274 getrusage(RUSAGE_SELF,&tend);
275 i=(long)tend.ru_utime.tv_usec-(long)tstart.ru_utime.tv_usec;
276 ret=((double)(tend.ru_utime.tv_sec-tstart.ru_utime.tv_sec))
277 +((double)i)/1000000.0;
278 return((ret < 0.001)?0.001:ret);
283 static struct timeval tstart,tend;
286 gettimeofday_used = 1;
289 gettimeofday(&tstart,NULL);
294 gettimeofday(&tend,NULL);
295 i=(long)tend.tv_usec-(long)tstart.tv_usec;
296 ret=((double)(tend.tv_sec-tstart.tv_sec))+((double)i)/1000000.0;
297 return((ret < 0.001)?0.001:ret);
300 #else /* ndef USE_TOD */
305 static struct tms tstart,tend;
316 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
317 return((ret < 1e-3)?1e-3:ret);
320 # endif /* times() */
321 # if defined(TIMES) && defined(TIMEB)
326 static struct timeb tstart,tend;
338 i=(long)tend.millitm-(long)tstart.millitm;
339 ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
340 return((ret < 0.001)?0.001:ret);
347 int MAIN(int, char **);
349 int MAIN(int argc, char **argv)
352 unsigned char *buf=NULL,*buf2=NULL;
354 long count,rsa_count,save_count=0;
356 #ifndef OPENSSL_NO_RSA
359 #ifndef OPENSSL_NO_MD2
360 unsigned char md2[MD2_DIGEST_LENGTH];
362 #ifndef OPENSSL_NO_MDC2
363 unsigned char mdc2[MDC2_DIGEST_LENGTH];
365 #ifndef OPENSSL_NO_MD4
366 unsigned char md4[MD4_DIGEST_LENGTH];
368 #ifndef OPENSSL_NO_MD5
369 unsigned char md5[MD5_DIGEST_LENGTH];
370 unsigned char hmac[MD5_DIGEST_LENGTH];
372 #ifndef OPENSSL_NO_SHA
373 unsigned char sha[SHA_DIGEST_LENGTH];
375 #ifndef OPENSSL_NO_RIPEMD
376 unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];
378 #ifndef OPENSSL_NO_RC4
381 #ifndef OPENSSL_NO_RC5
384 #ifndef OPENSSL_NO_RC2
387 #ifndef OPENSSL_NO_IDEA
388 IDEA_KEY_SCHEDULE idea_ks;
390 #ifndef OPENSSL_NO_BF
393 #ifndef OPENSSL_NO_CAST
396 static unsigned char key16[16]=
397 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
398 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
400 #ifndef OPENSSL_NO_DES
401 DES_cblock *buf_as_des_cblock = NULL;
402 static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
403 static des_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
404 static des_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
405 DES_key_schedule sch;
406 DES_key_schedule sch2;
407 DES_key_schedule sch3;
419 #define D_CBC_IDEA 10
423 #define D_CBC_CAST 14
426 long c[ALGOR_NUM][SIZE_NUM];
434 #ifndef OPENSSL_NO_RSA
435 RSA *rsa_key[RSA_NUM];
436 long rsa_c[RSA_NUM][2];
437 static unsigned int rsa_bits[RSA_NUM]={512,1024,2048,4096};
438 static unsigned char *rsa_data[RSA_NUM]=
439 {test512,test1024,test2048,test4096};
440 static int rsa_data_length[RSA_NUM]={
441 sizeof(test512),sizeof(test1024),
442 sizeof(test2048),sizeof(test4096)};
444 #ifndef OPENSSL_NO_DSA
445 DSA *dsa_key[DSA_NUM];
446 long dsa_c[DSA_NUM][2];
447 static unsigned int dsa_bits[DSA_NUM]={512,1024,2048};
449 int rsa_doit[RSA_NUM];
450 int dsa_doit[DSA_NUM];
453 const EVP_CIPHER *evp=NULL;
464 memset(results, 0, sizeof(results));
465 #ifndef OPENSSL_NO_DSA
466 memset(dsa_key,0,sizeof(dsa_key));
470 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
471 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
473 #ifndef OPENSSL_NO_RSA
474 memset(rsa_key,0,sizeof(rsa_key));
475 for (i=0; i<RSA_NUM; i++)
479 if ((buf=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
481 BIO_printf(bio_err,"out of memory\n");
484 #ifndef OPENSSL_NO_DES
485 buf_as_des_cblock = (des_cblock *)buf;
487 if ((buf2=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
489 BIO_printf(bio_err,"out of memory\n");
493 memset(c,0,sizeof(c));
494 memset(iv,0,sizeof(iv));
496 for (i=0; i<ALGOR_NUM; i++)
498 for (i=0; i<RSA_NUM; i++)
500 for (i=0; i<DSA_NUM; i++)
508 if ((argc > 0) && (strcmp(*argv,"-elapsed") == 0))
511 j--; /* Otherwise, -elapsed gets confused with
514 else if ((argc > 0) && (strcmp(*argv,"-evp") == 0))
520 BIO_printf(bio_err,"no EVP given\n");
523 evp=EVP_get_cipherbyname(*argv);
526 BIO_printf(bio_err,"%s is an unknown cipher\n",*argv);
531 else if (argc > 0 && !strcmp(*argv,"-decrypt"))
534 j--; /* Otherwise, -elapsed gets confused with
537 else if ((argc > 0) && (strcmp(*argv,"-engine") == 0))
543 BIO_printf(bio_err,"no engine given\n");
546 e = setup_engine(bio_err, *argv, 0);
547 /* j will be increased again further down. We just
548 don't want speed to confuse an engine with an
549 algorithm, especially when none is given (which
550 means all of them should be run) */
554 else if ((argc > 0) && (strcmp(*argv,"-multi") == 0))
560 BIO_printf(bio_err,"no multi count given\n");
566 BIO_printf(bio_err,"bad multi count\n");
569 j--; /* Otherwise, -mr gets confused with
573 else if (argc > 0 && !strcmp(*argv,"-mr"))
576 j--; /* Otherwise, -mr gets confused with
580 #ifndef OPENSSL_NO_MD2
581 if (strcmp(*argv,"md2") == 0) doit[D_MD2]=1;
584 #ifndef OPENSSL_NO_MDC2
585 if (strcmp(*argv,"mdc2") == 0) doit[D_MDC2]=1;
588 #ifndef OPENSSL_NO_MD4
589 if (strcmp(*argv,"md4") == 0) doit[D_MD4]=1;
592 #ifndef OPENSSL_NO_MD5
593 if (strcmp(*argv,"md5") == 0) doit[D_MD5]=1;
596 #ifndef OPENSSL_NO_MD5
597 if (strcmp(*argv,"hmac") == 0) doit[D_HMAC]=1;
600 #ifndef OPENSSL_NO_SHA
601 if (strcmp(*argv,"sha1") == 0) doit[D_SHA1]=1;
603 if (strcmp(*argv,"sha") == 0) doit[D_SHA1]=1;
606 #ifndef OPENSSL_NO_RIPEMD
607 if (strcmp(*argv,"ripemd") == 0) doit[D_RMD160]=1;
609 if (strcmp(*argv,"rmd160") == 0) doit[D_RMD160]=1;
611 if (strcmp(*argv,"ripemd160") == 0) doit[D_RMD160]=1;
614 #ifndef OPENSSL_NO_RC4
615 if (strcmp(*argv,"rc4") == 0) doit[D_RC4]=1;
618 #ifndef OPENSSL_NO_DES
619 if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1;
620 else if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1;
623 #ifndef OPENSSL_NO_RSA
624 #if 0 /* was: #ifdef RSAref */
625 if (strcmp(*argv,"rsaref") == 0)
627 RSA_set_default_openssl_method(RSA_PKCS1_RSAref());
633 if (strcmp(*argv,"openssl") == 0)
635 RSA_set_default_method(RSA_PKCS1_SSLeay());
640 #endif /* !OPENSSL_NO_RSA */
641 if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2;
642 else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2;
643 else if (strcmp(*argv,"dsa2048") == 0) dsa_doit[R_DSA_2048]=2;
644 else if (strcmp(*argv,"rsa512") == 0) rsa_doit[R_RSA_512]=2;
645 else if (strcmp(*argv,"rsa1024") == 0) rsa_doit[R_RSA_1024]=2;
646 else if (strcmp(*argv,"rsa2048") == 0) rsa_doit[R_RSA_2048]=2;
647 else if (strcmp(*argv,"rsa4096") == 0) rsa_doit[R_RSA_4096]=2;
649 #ifndef OPENSSL_NO_RC2
650 if (strcmp(*argv,"rc2-cbc") == 0) doit[D_CBC_RC2]=1;
651 else if (strcmp(*argv,"rc2") == 0) doit[D_CBC_RC2]=1;
654 #ifndef OPENSSL_NO_RC5
655 if (strcmp(*argv,"rc5-cbc") == 0) doit[D_CBC_RC5]=1;
656 else if (strcmp(*argv,"rc5") == 0) doit[D_CBC_RC5]=1;
659 #ifndef OPENSSL_NO_IDEA
660 if (strcmp(*argv,"idea-cbc") == 0) doit[D_CBC_IDEA]=1;
661 else if (strcmp(*argv,"idea") == 0) doit[D_CBC_IDEA]=1;
664 #ifndef OPENSSL_NO_BF
665 if (strcmp(*argv,"bf-cbc") == 0) doit[D_CBC_BF]=1;
666 else if (strcmp(*argv,"blowfish") == 0) doit[D_CBC_BF]=1;
667 else if (strcmp(*argv,"bf") == 0) doit[D_CBC_BF]=1;
670 #ifndef OPENSSL_NO_CAST
671 if (strcmp(*argv,"cast-cbc") == 0) doit[D_CBC_CAST]=1;
672 else if (strcmp(*argv,"cast") == 0) doit[D_CBC_CAST]=1;
673 else if (strcmp(*argv,"cast5") == 0) doit[D_CBC_CAST]=1;
676 #ifndef OPENSSL_NO_DES
677 if (strcmp(*argv,"des") == 0)
684 #ifndef OPENSSL_NO_RSA
685 if (strcmp(*argv,"rsa") == 0)
687 rsa_doit[R_RSA_512]=1;
688 rsa_doit[R_RSA_1024]=1;
689 rsa_doit[R_RSA_2048]=1;
690 rsa_doit[R_RSA_4096]=1;
694 #ifndef OPENSSL_NO_DSA
695 if (strcmp(*argv,"dsa") == 0)
697 dsa_doit[R_DSA_512]=1;
698 dsa_doit[R_DSA_1024]=1;
703 BIO_printf(bio_err,"Error: bad option or value\n");
704 BIO_printf(bio_err,"\n");
705 BIO_printf(bio_err,"Available values:\n");
706 #ifndef OPENSSL_NO_MD2
707 BIO_printf(bio_err,"md2 ");
709 #ifndef OPENSSL_NO_MDC2
710 BIO_printf(bio_err,"mdc2 ");
712 #ifndef OPENSSL_NO_MD4
713 BIO_printf(bio_err,"md4 ");
715 #ifndef OPENSSL_NO_MD5
716 BIO_printf(bio_err,"md5 ");
717 #ifndef OPENSSL_NO_HMAC
718 BIO_printf(bio_err,"hmac ");
721 #ifndef OPENSSL_NO_SHA1
722 BIO_printf(bio_err,"sha1 ");
724 #ifndef OPENSSL_NO_RIPEMD160
725 BIO_printf(bio_err,"rmd160");
727 #if !defined(OPENSSL_NO_MD2) || !defined(OPENSSL_NO_MDC2) || \
728 !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \
729 !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160)
730 BIO_printf(bio_err,"\n");
733 #ifndef OPENSSL_NO_IDEA
734 BIO_printf(bio_err,"idea-cbc ");
736 #ifndef OPENSSL_NO_RC2
737 BIO_printf(bio_err,"rc2-cbc ");
739 #ifndef OPENSSL_NO_RC5
740 BIO_printf(bio_err,"rc5-cbc ");
742 #ifndef OPENSSL_NO_BF
743 BIO_printf(bio_err,"bf-cbc");
745 #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
746 !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_RC5)
747 BIO_printf(bio_err,"\n");
750 BIO_printf(bio_err,"des-cbc des-ede3 ");
751 #ifndef OPENSSL_NO_RC4
752 BIO_printf(bio_err,"rc4");
754 BIO_printf(bio_err,"\n");
756 #ifndef OPENSSL_NO_RSA
757 BIO_printf(bio_err,"rsa512 rsa1024 rsa2048 rsa4096\n");
760 #ifndef OPENSSL_NO_DSA
761 BIO_printf(bio_err,"dsa512 dsa1024 dsa2048\n");
764 #ifndef OPENSSL_NO_IDEA
765 BIO_printf(bio_err,"idea ");
767 #ifndef OPENSSL_NO_RC2
768 BIO_printf(bio_err,"rc2 ");
770 #ifndef OPENSSL_NO_DES
771 BIO_printf(bio_err,"des ");
773 #ifndef OPENSSL_NO_RSA
774 BIO_printf(bio_err,"rsa ");
776 #ifndef OPENSSL_NO_BF
777 BIO_printf(bio_err,"blowfish");
779 #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
780 !defined(OPENSSL_NO_DES) || !defined(OPENSSL_NO_RSA) || \
781 !defined(OPENSSL_NO_BF)
782 BIO_printf(bio_err,"\n");
785 BIO_printf(bio_err,"\n");
786 BIO_printf(bio_err,"Available options:\n");
788 BIO_printf(bio_err,"-elapsed measure time in real time instead of CPU user time.\n");
790 BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n");
791 BIO_printf(bio_err,"-evp e use EVP e.\n");
792 BIO_printf(bio_err,"-decrypt time decryption instead of encryption (only EVP).\n");
793 BIO_printf(bio_err,"-mr produce machine readable output.\n");
795 BIO_printf(bio_err,"-multi n run n benchmarks in parallel.\n");
805 if(multi && do_multi(multi))
811 for (i=0; i<ALGOR_NUM; i++)
816 for (i=0; i<RSA_NUM; i++)
818 for (i=0; i<DSA_NUM; i++)
821 for (i=0; i<ALGOR_NUM; i++)
822 if (doit[i]) pr_header++;
824 if (usertime == 0 && !mr)
825 BIO_printf(bio_err,"You have chosen to measure elapsed time instead of user CPU time.\n");
826 if (usertime <= 0 && !mr)
828 BIO_printf(bio_err,"To get the most accurate results, try to run this\n");
829 BIO_printf(bio_err,"program when this computer is idle.\n");
832 #ifndef OPENSSL_NO_RSA
833 for (i=0; i<RSA_NUM; i++)
835 const unsigned char *p;
838 rsa_key[i]=d2i_RSAPrivateKey(NULL,&p,rsa_data_length[i]);
839 if (rsa_key[i] == NULL)
841 BIO_printf(bio_err,"internal error loading RSA key number %d\n",i);
847 BIO_printf(bio_err,mr ? "+RK:%d:"
848 : "Loaded RSA key, %d bit modulus and e= 0x",
849 BN_num_bits(rsa_key[i]->n));
850 BN_print(bio_err,rsa_key[i]->e);
851 BIO_printf(bio_err,"\n");
857 #ifndef OPENSSL_NO_DSA
858 dsa_key[0]=get_dsa512();
859 dsa_key[1]=get_dsa1024();
860 dsa_key[2]=get_dsa2048();
863 #ifndef OPENSSL_NO_DES
864 DES_set_key_unchecked(&key,&sch);
865 DES_set_key_unchecked(&key2,&sch2);
866 DES_set_key_unchecked(&key3,&sch3);
868 #ifndef OPENSSL_NO_IDEA
869 idea_set_encrypt_key(key16,&idea_ks);
871 #ifndef OPENSSL_NO_RC4
872 RC4_set_key(&rc4_ks,16,key16);
874 #ifndef OPENSSL_NO_RC2
875 RC2_set_key(&rc2_ks,16,key16,128);
877 #ifndef OPENSSL_NO_RC5
878 RC5_32_set_key(&rc5_ks,16,key16,12);
880 #ifndef OPENSSL_NO_BF
881 BF_set_key(&bf_ks,16,key16);
883 #ifndef OPENSSL_NO_CAST
884 CAST_set_key(&cast_ks,16,key16);
886 #ifndef OPENSSL_NO_RSA
887 memset(rsa_c,0,sizeof(rsa_c));
890 #ifndef OPENSSL_NO_DES
891 BIO_printf(bio_err,"First we calculate the approximate speed ...\n");
896 Time_F(START,usertime);
897 for (i=count; i; i--)
898 des_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock,
903 c[D_MD2][0]=count/10;
904 c[D_MDC2][0]=count/10;
909 c[D_RMD160][0]=count;
911 c[D_CBC_DES][0]=count;
912 c[D_EDE3_DES][0]=count/3;
913 c[D_CBC_IDEA][0]=count;
914 c[D_CBC_RC2][0]=count;
915 c[D_CBC_RC5][0]=count;
916 c[D_CBC_BF][0]=count;
917 c[D_CBC_CAST][0]=count;
919 for (i=1; i<SIZE_NUM; i++)
921 c[D_MD2][i]=c[D_MD2][0]*4*lengths[0]/lengths[i];
922 c[D_MDC2][i]=c[D_MDC2][0]*4*lengths[0]/lengths[i];
923 c[D_MD4][i]=c[D_MD4][0]*4*lengths[0]/lengths[i];
924 c[D_MD5][i]=c[D_MD5][0]*4*lengths[0]/lengths[i];
925 c[D_HMAC][i]=c[D_HMAC][0]*4*lengths[0]/lengths[i];
926 c[D_SHA1][i]=c[D_SHA1][0]*4*lengths[0]/lengths[i];
927 c[D_RMD160][i]=c[D_RMD160][0]*4*lengths[0]/lengths[i];
929 for (i=1; i<SIZE_NUM; i++)
933 l0=(long)lengths[i-1];
935 c[D_RC4][i]=c[D_RC4][i-1]*l0/l1;
936 c[D_CBC_DES][i]=c[D_CBC_DES][i-1]*l0/l1;
937 c[D_EDE3_DES][i]=c[D_EDE3_DES][i-1]*l0/l1;
938 c[D_CBC_IDEA][i]=c[D_CBC_IDEA][i-1]*l0/l1;
939 c[D_CBC_RC2][i]=c[D_CBC_RC2][i-1]*l0/l1;
940 c[D_CBC_RC5][i]=c[D_CBC_RC5][i-1]*l0/l1;
941 c[D_CBC_BF][i]=c[D_CBC_BF][i-1]*l0/l1;
942 c[D_CBC_CAST][i]=c[D_CBC_CAST][i-1]*l0/l1;
944 #ifndef OPENSSL_NO_RSA
945 rsa_c[R_RSA_512][0]=count/2000;
946 rsa_c[R_RSA_512][1]=count/400;
947 for (i=1; i<RSA_NUM; i++)
949 rsa_c[i][0]=rsa_c[i-1][0]/8;
950 rsa_c[i][1]=rsa_c[i-1][1]/4;
951 if ((rsa_doit[i] <= 1) && (rsa_c[i][0] == 0))
955 if (rsa_c[i][0] == 0)
964 #ifndef OPENSSL_NO_DSA
965 dsa_c[R_DSA_512][0]=count/1000;
966 dsa_c[R_DSA_512][1]=count/1000/2;
967 for (i=1; i<DSA_NUM; i++)
969 dsa_c[i][0]=dsa_c[i-1][0]/4;
970 dsa_c[i][1]=dsa_c[i-1][1]/4;
971 if ((dsa_doit[i] <= 1) && (dsa_c[i][0] == 0))
984 #define COND(d) (count < (d))
987 /* not worth fixing */
988 # error "You cannot disable DES on systems without SIGALRM."
989 #endif /* OPENSSL_NO_DES */
991 #define COND(c) (run)
992 #define COUNT(d) (count)
993 signal(SIGALRM,sig_done);
996 #ifndef OPENSSL_NO_MD2
999 for (j=0; j<SIZE_NUM; j++)
1001 print_message(names[D_MD2],c[D_MD2][j],lengths[j]);
1003 for (count=0,run=1; COND(c[D_MD2][j]); count++)
1004 EVP_Digest(buf,(unsigned long)lengths[j],&(md2[0]),NULL,EVP_md2(),NULL);
1006 print_result(D_MD2,j,count,d);
1010 #ifndef OPENSSL_NO_MDC2
1013 for (j=0; j<SIZE_NUM; j++)
1015 print_message(names[D_MDC2],c[D_MDC2][j],lengths[j]);
1017 for (count=0,run=1; COND(c[D_MDC2][j]); count++)
1018 EVP_Digest(buf,(unsigned long)lengths[j],&(mdc2[0]),NULL,EVP_mdc2(),NULL);
1020 print_result(D_MDC2,j,count,d);
1025 #ifndef OPENSSL_NO_MD4
1028 for (j=0; j<SIZE_NUM; j++)
1030 print_message(names[D_MD4],c[D_MD4][j],lengths[j]);
1032 for (count=0,run=1; COND(c[D_MD4][j]); count++)
1033 EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md4[0]),NULL,EVP_md4(),NULL);
1035 print_result(D_MD4,j,count,d);
1040 #ifndef OPENSSL_NO_MD5
1043 for (j=0; j<SIZE_NUM; j++)
1045 print_message(names[D_MD5],c[D_MD5][j],lengths[j]);
1047 for (count=0,run=1; COND(c[D_MD5][j]); count++)
1048 EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md5[0]),NULL,EVP_get_digestbyname("md5"),NULL);
1050 print_result(D_MD5,j,count,d);
1055 #if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC)
1060 HMAC_CTX_init(&hctx);
1061 HMAC_Init(&hctx,(unsigned char *)"This is a key...",
1064 for (j=0; j<SIZE_NUM; j++)
1066 print_message(names[D_HMAC],c[D_HMAC][j],lengths[j]);
1068 for (count=0,run=1; COND(c[D_HMAC][j]); count++)
1070 HMAC_Init(&hctx,NULL,0,NULL);
1071 HMAC_Update(&hctx,buf,lengths[j]);
1072 HMAC_Final(&hctx,&(hmac[0]),NULL);
1075 print_result(D_HMAC,j,count,d);
1077 HMAC_CTX_cleanup(&hctx);
1080 #ifndef OPENSSL_NO_SHA
1083 for (j=0; j<SIZE_NUM; j++)
1085 print_message(names[D_SHA1],c[D_SHA1][j],lengths[j]);
1087 for (count=0,run=1; COND(c[D_SHA1][j]); count++)
1088 EVP_Digest(buf,(unsigned long)lengths[j],&(sha[0]),NULL,EVP_sha1(),NULL);
1090 print_result(D_SHA1,j,count,d);
1094 #ifndef OPENSSL_NO_RIPEMD
1097 for (j=0; j<SIZE_NUM; j++)
1099 print_message(names[D_RMD160],c[D_RMD160][j],lengths[j]);
1101 for (count=0,run=1; COND(c[D_RMD160][j]); count++)
1102 EVP_Digest(buf,(unsigned long)lengths[j],&(rmd160[0]),NULL,EVP_ripemd160(),NULL);
1104 print_result(D_RMD160,j,count,d);
1108 #ifndef OPENSSL_NO_RC4
1111 for (j=0; j<SIZE_NUM; j++)
1113 print_message(names[D_RC4],c[D_RC4][j],lengths[j]);
1115 for (count=0,run=1; COND(c[D_RC4][j]); count++)
1116 RC4(&rc4_ks,(unsigned int)lengths[j],
1119 print_result(D_RC4,j,count,d);
1123 #ifndef OPENSSL_NO_DES
1124 if (doit[D_CBC_DES])
1126 for (j=0; j<SIZE_NUM; j++)
1128 print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
1130 for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
1131 DES_ncbc_encrypt(buf,buf,lengths[j],&sch,
1134 print_result(D_CBC_DES,j,count,d);
1138 if (doit[D_EDE3_DES])
1140 for (j=0; j<SIZE_NUM; j++)
1142 print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
1144 for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
1145 DES_ede3_cbc_encrypt(buf,buf,lengths[j],
1149 print_result(D_EDE3_DES,j,count,d);
1153 #ifndef OPENSSL_NO_IDEA
1154 if (doit[D_CBC_IDEA])
1156 for (j=0; j<SIZE_NUM; j++)
1158 print_message(names[D_CBC_IDEA],c[D_CBC_IDEA][j],lengths[j]);
1160 for (count=0,run=1; COND(c[D_CBC_IDEA][j]); count++)
1161 idea_cbc_encrypt(buf,buf,
1162 (unsigned long)lengths[j],&idea_ks,
1165 print_result(D_CBC_IDEA,j,count,d);
1169 #ifndef OPENSSL_NO_RC2
1170 if (doit[D_CBC_RC2])
1172 for (j=0; j<SIZE_NUM; j++)
1174 print_message(names[D_CBC_RC2],c[D_CBC_RC2][j],lengths[j]);
1176 for (count=0,run=1; COND(c[D_CBC_RC2][j]); count++)
1177 RC2_cbc_encrypt(buf,buf,
1178 (unsigned long)lengths[j],&rc2_ks,
1181 print_result(D_CBC_RC2,j,count,d);
1185 #ifndef OPENSSL_NO_RC5
1186 if (doit[D_CBC_RC5])
1188 for (j=0; j<SIZE_NUM; j++)
1190 print_message(names[D_CBC_RC5],c[D_CBC_RC5][j],lengths[j]);
1192 for (count=0,run=1; COND(c[D_CBC_RC5][j]); count++)
1193 RC5_32_cbc_encrypt(buf,buf,
1194 (unsigned long)lengths[j],&rc5_ks,
1197 print_result(D_CBC_RC5,j,count,d);
1201 #ifndef OPENSSL_NO_BF
1204 for (j=0; j<SIZE_NUM; j++)
1206 print_message(names[D_CBC_BF],c[D_CBC_BF][j],lengths[j]);
1208 for (count=0,run=1; COND(c[D_CBC_BF][j]); count++)
1209 BF_cbc_encrypt(buf,buf,
1210 (unsigned long)lengths[j],&bf_ks,
1213 print_result(D_CBC_BF,j,count,d);
1217 #ifndef OPENSSL_NO_CAST
1218 if (doit[D_CBC_CAST])
1220 for (j=0; j<SIZE_NUM; j++)
1222 print_message(names[D_CBC_CAST],c[D_CBC_CAST][j],lengths[j]);
1224 for (count=0,run=1; COND(c[D_CBC_CAST][j]); count++)
1225 CAST_cbc_encrypt(buf,buf,
1226 (unsigned long)lengths[j],&cast_ks,
1229 print_result(D_CBC_CAST,j,count,d);
1236 for (j=0; j<SIZE_NUM; j++)
1241 names[D_EVP]=OBJ_nid2ln(evp->nid);
1242 print_message(names[D_EVP],save_count,
1244 EVP_CIPHER_CTX_init(&ctx);
1246 EVP_DecryptInit_ex(&ctx,evp,NULL,key16,iv);
1248 EVP_EncryptInit_ex(&ctx,evp,NULL,key16,iv);
1252 for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1253 EVP_DecryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
1255 for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1256 EVP_EncryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
1258 EVP_DecryptFinal_ex(&ctx,buf,&outl);
1260 EVP_EncryptFinal_ex(&ctx,buf,&outl);
1262 print_result(D_EVP,j,count,d);
1266 RAND_pseudo_bytes(buf,36);
1267 #ifndef OPENSSL_NO_RSA
1268 for (j=0; j<RSA_NUM; j++)
1271 if (!rsa_doit[j]) continue;
1272 ret=RSA_sign(NID_md5_sha1, buf,36, buf2, &rsa_num, rsa_key[j]);
1275 BIO_printf(bio_err,"RSA sign failure. No RSA sign will be done.\n");
1276 ERR_print_errors(bio_err);
1281 pkey_print_message("private","rsa",
1282 rsa_c[j][0],rsa_bits[j],
1284 /* RSA_blinding_on(rsa_key[j],NULL); */
1286 for (count=0,run=1; COND(rsa_c[j][0]); count++)
1288 ret=RSA_sign(NID_md5_sha1, buf,36, buf2,
1289 &rsa_num, rsa_key[j]);
1293 "RSA sign failure\n");
1294 ERR_print_errors(bio_err);
1300 BIO_printf(bio_err,mr ? "+R1:%ld:%d:%.2f\n"
1301 : "%ld %d bit private RSA's in %.2fs\n",
1302 count,rsa_bits[j],d);
1303 rsa_results[j][0]=d/(double)count;
1308 ret=RSA_verify(NID_md5_sha1, buf,36, buf2, rsa_num, rsa_key[j]);
1311 BIO_printf(bio_err,"RSA verify failure. No RSA verify will be done.\n");
1312 ERR_print_errors(bio_err);
1317 pkey_print_message("public","rsa",
1318 rsa_c[j][1],rsa_bits[j],
1321 for (count=0,run=1; COND(rsa_c[j][1]); count++)
1323 ret=RSA_verify(NID_md5_sha1, buf,36, buf2,
1324 rsa_num, rsa_key[j]);
1328 "RSA verify failure\n");
1329 ERR_print_errors(bio_err);
1335 BIO_printf(bio_err,mr ? "+R2:%ld:%d:%.2f\n"
1336 : "%ld %d bit public RSA's in %.2fs\n",
1337 count,rsa_bits[j],d);
1338 rsa_results[j][1]=d/(double)count;
1344 /* if longer than 10s, don't do any more */
1345 for (j++; j<RSA_NUM; j++)
1351 RAND_pseudo_bytes(buf,20);
1352 #ifndef OPENSSL_NO_DSA
1353 if (RAND_status() != 1)
1355 RAND_seed(rnd_seed, sizeof rnd_seed);
1358 for (j=0; j<DSA_NUM; j++)
1363 if (!dsa_doit[j]) continue;
1364 /* DSA_generate_key(dsa_key[j]); */
1365 /* DSA_sign_setup(dsa_key[j],NULL); */
1366 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1370 BIO_printf(bio_err,"DSA sign failure. No DSA sign will be done.\n");
1371 ERR_print_errors(bio_err);
1376 pkey_print_message("sign","dsa",
1377 dsa_c[j][0],dsa_bits[j],
1380 for (count=0,run=1; COND(dsa_c[j][0]); count++)
1382 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1387 "DSA sign failure\n");
1388 ERR_print_errors(bio_err);
1394 BIO_printf(bio_err,mr ? "+R3:%ld:%d:%.2f\n"
1395 : "%ld %d bit DSA signs in %.2fs\n",
1396 count,dsa_bits[j],d);
1397 dsa_results[j][0]=d/(double)count;
1401 ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1405 BIO_printf(bio_err,"DSA verify failure. No DSA verify will be done.\n");
1406 ERR_print_errors(bio_err);
1411 pkey_print_message("verify","dsa",
1412 dsa_c[j][1],dsa_bits[j],
1415 for (count=0,run=1; COND(dsa_c[j][1]); count++)
1417 ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1422 "DSA verify failure\n");
1423 ERR_print_errors(bio_err);
1429 BIO_printf(bio_err,mr ? "+R4:%ld:%d:%.2f\n"
1430 : "%ld %d bit DSA verify in %.2fs\n",
1431 count,dsa_bits[j],d);
1432 dsa_results[j][1]=d/(double)count;
1437 /* if longer than 10s, don't do any more */
1438 for (j++; j<DSA_NUM; j++)
1442 if (rnd_fake) RAND_cleanup();
1447 fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_VERSION));
1448 fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_BUILT_ON));
1450 printf("%s ",BN_options());
1451 #ifndef OPENSSL_NO_MD2
1452 printf("%s ",MD2_options());
1454 #ifndef OPENSSL_NO_RC4
1455 printf("%s ",RC4_options());
1457 #ifndef OPENSSL_NO_DES
1458 printf("%s ",des_options());
1460 #ifndef OPENSSL_NO_IDEA
1461 printf("%s ",idea_options());
1463 #ifndef OPENSSL_NO_BF
1464 printf("%s ",BF_options());
1466 fprintf(stdout,"\n%s\n",SSLeay_version(SSLEAY_CFLAGS));
1467 printf("available timing options: ");
1478 #define as_string(s) (#s)
1479 printf("HZ=%g", HZ);
1481 printf(" [sysconf value]");
1485 printf("timing function used: %s%s%s%s%s%s%s\n",
1486 (ftime_used ? "ftime" : ""),
1487 (ftime_used + times_used > 1 ? "," : ""),
1488 (times_used ? "times" : ""),
1489 (ftime_used + times_used + gettimeofday_used > 1 ? "," : ""),
1490 (gettimeofday_used ? "gettimeofday" : ""),
1491 (ftime_used + times_used + gettimeofday_used + getrusage_used > 1 ? "," : ""),
1492 (getrusage_used ? "getrusage" : ""));
1498 fprintf(stdout,"+H");
1501 fprintf(stdout,"The 'numbers' are in 1000s of bytes per second processed.\n");
1502 fprintf(stdout,"type ");
1504 for (j=0; j<SIZE_NUM; j++)
1505 fprintf(stdout,mr ? ":%d" : "%7d bytes",lengths[j]);
1506 fprintf(stdout,"\n");
1509 for (k=0; k<ALGOR_NUM; k++)
1511 if (!doit[k]) continue;
1513 fprintf(stdout,"+F:%d:%s",k,names[k]);
1515 fprintf(stdout,"%-13s",names[k]);
1516 for (j=0; j<SIZE_NUM; j++)
1518 if (results[k][j] > 10000 && !mr)
1519 fprintf(stdout," %11.2fk",results[k][j]/1e3);
1521 fprintf(stdout,mr ? ":%.2f" : " %11.2f ",results[k][j]);
1523 fprintf(stdout,"\n");
1525 #ifndef OPENSSL_NO_RSA
1527 for (k=0; k<RSA_NUM; k++)
1529 if (!rsa_doit[k]) continue;
1532 printf("%18ssign verify sign/s verify/s\n"," ");
1536 fprintf(stdout,"+F2:%u:%u:%f:%f\n",
1537 k,rsa_bits[k],rsa_results[k][0],
1540 fprintf(stdout,"rsa %4u bits %8.4fs %8.4fs %8.1f %8.1f\n",
1541 rsa_bits[k],rsa_results[k][0],rsa_results[k][1],
1542 1.0/rsa_results[k][0],1.0/rsa_results[k][1]);
1545 #ifndef OPENSSL_NO_DSA
1547 for (k=0; k<DSA_NUM; k++)
1549 if (!dsa_doit[k]) continue;
1552 printf("%18ssign verify sign/s verify/s\n"," ");
1556 fprintf(stdout,"+F3:%u:%u:%f:%f\n",
1557 k,dsa_bits[k],dsa_results[k][0],dsa_results[k][1]);
1559 fprintf(stdout,"dsa %4u bits %8.4fs %8.4fs %8.1f %8.1f\n",
1560 dsa_bits[k],dsa_results[k][0],dsa_results[k][1],
1561 1.0/dsa_results[k][0],1.0/dsa_results[k][1]);
1566 ERR_print_errors(bio_err);
1567 if (buf != NULL) OPENSSL_free(buf);
1568 if (buf2 != NULL) OPENSSL_free(buf2);
1569 #ifndef OPENSSL_NO_RSA
1570 for (i=0; i<RSA_NUM; i++)
1571 if (rsa_key[i] != NULL)
1572 RSA_free(rsa_key[i]);
1574 #ifndef OPENSSL_NO_DSA
1575 for (i=0; i<DSA_NUM; i++)
1576 if (dsa_key[i] != NULL)
1577 DSA_free(dsa_key[i]);
1583 static void print_message(const char *s, long num, int length)
1586 BIO_printf(bio_err,mr ? "+DT:%s:%d:%d\n"
1587 : "Doing %s for %ds on %d size blocks: ",s,SECONDS,length);
1588 (void)BIO_flush(bio_err);
1591 BIO_printf(bio_err,mr ? "+DN:%s:%ld:%d\n"
1592 : "Doing %s %ld times on %d size blocks: ",s,num,length);
1593 (void)BIO_flush(bio_err);
1600 static void pkey_print_message(char *str, char *str2, long num, int bits,
1604 BIO_printf(bio_err,mr ? "+DTP:%d:%s:%s:%d\n"
1605 : "Doing %d bit %s %s's for %ds: ",bits,str,str2,tm);
1606 (void)BIO_flush(bio_err);
1609 BIO_printf(bio_err,mr ? "+DNP:%ld:%d:%s:%s\n"
1610 : "Doing %ld %d bit %s %s's: ",num,bits,str,str2);
1611 (void)BIO_flush(bio_err);
1618 static void print_result(int alg,int run_no,int count,double time_used)
1620 BIO_printf(bio_err,mr ? "+R:%ld:%s:%f\n"
1621 : "%ld %s's in %.2fs\n",count,names[alg],time_used);
1622 results[alg][run_no]=((double)count)/time_used*lengths[run_no];
1625 static char *sstrsep(char **string, const char *delim)
1628 char *token = *string;
1633 memset(isdelim, 0, 256);
1638 isdelim[(unsigned char)(*delim)] = 1;
1642 while (!isdelim[(unsigned char)(**string)])
1657 static int do_multi(int multi)
1662 static char sep[]=":";
1664 fds=malloc(multi*sizeof *fds);
1665 for(n=0 ; n < multi ; ++n)
1683 printf("Forked child %d\n",n);
1686 /* for now, assume the pipe is long enough to take all the output */
1687 for(n=0 ; n < multi ; ++n)
1693 f=fdopen(fds[n],"r");
1694 while(fgets(buf,sizeof buf,f))
1701 fprintf(stderr,"Don't understand line '%s' from child %d\n",
1705 printf("Got: %s from %d\n",buf,n);
1706 if(!strncmp(buf,"+F:",3))
1712 alg=atoi(sstrsep(&p,sep));
1714 for(j=0 ; j < SIZE_NUM ; ++j)
1715 results[alg][j]+=atof(sstrsep(&p,sep));
1717 else if(!strncmp(buf,"+F2:",4))
1723 k=atoi(sstrsep(&p,sep));
1726 d=atof(sstrsep(&p,sep));
1728 rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
1730 rsa_results[k][0]=d;
1732 d=atof(sstrsep(&p,sep));
1734 rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
1736 rsa_results[k][1]=d;
1738 else if(!strncmp(buf,"+F2:",4))
1744 k=atoi(sstrsep(&p,sep));
1747 d=atof(sstrsep(&p,sep));
1749 rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
1751 rsa_results[k][0]=d;
1753 d=atof(sstrsep(&p,sep));
1755 rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
1757 rsa_results[k][1]=d;
1759 else if(!strncmp(buf,"+F3:",4))
1765 k=atoi(sstrsep(&p,sep));
1768 d=atof(sstrsep(&p,sep));
1770 dsa_results[k][0]=1/(1/dsa_results[k][0]+1/d);
1772 dsa_results[k][0]=d;
1774 d=atof(sstrsep(&p,sep));
1776 dsa_results[k][1]=1/(1/dsa_results[k][1]+1/d);
1778 dsa_results[k][1]=d;
1780 else if(!strncmp(buf,"+H:",3))
1784 fprintf(stderr,"Unknown type '%s' from child %d\n",buf,n);