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 #include OPENSSL_UNISTD
88 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(OPENSSL_SYS_MACOSX)
90 #elif !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
93 #if !defined(_UNICOS) && !defined(__OpenBSD__) && !defined(sgi) && !defined(__FreeBSD__) && !(defined(__bsdi) || defined(__bsdi__)) && !defined(_AIX) && !defined(OPENSSL_SYS_MPE) && !defined(__NetBSD__) /* FIXME */
101 # include <sys/types.h>
102 # include <sys/times.h>
105 # include <sys/time.h>
106 # include <sys/resource.h>
109 /* Depending on the VMS version, the tms structure is perhaps defined.
110 The __TMS macro will show if it was. If it wasn't defined, we should
111 undefine TIMES, since that tells the rest of the program how things
112 should be handled. -- Richard Levitte */
113 #if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
118 #include <sys/timeb.h>
121 #if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD)
122 #error "It seems neither struct tms nor struct timeb is supported in this platform!"
125 #if defined(sun) || defined(__ultrix)
126 #define _POSIX_SOURCE
128 #include <sys/param.h>
131 #ifndef OPENSSL_NO_DES
132 #include <openssl/des_old.h>
134 #ifndef OPENSSL_NO_MD2
135 #include <openssl/md2.h>
137 #ifndef OPENSSL_NO_MDC2
138 #include <openssl/mdc2.h>
140 #ifndef OPENSSL_NO_MD4
141 #include <openssl/md4.h>
143 #ifndef OPENSSL_NO_MD5
144 #include <openssl/md5.h>
146 #ifndef OPENSSL_NO_HMAC
147 #include <openssl/hmac.h>
149 #include <openssl/evp.h>
150 #ifndef OPENSSL_NO_SHA
151 #include <openssl/sha.h>
153 #ifndef OPENSSL_NO_RIPEMD
154 #include <openssl/ripemd.h>
156 #ifndef OPENSSL_NO_RC4
157 #include <openssl/rc4.h>
159 #ifndef OPENSSL_NO_RC5
160 #include <openssl/rc5.h>
162 #ifndef OPENSSL_NO_RC2
163 #include <openssl/rc2.h>
165 #ifndef OPENSSL_NO_IDEA
166 #include <openssl/idea.h>
168 #ifndef OPENSSL_NO_BF
169 #include <openssl/blowfish.h>
171 #ifndef OPENSSL_NO_CAST
172 #include <openssl/cast.h>
174 #ifndef OPENSSL_NO_RSA
175 #include <openssl/rsa.h>
176 #include "./testrsa.h"
178 #include <openssl/x509.h>
179 #ifndef OPENSSL_NO_DSA
180 #include "./testdsa.h"
183 /* The following if from times(3) man page. It may need to be changed */
186 # define HZ ((double)sysconf(_SC_CLK_TCK))
189 # ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
191 # else /* _BSD_CLK_TCK_ */
192 # define HZ ((double)_BSD_CLK_TCK_)
195 # define HZ ((double)CLK_TCK)
201 #define BUFSIZE ((long)1024*8+1)
204 static char ftime_used = 0, times_used = 0, gettimeofday_used = 0, getrusage_used = 0;
206 static int usertime=1;
208 static double Time_F(int s);
209 static void print_message(const char *s,long num,int length);
210 static void pkey_print_message(char *str,char *str2,long num,int bits,int sec);
211 static void print_result(int alg,int run_no,int count,double time_used);
212 static int do_multi(int multi);
214 #if defined(__STDC__) || defined(sgi) || defined(_AIX)
215 #define SIGRETTYPE void
217 #define SIGRETTYPE int
224 static const char *names[ALGOR_NUM]={
225 "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4",
226 "des cbc","des ede3","idea cbc",
227 "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc"};
228 static double results[ALGOR_NUM][SIZE_NUM];
229 static int lengths[SIZE_NUM]={8,64,256,1024,8*1024};
230 static double rsa_results[RSA_NUM][2];
231 static double dsa_results[DSA_NUM][2];
233 static SIGRETTYPE sig_done(int sig);
234 static SIGRETTYPE sig_done(int sig)
236 signal(SIGALRM,sig_done);
247 static double Time_F(int s)
254 static struct rusage tstart,tend;
259 getrusage(RUSAGE_SELF,&tstart);
266 getrusage(RUSAGE_SELF,&tend);
267 i=(long)tend.ru_utime.tv_usec-(long)tstart.ru_utime.tv_usec;
268 ret=((double)(tend.ru_utime.tv_sec-tstart.ru_utime.tv_sec))
269 +((double)i)/1000000.0;
270 return((ret < 0.001)?0.001:ret);
275 static struct timeval tstart,tend;
278 gettimeofday_used = 1;
281 gettimeofday(&tstart,NULL);
286 gettimeofday(&tend,NULL);
287 i=(long)tend.tv_usec-(long)tstart.tv_usec;
288 ret=((double)(tend.tv_sec-tstart.tv_sec))+((double)i)/1000000.0;
289 return((ret < 0.001)?0.001:ret);
292 #else /* ndef USE_TOD */
297 static struct tms tstart,tend;
308 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
309 return((ret < 1e-3)?1e-3:ret);
312 # endif /* times() */
313 # if defined(TIMES) && defined(TIMEB)
318 static struct timeb tstart,tend;
330 i=(long)tend.millitm-(long)tstart.millitm;
331 ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
332 return((ret < 0.001)?0.001:ret);
339 int MAIN(int, char **);
341 int MAIN(int argc, char **argv)
344 unsigned char *buf=NULL,*buf2=NULL;
346 long count,rsa_count,save_count=0;
348 #ifndef OPENSSL_NO_RSA
351 #ifndef OPENSSL_NO_MD2
352 unsigned char md2[MD2_DIGEST_LENGTH];
354 #ifndef OPENSSL_NO_MDC2
355 unsigned char mdc2[MDC2_DIGEST_LENGTH];
357 #ifndef OPENSSL_NO_MD4
358 unsigned char md4[MD4_DIGEST_LENGTH];
360 #ifndef OPENSSL_NO_MD5
361 unsigned char md5[MD5_DIGEST_LENGTH];
362 unsigned char hmac[MD5_DIGEST_LENGTH];
364 #ifndef OPENSSL_NO_SHA
365 unsigned char sha[SHA_DIGEST_LENGTH];
367 #ifndef OPENSSL_NO_RIPEMD
368 unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];
370 #ifndef OPENSSL_NO_RC4
373 #ifndef OPENSSL_NO_RC5
376 #ifndef OPENSSL_NO_RC2
379 #ifndef OPENSSL_NO_IDEA
380 IDEA_KEY_SCHEDULE idea_ks;
382 #ifndef OPENSSL_NO_BF
385 #ifndef OPENSSL_NO_CAST
388 static unsigned char key16[16]=
389 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
390 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
392 #ifndef OPENSSL_NO_DES
393 DES_cblock *buf_as_des_cblock = NULL;
394 static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
395 static des_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
396 static des_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
397 DES_key_schedule sch;
398 DES_key_schedule sch2;
399 DES_key_schedule sch3;
411 #define D_CBC_IDEA 10
415 #define D_CBC_CAST 14
418 long c[ALGOR_NUM][SIZE_NUM];
426 #ifndef OPENSSL_NO_RSA
427 RSA *rsa_key[RSA_NUM];
428 long rsa_c[RSA_NUM][2];
429 static unsigned int rsa_bits[RSA_NUM]={512,1024,2048,4096};
430 static unsigned char *rsa_data[RSA_NUM]=
431 {test512,test1024,test2048,test4096};
432 static int rsa_data_length[RSA_NUM]={
433 sizeof(test512),sizeof(test1024),
434 sizeof(test2048),sizeof(test4096)};
436 #ifndef OPENSSL_NO_DSA
437 DSA *dsa_key[DSA_NUM];
438 long dsa_c[DSA_NUM][2];
439 static unsigned int dsa_bits[DSA_NUM]={512,1024,2048};
441 int rsa_doit[RSA_NUM];
442 int dsa_doit[DSA_NUM];
445 const EVP_CIPHER *evp=NULL;
454 memset(results, 0, sizeof(results));
455 #ifndef OPENSSL_NO_DSA
456 memset(dsa_key,0,sizeof(dsa_key));
460 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
461 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
463 #ifndef OPENSSL_NO_RSA
464 memset(rsa_key,0,sizeof(rsa_key));
465 for (i=0; i<RSA_NUM; i++)
469 if ((buf=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
471 BIO_printf(bio_err,"out of memory\n");
474 #ifndef OPENSSL_NO_DES
475 buf_as_des_cblock = (des_cblock *)buf;
477 if ((buf2=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
479 BIO_printf(bio_err,"out of memory\n");
483 memset(c,0,sizeof(c));
484 memset(iv,0,sizeof(iv));
486 for (i=0; i<ALGOR_NUM; i++)
488 for (i=0; i<RSA_NUM; i++)
490 for (i=0; i<DSA_NUM; i++)
498 if ((argc > 0) && (strcmp(*argv,"-elapsed") == 0))
501 j--; /* Otherwise, -elapsed gets confused with
504 else if ((argc > 0) && (strcmp(*argv,"-evp") == 0))
510 BIO_printf(bio_err,"no EVP given\n");
513 evp=EVP_get_cipherbyname(*argv);
516 BIO_printf(bio_err,"%s is an unknown cipher\n",*argv);
521 else if (argc > 0 && !strcmp(*argv,"-decrypt"))
524 j--; /* Otherwise, -elapsed gets confused with
527 else if ((argc > 0) && (strcmp(*argv,"-engine") == 0))
533 BIO_printf(bio_err,"no engine given\n");
536 e = setup_engine(bio_err, *argv, 0);
537 /* j will be increased again further down. We just
538 don't want speed to confuse an engine with an
539 algorithm, especially when none is given (which
540 means all of them should be run) */
543 else if ((argc > 0) && (strcmp(*argv,"-multi") == 0))
549 BIO_printf(bio_err,"no multi count given\n");
555 BIO_printf(bio_err,"bad multi count\n");
559 else if (argc > 0 && !strcmp(*argv,"-mr"))
562 j--; /* Otherwise, -mr gets confused with
566 #ifndef OPENSSL_NO_MD2
567 if (strcmp(*argv,"md2") == 0) doit[D_MD2]=1;
570 #ifndef OPENSSL_NO_MDC2
571 if (strcmp(*argv,"mdc2") == 0) doit[D_MDC2]=1;
574 #ifndef OPENSSL_NO_MD4
575 if (strcmp(*argv,"md4") == 0) doit[D_MD4]=1;
578 #ifndef OPENSSL_NO_MD5
579 if (strcmp(*argv,"md5") == 0) doit[D_MD5]=1;
582 #ifndef OPENSSL_NO_MD5
583 if (strcmp(*argv,"hmac") == 0) doit[D_HMAC]=1;
586 #ifndef OPENSSL_NO_SHA
587 if (strcmp(*argv,"sha1") == 0) doit[D_SHA1]=1;
589 if (strcmp(*argv,"sha") == 0) doit[D_SHA1]=1;
592 #ifndef OPENSSL_NO_RIPEMD
593 if (strcmp(*argv,"ripemd") == 0) doit[D_RMD160]=1;
595 if (strcmp(*argv,"rmd160") == 0) doit[D_RMD160]=1;
597 if (strcmp(*argv,"ripemd160") == 0) doit[D_RMD160]=1;
600 #ifndef OPENSSL_NO_RC4
601 if (strcmp(*argv,"rc4") == 0) doit[D_RC4]=1;
604 #ifndef OPENSSL_NO_DES
605 if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1;
606 else if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1;
609 #ifndef OPENSSL_NO_RSA
610 #if 0 /* was: #ifdef RSAref */
611 if (strcmp(*argv,"rsaref") == 0)
613 RSA_set_default_openssl_method(RSA_PKCS1_RSAref());
619 if (strcmp(*argv,"openssl") == 0)
621 RSA_set_default_method(RSA_PKCS1_SSLeay());
626 #endif /* !OPENSSL_NO_RSA */
627 if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2;
628 else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2;
629 else if (strcmp(*argv,"dsa2048") == 0) dsa_doit[R_DSA_2048]=2;
630 else if (strcmp(*argv,"rsa512") == 0) rsa_doit[R_RSA_512]=2;
631 else if (strcmp(*argv,"rsa1024") == 0) rsa_doit[R_RSA_1024]=2;
632 else if (strcmp(*argv,"rsa2048") == 0) rsa_doit[R_RSA_2048]=2;
633 else if (strcmp(*argv,"rsa4096") == 0) rsa_doit[R_RSA_4096]=2;
635 #ifndef OPENSSL_NO_RC2
636 if (strcmp(*argv,"rc2-cbc") == 0) doit[D_CBC_RC2]=1;
637 else if (strcmp(*argv,"rc2") == 0) doit[D_CBC_RC2]=1;
640 #ifndef OPENSSL_NO_RC5
641 if (strcmp(*argv,"rc5-cbc") == 0) doit[D_CBC_RC5]=1;
642 else if (strcmp(*argv,"rc5") == 0) doit[D_CBC_RC5]=1;
645 #ifndef OPENSSL_NO_IDEA
646 if (strcmp(*argv,"idea-cbc") == 0) doit[D_CBC_IDEA]=1;
647 else if (strcmp(*argv,"idea") == 0) doit[D_CBC_IDEA]=1;
650 #ifndef OPENSSL_NO_BF
651 if (strcmp(*argv,"bf-cbc") == 0) doit[D_CBC_BF]=1;
652 else if (strcmp(*argv,"blowfish") == 0) doit[D_CBC_BF]=1;
653 else if (strcmp(*argv,"bf") == 0) doit[D_CBC_BF]=1;
656 #ifndef OPENSSL_NO_CAST
657 if (strcmp(*argv,"cast-cbc") == 0) doit[D_CBC_CAST]=1;
658 else if (strcmp(*argv,"cast") == 0) doit[D_CBC_CAST]=1;
659 else if (strcmp(*argv,"cast5") == 0) doit[D_CBC_CAST]=1;
662 #ifndef OPENSSL_NO_DES
663 if (strcmp(*argv,"des") == 0)
670 #ifndef OPENSSL_NO_RSA
671 if (strcmp(*argv,"rsa") == 0)
673 rsa_doit[R_RSA_512]=1;
674 rsa_doit[R_RSA_1024]=1;
675 rsa_doit[R_RSA_2048]=1;
676 rsa_doit[R_RSA_4096]=1;
680 #ifndef OPENSSL_NO_DSA
681 if (strcmp(*argv,"dsa") == 0)
683 dsa_doit[R_DSA_512]=1;
684 dsa_doit[R_DSA_1024]=1;
689 BIO_printf(bio_err,"Error: bad option or value\n");
690 BIO_printf(bio_err,"\n");
691 BIO_printf(bio_err,"Available values:\n");
692 #ifndef OPENSSL_NO_MD2
693 BIO_printf(bio_err,"md2 ");
695 #ifndef OPENSSL_NO_MDC2
696 BIO_printf(bio_err,"mdc2 ");
698 #ifndef OPENSSL_NO_MD4
699 BIO_printf(bio_err,"md4 ");
701 #ifndef OPENSSL_NO_MD5
702 BIO_printf(bio_err,"md5 ");
703 #ifndef OPENSSL_NO_HMAC
704 BIO_printf(bio_err,"hmac ");
707 #ifndef OPENSSL_NO_SHA1
708 BIO_printf(bio_err,"sha1 ");
710 #ifndef OPENSSL_NO_RIPEMD160
711 BIO_printf(bio_err,"rmd160");
713 #if !defined(OPENSSL_NO_MD2) || !defined(OPENSSL_NO_MDC2) || \
714 !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \
715 !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160)
716 BIO_printf(bio_err,"\n");
719 #ifndef OPENSSL_NO_IDEA
720 BIO_printf(bio_err,"idea-cbc ");
722 #ifndef OPENSSL_NO_RC2
723 BIO_printf(bio_err,"rc2-cbc ");
725 #ifndef OPENSSL_NO_RC5
726 BIO_printf(bio_err,"rc5-cbc ");
728 #ifndef OPENSSL_NO_BF
729 BIO_printf(bio_err,"bf-cbc");
731 #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
732 !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_RC5)
733 BIO_printf(bio_err,"\n");
736 BIO_printf(bio_err,"des-cbc des-ede3 ");
737 #ifndef OPENSSL_NO_RC4
738 BIO_printf(bio_err,"rc4");
740 BIO_printf(bio_err,"\n");
742 #ifndef OPENSSL_NO_RSA
743 BIO_printf(bio_err,"rsa512 rsa1024 rsa2048 rsa4096\n");
746 #ifndef OPENSSL_NO_DSA
747 BIO_printf(bio_err,"dsa512 dsa1024 dsa2048\n");
750 #ifndef OPENSSL_NO_IDEA
751 BIO_printf(bio_err,"idea ");
753 #ifndef OPENSSL_NO_RC2
754 BIO_printf(bio_err,"rc2 ");
756 #ifndef OPENSSL_NO_DES
757 BIO_printf(bio_err,"des ");
759 #ifndef OPENSSL_NO_RSA
760 BIO_printf(bio_err,"rsa ");
762 #ifndef OPENSSL_NO_BF
763 BIO_printf(bio_err,"blowfish");
765 #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
766 !defined(OPENSSL_NO_DES) || !defined(OPENSSL_NO_RSA) || \
767 !defined(OPENSSL_NO_BF)
768 BIO_printf(bio_err,"\n");
771 BIO_printf(bio_err,"\n");
772 BIO_printf(bio_err,"Available options:\n");
774 BIO_printf(bio_err,"-elapsed measure time in real time instead of CPU user time.\n");
776 BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n");
777 BIO_printf(bio_err,"-evp e use EVP e.\n");
778 BIO_printf(bio_err,"-decrypt time decryption instead of encryption (only EVP).\n");
779 BIO_printf(bio_err,"-mr produce machine readable output.\n");
780 BIO_printf(bio_err,"-multi n run n benchmarks in parallel.\n");
788 if(multi && do_multi(multi))
793 for (i=0; i<ALGOR_NUM; i++)
798 for (i=0; i<RSA_NUM; i++)
800 for (i=0; i<DSA_NUM; i++)
803 for (i=0; i<ALGOR_NUM; i++)
804 if (doit[i]) pr_header++;
806 if (usertime == 0 && !mr)
807 BIO_printf(bio_err,"You have chosen to measure elapsed time instead of user CPU time.\n");
808 if (usertime <= 0 && !mr)
810 BIO_printf(bio_err,"To get the most accurate results, try to run this\n");
811 BIO_printf(bio_err,"program when this computer is idle.\n");
814 #ifndef OPENSSL_NO_RSA
815 for (i=0; i<RSA_NUM; i++)
817 const unsigned char *p;
820 rsa_key[i]=d2i_RSAPrivateKey(NULL,&p,rsa_data_length[i]);
821 if (rsa_key[i] == NULL)
823 BIO_printf(bio_err,"internal error loading RSA key number %d\n",i);
829 BIO_printf(bio_err,mr ? "+RK:%d:"
830 : "Loaded RSA key, %d bit modulus and e= 0x",
831 BN_num_bits(rsa_key[i]->n));
832 BN_print(bio_err,rsa_key[i]->e);
833 BIO_printf(bio_err,"\n");
839 #ifndef OPENSSL_NO_DSA
840 dsa_key[0]=get_dsa512();
841 dsa_key[1]=get_dsa1024();
842 dsa_key[2]=get_dsa2048();
845 #ifndef OPENSSL_NO_DES
846 DES_set_key_unchecked(&key,&sch);
847 DES_set_key_unchecked(&key2,&sch2);
848 DES_set_key_unchecked(&key3,&sch3);
850 #ifndef OPENSSL_NO_IDEA
851 idea_set_encrypt_key(key16,&idea_ks);
853 #ifndef OPENSSL_NO_RC4
854 RC4_set_key(&rc4_ks,16,key16);
856 #ifndef OPENSSL_NO_RC2
857 RC2_set_key(&rc2_ks,16,key16,128);
859 #ifndef OPENSSL_NO_RC5
860 RC5_32_set_key(&rc5_ks,16,key16,12);
862 #ifndef OPENSSL_NO_BF
863 BF_set_key(&bf_ks,16,key16);
865 #ifndef OPENSSL_NO_CAST
866 CAST_set_key(&cast_ks,16,key16);
868 #ifndef OPENSSL_NO_RSA
869 memset(rsa_c,0,sizeof(rsa_c));
872 #ifndef OPENSSL_NO_DES
873 BIO_printf(bio_err,"First we calculate the approximate speed ...\n");
878 Time_F(START,usertime);
879 for (i=count; i; i--)
880 des_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock,
885 c[D_MD2][0]=count/10;
886 c[D_MDC2][0]=count/10;
891 c[D_RMD160][0]=count;
893 c[D_CBC_DES][0]=count;
894 c[D_EDE3_DES][0]=count/3;
895 c[D_CBC_IDEA][0]=count;
896 c[D_CBC_RC2][0]=count;
897 c[D_CBC_RC5][0]=count;
898 c[D_CBC_BF][0]=count;
899 c[D_CBC_CAST][0]=count;
901 for (i=1; i<SIZE_NUM; i++)
903 c[D_MD2][i]=c[D_MD2][0]*4*lengths[0]/lengths[i];
904 c[D_MDC2][i]=c[D_MDC2][0]*4*lengths[0]/lengths[i];
905 c[D_MD4][i]=c[D_MD4][0]*4*lengths[0]/lengths[i];
906 c[D_MD5][i]=c[D_MD5][0]*4*lengths[0]/lengths[i];
907 c[D_HMAC][i]=c[D_HMAC][0]*4*lengths[0]/lengths[i];
908 c[D_SHA1][i]=c[D_SHA1][0]*4*lengths[0]/lengths[i];
909 c[D_RMD160][i]=c[D_RMD160][0]*4*lengths[0]/lengths[i];
911 for (i=1; i<SIZE_NUM; i++)
915 l0=(long)lengths[i-1];
917 c[D_RC4][i]=c[D_RC4][i-1]*l0/l1;
918 c[D_CBC_DES][i]=c[D_CBC_DES][i-1]*l0/l1;
919 c[D_EDE3_DES][i]=c[D_EDE3_DES][i-1]*l0/l1;
920 c[D_CBC_IDEA][i]=c[D_CBC_IDEA][i-1]*l0/l1;
921 c[D_CBC_RC2][i]=c[D_CBC_RC2][i-1]*l0/l1;
922 c[D_CBC_RC5][i]=c[D_CBC_RC5][i-1]*l0/l1;
923 c[D_CBC_BF][i]=c[D_CBC_BF][i-1]*l0/l1;
924 c[D_CBC_CAST][i]=c[D_CBC_CAST][i-1]*l0/l1;
926 #ifndef OPENSSL_NO_RSA
927 rsa_c[R_RSA_512][0]=count/2000;
928 rsa_c[R_RSA_512][1]=count/400;
929 for (i=1; i<RSA_NUM; i++)
931 rsa_c[i][0]=rsa_c[i-1][0]/8;
932 rsa_c[i][1]=rsa_c[i-1][1]/4;
933 if ((rsa_doit[i] <= 1) && (rsa_c[i][0] == 0))
937 if (rsa_c[i][0] == 0)
946 #ifndef OPENSSL_NO_DSA
947 dsa_c[R_DSA_512][0]=count/1000;
948 dsa_c[R_DSA_512][1]=count/1000/2;
949 for (i=1; i<DSA_NUM; i++)
951 dsa_c[i][0]=dsa_c[i-1][0]/4;
952 dsa_c[i][1]=dsa_c[i-1][1]/4;
953 if ((dsa_doit[i] <= 1) && (dsa_c[i][0] == 0))
966 #define COND(d) (count < (d))
969 /* not worth fixing */
970 # error "You cannot disable DES on systems without SIGALRM."
971 #endif /* OPENSSL_NO_DES */
973 #define COND(c) (run)
974 #define COUNT(d) (count)
975 signal(SIGALRM,sig_done);
978 #ifndef OPENSSL_NO_MD2
981 for (j=0; j<SIZE_NUM; j++)
983 print_message(names[D_MD2],c[D_MD2][j],lengths[j]);
985 for (count=0,run=1; COND(c[D_MD2][j]); count++)
986 EVP_Digest(buf,(unsigned long)lengths[j],&(md2[0]),NULL,EVP_md2(),NULL);
988 print_result(D_MD2,j,count,d);
992 #ifndef OPENSSL_NO_MDC2
995 for (j=0; j<SIZE_NUM; j++)
997 print_message(names[D_MDC2],c[D_MDC2][j],lengths[j]);
999 for (count=0,run=1; COND(c[D_MDC2][j]); count++)
1000 EVP_Digest(buf,(unsigned long)lengths[j],&(mdc2[0]),NULL,EVP_mdc2(),NULL);
1002 print_result(D_MDC2,j,count,d);
1007 #ifndef OPENSSL_NO_MD4
1010 for (j=0; j<SIZE_NUM; j++)
1012 print_message(names[D_MD4],c[D_MD4][j],lengths[j]);
1014 for (count=0,run=1; COND(c[D_MD4][j]); count++)
1015 EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md4[0]),NULL,EVP_md4(),NULL);
1017 print_result(D_MD4,j,count,d);
1022 #ifndef OPENSSL_NO_MD5
1025 for (j=0; j<SIZE_NUM; j++)
1027 print_message(names[D_MD5],c[D_MD5][j],lengths[j]);
1029 for (count=0,run=1; COND(c[D_MD5][j]); count++)
1030 EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md5[0]),NULL,EVP_get_digestbyname("md5"),NULL);
1032 print_result(D_MD5,j,count,d);
1037 #if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC)
1042 HMAC_CTX_init(&hctx);
1043 HMAC_Init(&hctx,(unsigned char *)"This is a key...",
1046 for (j=0; j<SIZE_NUM; j++)
1048 print_message(names[D_HMAC],c[D_HMAC][j],lengths[j]);
1050 for (count=0,run=1; COND(c[D_HMAC][j]); count++)
1052 HMAC_Init(&hctx,NULL,0,NULL);
1053 HMAC_Update(&hctx,buf,lengths[j]);
1054 HMAC_Final(&hctx,&(hmac[0]),NULL);
1057 print_result(D_HMAC,j,count,d);
1059 HMAC_CTX_cleanup(&hctx);
1062 #ifndef OPENSSL_NO_SHA
1065 for (j=0; j<SIZE_NUM; j++)
1067 print_message(names[D_SHA1],c[D_SHA1][j],lengths[j]);
1069 for (count=0,run=1; COND(c[D_SHA1][j]); count++)
1070 EVP_Digest(buf,(unsigned long)lengths[j],&(sha[0]),NULL,EVP_sha1(),NULL);
1072 print_result(D_SHA1,j,count,d);
1076 #ifndef OPENSSL_NO_RIPEMD
1079 for (j=0; j<SIZE_NUM; j++)
1081 print_message(names[D_RMD160],c[D_RMD160][j],lengths[j]);
1083 for (count=0,run=1; COND(c[D_RMD160][j]); count++)
1084 EVP_Digest(buf,(unsigned long)lengths[j],&(rmd160[0]),NULL,EVP_ripemd160(),NULL);
1086 print_result(D_RMD160,j,count,d);
1090 #ifndef OPENSSL_NO_RC4
1093 for (j=0; j<SIZE_NUM; j++)
1095 print_message(names[D_RC4],c[D_RC4][j],lengths[j]);
1097 for (count=0,run=1; COND(c[D_RC4][j]); count++)
1098 RC4(&rc4_ks,(unsigned int)lengths[j],
1101 print_result(D_RC4,j,count,d);
1105 #ifndef OPENSSL_NO_DES
1106 if (doit[D_CBC_DES])
1108 for (j=0; j<SIZE_NUM; j++)
1110 print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
1112 for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
1113 DES_ncbc_encrypt(buf,buf,lengths[j],&sch,
1116 print_result(D_CBC_DES,j,count,d);
1120 if (doit[D_EDE3_DES])
1122 for (j=0; j<SIZE_NUM; j++)
1124 print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
1126 for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
1127 DES_ede3_cbc_encrypt(buf,buf,lengths[j],
1131 print_result(D_EDE3_DES,j,count,d);
1135 #ifndef OPENSSL_NO_IDEA
1136 if (doit[D_CBC_IDEA])
1138 for (j=0; j<SIZE_NUM; j++)
1140 print_message(names[D_CBC_IDEA],c[D_CBC_IDEA][j],lengths[j]);
1142 for (count=0,run=1; COND(c[D_CBC_IDEA][j]); count++)
1143 idea_cbc_encrypt(buf,buf,
1144 (unsigned long)lengths[j],&idea_ks,
1147 print_result(D_CBC_IDEA,j,count,d);
1151 #ifndef OPENSSL_NO_RC2
1152 if (doit[D_CBC_RC2])
1154 for (j=0; j<SIZE_NUM; j++)
1156 print_message(names[D_CBC_RC2],c[D_CBC_RC2][j],lengths[j]);
1158 for (count=0,run=1; COND(c[D_CBC_RC2][j]); count++)
1159 RC2_cbc_encrypt(buf,buf,
1160 (unsigned long)lengths[j],&rc2_ks,
1163 print_result(D_CBC_RC2,j,count,d);
1167 #ifndef OPENSSL_NO_RC5
1168 if (doit[D_CBC_RC5])
1170 for (j=0; j<SIZE_NUM; j++)
1172 print_message(names[D_CBC_RC5],c[D_CBC_RC5][j],lengths[j]);
1174 for (count=0,run=1; COND(c[D_CBC_RC5][j]); count++)
1175 RC5_32_cbc_encrypt(buf,buf,
1176 (unsigned long)lengths[j],&rc5_ks,
1179 print_result(D_CBC_RC5,j,count,d);
1183 #ifndef OPENSSL_NO_BF
1186 for (j=0; j<SIZE_NUM; j++)
1188 print_message(names[D_CBC_BF],c[D_CBC_BF][j],lengths[j]);
1190 for (count=0,run=1; COND(c[D_CBC_BF][j]); count++)
1191 BF_cbc_encrypt(buf,buf,
1192 (unsigned long)lengths[j],&bf_ks,
1195 print_result(D_CBC_BF,j,count,d);
1199 #ifndef OPENSSL_NO_CAST
1200 if (doit[D_CBC_CAST])
1202 for (j=0; j<SIZE_NUM; j++)
1204 print_message(names[D_CBC_CAST],c[D_CBC_CAST][j],lengths[j]);
1206 for (count=0,run=1; COND(c[D_CBC_CAST][j]); count++)
1207 CAST_cbc_encrypt(buf,buf,
1208 (unsigned long)lengths[j],&cast_ks,
1211 print_result(D_CBC_CAST,j,count,d);
1218 for (j=0; j<SIZE_NUM; j++)
1223 names[D_EVP]=OBJ_nid2ln(evp->nid);
1224 print_message(names[D_EVP],save_count,
1226 EVP_CIPHER_CTX_init(&ctx);
1228 EVP_DecryptInit_ex(&ctx,evp,NULL,key16,iv);
1230 EVP_EncryptInit_ex(&ctx,evp,NULL,key16,iv);
1234 for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1235 EVP_DecryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
1237 for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1238 EVP_EncryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
1240 EVP_DecryptFinal_ex(&ctx,buf,&outl);
1242 EVP_EncryptFinal_ex(&ctx,buf,&outl);
1244 print_result(D_EVP,j,count,d);
1248 RAND_pseudo_bytes(buf,36);
1249 #ifndef OPENSSL_NO_RSA
1250 for (j=0; j<RSA_NUM; j++)
1253 if (!rsa_doit[j]) continue;
1254 ret=RSA_sign(NID_md5_sha1, buf,36, buf2, &rsa_num, rsa_key[j]);
1257 BIO_printf(bio_err,"RSA sign failure. No RSA sign will be done.\n");
1258 ERR_print_errors(bio_err);
1263 pkey_print_message("private","rsa",
1264 rsa_c[j][0],rsa_bits[j],
1266 /* RSA_blinding_on(rsa_key[j],NULL); */
1268 for (count=0,run=1; COND(rsa_c[j][0]); count++)
1270 ret=RSA_sign(NID_md5_sha1, buf,36, buf2,
1271 &rsa_num, rsa_key[j]);
1275 "RSA sign failure\n");
1276 ERR_print_errors(bio_err);
1282 BIO_printf(bio_err,mr ? "+R1:%ld:%d:%.2f\n"
1283 : "%ld %d bit private RSA's in %.2fs\n",
1284 count,rsa_bits[j],d);
1285 rsa_results[j][0]=d/(double)count;
1290 ret=RSA_verify(NID_md5_sha1, buf,36, buf2, rsa_num, rsa_key[j]);
1293 BIO_printf(bio_err,"RSA verify failure. No RSA verify will be done.\n");
1294 ERR_print_errors(bio_err);
1299 pkey_print_message("public","rsa",
1300 rsa_c[j][1],rsa_bits[j],
1303 for (count=0,run=1; COND(rsa_c[j][1]); count++)
1305 ret=RSA_verify(NID_md5_sha1, buf,36, buf2,
1306 rsa_num, rsa_key[j]);
1310 "RSA verify failure\n");
1311 ERR_print_errors(bio_err);
1317 BIO_printf(bio_err,mr ? "+R2:%ld:%d:%.2f\n"
1318 : "%ld %d bit public RSA's in %.2fs\n",
1319 count,rsa_bits[j],d);
1320 rsa_results[j][1]=d/(double)count;
1326 /* if longer than 10s, don't do any more */
1327 for (j++; j<RSA_NUM; j++)
1333 RAND_pseudo_bytes(buf,20);
1334 #ifndef OPENSSL_NO_DSA
1335 if (RAND_status() != 1)
1337 RAND_seed(rnd_seed, sizeof rnd_seed);
1340 for (j=0; j<DSA_NUM; j++)
1345 if (!dsa_doit[j]) continue;
1346 /* DSA_generate_key(dsa_key[j]); */
1347 /* DSA_sign_setup(dsa_key[j],NULL); */
1348 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1352 BIO_printf(bio_err,"DSA sign failure. No DSA sign will be done.\n");
1353 ERR_print_errors(bio_err);
1358 pkey_print_message("sign","dsa",
1359 dsa_c[j][0],dsa_bits[j],
1362 for (count=0,run=1; COND(dsa_c[j][0]); count++)
1364 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1369 "DSA sign failure\n");
1370 ERR_print_errors(bio_err);
1376 BIO_printf(bio_err,mr ? "+R3:%ld:%d:%.2f\n"
1377 : "%ld %d bit DSA signs in %.2fs\n",
1378 count,dsa_bits[j],d);
1379 dsa_results[j][0]=d/(double)count;
1383 ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1387 BIO_printf(bio_err,"DSA verify failure. No DSA verify will be done.\n");
1388 ERR_print_errors(bio_err);
1393 pkey_print_message("verify","dsa",
1394 dsa_c[j][1],dsa_bits[j],
1397 for (count=0,run=1; COND(dsa_c[j][1]); count++)
1399 ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1404 "DSA verify failure\n");
1405 ERR_print_errors(bio_err);
1411 BIO_printf(bio_err,mr ? "+R4:%ld:%d:%.2f\n"
1412 : "%ld %d bit DSA verify in %.2fs\n",
1413 count,dsa_bits[j],d);
1414 dsa_results[j][1]=d/(double)count;
1419 /* if longer than 10s, don't do any more */
1420 for (j++; j<DSA_NUM; j++)
1424 if (rnd_fake) RAND_cleanup();
1429 fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_VERSION));
1430 fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_BUILT_ON));
1432 printf("%s ",BN_options());
1433 #ifndef OPENSSL_NO_MD2
1434 printf("%s ",MD2_options());
1436 #ifndef OPENSSL_NO_RC4
1437 printf("%s ",RC4_options());
1439 #ifndef OPENSSL_NO_DES
1440 printf("%s ",des_options());
1442 #ifndef OPENSSL_NO_IDEA
1443 printf("%s ",idea_options());
1445 #ifndef OPENSSL_NO_BF
1446 printf("%s ",BF_options());
1448 fprintf(stdout,"\n%s\n",SSLeay_version(SSLEAY_CFLAGS));
1449 printf("available timing options: ");
1460 #define as_string(s) (#s)
1461 printf("HZ=%g", HZ);
1463 printf(" [sysconf value]");
1467 printf("timing function used: %s%s%s%s%s%s%s\n",
1468 (ftime_used ? "ftime" : ""),
1469 (ftime_used + times_used > 1 ? "," : ""),
1470 (times_used ? "times" : ""),
1471 (ftime_used + times_used + gettimeofday_used > 1 ? "," : ""),
1472 (gettimeofday_used ? "gettimeofday" : ""),
1473 (ftime_used + times_used + gettimeofday_used + getrusage_used > 1 ? "," : ""),
1474 (getrusage_used ? "getrusage" : ""));
1480 fprintf(stdout,"+H");
1483 fprintf(stdout,"The 'numbers' are in 1000s of bytes per second processed.\n");
1484 fprintf(stdout,"type ");
1486 for (j=0; j<SIZE_NUM; j++)
1487 fprintf(stdout,mr ? ":%d" : "%7d bytes",lengths[j]);
1488 fprintf(stdout,"\n");
1491 for (k=0; k<ALGOR_NUM; k++)
1493 if (!doit[k]) continue;
1495 fprintf(stdout,"+F:%d:%s",k,names[k]);
1497 fprintf(stdout,"%-13s",names[k]);
1498 for (j=0; j<SIZE_NUM; j++)
1500 if (results[k][j] > 10000 && !mr)
1501 fprintf(stdout," %11.2fk",results[k][j]/1e3);
1503 fprintf(stdout,mr ? ":%.2f" : " %11.2f ",results[k][j]);
1505 fprintf(stdout,"\n");
1507 #ifndef OPENSSL_NO_RSA
1509 for (k=0; k<RSA_NUM; k++)
1511 if (!rsa_doit[k]) continue;
1514 printf("%18ssign verify sign/s verify/s\n"," ");
1518 fprintf(stdout,"+F2:%u:%u:%f:%f\n",
1519 k,rsa_bits[k],rsa_results[k][0],
1522 fprintf(stdout,"rsa %4u bits %8.4fs %8.4fs %8.1f %8.1f\n",
1523 rsa_bits[k],rsa_results[k][0],rsa_results[k][1],
1524 1.0/rsa_results[k][0],1.0/rsa_results[k][1]);
1527 #ifndef OPENSSL_NO_DSA
1529 for (k=0; k<DSA_NUM; k++)
1531 if (!dsa_doit[k]) continue;
1534 printf("%18ssign verify sign/s verify/s\n"," ");
1538 fprintf(stdout,"+F3:%u:%u:%f:%f\n",
1539 k,dsa_bits[k],dsa_results[k][0],dsa_results[k][1]);
1541 fprintf(stdout,"dsa %4u bits %8.4fs %8.4fs %8.1f %8.1f\n",
1542 dsa_bits[k],dsa_results[k][0],dsa_results[k][1],
1543 1.0/dsa_results[k][0],1.0/dsa_results[k][1]);
1548 ERR_print_errors(bio_err);
1549 if (buf != NULL) OPENSSL_free(buf);
1550 if (buf2 != NULL) OPENSSL_free(buf2);
1551 #ifndef OPENSSL_NO_RSA
1552 for (i=0; i<RSA_NUM; i++)
1553 if (rsa_key[i] != NULL)
1554 RSA_free(rsa_key[i]);
1556 #ifndef OPENSSL_NO_DSA
1557 for (i=0; i<DSA_NUM; i++)
1558 if (dsa_key[i] != NULL)
1559 DSA_free(dsa_key[i]);
1565 static void print_message(const char *s, long num, int length)
1568 BIO_printf(bio_err,mr ? "+DT:%s:%d:%d\n"
1569 : "Doing %s for %ds on %d size blocks: ",s,SECONDS,length);
1570 (void)BIO_flush(bio_err);
1573 BIO_printf(bio_err,mr ? "+DN:%s:%ld:%d\n"
1574 : "Doing %s %ld times on %d size blocks: ",s,num,length);
1575 (void)BIO_flush(bio_err);
1582 static void pkey_print_message(char *str, char *str2, long num, int bits,
1586 BIO_printf(bio_err,mr ? "+DTP:%d:%s:%s:%d\n"
1587 : "Doing %d bit %s %s's for %ds: ",bits,str,str2,tm);
1588 (void)BIO_flush(bio_err);
1591 BIO_printf(bio_err,mr ? "+DNP:%ld:%d:%s:%s\n"
1592 : "Doing %ld %d bit %s %s's: ",num,bits,str,str2);
1593 (void)BIO_flush(bio_err);
1600 static void print_result(int alg,int run_no,int count,double time_used)
1602 BIO_printf(bio_err,mr ? "+R:%ld:%s:%f\n"
1603 : "%ld %s's in %.2fs\n",count,names[alg],time_used);
1604 results[alg][run_no]=((double)count)/time_used*lengths[run_no];
1607 static char *sstrsep(char **string, const char *delim)
1610 char *token = *string;
1615 memset(isdelim, 0, 256);
1620 isdelim[(unsigned char)(*delim)] = 1;
1624 while (!isdelim[(unsigned char)(**string)])
1638 static int do_multi(int multi)
1643 static char sep[]=":";
1645 fds=malloc(multi*sizeof *fds);
1646 for(n=0 ; n < multi ; ++n)
1664 printf("Forked child %d\n",n);
1667 /* for now, assume the pipe is long enough to take all the output */
1668 for(n=0 ; n < multi ; ++n)
1674 f=fdopen(fds[n],"r");
1675 while(fgets(buf,sizeof buf,f))
1682 fprintf(stderr,"Don't understand line '%s' from child %d\n",
1686 printf("Got: %s from %d\n",buf,n);
1687 if(!strncmp(buf,"+F:",3))
1693 alg=atoi(sstrsep(&p,sep));
1695 for(j=0 ; j < SIZE_NUM ; ++j)
1696 results[alg][j]+=atof(sstrsep(&p,sep));
1698 else if(!strncmp(buf,"+F2:",4))
1704 k=atoi(sstrsep(&p,sep));
1707 d=atof(sstrsep(&p,sep));
1709 rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
1711 rsa_results[k][0]=d;
1713 d=atof(sstrsep(&p,sep));
1715 rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
1717 rsa_results[k][1]=d;
1719 else if(!strncmp(buf,"+F2:",4))
1725 k=atoi(sstrsep(&p,sep));
1728 d=atof(sstrsep(&p,sep));
1730 rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
1732 rsa_results[k][0]=d;
1734 d=atof(sstrsep(&p,sep));
1736 rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
1738 rsa_results[k][1]=d;
1740 else if(!strncmp(buf,"+F3:",4))
1746 k=atoi(sstrsep(&p,sep));
1749 d=atof(sstrsep(&p,sep));
1751 dsa_results[k][0]=1/(1/dsa_results[k][0]+1/d);
1753 dsa_results[k][0]=d;
1755 d=atof(sstrsep(&p,sep));
1757 dsa_results[k][1]=1/(1/dsa_results[k][1]+1/d);
1759 dsa_results[k][1]=d;
1761 else if(!strncmp(buf,"+H:",3))
1765 fprintf(stderr,"Unknown type '%s' from child %d\n",buf,n);