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.]
58 /* ====================================================================
59 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
61 * Portions of the attached software ("Contribution") are developed by
62 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
64 * The Contribution is licensed pursuant to the OpenSSL open source
65 * license provided above.
67 * The ECDH and ECDSA speed test software is originally written by
68 * Sumit Gupta of Sun Microsystems Laboratories.
72 /* most of this code has been pilfered from my libdes speed.c program */
74 #ifndef OPENSSL_NO_SPEED
78 #define RSA_SECONDS 10
79 #define DSA_SECONDS 10
80 #define ECDSA_SECONDS 10
81 #define ECDH_SECONDS 10
83 /* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
84 /* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
87 #define PROG speed_main
95 #ifdef OPENSSL_NO_STDIO
98 #include <openssl/crypto.h>
99 #include <openssl/rand.h>
100 #include <openssl/err.h>
101 #include <openssl/evp.h>
102 #include <openssl/objects.h>
103 #if !defined(OPENSSL_SYS_MSDOS)
104 #include OPENSSL_UNISTD
107 #ifndef OPENSSL_SYS_NETWARE
115 #include <openssl/bn.h>
116 #ifndef OPENSSL_NO_DES
117 #include <openssl/des.h>
119 #ifndef OPENSSL_NO_AES
120 #include <openssl/aes.h>
122 #ifndef OPENSSL_NO_MD2
123 #include <openssl/md2.h>
125 #ifndef OPENSSL_NO_MDC2
126 #include <openssl/mdc2.h>
128 #ifndef OPENSSL_NO_MD4
129 #include <openssl/md4.h>
131 #ifndef OPENSSL_NO_MD5
132 #include <openssl/md5.h>
134 #ifndef OPENSSL_NO_HMAC
135 #include <openssl/hmac.h>
137 #include <openssl/evp.h>
138 #ifndef OPENSSL_NO_SHA
139 #include <openssl/sha.h>
141 #ifndef OPENSSL_NO_RIPEMD
142 #include <openssl/ripemd.h>
144 #ifndef OPENSSL_NO_RC4
145 #include <openssl/rc4.h>
147 #ifndef OPENSSL_NO_RC5
148 #include <openssl/rc5.h>
150 #ifndef OPENSSL_NO_RC2
151 #include <openssl/rc2.h>
153 #ifndef OPENSSL_NO_IDEA
154 #include <openssl/idea.h>
156 #ifndef OPENSSL_NO_BF
157 #include <openssl/blowfish.h>
159 #ifndef OPENSSL_NO_CAST
160 #include <openssl/cast.h>
162 #ifndef OPENSSL_NO_RSA
163 #include <openssl/rsa.h>
164 #include "./testrsa.h"
166 #include <openssl/x509.h>
167 #ifndef OPENSSL_NO_DSA
168 #include <openssl/dsa.h>
169 #include "./testdsa.h"
171 #ifndef OPENSSL_NO_ECDSA
172 #include <openssl/ecdsa.h>
174 #ifndef OPENSSL_NO_ECDH
175 #include <openssl/ecdh.h>
178 #if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2) && !defined(OPENSSL_SYS_NETWARE)
183 #define BUFSIZE ((long)1024*8+1)
186 static char ftime_used = 0, times_used = 0, gettimeofday_used = 0, getrusage_used = 0;
188 static int usertime=1;
190 static double Time_F(int s);
191 static void print_message(const char *s,long num,int length);
192 static void pkey_print_message(const char *str, const char *str2,
193 long num, int bits, int sec);
194 static void print_result(int alg,int run_no,int count,double time_used);
196 static int do_multi(int multi);
205 #define MAX_ECDH_SIZE 256
207 static const char *names[ALGOR_NUM]={
208 "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4",
209 "des cbc","des ede3","idea cbc",
210 "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc",
211 "aes-128 cbc","aes-192 cbc","aes-256 cbc","evp","sha256","sha512"};
212 static double results[ALGOR_NUM][SIZE_NUM];
213 static int lengths[SIZE_NUM]={16,64,256,1024,8*1024};
214 static double rsa_results[RSA_NUM][2];
215 static double dsa_results[DSA_NUM][2];
216 #ifndef OPENSSL_NO_ECDSA
217 static double ecdsa_results[EC_NUM][2];
219 #ifndef OPENSSL_NO_ECDH
220 static double ecdh_results[EC_NUM][1];
223 #if defined(OPENSSL_NO_DSA) && !(defined(OPENSSL_NO_ECDSA) && defined(OPENSSL_NO_ECDH))
224 static const char rnd_seed[] = "string to make the random number generator think it has entropy";
225 static int rnd_fake = 0;
229 #if defined(__STDC__) || defined(sgi) || defined(_AIX)
230 #define SIGRETTYPE void
232 #define SIGRETTYPE int
235 static SIGRETTYPE sig_done(int sig);
236 static SIGRETTYPE sig_done(int sig)
238 signal(SIGALRM,sig_done);
252 static unsigned int lapse,schlock;
253 static void alarm(unsigned int secs) { lapse = secs*1000; }
255 static DWORD WINAPI sleepy(VOID *arg)
263 static double Time_F(int s)
269 thr = CreateThread(NULL,4096,sleepy,NULL,0,NULL);
272 DWORD ret=GetLastError();
273 BIO_printf(bio_err,"unable to CreateThread (%d)",ret);
276 CloseHandle(thr); /* detach the thread */
277 while (!schlock) Sleep(0); /* scheduler spinlock */
280 return app_tminterval(s,usertime);
284 static double Time_F(int s)
286 return app_tminterval(s,usertime);
291 #ifndef OPENSSL_NO_ECDH
292 static const int KDF1_SHA1_len = 20;
293 static void *KDF1_SHA1(const void *in, size_t inlen, void *out, size_t *outlen)
295 #ifndef OPENSSL_NO_SHA
296 if (*outlen < SHA_DIGEST_LENGTH)
299 *outlen = SHA_DIGEST_LENGTH;
300 return SHA1(in, inlen, out);
303 #endif /* OPENSSL_NO_SHA */
305 #endif /* OPENSSL_NO_ECDH */
308 int MAIN(int, char **);
310 int MAIN(int argc, char **argv)
312 #ifndef OPENSSL_NO_ENGINE
315 unsigned char *buf=NULL,*buf2=NULL;
317 long count=0,save_count=0;
319 #if !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_DSA)
322 #ifndef OPENSSL_NO_RSA
325 unsigned char md[EVP_MAX_MD_SIZE];
326 #ifndef OPENSSL_NO_MD2
327 unsigned char md2[MD2_DIGEST_LENGTH];
329 #ifndef OPENSSL_NO_MDC2
330 unsigned char mdc2[MDC2_DIGEST_LENGTH];
332 #ifndef OPENSSL_NO_MD4
333 unsigned char md4[MD4_DIGEST_LENGTH];
335 #ifndef OPENSSL_NO_MD5
336 unsigned char md5[MD5_DIGEST_LENGTH];
337 unsigned char hmac[MD5_DIGEST_LENGTH];
339 #ifndef OPENSSL_NO_SHA
340 unsigned char sha[SHA_DIGEST_LENGTH];
341 #ifndef OPENSSL_NO_SHA256
342 unsigned char sha256[SHA256_DIGEST_LENGTH];
344 #ifndef OPENSSL_NO_SHA512
345 unsigned char sha512[SHA512_DIGEST_LENGTH];
348 #ifndef OPENSSL_NO_RIPEMD
349 unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];
351 #ifndef OPENSSL_NO_RC4
354 #ifndef OPENSSL_NO_RC5
357 #ifndef OPENSSL_NO_RC2
360 #ifndef OPENSSL_NO_IDEA
361 IDEA_KEY_SCHEDULE idea_ks;
363 #ifndef OPENSSL_NO_BF
366 #ifndef OPENSSL_NO_CAST
369 static const unsigned char key16[16]=
370 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
371 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
372 #ifndef OPENSSL_NO_AES
373 static const unsigned char key24[24]=
374 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
375 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
376 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
377 static const unsigned char key32[32]=
378 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
379 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
380 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,
381 0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56};
383 #ifndef OPENSSL_NO_AES
384 #define MAX_BLOCK_SIZE 128
386 #define MAX_BLOCK_SIZE 64
388 unsigned char DES_iv[8];
389 unsigned char iv[MAX_BLOCK_SIZE/8];
390 #ifndef OPENSSL_NO_DES
391 DES_cblock *buf_as_des_cblock = NULL;
392 static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
393 static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
394 static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
395 DES_key_schedule sch;
396 DES_key_schedule sch2;
397 DES_key_schedule sch3;
399 #ifndef OPENSSL_NO_AES
400 AES_KEY aes_ks1, aes_ks2, aes_ks3;
412 #define D_CBC_IDEA 10
416 #define D_CBC_CAST 14
417 #define D_CBC_128_AES 15
418 #define D_CBC_192_AES 16
419 #define D_CBC_256_AES 17
424 long c[ALGOR_NUM][SIZE_NUM];
450 #ifndef OPENSSL_NO_RSA
451 RSA *rsa_key[RSA_NUM];
452 long rsa_c[RSA_NUM][2];
453 static unsigned int rsa_bits[RSA_NUM]={512,1024,2048,4096};
454 static unsigned char *rsa_data[RSA_NUM]=
455 {test512,test1024,test2048,test4096};
456 static int rsa_data_length[RSA_NUM]={
457 sizeof(test512),sizeof(test1024),
458 sizeof(test2048),sizeof(test4096)};
460 #ifndef OPENSSL_NO_DSA
461 DSA *dsa_key[DSA_NUM];
462 long dsa_c[DSA_NUM][2];
463 static unsigned int dsa_bits[DSA_NUM]={512,1024,2048};
465 #ifndef OPENSSL_NO_EC
466 /* We only test over the following curves as they are representative,
467 * To add tests over more curves, simply add the curve NID
468 * and curve name to the following arrays and increase the
469 * EC_NUM value accordingly.
471 static unsigned int test_curves[EC_NUM] =
475 NID_X9_62_prime192v1,
477 NID_X9_62_prime256v1,
492 static const char * test_curves_names[EC_NUM] =
513 static int test_curves_bits[EC_NUM] =
515 160, 192, 224, 256, 384, 521,
516 163, 233, 283, 409, 571,
517 163, 233, 283, 409, 571
522 #ifndef OPENSSL_NO_ECDSA
523 unsigned char ecdsasig[256];
524 unsigned int ecdsasiglen;
525 EC_KEY *ecdsa[EC_NUM];
526 long ecdsa_c[EC_NUM][2];
529 #ifndef OPENSSL_NO_ECDH
530 EC_KEY *ecdh_a[EC_NUM], *ecdh_b[EC_NUM];
531 unsigned char secret_a[MAX_ECDH_SIZE], secret_b[MAX_ECDH_SIZE];
532 int secret_size_a, secret_size_b;
535 long ecdh_c[EC_NUM][2];
538 int rsa_doit[RSA_NUM];
539 int dsa_doit[DSA_NUM];
540 #ifndef OPENSSL_NO_ECDSA
541 int ecdsa_doit[EC_NUM];
543 #ifndef OPENSSL_NO_ECDH
544 int ecdh_doit[EC_NUM];
548 const EVP_CIPHER *evp_cipher=NULL;
549 const EVP_MD *evp_md=NULL;
560 memset(results, 0, sizeof(results));
561 #ifndef OPENSSL_NO_DSA
562 memset(dsa_key,0,sizeof(dsa_key));
564 #ifndef OPENSSL_NO_ECDSA
565 for (i=0; i<EC_NUM; i++) ecdsa[i] = NULL;
567 #ifndef OPENSSL_NO_ECDH
568 for (i=0; i<EC_NUM; i++)
577 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
578 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
580 if (!load_config(bio_err, NULL))
583 #ifndef OPENSSL_NO_RSA
584 memset(rsa_key,0,sizeof(rsa_key));
585 for (i=0; i<RSA_NUM; i++)
589 if ((buf=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
591 BIO_printf(bio_err,"out of memory\n");
594 #ifndef OPENSSL_NO_DES
595 buf_as_des_cblock = (DES_cblock *)buf;
597 if ((buf2=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
599 BIO_printf(bio_err,"out of memory\n");
603 memset(c,0,sizeof(c));
604 memset(DES_iv,0,sizeof(DES_iv));
605 memset(iv,0,sizeof(iv));
607 for (i=0; i<ALGOR_NUM; i++)
609 for (i=0; i<RSA_NUM; i++)
611 for (i=0; i<DSA_NUM; i++)
613 #ifndef OPENSSL_NO_ECDSA
614 for (i=0; i<EC_NUM; i++)
617 #ifndef OPENSSL_NO_ECDH
618 for (i=0; i<EC_NUM; i++)
628 if ((argc > 0) && (strcmp(*argv,"-elapsed") == 0))
631 j--; /* Otherwise, -elapsed gets confused with
634 else if ((argc > 0) && (strcmp(*argv,"-evp") == 0))
640 BIO_printf(bio_err,"no EVP given\n");
643 evp_cipher=EVP_get_cipherbyname(*argv);
646 evp_md=EVP_get_digestbyname(*argv);
648 if(!evp_cipher && !evp_md)
650 BIO_printf(bio_err,"%s is an unknown cipher or digest\n",*argv);
655 else if (argc > 0 && !strcmp(*argv,"-decrypt"))
658 j--; /* Otherwise, -elapsed gets confused with
661 #ifndef OPENSSL_NO_ENGINE
662 else if ((argc > 0) && (strcmp(*argv,"-engine") == 0))
668 BIO_printf(bio_err,"no engine given\n");
671 e = setup_engine(bio_err, *argv, 0);
672 /* j will be increased again further down. We just
673 don't want speed to confuse an engine with an
674 algorithm, especially when none is given (which
675 means all of them should be run) */
680 else if ((argc > 0) && (strcmp(*argv,"-multi") == 0))
686 BIO_printf(bio_err,"no multi count given\n");
692 BIO_printf(bio_err,"bad multi count\n");
695 j--; /* Otherwise, -mr gets confused with
699 else if (argc > 0 && !strcmp(*argv,"-mr"))
702 j--; /* Otherwise, -mr gets confused with
706 #ifndef OPENSSL_NO_MD2
707 if (strcmp(*argv,"md2") == 0) doit[D_MD2]=1;
710 #ifndef OPENSSL_NO_MDC2
711 if (strcmp(*argv,"mdc2") == 0) doit[D_MDC2]=1;
714 #ifndef OPENSSL_NO_MD4
715 if (strcmp(*argv,"md4") == 0) doit[D_MD4]=1;
718 #ifndef OPENSSL_NO_MD5
719 if (strcmp(*argv,"md5") == 0) doit[D_MD5]=1;
722 #ifndef OPENSSL_NO_MD5
723 if (strcmp(*argv,"hmac") == 0) doit[D_HMAC]=1;
726 #ifndef OPENSSL_NO_SHA
727 if (strcmp(*argv,"sha1") == 0) doit[D_SHA1]=1;
729 if (strcmp(*argv,"sha") == 0) doit[D_SHA1]=1,
733 #ifndef OPENSSL_NO_SHA256
734 if (strcmp(*argv,"sha256") == 0) doit[D_SHA256]=1;
737 #ifndef OPENSSL_NO_SHA512
738 if (strcmp(*argv,"sha512") == 0) doit[D_SHA512]=1;
742 #ifndef OPENSSL_NO_RIPEMD
743 if (strcmp(*argv,"ripemd") == 0) doit[D_RMD160]=1;
745 if (strcmp(*argv,"rmd160") == 0) doit[D_RMD160]=1;
747 if (strcmp(*argv,"ripemd160") == 0) doit[D_RMD160]=1;
750 #ifndef OPENSSL_NO_RC4
751 if (strcmp(*argv,"rc4") == 0) doit[D_RC4]=1;
754 #ifndef OPENSSL_NO_DES
755 if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1;
756 else if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1;
759 #ifndef OPENSSL_NO_AES
760 if (strcmp(*argv,"aes-128-cbc") == 0) doit[D_CBC_128_AES]=1;
761 else if (strcmp(*argv,"aes-192-cbc") == 0) doit[D_CBC_192_AES]=1;
762 else if (strcmp(*argv,"aes-256-cbc") == 0) doit[D_CBC_256_AES]=1;
765 #ifndef OPENSSL_NO_RSA
766 #if 0 /* was: #ifdef RSAref */
767 if (strcmp(*argv,"rsaref") == 0)
769 RSA_set_default_openssl_method(RSA_PKCS1_RSAref());
775 if (strcmp(*argv,"openssl") == 0)
777 RSA_set_default_method(RSA_PKCS1_SSLeay());
782 #endif /* !OPENSSL_NO_RSA */
783 if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2;
784 else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2;
785 else if (strcmp(*argv,"dsa2048") == 0) dsa_doit[R_DSA_2048]=2;
786 else if (strcmp(*argv,"rsa512") == 0) rsa_doit[R_RSA_512]=2;
787 else if (strcmp(*argv,"rsa1024") == 0) rsa_doit[R_RSA_1024]=2;
788 else if (strcmp(*argv,"rsa2048") == 0) rsa_doit[R_RSA_2048]=2;
789 else if (strcmp(*argv,"rsa4096") == 0) rsa_doit[R_RSA_4096]=2;
791 #ifndef OPENSSL_NO_RC2
792 if (strcmp(*argv,"rc2-cbc") == 0) doit[D_CBC_RC2]=1;
793 else if (strcmp(*argv,"rc2") == 0) doit[D_CBC_RC2]=1;
796 #ifndef OPENSSL_NO_RC5
797 if (strcmp(*argv,"rc5-cbc") == 0) doit[D_CBC_RC5]=1;
798 else if (strcmp(*argv,"rc5") == 0) doit[D_CBC_RC5]=1;
801 #ifndef OPENSSL_NO_IDEA
802 if (strcmp(*argv,"idea-cbc") == 0) doit[D_CBC_IDEA]=1;
803 else if (strcmp(*argv,"idea") == 0) doit[D_CBC_IDEA]=1;
806 #ifndef OPENSSL_NO_BF
807 if (strcmp(*argv,"bf-cbc") == 0) doit[D_CBC_BF]=1;
808 else if (strcmp(*argv,"blowfish") == 0) doit[D_CBC_BF]=1;
809 else if (strcmp(*argv,"bf") == 0) doit[D_CBC_BF]=1;
812 #ifndef OPENSSL_NO_CAST
813 if (strcmp(*argv,"cast-cbc") == 0) doit[D_CBC_CAST]=1;
814 else if (strcmp(*argv,"cast") == 0) doit[D_CBC_CAST]=1;
815 else if (strcmp(*argv,"cast5") == 0) doit[D_CBC_CAST]=1;
818 #ifndef OPENSSL_NO_DES
819 if (strcmp(*argv,"des") == 0)
826 #ifndef OPENSSL_NO_AES
827 if (strcmp(*argv,"aes") == 0)
829 doit[D_CBC_128_AES]=1;
830 doit[D_CBC_192_AES]=1;
831 doit[D_CBC_256_AES]=1;
835 #ifndef OPENSSL_NO_RSA
836 if (strcmp(*argv,"rsa") == 0)
838 rsa_doit[R_RSA_512]=1;
839 rsa_doit[R_RSA_1024]=1;
840 rsa_doit[R_RSA_2048]=1;
841 rsa_doit[R_RSA_4096]=1;
845 #ifndef OPENSSL_NO_DSA
846 if (strcmp(*argv,"dsa") == 0)
848 dsa_doit[R_DSA_512]=1;
849 dsa_doit[R_DSA_1024]=1;
850 dsa_doit[R_DSA_2048]=1;
854 #ifndef OPENSSL_NO_ECDSA
855 if (strcmp(*argv,"ecdsap160") == 0) ecdsa_doit[R_EC_P160]=2;
856 else if (strcmp(*argv,"ecdsap192") == 0) ecdsa_doit[R_EC_P192]=2;
857 else if (strcmp(*argv,"ecdsap224") == 0) ecdsa_doit[R_EC_P224]=2;
858 else if (strcmp(*argv,"ecdsap256") == 0) ecdsa_doit[R_EC_P256]=2;
859 else if (strcmp(*argv,"ecdsap384") == 0) ecdsa_doit[R_EC_P384]=2;
860 else if (strcmp(*argv,"ecdsap521") == 0) ecdsa_doit[R_EC_P521]=2;
861 else if (strcmp(*argv,"ecdsak163") == 0) ecdsa_doit[R_EC_K163]=2;
862 else if (strcmp(*argv,"ecdsak233") == 0) ecdsa_doit[R_EC_K233]=2;
863 else if (strcmp(*argv,"ecdsak283") == 0) ecdsa_doit[R_EC_K283]=2;
864 else if (strcmp(*argv,"ecdsak409") == 0) ecdsa_doit[R_EC_K409]=2;
865 else if (strcmp(*argv,"ecdsak571") == 0) ecdsa_doit[R_EC_K571]=2;
866 else if (strcmp(*argv,"ecdsab163") == 0) ecdsa_doit[R_EC_B163]=2;
867 else if (strcmp(*argv,"ecdsab233") == 0) ecdsa_doit[R_EC_B233]=2;
868 else if (strcmp(*argv,"ecdsab283") == 0) ecdsa_doit[R_EC_B283]=2;
869 else if (strcmp(*argv,"ecdsab409") == 0) ecdsa_doit[R_EC_B409]=2;
870 else if (strcmp(*argv,"ecdsab571") == 0) ecdsa_doit[R_EC_B571]=2;
871 else if (strcmp(*argv,"ecdsa") == 0)
873 for (i=0; i < EC_NUM; i++)
878 #ifndef OPENSSL_NO_ECDH
879 if (strcmp(*argv,"ecdhp160") == 0) ecdh_doit[R_EC_P160]=2;
880 else if (strcmp(*argv,"ecdhp192") == 0) ecdh_doit[R_EC_P192]=2;
881 else if (strcmp(*argv,"ecdhp224") == 0) ecdh_doit[R_EC_P224]=2;
882 else if (strcmp(*argv,"ecdhp256") == 0) ecdh_doit[R_EC_P256]=2;
883 else if (strcmp(*argv,"ecdhp384") == 0) ecdh_doit[R_EC_P384]=2;
884 else if (strcmp(*argv,"ecdhp521") == 0) ecdh_doit[R_EC_P521]=2;
885 else if (strcmp(*argv,"ecdhk163") == 0) ecdh_doit[R_EC_K163]=2;
886 else if (strcmp(*argv,"ecdhk233") == 0) ecdh_doit[R_EC_K233]=2;
887 else if (strcmp(*argv,"ecdhk283") == 0) ecdh_doit[R_EC_K283]=2;
888 else if (strcmp(*argv,"ecdhk409") == 0) ecdh_doit[R_EC_K409]=2;
889 else if (strcmp(*argv,"ecdhk571") == 0) ecdh_doit[R_EC_K571]=2;
890 else if (strcmp(*argv,"ecdhb163") == 0) ecdh_doit[R_EC_B163]=2;
891 else if (strcmp(*argv,"ecdhb233") == 0) ecdh_doit[R_EC_B233]=2;
892 else if (strcmp(*argv,"ecdhb283") == 0) ecdh_doit[R_EC_B283]=2;
893 else if (strcmp(*argv,"ecdhb409") == 0) ecdh_doit[R_EC_B409]=2;
894 else if (strcmp(*argv,"ecdhb571") == 0) ecdh_doit[R_EC_B571]=2;
895 else if (strcmp(*argv,"ecdh") == 0)
897 for (i=0; i < EC_NUM; i++)
903 BIO_printf(bio_err,"Error: bad option or value\n");
904 BIO_printf(bio_err,"\n");
905 BIO_printf(bio_err,"Available values:\n");
906 #ifndef OPENSSL_NO_MD2
907 BIO_printf(bio_err,"md2 ");
909 #ifndef OPENSSL_NO_MDC2
910 BIO_printf(bio_err,"mdc2 ");
912 #ifndef OPENSSL_NO_MD4
913 BIO_printf(bio_err,"md4 ");
915 #ifndef OPENSSL_NO_MD5
916 BIO_printf(bio_err,"md5 ");
917 #ifndef OPENSSL_NO_HMAC
918 BIO_printf(bio_err,"hmac ");
921 #ifndef OPENSSL_NO_SHA1
922 BIO_printf(bio_err,"sha1 ");
924 #ifndef OPENSSL_NO_SHA256
925 BIO_printf(bio_err,"sha256 ");
927 #ifndef OPENSSL_NO_SHA512
928 BIO_printf(bio_err,"sha512 ");
930 #ifndef OPENSSL_NO_RIPEMD160
931 BIO_printf(bio_err,"rmd160");
933 #if !defined(OPENSSL_NO_MD2) || !defined(OPENSSL_NO_MDC2) || \
934 !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \
935 !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160)
936 BIO_printf(bio_err,"\n");
939 #ifndef OPENSSL_NO_IDEA
940 BIO_printf(bio_err,"idea-cbc ");
942 #ifndef OPENSSL_NO_RC2
943 BIO_printf(bio_err,"rc2-cbc ");
945 #ifndef OPENSSL_NO_RC5
946 BIO_printf(bio_err,"rc5-cbc ");
948 #ifndef OPENSSL_NO_BF
949 BIO_printf(bio_err,"bf-cbc");
951 #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
952 !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_RC5)
953 BIO_printf(bio_err,"\n");
955 #ifndef OPENSSL_NO_DES
956 BIO_printf(bio_err,"des-cbc des-ede3 ");
958 #ifndef OPENSSL_NO_AES
959 BIO_printf(bio_err,"aes-128-cbc aes-192-cbc aes-256-cbc ");
961 #ifndef OPENSSL_NO_RC4
962 BIO_printf(bio_err,"rc4");
964 BIO_printf(bio_err,"\n");
966 #ifndef OPENSSL_NO_RSA
967 BIO_printf(bio_err,"rsa512 rsa1024 rsa2048 rsa4096\n");
970 #ifndef OPENSSL_NO_DSA
971 BIO_printf(bio_err,"dsa512 dsa1024 dsa2048\n");
973 #ifndef OPENSSL_NO_ECDSA
974 BIO_printf(bio_err,"ecdsap160 ecdsap192 ecdsap224 ecdsap256 ecdsap384 ecdsap521\n");
975 BIO_printf(bio_err,"ecdsak163 ecdsak233 ecdsak283 ecdsak409 ecdsak571\n");
976 BIO_printf(bio_err,"ecdsab163 ecdsab233 ecdsab283 ecdsab409 ecdsab571\n");
977 BIO_printf(bio_err,"ecdsa\n");
979 #ifndef OPENSSL_NO_ECDH
980 BIO_printf(bio_err,"ecdhp160 ecdhp192 ecdhp224 ecdhp256 ecdhp384 ecdhp521\n");
981 BIO_printf(bio_err,"ecdhk163 ecdhk233 ecdhk283 ecdhk409 ecdhk571\n");
982 BIO_printf(bio_err,"ecdhb163 ecdhb233 ecdhb283 ecdhb409 ecdhb571\n");
983 BIO_printf(bio_err,"ecdh\n");
986 #ifndef OPENSSL_NO_IDEA
987 BIO_printf(bio_err,"idea ");
989 #ifndef OPENSSL_NO_RC2
990 BIO_printf(bio_err,"rc2 ");
992 #ifndef OPENSSL_NO_DES
993 BIO_printf(bio_err,"des ");
995 #ifndef OPENSSL_NO_AES
996 BIO_printf(bio_err,"aes ");
998 #ifndef OPENSSL_NO_RSA
999 BIO_printf(bio_err,"rsa ");
1001 #ifndef OPENSSL_NO_BF
1002 BIO_printf(bio_err,"blowfish");
1004 #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
1005 !defined(OPENSSL_NO_DES) || !defined(OPENSSL_NO_RSA) || \
1006 !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_AES)
1007 BIO_printf(bio_err,"\n");
1010 BIO_printf(bio_err,"\n");
1011 BIO_printf(bio_err,"Available options:\n");
1012 #if defined(TIMES) || defined(USE_TOD)
1013 BIO_printf(bio_err,"-elapsed measure time in real time instead of CPU user time.\n");
1015 #ifndef OPENSSL_NO_ENGINE
1016 BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n");
1018 BIO_printf(bio_err,"-evp e use EVP e.\n");
1019 BIO_printf(bio_err,"-decrypt time decryption instead of encryption (only EVP).\n");
1020 BIO_printf(bio_err,"-mr produce machine readable output.\n");
1022 BIO_printf(bio_err,"-multi n run n benchmarks in parallel.\n");
1032 if(multi && do_multi(multi))
1038 for (i=0; i<ALGOR_NUM; i++)
1043 for (i=0; i<RSA_NUM; i++)
1045 for (i=0; i<DSA_NUM; i++)
1048 for (i=0; i<ALGOR_NUM; i++)
1049 if (doit[i]) pr_header++;
1051 if (usertime == 0 && !mr)
1052 BIO_printf(bio_err,"You have chosen to measure elapsed time instead of user CPU time.\n");
1053 if (usertime <= 0 && !mr)
1055 BIO_printf(bio_err,"To get the most accurate results, try to run this\n");
1056 BIO_printf(bio_err,"program when this computer is idle.\n");
1059 #ifndef OPENSSL_NO_RSA
1060 for (i=0; i<RSA_NUM; i++)
1062 const unsigned char *p;
1065 rsa_key[i]=d2i_RSAPrivateKey(NULL,&p,rsa_data_length[i]);
1066 if (rsa_key[i] == NULL)
1068 BIO_printf(bio_err,"internal error loading RSA key number %d\n",i);
1074 BIO_printf(bio_err,mr ? "+RK:%d:"
1075 : "Loaded RSA key, %d bit modulus and e= 0x",
1076 BN_num_bits(rsa_key[i]->n));
1077 BN_print(bio_err,rsa_key[i]->e);
1078 BIO_printf(bio_err,"\n");
1084 #ifndef OPENSSL_NO_DSA
1085 dsa_key[0]=get_dsa512();
1086 dsa_key[1]=get_dsa1024();
1087 dsa_key[2]=get_dsa2048();
1090 #ifndef OPENSSL_NO_DES
1091 DES_set_key_unchecked(&key,&sch);
1092 DES_set_key_unchecked(&key2,&sch2);
1093 DES_set_key_unchecked(&key3,&sch3);
1095 #ifndef OPENSSL_NO_AES
1096 AES_set_encrypt_key(key16,128,&aes_ks1);
1097 AES_set_encrypt_key(key24,192,&aes_ks2);
1098 AES_set_encrypt_key(key32,256,&aes_ks3);
1100 #ifndef OPENSSL_NO_IDEA
1101 idea_set_encrypt_key(key16,&idea_ks);
1103 #ifndef OPENSSL_NO_RC4
1104 RC4_set_key(&rc4_ks,16,key16);
1106 #ifndef OPENSSL_NO_RC2
1107 RC2_set_key(&rc2_ks,16,key16,128);
1109 #ifndef OPENSSL_NO_RC5
1110 RC5_32_set_key(&rc5_ks,16,key16,12);
1112 #ifndef OPENSSL_NO_BF
1113 BF_set_key(&bf_ks,16,key16);
1115 #ifndef OPENSSL_NO_CAST
1116 CAST_set_key(&cast_ks,16,key16);
1118 #ifndef OPENSSL_NO_RSA
1119 memset(rsa_c,0,sizeof(rsa_c));
1122 #ifndef OPENSSL_NO_DES
1123 BIO_printf(bio_err,"First we calculate the approximate speed ...\n");
1129 for (it=count; it; it--)
1130 DES_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock,
1135 c[D_MD2][0]=count/10;
1136 c[D_MDC2][0]=count/10;
1141 c[D_RMD160][0]=count;
1142 c[D_RC4][0]=count*5;
1143 c[D_CBC_DES][0]=count;
1144 c[D_EDE3_DES][0]=count/3;
1145 c[D_CBC_IDEA][0]=count;
1146 c[D_CBC_RC2][0]=count;
1147 c[D_CBC_RC5][0]=count;
1148 c[D_CBC_BF][0]=count;
1149 c[D_CBC_CAST][0]=count;
1150 c[D_CBC_128_AES][0]=count;
1151 c[D_CBC_192_AES][0]=count;
1152 c[D_CBC_256_AES][0]=count;
1153 c[D_SHA256][0]=count;
1154 c[D_SHA512][0]=count;
1156 for (i=1; i<SIZE_NUM; i++)
1158 c[D_MD2][i]=c[D_MD2][0]*4*lengths[0]/lengths[i];
1159 c[D_MDC2][i]=c[D_MDC2][0]*4*lengths[0]/lengths[i];
1160 c[D_MD4][i]=c[D_MD4][0]*4*lengths[0]/lengths[i];
1161 c[D_MD5][i]=c[D_MD5][0]*4*lengths[0]/lengths[i];
1162 c[D_HMAC][i]=c[D_HMAC][0]*4*lengths[0]/lengths[i];
1163 c[D_SHA1][i]=c[D_SHA1][0]*4*lengths[0]/lengths[i];
1164 c[D_RMD160][i]=c[D_RMD160][0]*4*lengths[0]/lengths[i];
1165 c[D_SHA256][i]=c[D_SHA256][0]*4*lengths[0]/lengths[i];
1166 c[D_SHA512][i]=c[D_SHA512][0]*4*lengths[0]/lengths[i];
1168 for (i=1; i<SIZE_NUM; i++)
1172 l0=(long)lengths[i-1];
1173 l1=(long)lengths[i];
1174 c[D_RC4][i]=c[D_RC4][i-1]*l0/l1;
1175 c[D_CBC_DES][i]=c[D_CBC_DES][i-1]*l0/l1;
1176 c[D_EDE3_DES][i]=c[D_EDE3_DES][i-1]*l0/l1;
1177 c[D_CBC_IDEA][i]=c[D_CBC_IDEA][i-1]*l0/l1;
1178 c[D_CBC_RC2][i]=c[D_CBC_RC2][i-1]*l0/l1;
1179 c[D_CBC_RC5][i]=c[D_CBC_RC5][i-1]*l0/l1;
1180 c[D_CBC_BF][i]=c[D_CBC_BF][i-1]*l0/l1;
1181 c[D_CBC_CAST][i]=c[D_CBC_CAST][i-1]*l0/l1;
1182 c[D_CBC_128_AES][i]=c[D_CBC_128_AES][i-1]*l0/l1;
1183 c[D_CBC_192_AES][i]=c[D_CBC_192_AES][i-1]*l0/l1;
1184 c[D_CBC_256_AES][i]=c[D_CBC_256_AES][i-1]*l0/l1;
1186 #ifndef OPENSSL_NO_RSA
1187 rsa_c[R_RSA_512][0]=count/2000;
1188 rsa_c[R_RSA_512][1]=count/400;
1189 for (i=1; i<RSA_NUM; i++)
1191 rsa_c[i][0]=rsa_c[i-1][0]/8;
1192 rsa_c[i][1]=rsa_c[i-1][1]/4;
1193 if ((rsa_doit[i] <= 1) && (rsa_c[i][0] == 0))
1197 if (rsa_c[i][0] == 0)
1206 #ifndef OPENSSL_NO_DSA
1207 dsa_c[R_DSA_512][0]=count/1000;
1208 dsa_c[R_DSA_512][1]=count/1000/2;
1209 for (i=1; i<DSA_NUM; i++)
1211 dsa_c[i][0]=dsa_c[i-1][0]/4;
1212 dsa_c[i][1]=dsa_c[i-1][1]/4;
1213 if ((dsa_doit[i] <= 1) && (dsa_c[i][0] == 0))
1226 #ifndef OPENSSL_NO_ECDSA
1227 ecdsa_c[R_EC_P160][0]=count/1000;
1228 ecdsa_c[R_EC_P160][1]=count/1000/2;
1229 for (i=R_EC_P192; i<=R_EC_P521; i++)
1231 ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
1232 ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
1233 if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
1237 if (ecdsa_c[i] == 0)
1244 ecdsa_c[R_EC_K163][0]=count/1000;
1245 ecdsa_c[R_EC_K163][1]=count/1000/2;
1246 for (i=R_EC_K233; i<=R_EC_K571; i++)
1248 ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
1249 ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
1250 if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
1254 if (ecdsa_c[i] == 0)
1261 ecdsa_c[R_EC_B163][0]=count/1000;
1262 ecdsa_c[R_EC_B163][1]=count/1000/2;
1263 for (i=R_EC_B233; i<=R_EC_B571; i++)
1265 ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
1266 ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
1267 if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
1271 if (ecdsa_c[i] == 0)
1280 #ifndef OPENSSL_NO_ECDH
1281 ecdh_c[R_EC_P160][0]=count/1000;
1282 ecdh_c[R_EC_P160][1]=count/1000;
1283 for (i=R_EC_P192; i<=R_EC_P521; i++)
1285 ecdh_c[i][0]=ecdh_c[i-1][0]/2;
1286 ecdh_c[i][1]=ecdh_c[i-1][1]/2;
1287 if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
1298 ecdh_c[R_EC_K163][0]=count/1000;
1299 ecdh_c[R_EC_K163][1]=count/1000;
1300 for (i=R_EC_K233; i<=R_EC_K571; i++)
1302 ecdh_c[i][0]=ecdh_c[i-1][0]/2;
1303 ecdh_c[i][1]=ecdh_c[i-1][1]/2;
1304 if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
1315 ecdh_c[R_EC_B163][0]=count/1000;
1316 ecdh_c[R_EC_B163][1]=count/1000;
1317 for (i=R_EC_B233; i<=R_EC_B571; i++)
1319 ecdh_c[i][0]=ecdh_c[i-1][0]/2;
1320 ecdh_c[i][1]=ecdh_c[i-1][1]/2;
1321 if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
1334 #define COND(d) (count < (d))
1335 #define COUNT(d) (d)
1337 /* not worth fixing */
1338 # error "You cannot disable DES on systems without SIGALRM."
1339 #endif /* OPENSSL_NO_DES */
1341 #define COND(c) (run)
1342 #define COUNT(d) (count)
1344 signal(SIGALRM,sig_done);
1346 #endif /* SIGALRM */
1348 #ifndef OPENSSL_NO_MD2
1351 for (j=0; j<SIZE_NUM; j++)
1353 print_message(names[D_MD2],c[D_MD2][j],lengths[j]);
1355 for (count=0,run=1; COND(c[D_MD2][j]); count++)
1356 EVP_Digest(buf,(unsigned long)lengths[j],&(md2[0]),NULL,EVP_md2(),NULL);
1358 print_result(D_MD2,j,count,d);
1362 #ifndef OPENSSL_NO_MDC2
1365 for (j=0; j<SIZE_NUM; j++)
1367 print_message(names[D_MDC2],c[D_MDC2][j],lengths[j]);
1369 for (count=0,run=1; COND(c[D_MDC2][j]); count++)
1370 EVP_Digest(buf,(unsigned long)lengths[j],&(mdc2[0]),NULL,EVP_mdc2(),NULL);
1372 print_result(D_MDC2,j,count,d);
1377 #ifndef OPENSSL_NO_MD4
1380 for (j=0; j<SIZE_NUM; j++)
1382 print_message(names[D_MD4],c[D_MD4][j],lengths[j]);
1384 for (count=0,run=1; COND(c[D_MD4][j]); count++)
1385 EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md4[0]),NULL,EVP_md4(),NULL);
1387 print_result(D_MD4,j,count,d);
1392 #ifndef OPENSSL_NO_MD5
1395 for (j=0; j<SIZE_NUM; j++)
1397 print_message(names[D_MD5],c[D_MD5][j],lengths[j]);
1399 for (count=0,run=1; COND(c[D_MD5][j]); count++)
1400 EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md5[0]),NULL,EVP_get_digestbyname("md5"),NULL);
1402 print_result(D_MD5,j,count,d);
1407 #if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC)
1412 HMAC_CTX_init(&hctx);
1413 HMAC_Init_ex(&hctx,(unsigned char *)"This is a key...",
1414 16,EVP_md5(), NULL);
1416 for (j=0; j<SIZE_NUM; j++)
1418 print_message(names[D_HMAC],c[D_HMAC][j],lengths[j]);
1420 for (count=0,run=1; COND(c[D_HMAC][j]); count++)
1422 HMAC_Init_ex(&hctx,NULL,0,NULL,NULL);
1423 HMAC_Update(&hctx,buf,lengths[j]);
1424 HMAC_Final(&hctx,&(hmac[0]),NULL);
1427 print_result(D_HMAC,j,count,d);
1429 HMAC_CTX_cleanup(&hctx);
1432 #ifndef OPENSSL_NO_SHA
1435 for (j=0; j<SIZE_NUM; j++)
1437 print_message(names[D_SHA1],c[D_SHA1][j],lengths[j]);
1439 for (count=0,run=1; COND(c[D_SHA1][j]); count++)
1440 EVP_Digest(buf,(unsigned long)lengths[j],&(sha[0]),NULL,EVP_sha1(),NULL);
1442 print_result(D_SHA1,j,count,d);
1446 #ifndef OPENSSL_NO_SHA256
1449 for (j=0; j<SIZE_NUM; j++)
1451 print_message(names[D_SHA256],c[D_SHA256][j],lengths[j]);
1453 for (count=0,run=1; COND(c[D_SHA256][j]); count++)
1454 SHA256(buf,lengths[j],sha256);
1456 print_result(D_SHA256,j,count,d);
1461 #ifndef OPENSSL_NO_SHA512
1464 for (j=0; j<SIZE_NUM; j++)
1466 print_message(names[D_SHA512],c[D_SHA512][j],lengths[j]);
1468 for (count=0,run=1; COND(c[D_SHA512][j]); count++)
1469 SHA512(buf,lengths[j],sha512);
1471 print_result(D_SHA512,j,count,d);
1477 #ifndef OPENSSL_NO_RIPEMD
1480 for (j=0; j<SIZE_NUM; j++)
1482 print_message(names[D_RMD160],c[D_RMD160][j],lengths[j]);
1484 for (count=0,run=1; COND(c[D_RMD160][j]); count++)
1485 EVP_Digest(buf,(unsigned long)lengths[j],&(rmd160[0]),NULL,EVP_ripemd160(),NULL);
1487 print_result(D_RMD160,j,count,d);
1491 #ifndef OPENSSL_NO_RC4
1494 for (j=0; j<SIZE_NUM; j++)
1496 print_message(names[D_RC4],c[D_RC4][j],lengths[j]);
1498 for (count=0,run=1; COND(c[D_RC4][j]); count++)
1499 RC4(&rc4_ks,(unsigned int)lengths[j],
1502 print_result(D_RC4,j,count,d);
1506 #ifndef OPENSSL_NO_DES
1507 if (doit[D_CBC_DES])
1509 for (j=0; j<SIZE_NUM; j++)
1511 print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
1513 for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
1514 DES_ncbc_encrypt(buf,buf,lengths[j],&sch,
1515 &DES_iv,DES_ENCRYPT);
1517 print_result(D_CBC_DES,j,count,d);
1521 if (doit[D_EDE3_DES])
1523 for (j=0; j<SIZE_NUM; j++)
1525 print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
1527 for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
1528 DES_ede3_cbc_encrypt(buf,buf,lengths[j],
1530 &DES_iv,DES_ENCRYPT);
1532 print_result(D_EDE3_DES,j,count,d);
1536 #ifndef OPENSSL_NO_AES
1537 if (doit[D_CBC_128_AES])
1539 for (j=0; j<SIZE_NUM; j++)
1541 print_message(names[D_CBC_128_AES],c[D_CBC_128_AES][j],lengths[j]);
1543 for (count=0,run=1; COND(c[D_CBC_128_AES][j]); count++)
1544 AES_cbc_encrypt(buf,buf,
1545 (unsigned long)lengths[j],&aes_ks1,
1548 print_result(D_CBC_128_AES,j,count,d);
1551 if (doit[D_CBC_192_AES])
1553 for (j=0; j<SIZE_NUM; j++)
1555 print_message(names[D_CBC_192_AES],c[D_CBC_192_AES][j],lengths[j]);
1557 for (count=0,run=1; COND(c[D_CBC_192_AES][j]); count++)
1558 AES_cbc_encrypt(buf,buf,
1559 (unsigned long)lengths[j],&aes_ks2,
1562 print_result(D_CBC_192_AES,j,count,d);
1565 if (doit[D_CBC_256_AES])
1567 for (j=0; j<SIZE_NUM; j++)
1569 print_message(names[D_CBC_256_AES],c[D_CBC_256_AES][j],lengths[j]);
1571 for (count=0,run=1; COND(c[D_CBC_256_AES][j]); count++)
1572 AES_cbc_encrypt(buf,buf,
1573 (unsigned long)lengths[j],&aes_ks3,
1576 print_result(D_CBC_256_AES,j,count,d);
1581 #ifndef OPENSSL_NO_IDEA
1582 if (doit[D_CBC_IDEA])
1584 for (j=0; j<SIZE_NUM; j++)
1586 print_message(names[D_CBC_IDEA],c[D_CBC_IDEA][j],lengths[j]);
1588 for (count=0,run=1; COND(c[D_CBC_IDEA][j]); count++)
1589 idea_cbc_encrypt(buf,buf,
1590 (unsigned long)lengths[j],&idea_ks,
1593 print_result(D_CBC_IDEA,j,count,d);
1597 #ifndef OPENSSL_NO_RC2
1598 if (doit[D_CBC_RC2])
1600 for (j=0; j<SIZE_NUM; j++)
1602 print_message(names[D_CBC_RC2],c[D_CBC_RC2][j],lengths[j]);
1604 for (count=0,run=1; COND(c[D_CBC_RC2][j]); count++)
1605 RC2_cbc_encrypt(buf,buf,
1606 (unsigned long)lengths[j],&rc2_ks,
1609 print_result(D_CBC_RC2,j,count,d);
1613 #ifndef OPENSSL_NO_RC5
1614 if (doit[D_CBC_RC5])
1616 for (j=0; j<SIZE_NUM; j++)
1618 print_message(names[D_CBC_RC5],c[D_CBC_RC5][j],lengths[j]);
1620 for (count=0,run=1; COND(c[D_CBC_RC5][j]); count++)
1621 RC5_32_cbc_encrypt(buf,buf,
1622 (unsigned long)lengths[j],&rc5_ks,
1625 print_result(D_CBC_RC5,j,count,d);
1629 #ifndef OPENSSL_NO_BF
1632 for (j=0; j<SIZE_NUM; j++)
1634 print_message(names[D_CBC_BF],c[D_CBC_BF][j],lengths[j]);
1636 for (count=0,run=1; COND(c[D_CBC_BF][j]); count++)
1637 BF_cbc_encrypt(buf,buf,
1638 (unsigned long)lengths[j],&bf_ks,
1641 print_result(D_CBC_BF,j,count,d);
1645 #ifndef OPENSSL_NO_CAST
1646 if (doit[D_CBC_CAST])
1648 for (j=0; j<SIZE_NUM; j++)
1650 print_message(names[D_CBC_CAST],c[D_CBC_CAST][j],lengths[j]);
1652 for (count=0,run=1; COND(c[D_CBC_CAST][j]); count++)
1653 CAST_cbc_encrypt(buf,buf,
1654 (unsigned long)lengths[j],&cast_ks,
1657 print_result(D_CBC_CAST,j,count,d);
1664 for (j=0; j<SIZE_NUM; j++)
1671 names[D_EVP]=OBJ_nid2ln(evp_cipher->nid);
1672 /* -O3 -fschedule-insns messes up an
1673 * optimization here! names[D_EVP]
1674 * somehow becomes NULL */
1675 print_message(names[D_EVP],save_count,
1678 EVP_CIPHER_CTX_init(&ctx);
1680 EVP_DecryptInit_ex(&ctx,evp_cipher,NULL,key16,iv);
1682 EVP_EncryptInit_ex(&ctx,evp_cipher,NULL,key16,iv);
1683 EVP_CIPHER_CTX_set_padding(&ctx, 0);
1687 for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1688 EVP_DecryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
1690 for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1691 EVP_EncryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
1693 EVP_DecryptFinal_ex(&ctx,buf,&outl);
1695 EVP_EncryptFinal_ex(&ctx,buf,&outl);
1697 EVP_CIPHER_CTX_cleanup(&ctx);
1701 names[D_EVP]=OBJ_nid2ln(evp_md->type);
1702 print_message(names[D_EVP],save_count,
1706 for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1707 EVP_Digest(buf,lengths[j],&(md[0]),NULL,evp_md,NULL);
1711 print_result(D_EVP,j,count,d);
1715 RAND_pseudo_bytes(buf,36);
1716 #ifndef OPENSSL_NO_RSA
1717 for (j=0; j<RSA_NUM; j++)
1720 if (!rsa_doit[j]) continue;
1721 ret=RSA_sign(NID_md5_sha1, buf,36, buf2, &rsa_num, rsa_key[j]);
1724 BIO_printf(bio_err,"RSA sign failure. No RSA sign will be done.\n");
1725 ERR_print_errors(bio_err);
1730 pkey_print_message("private","rsa",
1731 rsa_c[j][0],rsa_bits[j],
1733 /* RSA_blinding_on(rsa_key[j],NULL); */
1735 for (count=0,run=1; COND(rsa_c[j][0]); count++)
1737 ret=RSA_sign(NID_md5_sha1, buf,36, buf2,
1738 &rsa_num, rsa_key[j]);
1742 "RSA sign failure\n");
1743 ERR_print_errors(bio_err);
1749 BIO_printf(bio_err,mr ? "+R1:%ld:%d:%.2f\n"
1750 : "%ld %d bit private RSA's in %.2fs\n",
1751 count,rsa_bits[j],d);
1752 rsa_results[j][0]=d/(double)count;
1757 ret=RSA_verify(NID_md5_sha1, buf,36, buf2, rsa_num, rsa_key[j]);
1760 BIO_printf(bio_err,"RSA verify failure. No RSA verify will be done.\n");
1761 ERR_print_errors(bio_err);
1766 pkey_print_message("public","rsa",
1767 rsa_c[j][1],rsa_bits[j],
1770 for (count=0,run=1; COND(rsa_c[j][1]); count++)
1772 ret=RSA_verify(NID_md5_sha1, buf,36, buf2,
1773 rsa_num, rsa_key[j]);
1777 "RSA verify failure\n");
1778 ERR_print_errors(bio_err);
1784 BIO_printf(bio_err,mr ? "+R2:%ld:%d:%.2f\n"
1785 : "%ld %d bit public RSA's in %.2fs\n",
1786 count,rsa_bits[j],d);
1787 rsa_results[j][1]=d/(double)count;
1793 /* if longer than 10s, don't do any more */
1794 for (j++; j<RSA_NUM; j++)
1800 RAND_pseudo_bytes(buf,20);
1801 #ifndef OPENSSL_NO_DSA
1802 if (RAND_status() != 1)
1804 RAND_seed(rnd_seed, sizeof rnd_seed);
1807 for (j=0; j<DSA_NUM; j++)
1812 if (!dsa_doit[j]) continue;
1813 /* DSA_generate_key(dsa_key[j]); */
1814 /* DSA_sign_setup(dsa_key[j],NULL); */
1815 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1819 BIO_printf(bio_err,"DSA sign failure. No DSA sign will be done.\n");
1820 ERR_print_errors(bio_err);
1825 pkey_print_message("sign","dsa",
1826 dsa_c[j][0],dsa_bits[j],
1829 for (count=0,run=1; COND(dsa_c[j][0]); count++)
1831 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1836 "DSA sign failure\n");
1837 ERR_print_errors(bio_err);
1843 BIO_printf(bio_err,mr ? "+R3:%ld:%d:%.2f\n"
1844 : "%ld %d bit DSA signs in %.2fs\n",
1845 count,dsa_bits[j],d);
1846 dsa_results[j][0]=d/(double)count;
1850 ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1854 BIO_printf(bio_err,"DSA verify failure. No DSA verify will be done.\n");
1855 ERR_print_errors(bio_err);
1860 pkey_print_message("verify","dsa",
1861 dsa_c[j][1],dsa_bits[j],
1864 for (count=0,run=1; COND(dsa_c[j][1]); count++)
1866 ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1871 "DSA verify failure\n");
1872 ERR_print_errors(bio_err);
1878 BIO_printf(bio_err,mr ? "+R4:%ld:%d:%.2f\n"
1879 : "%ld %d bit DSA verify in %.2fs\n",
1880 count,dsa_bits[j],d);
1881 dsa_results[j][1]=d/(double)count;
1886 /* if longer than 10s, don't do any more */
1887 for (j++; j<DSA_NUM; j++)
1891 if (rnd_fake) RAND_cleanup();
1894 #ifndef OPENSSL_NO_ECDSA
1895 if (RAND_status() != 1)
1897 RAND_seed(rnd_seed, sizeof rnd_seed);
1900 for (j=0; j<EC_NUM; j++)
1904 if (!ecdsa_doit[j]) continue; /* Ignore Curve */
1905 ecdsa[j] = EC_KEY_new_by_curve_name(test_curves[j]);
1906 if (ecdsa[j] == NULL)
1908 BIO_printf(bio_err,"ECDSA failure.\n");
1909 ERR_print_errors(bio_err);
1915 EC_KEY_precompute_mult(ecdsa[j], NULL);
1917 /* Perform ECDSA signature test */
1918 EC_KEY_generate_key(ecdsa[j]);
1919 ret = ECDSA_sign(0, buf, 20, ecdsasig,
1920 &ecdsasiglen, ecdsa[j]);
1923 BIO_printf(bio_err,"ECDSA sign failure. No ECDSA sign will be done.\n");
1924 ERR_print_errors(bio_err);
1929 pkey_print_message("sign","ecdsa",
1931 test_curves_bits[j],
1935 for (count=0,run=1; COND(ecdsa_c[j][0]);
1938 ret=ECDSA_sign(0, buf, 20,
1939 ecdsasig, &ecdsasiglen,
1943 BIO_printf(bio_err, "ECDSA sign failure\n");
1944 ERR_print_errors(bio_err);
1951 BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" :
1952 "%ld %d bit ECDSA signs in %.2fs \n",
1953 count, test_curves_bits[j], d);
1954 ecdsa_results[j][0]=d/(double)count;
1958 /* Perform ECDSA verification test */
1959 ret=ECDSA_verify(0, buf, 20, ecdsasig,
1960 ecdsasiglen, ecdsa[j]);
1963 BIO_printf(bio_err,"ECDSA verify failure. No ECDSA verify will be done.\n");
1964 ERR_print_errors(bio_err);
1969 pkey_print_message("verify","ecdsa",
1971 test_curves_bits[j],
1974 for (count=0,run=1; COND(ecdsa_c[j][1]); count++)
1976 ret=ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]);
1979 BIO_printf(bio_err, "ECDSA verify failure\n");
1980 ERR_print_errors(bio_err);
1986 BIO_printf(bio_err, mr? "+R6:%ld:%d:%.2f\n"
1987 : "%ld %d bit ECDSA verify in %.2fs\n",
1988 count, test_curves_bits[j], d);
1989 ecdsa_results[j][1]=d/(double)count;
1994 /* if longer than 10s, don't do any more */
1995 for (j++; j<EC_NUM; j++)
2000 if (rnd_fake) RAND_cleanup();
2003 #ifndef OPENSSL_NO_ECDH
2004 if (RAND_status() != 1)
2006 RAND_seed(rnd_seed, sizeof rnd_seed);
2009 for (j=0; j<EC_NUM; j++)
2011 if (!ecdh_doit[j]) continue;
2012 ecdh_a[j] = EC_KEY_new_by_curve_name(test_curves[j]);
2013 ecdh_b[j] = EC_KEY_new_by_curve_name(test_curves[j]);
2014 if ((ecdh_a[j] == NULL) || (ecdh_b[j] == NULL))
2016 BIO_printf(bio_err,"ECDH failure.\n");
2017 ERR_print_errors(bio_err);
2022 /* generate two ECDH key pairs */
2023 if (!EC_KEY_generate_key(ecdh_a[j]) ||
2024 !EC_KEY_generate_key(ecdh_b[j]))
2026 BIO_printf(bio_err,"ECDH key generation failure.\n");
2027 ERR_print_errors(bio_err);
2032 /* If field size is not more than 24 octets, then use SHA-1 hash of result;
2033 * otherwise, use result (see section 4.8 of draft-ietf-tls-ecc-03.txt).
2035 int field_size, outlen;
2036 void *(*kdf)(const void *in, size_t inlen, void *out, size_t *xoutlen);
2037 field_size = EC_GROUP_get_degree(EC_KEY_get0_group(ecdh_a[j]));
2038 if (field_size <= 24 * 8)
2040 outlen = KDF1_SHA1_len;
2045 outlen = (field_size+7)/8;
2048 secret_size_a = ECDH_compute_key(secret_a, outlen,
2049 EC_KEY_get0_public_key(ecdh_b[j]),
2051 secret_size_b = ECDH_compute_key(secret_b, outlen,
2052 EC_KEY_get0_public_key(ecdh_a[j]),
2054 if (secret_size_a != secret_size_b)
2059 for (secret_idx = 0;
2060 (secret_idx < secret_size_a)
2061 && (ecdh_checks == 1);
2064 if (secret_a[secret_idx] != secret_b[secret_idx])
2068 if (ecdh_checks == 0)
2070 BIO_printf(bio_err,"ECDH computations don't match.\n");
2071 ERR_print_errors(bio_err);
2075 pkey_print_message("","ecdh",
2077 test_curves_bits[j],
2080 for (count=0,run=1; COND(ecdh_c[j][0]); count++)
2082 ECDH_compute_key(secret_a, outlen,
2083 EC_KEY_get0_public_key(ecdh_b[j]),
2087 BIO_printf(bio_err, mr ? "+R7:%ld:%d:%.2f\n" :"%ld %d-bit ECDH ops in %.2fs\n",
2088 count, test_curves_bits[j], d);
2089 ecdh_results[j][0]=d/(double)count;
2097 /* if longer than 10s, don't do any more */
2098 for (j++; j<EC_NUM; j++)
2102 if (rnd_fake) RAND_cleanup();
2109 fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_VERSION));
2110 fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_BUILT_ON));
2112 printf("%s ",BN_options());
2113 #ifndef OPENSSL_NO_MD2
2114 printf("%s ",MD2_options());
2116 #ifndef OPENSSL_NO_RC4
2117 printf("%s ",RC4_options());
2119 #ifndef OPENSSL_NO_DES
2120 printf("%s ",DES_options());
2122 #ifndef OPENSSL_NO_AES
2123 printf("%s ",AES_options());
2125 #ifndef OPENSSL_NO_IDEA
2126 printf("%s ",idea_options());
2128 #ifndef OPENSSL_NO_BF
2129 printf("%s ",BF_options());
2131 fprintf(stdout,"\n%s\n",SSLeay_version(SSLEAY_CFLAGS));
2137 fprintf(stdout,"+H");
2140 fprintf(stdout,"The 'numbers' are in 1000s of bytes per second processed.\n");
2141 fprintf(stdout,"type ");
2143 for (j=0; j<SIZE_NUM; j++)
2144 fprintf(stdout,mr ? ":%d" : "%7d bytes",lengths[j]);
2145 fprintf(stdout,"\n");
2148 for (k=0; k<ALGOR_NUM; k++)
2150 if (!doit[k]) continue;
2152 fprintf(stdout,"+F:%d:%s",k,names[k]);
2154 fprintf(stdout,"%-13s",names[k]);
2155 for (j=0; j<SIZE_NUM; j++)
2157 if (results[k][j] > 10000 && !mr)
2158 fprintf(stdout," %11.2fk",results[k][j]/1e3);
2160 fprintf(stdout,mr ? ":%.2f" : " %11.2f ",results[k][j]);
2162 fprintf(stdout,"\n");
2164 #ifndef OPENSSL_NO_RSA
2166 for (k=0; k<RSA_NUM; k++)
2168 if (!rsa_doit[k]) continue;
2171 printf("%18ssign verify sign/s verify/s\n"," ");
2175 fprintf(stdout,"+F2:%u:%u:%f:%f\n",
2176 k,rsa_bits[k],rsa_results[k][0],
2179 fprintf(stdout,"rsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
2180 rsa_bits[k],rsa_results[k][0],rsa_results[k][1],
2181 1.0/rsa_results[k][0],1.0/rsa_results[k][1]);
2184 #ifndef OPENSSL_NO_DSA
2186 for (k=0; k<DSA_NUM; k++)
2188 if (!dsa_doit[k]) continue;
2191 printf("%18ssign verify sign/s verify/s\n"," ");
2195 fprintf(stdout,"+F3:%u:%u:%f:%f\n",
2196 k,dsa_bits[k],dsa_results[k][0],dsa_results[k][1]);
2198 fprintf(stdout,"dsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
2199 dsa_bits[k],dsa_results[k][0],dsa_results[k][1],
2200 1.0/dsa_results[k][0],1.0/dsa_results[k][1]);
2203 #ifndef OPENSSL_NO_ECDSA
2205 for (k=0; k<EC_NUM; k++)
2207 if (!ecdsa_doit[k]) continue;
2210 printf("%30ssign verify sign/s verify/s\n"," ");
2215 fprintf(stdout,"+F4:%u:%u:%f:%f\n",
2216 k, test_curves_bits[k],
2217 ecdsa_results[k][0],ecdsa_results[k][1]);
2220 "%4u bit ecdsa (%s) %8.4fs %8.4fs %8.1f %8.1f\n",
2221 test_curves_bits[k],
2222 test_curves_names[k],
2223 ecdsa_results[k][0],ecdsa_results[k][1],
2224 1.0/ecdsa_results[k][0],1.0/ecdsa_results[k][1]);
2229 #ifndef OPENSSL_NO_ECDH
2231 for (k=0; k<EC_NUM; k++)
2233 if (!ecdh_doit[k]) continue;
2236 printf("%30sop op/s\n"," ");
2240 fprintf(stdout,"+F5:%u:%u:%f:%f\n",
2241 k, test_curves_bits[k],
2242 ecdh_results[k][0], 1.0/ecdh_results[k][0]);
2245 fprintf(stdout,"%4u bit ecdh (%s) %8.4fs %8.1f\n",
2246 test_curves_bits[k],
2247 test_curves_names[k],
2248 ecdh_results[k][0], 1.0/ecdh_results[k][0]);
2255 ERR_print_errors(bio_err);
2256 if (buf != NULL) OPENSSL_free(buf);
2257 if (buf2 != NULL) OPENSSL_free(buf2);
2258 #ifndef OPENSSL_NO_RSA
2259 for (i=0; i<RSA_NUM; i++)
2260 if (rsa_key[i] != NULL)
2261 RSA_free(rsa_key[i]);
2263 #ifndef OPENSSL_NO_DSA
2264 for (i=0; i<DSA_NUM; i++)
2265 if (dsa_key[i] != NULL)
2266 DSA_free(dsa_key[i]);
2269 #ifndef OPENSSL_NO_ECDSA
2270 for (i=0; i<EC_NUM; i++)
2271 if (ecdsa[i] != NULL)
2272 EC_KEY_free(ecdsa[i]);
2274 #ifndef OPENSSL_NO_ECDH
2275 for (i=0; i<EC_NUM; i++)
2277 if (ecdh_a[i] != NULL)
2278 EC_KEY_free(ecdh_a[i]);
2279 if (ecdh_b[i] != NULL)
2280 EC_KEY_free(ecdh_b[i]);
2288 static void print_message(const char *s, long num, int length)
2291 BIO_printf(bio_err,mr ? "+DT:%s:%d:%d\n"
2292 : "Doing %s for %ds on %d size blocks: ",s,SECONDS,length);
2293 (void)BIO_flush(bio_err);
2296 BIO_printf(bio_err,mr ? "+DN:%s:%ld:%d\n"
2297 : "Doing %s %ld times on %d size blocks: ",s,num,length);
2298 (void)BIO_flush(bio_err);
2305 static void pkey_print_message(const char *str, const char *str2, long num,
2309 BIO_printf(bio_err,mr ? "+DTP:%d:%s:%s:%d\n"
2310 : "Doing %d bit %s %s's for %ds: ",bits,str,str2,tm);
2311 (void)BIO_flush(bio_err);
2314 BIO_printf(bio_err,mr ? "+DNP:%ld:%d:%s:%s\n"
2315 : "Doing %ld %d bit %s %s's: ",num,bits,str,str2);
2316 (void)BIO_flush(bio_err);
2323 static void print_result(int alg,int run_no,int count,double time_used)
2325 BIO_printf(bio_err,mr ? "+R:%d:%s:%f\n"
2326 : "%d %s's in %.2fs\n",count,names[alg],time_used);
2327 results[alg][run_no]=((double)count)/time_used*lengths[run_no];
2331 static char *sstrsep(char **string, const char *delim)
2334 char *token = *string;
2339 memset(isdelim, 0, sizeof isdelim);
2344 isdelim[(unsigned char)(*delim)] = 1;
2348 while (!isdelim[(unsigned char)(**string)])
2362 static int do_multi(int multi)
2367 static char sep[]=":";
2369 fds=malloc(multi*sizeof *fds);
2370 for(n=0 ; n < multi ; ++n)
2388 printf("Forked child %d\n",n);
2391 /* for now, assume the pipe is long enough to take all the output */
2392 for(n=0 ; n < multi ; ++n)
2398 f=fdopen(fds[n],"r");
2399 while(fgets(buf,sizeof buf,f))
2406 fprintf(stderr,"Don't understand line '%s' from child %d\n",
2410 printf("Got: %s from %d\n",buf,n);
2411 if(!strncmp(buf,"+F:",3))
2417 alg=atoi(sstrsep(&p,sep));
2419 for(j=0 ; j < SIZE_NUM ; ++j)
2420 results[alg][j]+=atof(sstrsep(&p,sep));
2422 else if(!strncmp(buf,"+F2:",4))
2428 k=atoi(sstrsep(&p,sep));
2431 d=atof(sstrsep(&p,sep));
2433 rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
2435 rsa_results[k][0]=d;
2437 d=atof(sstrsep(&p,sep));
2439 rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
2441 rsa_results[k][1]=d;
2443 else if(!strncmp(buf,"+F2:",4))
2449 k=atoi(sstrsep(&p,sep));
2452 d=atof(sstrsep(&p,sep));
2454 rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
2456 rsa_results[k][0]=d;
2458 d=atof(sstrsep(&p,sep));
2460 rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
2462 rsa_results[k][1]=d;
2464 else if(!strncmp(buf,"+F3:",4))
2470 k=atoi(sstrsep(&p,sep));
2473 d=atof(sstrsep(&p,sep));
2475 dsa_results[k][0]=1/(1/dsa_results[k][0]+1/d);
2477 dsa_results[k][0]=d;
2479 d=atof(sstrsep(&p,sep));
2481 dsa_results[k][1]=1/(1/dsa_results[k][1]+1/d);
2483 dsa_results[k][1]=d;
2485 #ifndef OPENSSL_NO_ECDSA
2486 else if(!strncmp(buf,"+F4:",4))
2492 k=atoi(sstrsep(&p,sep));
2495 d=atof(sstrsep(&p,sep));
2497 ecdsa_results[k][0]=1/(1/ecdsa_results[k][0]+1/d);
2499 ecdsa_results[k][0]=d;
2501 d=atof(sstrsep(&p,sep));
2503 ecdsa_results[k][1]=1/(1/ecdsa_results[k][1]+1/d);
2505 ecdsa_results[k][1]=d;
2509 #ifndef OPENSSL_NO_ECDH
2510 else if(!strncmp(buf,"+F5:",4))
2516 k=atoi(sstrsep(&p,sep));
2519 d=atof(sstrsep(&p,sep));
2521 ecdh_results[k][0]=1/(1/ecdh_results[k][0]+1/d);
2523 ecdh_results[k][0]=d;
2528 else if(!strncmp(buf,"+H:",3))
2532 fprintf(stderr,"Unknown type '%s' from child %d\n",buf,n);