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)
187 static int usertime=1;
189 static double Time_F(int s);
190 static void print_message(const char *s,long num,int length);
191 static void pkey_print_message(const char *str, const char *str2,
192 long num, int bits, int sec);
193 static void print_result(int alg,int run_no,int count,double time_used);
195 static int do_multi(int multi);
204 #define MAX_ECDH_SIZE 256
206 static const char *names[ALGOR_NUM]={
207 "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4",
208 "des cbc","des ede3","idea cbc",
209 "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc",
210 "aes-128 cbc","aes-192 cbc","aes-256 cbc","evp","sha256","sha512"};
211 static double results[ALGOR_NUM][SIZE_NUM];
212 static int lengths[SIZE_NUM]={16,64,256,1024,8*1024};
213 static double rsa_results[RSA_NUM][2];
214 static double dsa_results[DSA_NUM][2];
215 #ifndef OPENSSL_NO_ECDSA
216 static double ecdsa_results[EC_NUM][2];
218 #ifndef OPENSSL_NO_ECDH
219 static double ecdh_results[EC_NUM][1];
222 #if defined(OPENSSL_NO_DSA) && !(defined(OPENSSL_NO_ECDSA) && defined(OPENSSL_NO_ECDH))
223 static const char rnd_seed[] = "string to make the random number generator think it has entropy";
224 static int rnd_fake = 0;
228 #if defined(__STDC__) || defined(sgi) || defined(_AIX)
229 #define SIGRETTYPE void
231 #define SIGRETTYPE int
234 static SIGRETTYPE sig_done(int sig);
235 static SIGRETTYPE sig_done(int sig)
237 signal(SIGALRM,sig_done);
251 static unsigned int lapse,schlock;
252 static void alarm(unsigned int secs) { lapse = secs*1000; }
254 static DWORD WINAPI sleepy(VOID *arg)
262 static double Time_F(int s)
268 thr = CreateThread(NULL,4096,sleepy,NULL,0,NULL);
271 DWORD ret=GetLastError();
272 BIO_printf(bio_err,"unable to CreateThread (%d)",ret);
275 CloseHandle(thr); /* detach the thread */
276 while (!schlock) Sleep(0); /* scheduler spinlock */
279 return app_tminterval(s,usertime);
283 static double Time_F(int s)
285 return app_tminterval(s,usertime);
290 #ifndef OPENSSL_NO_ECDH
291 static const int KDF1_SHA1_len = 20;
292 static void *KDF1_SHA1(const void *in, size_t inlen, void *out, size_t *outlen)
294 #ifndef OPENSSL_NO_SHA
295 if (*outlen < SHA_DIGEST_LENGTH)
298 *outlen = SHA_DIGEST_LENGTH;
299 return SHA1(in, inlen, out);
302 #endif /* OPENSSL_NO_SHA */
304 #endif /* OPENSSL_NO_ECDH */
307 int MAIN(int, char **);
309 int MAIN(int argc, char **argv)
311 #ifndef OPENSSL_NO_ENGINE
314 unsigned char *buf=NULL,*buf2=NULL;
316 long count=0,save_count=0;
318 #if !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_DSA)
321 #ifndef OPENSSL_NO_RSA
324 unsigned char md[EVP_MAX_MD_SIZE];
325 #ifndef OPENSSL_NO_MD2
326 unsigned char md2[MD2_DIGEST_LENGTH];
328 #ifndef OPENSSL_NO_MDC2
329 unsigned char mdc2[MDC2_DIGEST_LENGTH];
331 #ifndef OPENSSL_NO_MD4
332 unsigned char md4[MD4_DIGEST_LENGTH];
334 #ifndef OPENSSL_NO_MD5
335 unsigned char md5[MD5_DIGEST_LENGTH];
336 unsigned char hmac[MD5_DIGEST_LENGTH];
338 #ifndef OPENSSL_NO_SHA
339 unsigned char sha[SHA_DIGEST_LENGTH];
340 #ifndef OPENSSL_NO_SHA256
341 unsigned char sha256[SHA256_DIGEST_LENGTH];
343 #ifndef OPENSSL_NO_SHA512
344 unsigned char sha512[SHA512_DIGEST_LENGTH];
347 #ifndef OPENSSL_NO_RIPEMD
348 unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];
350 #ifndef OPENSSL_NO_RC4
353 #ifndef OPENSSL_NO_RC5
356 #ifndef OPENSSL_NO_RC2
359 #ifndef OPENSSL_NO_IDEA
360 IDEA_KEY_SCHEDULE idea_ks;
362 #ifndef OPENSSL_NO_BF
365 #ifndef OPENSSL_NO_CAST
368 static const unsigned char key16[16]=
369 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
370 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
371 #ifndef OPENSSL_NO_AES
372 static const unsigned char key24[24]=
373 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
374 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
375 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
376 static const unsigned char key32[32]=
377 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
378 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
379 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,
380 0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56};
382 #ifndef OPENSSL_NO_AES
383 #define MAX_BLOCK_SIZE 128
385 #define MAX_BLOCK_SIZE 64
387 unsigned char DES_iv[8];
388 unsigned char iv[MAX_BLOCK_SIZE/8];
389 #ifndef OPENSSL_NO_DES
390 DES_cblock *buf_as_des_cblock = NULL;
391 static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
392 static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
393 static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
394 DES_key_schedule sch;
395 DES_key_schedule sch2;
396 DES_key_schedule sch3;
398 #ifndef OPENSSL_NO_AES
399 AES_KEY aes_ks1, aes_ks2, aes_ks3;
411 #define D_CBC_IDEA 10
415 #define D_CBC_CAST 14
416 #define D_CBC_128_AES 15
417 #define D_CBC_192_AES 16
418 #define D_CBC_256_AES 17
423 long c[ALGOR_NUM][SIZE_NUM];
449 #ifndef OPENSSL_NO_RSA
450 RSA *rsa_key[RSA_NUM];
451 long rsa_c[RSA_NUM][2];
452 static unsigned int rsa_bits[RSA_NUM]={512,1024,2048,4096};
453 static unsigned char *rsa_data[RSA_NUM]=
454 {test512,test1024,test2048,test4096};
455 static int rsa_data_length[RSA_NUM]={
456 sizeof(test512),sizeof(test1024),
457 sizeof(test2048),sizeof(test4096)};
459 #ifndef OPENSSL_NO_DSA
460 DSA *dsa_key[DSA_NUM];
461 long dsa_c[DSA_NUM][2];
462 static unsigned int dsa_bits[DSA_NUM]={512,1024,2048};
464 #ifndef OPENSSL_NO_EC
465 /* We only test over the following curves as they are representative,
466 * To add tests over more curves, simply add the curve NID
467 * and curve name to the following arrays and increase the
468 * EC_NUM value accordingly.
470 static unsigned int test_curves[EC_NUM] =
474 NID_X9_62_prime192v1,
476 NID_X9_62_prime256v1,
491 static const char * test_curves_names[EC_NUM] =
512 static int test_curves_bits[EC_NUM] =
514 160, 192, 224, 256, 384, 521,
515 163, 233, 283, 409, 571,
516 163, 233, 283, 409, 571
521 #ifndef OPENSSL_NO_ECDSA
522 unsigned char ecdsasig[256];
523 unsigned int ecdsasiglen;
524 EC_KEY *ecdsa[EC_NUM];
525 long ecdsa_c[EC_NUM][2];
528 #ifndef OPENSSL_NO_ECDH
529 EC_KEY *ecdh_a[EC_NUM], *ecdh_b[EC_NUM];
530 unsigned char secret_a[MAX_ECDH_SIZE], secret_b[MAX_ECDH_SIZE];
531 int secret_size_a, secret_size_b;
534 long ecdh_c[EC_NUM][2];
537 int rsa_doit[RSA_NUM];
538 int dsa_doit[DSA_NUM];
539 #ifndef OPENSSL_NO_ECDSA
540 int ecdsa_doit[EC_NUM];
542 #ifndef OPENSSL_NO_ECDH
543 int ecdh_doit[EC_NUM];
547 const EVP_CIPHER *evp_cipher=NULL;
548 const EVP_MD *evp_md=NULL;
559 memset(results, 0, sizeof(results));
560 #ifndef OPENSSL_NO_DSA
561 memset(dsa_key,0,sizeof(dsa_key));
563 #ifndef OPENSSL_NO_ECDSA
564 for (i=0; i<EC_NUM; i++) ecdsa[i] = NULL;
566 #ifndef OPENSSL_NO_ECDH
567 for (i=0; i<EC_NUM; i++)
576 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
577 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
579 if (!load_config(bio_err, NULL))
582 #ifndef OPENSSL_NO_RSA
583 memset(rsa_key,0,sizeof(rsa_key));
584 for (i=0; i<RSA_NUM; i++)
588 if ((buf=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
590 BIO_printf(bio_err,"out of memory\n");
593 #ifndef OPENSSL_NO_DES
594 buf_as_des_cblock = (DES_cblock *)buf;
596 if ((buf2=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
598 BIO_printf(bio_err,"out of memory\n");
602 memset(c,0,sizeof(c));
603 memset(DES_iv,0,sizeof(DES_iv));
604 memset(iv,0,sizeof(iv));
606 for (i=0; i<ALGOR_NUM; i++)
608 for (i=0; i<RSA_NUM; i++)
610 for (i=0; i<DSA_NUM; i++)
612 #ifndef OPENSSL_NO_ECDSA
613 for (i=0; i<EC_NUM; i++)
616 #ifndef OPENSSL_NO_ECDH
617 for (i=0; i<EC_NUM; i++)
627 if ((argc > 0) && (strcmp(*argv,"-elapsed") == 0))
630 j--; /* Otherwise, -elapsed gets confused with
633 else if ((argc > 0) && (strcmp(*argv,"-evp") == 0))
639 BIO_printf(bio_err,"no EVP given\n");
642 evp_cipher=EVP_get_cipherbyname(*argv);
645 evp_md=EVP_get_digestbyname(*argv);
647 if(!evp_cipher && !evp_md)
649 BIO_printf(bio_err,"%s is an unknown cipher or digest\n",*argv);
654 else if (argc > 0 && !strcmp(*argv,"-decrypt"))
657 j--; /* Otherwise, -elapsed gets confused with
660 #ifndef OPENSSL_NO_ENGINE
661 else if ((argc > 0) && (strcmp(*argv,"-engine") == 0))
667 BIO_printf(bio_err,"no engine given\n");
670 e = setup_engine(bio_err, *argv, 0);
671 /* j will be increased again further down. We just
672 don't want speed to confuse an engine with an
673 algorithm, especially when none is given (which
674 means all of them should be run) */
679 else if ((argc > 0) && (strcmp(*argv,"-multi") == 0))
685 BIO_printf(bio_err,"no multi count given\n");
691 BIO_printf(bio_err,"bad multi count\n");
694 j--; /* Otherwise, -mr gets confused with
698 else if (argc > 0 && !strcmp(*argv,"-mr"))
701 j--; /* Otherwise, -mr gets confused with
705 #ifndef OPENSSL_NO_MD2
706 if (strcmp(*argv,"md2") == 0) doit[D_MD2]=1;
709 #ifndef OPENSSL_NO_MDC2
710 if (strcmp(*argv,"mdc2") == 0) doit[D_MDC2]=1;
713 #ifndef OPENSSL_NO_MD4
714 if (strcmp(*argv,"md4") == 0) doit[D_MD4]=1;
717 #ifndef OPENSSL_NO_MD5
718 if (strcmp(*argv,"md5") == 0) doit[D_MD5]=1;
721 #ifndef OPENSSL_NO_MD5
722 if (strcmp(*argv,"hmac") == 0) doit[D_HMAC]=1;
725 #ifndef OPENSSL_NO_SHA
726 if (strcmp(*argv,"sha1") == 0) doit[D_SHA1]=1;
728 if (strcmp(*argv,"sha") == 0) doit[D_SHA1]=1,
732 #ifndef OPENSSL_NO_SHA256
733 if (strcmp(*argv,"sha256") == 0) doit[D_SHA256]=1;
736 #ifndef OPENSSL_NO_SHA512
737 if (strcmp(*argv,"sha512") == 0) doit[D_SHA512]=1;
741 #ifndef OPENSSL_NO_RIPEMD
742 if (strcmp(*argv,"ripemd") == 0) doit[D_RMD160]=1;
744 if (strcmp(*argv,"rmd160") == 0) doit[D_RMD160]=1;
746 if (strcmp(*argv,"ripemd160") == 0) doit[D_RMD160]=1;
749 #ifndef OPENSSL_NO_RC4
750 if (strcmp(*argv,"rc4") == 0) doit[D_RC4]=1;
753 #ifndef OPENSSL_NO_DES
754 if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1;
755 else if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1;
758 #ifndef OPENSSL_NO_AES
759 if (strcmp(*argv,"aes-128-cbc") == 0) doit[D_CBC_128_AES]=1;
760 else if (strcmp(*argv,"aes-192-cbc") == 0) doit[D_CBC_192_AES]=1;
761 else if (strcmp(*argv,"aes-256-cbc") == 0) doit[D_CBC_256_AES]=1;
764 #ifndef OPENSSL_NO_RSA
765 #if 0 /* was: #ifdef RSAref */
766 if (strcmp(*argv,"rsaref") == 0)
768 RSA_set_default_openssl_method(RSA_PKCS1_RSAref());
774 if (strcmp(*argv,"openssl") == 0)
776 RSA_set_default_method(RSA_PKCS1_SSLeay());
781 #endif /* !OPENSSL_NO_RSA */
782 if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2;
783 else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2;
784 else if (strcmp(*argv,"dsa2048") == 0) dsa_doit[R_DSA_2048]=2;
785 else if (strcmp(*argv,"rsa512") == 0) rsa_doit[R_RSA_512]=2;
786 else if (strcmp(*argv,"rsa1024") == 0) rsa_doit[R_RSA_1024]=2;
787 else if (strcmp(*argv,"rsa2048") == 0) rsa_doit[R_RSA_2048]=2;
788 else if (strcmp(*argv,"rsa4096") == 0) rsa_doit[R_RSA_4096]=2;
790 #ifndef OPENSSL_NO_RC2
791 if (strcmp(*argv,"rc2-cbc") == 0) doit[D_CBC_RC2]=1;
792 else if (strcmp(*argv,"rc2") == 0) doit[D_CBC_RC2]=1;
795 #ifndef OPENSSL_NO_RC5
796 if (strcmp(*argv,"rc5-cbc") == 0) doit[D_CBC_RC5]=1;
797 else if (strcmp(*argv,"rc5") == 0) doit[D_CBC_RC5]=1;
800 #ifndef OPENSSL_NO_IDEA
801 if (strcmp(*argv,"idea-cbc") == 0) doit[D_CBC_IDEA]=1;
802 else if (strcmp(*argv,"idea") == 0) doit[D_CBC_IDEA]=1;
805 #ifndef OPENSSL_NO_BF
806 if (strcmp(*argv,"bf-cbc") == 0) doit[D_CBC_BF]=1;
807 else if (strcmp(*argv,"blowfish") == 0) doit[D_CBC_BF]=1;
808 else if (strcmp(*argv,"bf") == 0) doit[D_CBC_BF]=1;
811 #ifndef OPENSSL_NO_CAST
812 if (strcmp(*argv,"cast-cbc") == 0) doit[D_CBC_CAST]=1;
813 else if (strcmp(*argv,"cast") == 0) doit[D_CBC_CAST]=1;
814 else if (strcmp(*argv,"cast5") == 0) doit[D_CBC_CAST]=1;
817 #ifndef OPENSSL_NO_DES
818 if (strcmp(*argv,"des") == 0)
825 #ifndef OPENSSL_NO_AES
826 if (strcmp(*argv,"aes") == 0)
828 doit[D_CBC_128_AES]=1;
829 doit[D_CBC_192_AES]=1;
830 doit[D_CBC_256_AES]=1;
834 #ifndef OPENSSL_NO_RSA
835 if (strcmp(*argv,"rsa") == 0)
837 rsa_doit[R_RSA_512]=1;
838 rsa_doit[R_RSA_1024]=1;
839 rsa_doit[R_RSA_2048]=1;
840 rsa_doit[R_RSA_4096]=1;
844 #ifndef OPENSSL_NO_DSA
845 if (strcmp(*argv,"dsa") == 0)
847 dsa_doit[R_DSA_512]=1;
848 dsa_doit[R_DSA_1024]=1;
849 dsa_doit[R_DSA_2048]=1;
853 #ifndef OPENSSL_NO_ECDSA
854 if (strcmp(*argv,"ecdsap160") == 0) ecdsa_doit[R_EC_P160]=2;
855 else if (strcmp(*argv,"ecdsap192") == 0) ecdsa_doit[R_EC_P192]=2;
856 else if (strcmp(*argv,"ecdsap224") == 0) ecdsa_doit[R_EC_P224]=2;
857 else if (strcmp(*argv,"ecdsap256") == 0) ecdsa_doit[R_EC_P256]=2;
858 else if (strcmp(*argv,"ecdsap384") == 0) ecdsa_doit[R_EC_P384]=2;
859 else if (strcmp(*argv,"ecdsap521") == 0) ecdsa_doit[R_EC_P521]=2;
860 else if (strcmp(*argv,"ecdsak163") == 0) ecdsa_doit[R_EC_K163]=2;
861 else if (strcmp(*argv,"ecdsak233") == 0) ecdsa_doit[R_EC_K233]=2;
862 else if (strcmp(*argv,"ecdsak283") == 0) ecdsa_doit[R_EC_K283]=2;
863 else if (strcmp(*argv,"ecdsak409") == 0) ecdsa_doit[R_EC_K409]=2;
864 else if (strcmp(*argv,"ecdsak571") == 0) ecdsa_doit[R_EC_K571]=2;
865 else if (strcmp(*argv,"ecdsab163") == 0) ecdsa_doit[R_EC_B163]=2;
866 else if (strcmp(*argv,"ecdsab233") == 0) ecdsa_doit[R_EC_B233]=2;
867 else if (strcmp(*argv,"ecdsab283") == 0) ecdsa_doit[R_EC_B283]=2;
868 else if (strcmp(*argv,"ecdsab409") == 0) ecdsa_doit[R_EC_B409]=2;
869 else if (strcmp(*argv,"ecdsab571") == 0) ecdsa_doit[R_EC_B571]=2;
870 else if (strcmp(*argv,"ecdsa") == 0)
872 for (i=0; i < EC_NUM; i++)
877 #ifndef OPENSSL_NO_ECDH
878 if (strcmp(*argv,"ecdhp160") == 0) ecdh_doit[R_EC_P160]=2;
879 else if (strcmp(*argv,"ecdhp192") == 0) ecdh_doit[R_EC_P192]=2;
880 else if (strcmp(*argv,"ecdhp224") == 0) ecdh_doit[R_EC_P224]=2;
881 else if (strcmp(*argv,"ecdhp256") == 0) ecdh_doit[R_EC_P256]=2;
882 else if (strcmp(*argv,"ecdhp384") == 0) ecdh_doit[R_EC_P384]=2;
883 else if (strcmp(*argv,"ecdhp521") == 0) ecdh_doit[R_EC_P521]=2;
884 else if (strcmp(*argv,"ecdhk163") == 0) ecdh_doit[R_EC_K163]=2;
885 else if (strcmp(*argv,"ecdhk233") == 0) ecdh_doit[R_EC_K233]=2;
886 else if (strcmp(*argv,"ecdhk283") == 0) ecdh_doit[R_EC_K283]=2;
887 else if (strcmp(*argv,"ecdhk409") == 0) ecdh_doit[R_EC_K409]=2;
888 else if (strcmp(*argv,"ecdhk571") == 0) ecdh_doit[R_EC_K571]=2;
889 else if (strcmp(*argv,"ecdhb163") == 0) ecdh_doit[R_EC_B163]=2;
890 else if (strcmp(*argv,"ecdhb233") == 0) ecdh_doit[R_EC_B233]=2;
891 else if (strcmp(*argv,"ecdhb283") == 0) ecdh_doit[R_EC_B283]=2;
892 else if (strcmp(*argv,"ecdhb409") == 0) ecdh_doit[R_EC_B409]=2;
893 else if (strcmp(*argv,"ecdhb571") == 0) ecdh_doit[R_EC_B571]=2;
894 else if (strcmp(*argv,"ecdh") == 0)
896 for (i=0; i < EC_NUM; i++)
902 BIO_printf(bio_err,"Error: bad option or value\n");
903 BIO_printf(bio_err,"\n");
904 BIO_printf(bio_err,"Available values:\n");
905 #ifndef OPENSSL_NO_MD2
906 BIO_printf(bio_err,"md2 ");
908 #ifndef OPENSSL_NO_MDC2
909 BIO_printf(bio_err,"mdc2 ");
911 #ifndef OPENSSL_NO_MD4
912 BIO_printf(bio_err,"md4 ");
914 #ifndef OPENSSL_NO_MD5
915 BIO_printf(bio_err,"md5 ");
916 #ifndef OPENSSL_NO_HMAC
917 BIO_printf(bio_err,"hmac ");
920 #ifndef OPENSSL_NO_SHA1
921 BIO_printf(bio_err,"sha1 ");
923 #ifndef OPENSSL_NO_SHA256
924 BIO_printf(bio_err,"sha256 ");
926 #ifndef OPENSSL_NO_SHA512
927 BIO_printf(bio_err,"sha512 ");
929 #ifndef OPENSSL_NO_RIPEMD160
930 BIO_printf(bio_err,"rmd160");
932 #if !defined(OPENSSL_NO_MD2) || !defined(OPENSSL_NO_MDC2) || \
933 !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \
934 !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160)
935 BIO_printf(bio_err,"\n");
938 #ifndef OPENSSL_NO_IDEA
939 BIO_printf(bio_err,"idea-cbc ");
941 #ifndef OPENSSL_NO_RC2
942 BIO_printf(bio_err,"rc2-cbc ");
944 #ifndef OPENSSL_NO_RC5
945 BIO_printf(bio_err,"rc5-cbc ");
947 #ifndef OPENSSL_NO_BF
948 BIO_printf(bio_err,"bf-cbc");
950 #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
951 !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_RC5)
952 BIO_printf(bio_err,"\n");
954 #ifndef OPENSSL_NO_DES
955 BIO_printf(bio_err,"des-cbc des-ede3 ");
957 #ifndef OPENSSL_NO_AES
958 BIO_printf(bio_err,"aes-128-cbc aes-192-cbc aes-256-cbc ");
960 #ifndef OPENSSL_NO_RC4
961 BIO_printf(bio_err,"rc4");
963 BIO_printf(bio_err,"\n");
965 #ifndef OPENSSL_NO_RSA
966 BIO_printf(bio_err,"rsa512 rsa1024 rsa2048 rsa4096\n");
969 #ifndef OPENSSL_NO_DSA
970 BIO_printf(bio_err,"dsa512 dsa1024 dsa2048\n");
972 #ifndef OPENSSL_NO_ECDSA
973 BIO_printf(bio_err,"ecdsap160 ecdsap192 ecdsap224 ecdsap256 ecdsap384 ecdsap521\n");
974 BIO_printf(bio_err,"ecdsak163 ecdsak233 ecdsak283 ecdsak409 ecdsak571\n");
975 BIO_printf(bio_err,"ecdsab163 ecdsab233 ecdsab283 ecdsab409 ecdsab571\n");
976 BIO_printf(bio_err,"ecdsa\n");
978 #ifndef OPENSSL_NO_ECDH
979 BIO_printf(bio_err,"ecdhp160 ecdhp192 ecdhp224 ecdhp256 ecdhp384 ecdhp521\n");
980 BIO_printf(bio_err,"ecdhk163 ecdhk233 ecdhk283 ecdhk409 ecdhk571\n");
981 BIO_printf(bio_err,"ecdhb163 ecdhb233 ecdhb283 ecdhb409 ecdhb571\n");
982 BIO_printf(bio_err,"ecdh\n");
985 #ifndef OPENSSL_NO_IDEA
986 BIO_printf(bio_err,"idea ");
988 #ifndef OPENSSL_NO_RC2
989 BIO_printf(bio_err,"rc2 ");
991 #ifndef OPENSSL_NO_DES
992 BIO_printf(bio_err,"des ");
994 #ifndef OPENSSL_NO_AES
995 BIO_printf(bio_err,"aes ");
997 #ifndef OPENSSL_NO_RSA
998 BIO_printf(bio_err,"rsa ");
1000 #ifndef OPENSSL_NO_BF
1001 BIO_printf(bio_err,"blowfish");
1003 #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
1004 !defined(OPENSSL_NO_DES) || !defined(OPENSSL_NO_RSA) || \
1005 !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_AES)
1006 BIO_printf(bio_err,"\n");
1009 BIO_printf(bio_err,"\n");
1010 BIO_printf(bio_err,"Available options:\n");
1011 #if defined(TIMES) || defined(USE_TOD)
1012 BIO_printf(bio_err,"-elapsed measure time in real time instead of CPU user time.\n");
1014 #ifndef OPENSSL_NO_ENGINE
1015 BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n");
1017 BIO_printf(bio_err,"-evp e use EVP e.\n");
1018 BIO_printf(bio_err,"-decrypt time decryption instead of encryption (only EVP).\n");
1019 BIO_printf(bio_err,"-mr produce machine readable output.\n");
1021 BIO_printf(bio_err,"-multi n run n benchmarks in parallel.\n");
1031 if(multi && do_multi(multi))
1037 for (i=0; i<ALGOR_NUM; i++)
1042 for (i=0; i<RSA_NUM; i++)
1044 for (i=0; i<DSA_NUM; i++)
1047 for (i=0; i<ALGOR_NUM; i++)
1048 if (doit[i]) pr_header++;
1050 if (usertime == 0 && !mr)
1051 BIO_printf(bio_err,"You have chosen to measure elapsed time instead of user CPU time.\n");
1053 #ifndef OPENSSL_NO_RSA
1054 for (i=0; i<RSA_NUM; i++)
1056 const unsigned char *p;
1059 rsa_key[i]=d2i_RSAPrivateKey(NULL,&p,rsa_data_length[i]);
1060 if (rsa_key[i] == NULL)
1062 BIO_printf(bio_err,"internal error loading RSA key number %d\n",i);
1068 BIO_printf(bio_err,mr ? "+RK:%d:"
1069 : "Loaded RSA key, %d bit modulus and e= 0x",
1070 BN_num_bits(rsa_key[i]->n));
1071 BN_print(bio_err,rsa_key[i]->e);
1072 BIO_printf(bio_err,"\n");
1078 #ifndef OPENSSL_NO_DSA
1079 dsa_key[0]=get_dsa512();
1080 dsa_key[1]=get_dsa1024();
1081 dsa_key[2]=get_dsa2048();
1084 #ifndef OPENSSL_NO_DES
1085 DES_set_key_unchecked(&key,&sch);
1086 DES_set_key_unchecked(&key2,&sch2);
1087 DES_set_key_unchecked(&key3,&sch3);
1089 #ifndef OPENSSL_NO_AES
1090 AES_set_encrypt_key(key16,128,&aes_ks1);
1091 AES_set_encrypt_key(key24,192,&aes_ks2);
1092 AES_set_encrypt_key(key32,256,&aes_ks3);
1094 #ifndef OPENSSL_NO_IDEA
1095 idea_set_encrypt_key(key16,&idea_ks);
1097 #ifndef OPENSSL_NO_RC4
1098 RC4_set_key(&rc4_ks,16,key16);
1100 #ifndef OPENSSL_NO_RC2
1101 RC2_set_key(&rc2_ks,16,key16,128);
1103 #ifndef OPENSSL_NO_RC5
1104 RC5_32_set_key(&rc5_ks,16,key16,12);
1106 #ifndef OPENSSL_NO_BF
1107 BF_set_key(&bf_ks,16,key16);
1109 #ifndef OPENSSL_NO_CAST
1110 CAST_set_key(&cast_ks,16,key16);
1112 #ifndef OPENSSL_NO_RSA
1113 memset(rsa_c,0,sizeof(rsa_c));
1116 #ifndef OPENSSL_NO_DES
1117 BIO_printf(bio_err,"First we calculate the approximate speed ...\n");
1123 for (it=count; it; it--)
1124 DES_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock,
1129 c[D_MD2][0]=count/10;
1130 c[D_MDC2][0]=count/10;
1135 c[D_RMD160][0]=count;
1136 c[D_RC4][0]=count*5;
1137 c[D_CBC_DES][0]=count;
1138 c[D_EDE3_DES][0]=count/3;
1139 c[D_CBC_IDEA][0]=count;
1140 c[D_CBC_RC2][0]=count;
1141 c[D_CBC_RC5][0]=count;
1142 c[D_CBC_BF][0]=count;
1143 c[D_CBC_CAST][0]=count;
1144 c[D_CBC_128_AES][0]=count;
1145 c[D_CBC_192_AES][0]=count;
1146 c[D_CBC_256_AES][0]=count;
1147 c[D_SHA256][0]=count;
1148 c[D_SHA512][0]=count;
1150 for (i=1; i<SIZE_NUM; i++)
1152 c[D_MD2][i]=c[D_MD2][0]*4*lengths[0]/lengths[i];
1153 c[D_MDC2][i]=c[D_MDC2][0]*4*lengths[0]/lengths[i];
1154 c[D_MD4][i]=c[D_MD4][0]*4*lengths[0]/lengths[i];
1155 c[D_MD5][i]=c[D_MD5][0]*4*lengths[0]/lengths[i];
1156 c[D_HMAC][i]=c[D_HMAC][0]*4*lengths[0]/lengths[i];
1157 c[D_SHA1][i]=c[D_SHA1][0]*4*lengths[0]/lengths[i];
1158 c[D_RMD160][i]=c[D_RMD160][0]*4*lengths[0]/lengths[i];
1159 c[D_SHA256][i]=c[D_SHA256][0]*4*lengths[0]/lengths[i];
1160 c[D_SHA512][i]=c[D_SHA512][0]*4*lengths[0]/lengths[i];
1162 for (i=1; i<SIZE_NUM; i++)
1166 l0=(long)lengths[i-1];
1167 l1=(long)lengths[i];
1168 c[D_RC4][i]=c[D_RC4][i-1]*l0/l1;
1169 c[D_CBC_DES][i]=c[D_CBC_DES][i-1]*l0/l1;
1170 c[D_EDE3_DES][i]=c[D_EDE3_DES][i-1]*l0/l1;
1171 c[D_CBC_IDEA][i]=c[D_CBC_IDEA][i-1]*l0/l1;
1172 c[D_CBC_RC2][i]=c[D_CBC_RC2][i-1]*l0/l1;
1173 c[D_CBC_RC5][i]=c[D_CBC_RC5][i-1]*l0/l1;
1174 c[D_CBC_BF][i]=c[D_CBC_BF][i-1]*l0/l1;
1175 c[D_CBC_CAST][i]=c[D_CBC_CAST][i-1]*l0/l1;
1176 c[D_CBC_128_AES][i]=c[D_CBC_128_AES][i-1]*l0/l1;
1177 c[D_CBC_192_AES][i]=c[D_CBC_192_AES][i-1]*l0/l1;
1178 c[D_CBC_256_AES][i]=c[D_CBC_256_AES][i-1]*l0/l1;
1180 #ifndef OPENSSL_NO_RSA
1181 rsa_c[R_RSA_512][0]=count/2000;
1182 rsa_c[R_RSA_512][1]=count/400;
1183 for (i=1; i<RSA_NUM; i++)
1185 rsa_c[i][0]=rsa_c[i-1][0]/8;
1186 rsa_c[i][1]=rsa_c[i-1][1]/4;
1187 if ((rsa_doit[i] <= 1) && (rsa_c[i][0] == 0))
1191 if (rsa_c[i][0] == 0)
1200 #ifndef OPENSSL_NO_DSA
1201 dsa_c[R_DSA_512][0]=count/1000;
1202 dsa_c[R_DSA_512][1]=count/1000/2;
1203 for (i=1; i<DSA_NUM; i++)
1205 dsa_c[i][0]=dsa_c[i-1][0]/4;
1206 dsa_c[i][1]=dsa_c[i-1][1]/4;
1207 if ((dsa_doit[i] <= 1) && (dsa_c[i][0] == 0))
1220 #ifndef OPENSSL_NO_ECDSA
1221 ecdsa_c[R_EC_P160][0]=count/1000;
1222 ecdsa_c[R_EC_P160][1]=count/1000/2;
1223 for (i=R_EC_P192; i<=R_EC_P521; i++)
1225 ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
1226 ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
1227 if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
1231 if (ecdsa_c[i] == 0)
1238 ecdsa_c[R_EC_K163][0]=count/1000;
1239 ecdsa_c[R_EC_K163][1]=count/1000/2;
1240 for (i=R_EC_K233; i<=R_EC_K571; i++)
1242 ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
1243 ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
1244 if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
1248 if (ecdsa_c[i] == 0)
1255 ecdsa_c[R_EC_B163][0]=count/1000;
1256 ecdsa_c[R_EC_B163][1]=count/1000/2;
1257 for (i=R_EC_B233; i<=R_EC_B571; i++)
1259 ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
1260 ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
1261 if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
1265 if (ecdsa_c[i] == 0)
1274 #ifndef OPENSSL_NO_ECDH
1275 ecdh_c[R_EC_P160][0]=count/1000;
1276 ecdh_c[R_EC_P160][1]=count/1000;
1277 for (i=R_EC_P192; i<=R_EC_P521; i++)
1279 ecdh_c[i][0]=ecdh_c[i-1][0]/2;
1280 ecdh_c[i][1]=ecdh_c[i-1][1]/2;
1281 if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
1292 ecdh_c[R_EC_K163][0]=count/1000;
1293 ecdh_c[R_EC_K163][1]=count/1000;
1294 for (i=R_EC_K233; i<=R_EC_K571; i++)
1296 ecdh_c[i][0]=ecdh_c[i-1][0]/2;
1297 ecdh_c[i][1]=ecdh_c[i-1][1]/2;
1298 if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
1309 ecdh_c[R_EC_B163][0]=count/1000;
1310 ecdh_c[R_EC_B163][1]=count/1000;
1311 for (i=R_EC_B233; i<=R_EC_B571; i++)
1313 ecdh_c[i][0]=ecdh_c[i-1][0]/2;
1314 ecdh_c[i][1]=ecdh_c[i-1][1]/2;
1315 if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
1328 #define COND(d) (count < (d))
1329 #define COUNT(d) (d)
1331 /* not worth fixing */
1332 # error "You cannot disable DES on systems without SIGALRM."
1333 #endif /* OPENSSL_NO_DES */
1335 #define COND(c) (run)
1336 #define COUNT(d) (count)
1338 signal(SIGALRM,sig_done);
1340 #endif /* SIGALRM */
1342 #ifndef OPENSSL_NO_MD2
1345 for (j=0; j<SIZE_NUM; j++)
1347 print_message(names[D_MD2],c[D_MD2][j],lengths[j]);
1349 for (count=0,run=1; COND(c[D_MD2][j]); count++)
1350 EVP_Digest(buf,(unsigned long)lengths[j],&(md2[0]),NULL,EVP_md2(),NULL);
1352 print_result(D_MD2,j,count,d);
1356 #ifndef OPENSSL_NO_MDC2
1359 for (j=0; j<SIZE_NUM; j++)
1361 print_message(names[D_MDC2],c[D_MDC2][j],lengths[j]);
1363 for (count=0,run=1; COND(c[D_MDC2][j]); count++)
1364 EVP_Digest(buf,(unsigned long)lengths[j],&(mdc2[0]),NULL,EVP_mdc2(),NULL);
1366 print_result(D_MDC2,j,count,d);
1371 #ifndef OPENSSL_NO_MD4
1374 for (j=0; j<SIZE_NUM; j++)
1376 print_message(names[D_MD4],c[D_MD4][j],lengths[j]);
1378 for (count=0,run=1; COND(c[D_MD4][j]); count++)
1379 EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md4[0]),NULL,EVP_md4(),NULL);
1381 print_result(D_MD4,j,count,d);
1386 #ifndef OPENSSL_NO_MD5
1389 for (j=0; j<SIZE_NUM; j++)
1391 print_message(names[D_MD5],c[D_MD5][j],lengths[j]);
1393 for (count=0,run=1; COND(c[D_MD5][j]); count++)
1394 EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md5[0]),NULL,EVP_get_digestbyname("md5"),NULL);
1396 print_result(D_MD5,j,count,d);
1401 #if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC)
1406 HMAC_CTX_init(&hctx);
1407 HMAC_Init_ex(&hctx,(unsigned char *)"This is a key...",
1408 16,EVP_md5(), NULL);
1410 for (j=0; j<SIZE_NUM; j++)
1412 print_message(names[D_HMAC],c[D_HMAC][j],lengths[j]);
1414 for (count=0,run=1; COND(c[D_HMAC][j]); count++)
1416 HMAC_Init_ex(&hctx,NULL,0,NULL,NULL);
1417 HMAC_Update(&hctx,buf,lengths[j]);
1418 HMAC_Final(&hctx,&(hmac[0]),NULL);
1421 print_result(D_HMAC,j,count,d);
1423 HMAC_CTX_cleanup(&hctx);
1426 #ifndef OPENSSL_NO_SHA
1429 for (j=0; j<SIZE_NUM; j++)
1431 print_message(names[D_SHA1],c[D_SHA1][j],lengths[j]);
1433 for (count=0,run=1; COND(c[D_SHA1][j]); count++)
1434 EVP_Digest(buf,(unsigned long)lengths[j],&(sha[0]),NULL,EVP_sha1(),NULL);
1436 print_result(D_SHA1,j,count,d);
1440 #ifndef OPENSSL_NO_SHA256
1443 for (j=0; j<SIZE_NUM; j++)
1445 print_message(names[D_SHA256],c[D_SHA256][j],lengths[j]);
1447 for (count=0,run=1; COND(c[D_SHA256][j]); count++)
1448 SHA256(buf,lengths[j],sha256);
1450 print_result(D_SHA256,j,count,d);
1455 #ifndef OPENSSL_NO_SHA512
1458 for (j=0; j<SIZE_NUM; j++)
1460 print_message(names[D_SHA512],c[D_SHA512][j],lengths[j]);
1462 for (count=0,run=1; COND(c[D_SHA512][j]); count++)
1463 SHA512(buf,lengths[j],sha512);
1465 print_result(D_SHA512,j,count,d);
1471 #ifndef OPENSSL_NO_RIPEMD
1474 for (j=0; j<SIZE_NUM; j++)
1476 print_message(names[D_RMD160],c[D_RMD160][j],lengths[j]);
1478 for (count=0,run=1; COND(c[D_RMD160][j]); count++)
1479 EVP_Digest(buf,(unsigned long)lengths[j],&(rmd160[0]),NULL,EVP_ripemd160(),NULL);
1481 print_result(D_RMD160,j,count,d);
1485 #ifndef OPENSSL_NO_RC4
1488 for (j=0; j<SIZE_NUM; j++)
1490 print_message(names[D_RC4],c[D_RC4][j],lengths[j]);
1492 for (count=0,run=1; COND(c[D_RC4][j]); count++)
1493 RC4(&rc4_ks,(unsigned int)lengths[j],
1496 print_result(D_RC4,j,count,d);
1500 #ifndef OPENSSL_NO_DES
1501 if (doit[D_CBC_DES])
1503 for (j=0; j<SIZE_NUM; j++)
1505 print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
1507 for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
1508 DES_ncbc_encrypt(buf,buf,lengths[j],&sch,
1509 &DES_iv,DES_ENCRYPT);
1511 print_result(D_CBC_DES,j,count,d);
1515 if (doit[D_EDE3_DES])
1517 for (j=0; j<SIZE_NUM; j++)
1519 print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
1521 for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
1522 DES_ede3_cbc_encrypt(buf,buf,lengths[j],
1524 &DES_iv,DES_ENCRYPT);
1526 print_result(D_EDE3_DES,j,count,d);
1530 #ifndef OPENSSL_NO_AES
1531 if (doit[D_CBC_128_AES])
1533 for (j=0; j<SIZE_NUM; j++)
1535 print_message(names[D_CBC_128_AES],c[D_CBC_128_AES][j],lengths[j]);
1537 for (count=0,run=1; COND(c[D_CBC_128_AES][j]); count++)
1538 AES_cbc_encrypt(buf,buf,
1539 (unsigned long)lengths[j],&aes_ks1,
1542 print_result(D_CBC_128_AES,j,count,d);
1545 if (doit[D_CBC_192_AES])
1547 for (j=0; j<SIZE_NUM; j++)
1549 print_message(names[D_CBC_192_AES],c[D_CBC_192_AES][j],lengths[j]);
1551 for (count=0,run=1; COND(c[D_CBC_192_AES][j]); count++)
1552 AES_cbc_encrypt(buf,buf,
1553 (unsigned long)lengths[j],&aes_ks2,
1556 print_result(D_CBC_192_AES,j,count,d);
1559 if (doit[D_CBC_256_AES])
1561 for (j=0; j<SIZE_NUM; j++)
1563 print_message(names[D_CBC_256_AES],c[D_CBC_256_AES][j],lengths[j]);
1565 for (count=0,run=1; COND(c[D_CBC_256_AES][j]); count++)
1566 AES_cbc_encrypt(buf,buf,
1567 (unsigned long)lengths[j],&aes_ks3,
1570 print_result(D_CBC_256_AES,j,count,d);
1575 #ifndef OPENSSL_NO_IDEA
1576 if (doit[D_CBC_IDEA])
1578 for (j=0; j<SIZE_NUM; j++)
1580 print_message(names[D_CBC_IDEA],c[D_CBC_IDEA][j],lengths[j]);
1582 for (count=0,run=1; COND(c[D_CBC_IDEA][j]); count++)
1583 idea_cbc_encrypt(buf,buf,
1584 (unsigned long)lengths[j],&idea_ks,
1587 print_result(D_CBC_IDEA,j,count,d);
1591 #ifndef OPENSSL_NO_RC2
1592 if (doit[D_CBC_RC2])
1594 for (j=0; j<SIZE_NUM; j++)
1596 print_message(names[D_CBC_RC2],c[D_CBC_RC2][j],lengths[j]);
1598 for (count=0,run=1; COND(c[D_CBC_RC2][j]); count++)
1599 RC2_cbc_encrypt(buf,buf,
1600 (unsigned long)lengths[j],&rc2_ks,
1603 print_result(D_CBC_RC2,j,count,d);
1607 #ifndef OPENSSL_NO_RC5
1608 if (doit[D_CBC_RC5])
1610 for (j=0; j<SIZE_NUM; j++)
1612 print_message(names[D_CBC_RC5],c[D_CBC_RC5][j],lengths[j]);
1614 for (count=0,run=1; COND(c[D_CBC_RC5][j]); count++)
1615 RC5_32_cbc_encrypt(buf,buf,
1616 (unsigned long)lengths[j],&rc5_ks,
1619 print_result(D_CBC_RC5,j,count,d);
1623 #ifndef OPENSSL_NO_BF
1626 for (j=0; j<SIZE_NUM; j++)
1628 print_message(names[D_CBC_BF],c[D_CBC_BF][j],lengths[j]);
1630 for (count=0,run=1; COND(c[D_CBC_BF][j]); count++)
1631 BF_cbc_encrypt(buf,buf,
1632 (unsigned long)lengths[j],&bf_ks,
1635 print_result(D_CBC_BF,j,count,d);
1639 #ifndef OPENSSL_NO_CAST
1640 if (doit[D_CBC_CAST])
1642 for (j=0; j<SIZE_NUM; j++)
1644 print_message(names[D_CBC_CAST],c[D_CBC_CAST][j],lengths[j]);
1646 for (count=0,run=1; COND(c[D_CBC_CAST][j]); count++)
1647 CAST_cbc_encrypt(buf,buf,
1648 (unsigned long)lengths[j],&cast_ks,
1651 print_result(D_CBC_CAST,j,count,d);
1658 for (j=0; j<SIZE_NUM; j++)
1665 names[D_EVP]=OBJ_nid2ln(evp_cipher->nid);
1666 /* -O3 -fschedule-insns messes up an
1667 * optimization here! names[D_EVP]
1668 * somehow becomes NULL */
1669 print_message(names[D_EVP],save_count,
1672 EVP_CIPHER_CTX_init(&ctx);
1674 EVP_DecryptInit_ex(&ctx,evp_cipher,NULL,key16,iv);
1676 EVP_EncryptInit_ex(&ctx,evp_cipher,NULL,key16,iv);
1677 EVP_CIPHER_CTX_set_padding(&ctx, 0);
1681 for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1682 EVP_DecryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
1684 for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1685 EVP_EncryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
1687 EVP_DecryptFinal_ex(&ctx,buf,&outl);
1689 EVP_EncryptFinal_ex(&ctx,buf,&outl);
1691 EVP_CIPHER_CTX_cleanup(&ctx);
1695 names[D_EVP]=OBJ_nid2ln(evp_md->type);
1696 print_message(names[D_EVP],save_count,
1700 for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1701 EVP_Digest(buf,lengths[j],&(md[0]),NULL,evp_md,NULL);
1705 print_result(D_EVP,j,count,d);
1709 RAND_pseudo_bytes(buf,36);
1710 #ifndef OPENSSL_NO_RSA
1711 for (j=0; j<RSA_NUM; j++)
1714 if (!rsa_doit[j]) continue;
1715 ret=RSA_sign(NID_md5_sha1, buf,36, buf2, &rsa_num, rsa_key[j]);
1718 BIO_printf(bio_err,"RSA sign failure. No RSA sign will be done.\n");
1719 ERR_print_errors(bio_err);
1724 pkey_print_message("private","rsa",
1725 rsa_c[j][0],rsa_bits[j],
1727 /* RSA_blinding_on(rsa_key[j],NULL); */
1729 for (count=0,run=1; COND(rsa_c[j][0]); count++)
1731 ret=RSA_sign(NID_md5_sha1, buf,36, buf2,
1732 &rsa_num, rsa_key[j]);
1736 "RSA sign failure\n");
1737 ERR_print_errors(bio_err);
1743 BIO_printf(bio_err,mr ? "+R1:%ld:%d:%.2f\n"
1744 : "%ld %d bit private RSA's in %.2fs\n",
1745 count,rsa_bits[j],d);
1746 rsa_results[j][0]=d/(double)count;
1751 ret=RSA_verify(NID_md5_sha1, buf,36, buf2, rsa_num, rsa_key[j]);
1754 BIO_printf(bio_err,"RSA verify failure. No RSA verify will be done.\n");
1755 ERR_print_errors(bio_err);
1760 pkey_print_message("public","rsa",
1761 rsa_c[j][1],rsa_bits[j],
1764 for (count=0,run=1; COND(rsa_c[j][1]); count++)
1766 ret=RSA_verify(NID_md5_sha1, buf,36, buf2,
1767 rsa_num, rsa_key[j]);
1771 "RSA verify failure\n");
1772 ERR_print_errors(bio_err);
1778 BIO_printf(bio_err,mr ? "+R2:%ld:%d:%.2f\n"
1779 : "%ld %d bit public RSA's in %.2fs\n",
1780 count,rsa_bits[j],d);
1781 rsa_results[j][1]=d/(double)count;
1787 /* if longer than 10s, don't do any more */
1788 for (j++; j<RSA_NUM; j++)
1794 RAND_pseudo_bytes(buf,20);
1795 #ifndef OPENSSL_NO_DSA
1796 if (RAND_status() != 1)
1798 RAND_seed(rnd_seed, sizeof rnd_seed);
1801 for (j=0; j<DSA_NUM; j++)
1806 if (!dsa_doit[j]) continue;
1807 /* DSA_generate_key(dsa_key[j]); */
1808 /* DSA_sign_setup(dsa_key[j],NULL); */
1809 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1813 BIO_printf(bio_err,"DSA sign failure. No DSA sign will be done.\n");
1814 ERR_print_errors(bio_err);
1819 pkey_print_message("sign","dsa",
1820 dsa_c[j][0],dsa_bits[j],
1823 for (count=0,run=1; COND(dsa_c[j][0]); count++)
1825 ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1830 "DSA sign failure\n");
1831 ERR_print_errors(bio_err);
1837 BIO_printf(bio_err,mr ? "+R3:%ld:%d:%.2f\n"
1838 : "%ld %d bit DSA signs in %.2fs\n",
1839 count,dsa_bits[j],d);
1840 dsa_results[j][0]=d/(double)count;
1844 ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1848 BIO_printf(bio_err,"DSA verify failure. No DSA verify will be done.\n");
1849 ERR_print_errors(bio_err);
1854 pkey_print_message("verify","dsa",
1855 dsa_c[j][1],dsa_bits[j],
1858 for (count=0,run=1; COND(dsa_c[j][1]); count++)
1860 ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1865 "DSA verify failure\n");
1866 ERR_print_errors(bio_err);
1872 BIO_printf(bio_err,mr ? "+R4:%ld:%d:%.2f\n"
1873 : "%ld %d bit DSA verify in %.2fs\n",
1874 count,dsa_bits[j],d);
1875 dsa_results[j][1]=d/(double)count;
1880 /* if longer than 10s, don't do any more */
1881 for (j++; j<DSA_NUM; j++)
1885 if (rnd_fake) RAND_cleanup();
1888 #ifndef OPENSSL_NO_ECDSA
1889 if (RAND_status() != 1)
1891 RAND_seed(rnd_seed, sizeof rnd_seed);
1894 for (j=0; j<EC_NUM; j++)
1898 if (!ecdsa_doit[j]) continue; /* Ignore Curve */
1899 ecdsa[j] = EC_KEY_new_by_curve_name(test_curves[j]);
1900 if (ecdsa[j] == NULL)
1902 BIO_printf(bio_err,"ECDSA failure.\n");
1903 ERR_print_errors(bio_err);
1909 EC_KEY_precompute_mult(ecdsa[j], NULL);
1911 /* Perform ECDSA signature test */
1912 EC_KEY_generate_key(ecdsa[j]);
1913 ret = ECDSA_sign(0, buf, 20, ecdsasig,
1914 &ecdsasiglen, ecdsa[j]);
1917 BIO_printf(bio_err,"ECDSA sign failure. No ECDSA sign will be done.\n");
1918 ERR_print_errors(bio_err);
1923 pkey_print_message("sign","ecdsa",
1925 test_curves_bits[j],
1929 for (count=0,run=1; COND(ecdsa_c[j][0]);
1932 ret=ECDSA_sign(0, buf, 20,
1933 ecdsasig, &ecdsasiglen,
1937 BIO_printf(bio_err, "ECDSA sign failure\n");
1938 ERR_print_errors(bio_err);
1945 BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" :
1946 "%ld %d bit ECDSA signs in %.2fs \n",
1947 count, test_curves_bits[j], d);
1948 ecdsa_results[j][0]=d/(double)count;
1952 /* Perform ECDSA verification test */
1953 ret=ECDSA_verify(0, buf, 20, ecdsasig,
1954 ecdsasiglen, ecdsa[j]);
1957 BIO_printf(bio_err,"ECDSA verify failure. No ECDSA verify will be done.\n");
1958 ERR_print_errors(bio_err);
1963 pkey_print_message("verify","ecdsa",
1965 test_curves_bits[j],
1968 for (count=0,run=1; COND(ecdsa_c[j][1]); count++)
1970 ret=ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]);
1973 BIO_printf(bio_err, "ECDSA verify failure\n");
1974 ERR_print_errors(bio_err);
1980 BIO_printf(bio_err, mr? "+R6:%ld:%d:%.2f\n"
1981 : "%ld %d bit ECDSA verify in %.2fs\n",
1982 count, test_curves_bits[j], d);
1983 ecdsa_results[j][1]=d/(double)count;
1988 /* if longer than 10s, don't do any more */
1989 for (j++; j<EC_NUM; j++)
1994 if (rnd_fake) RAND_cleanup();
1997 #ifndef OPENSSL_NO_ECDH
1998 if (RAND_status() != 1)
2000 RAND_seed(rnd_seed, sizeof rnd_seed);
2003 for (j=0; j<EC_NUM; j++)
2005 if (!ecdh_doit[j]) continue;
2006 ecdh_a[j] = EC_KEY_new_by_curve_name(test_curves[j]);
2007 ecdh_b[j] = EC_KEY_new_by_curve_name(test_curves[j]);
2008 if ((ecdh_a[j] == NULL) || (ecdh_b[j] == NULL))
2010 BIO_printf(bio_err,"ECDH failure.\n");
2011 ERR_print_errors(bio_err);
2016 /* generate two ECDH key pairs */
2017 if (!EC_KEY_generate_key(ecdh_a[j]) ||
2018 !EC_KEY_generate_key(ecdh_b[j]))
2020 BIO_printf(bio_err,"ECDH key generation failure.\n");
2021 ERR_print_errors(bio_err);
2026 /* If field size is not more than 24 octets, then use SHA-1 hash of result;
2027 * otherwise, use result (see section 4.8 of draft-ietf-tls-ecc-03.txt).
2029 int field_size, outlen;
2030 void *(*kdf)(const void *in, size_t inlen, void *out, size_t *xoutlen);
2031 field_size = EC_GROUP_get_degree(EC_KEY_get0_group(ecdh_a[j]));
2032 if (field_size <= 24 * 8)
2034 outlen = KDF1_SHA1_len;
2039 outlen = (field_size+7)/8;
2042 secret_size_a = ECDH_compute_key(secret_a, outlen,
2043 EC_KEY_get0_public_key(ecdh_b[j]),
2045 secret_size_b = ECDH_compute_key(secret_b, outlen,
2046 EC_KEY_get0_public_key(ecdh_a[j]),
2048 if (secret_size_a != secret_size_b)
2053 for (secret_idx = 0;
2054 (secret_idx < secret_size_a)
2055 && (ecdh_checks == 1);
2058 if (secret_a[secret_idx] != secret_b[secret_idx])
2062 if (ecdh_checks == 0)
2064 BIO_printf(bio_err,"ECDH computations don't match.\n");
2065 ERR_print_errors(bio_err);
2069 pkey_print_message("","ecdh",
2071 test_curves_bits[j],
2074 for (count=0,run=1; COND(ecdh_c[j][0]); count++)
2076 ECDH_compute_key(secret_a, outlen,
2077 EC_KEY_get0_public_key(ecdh_b[j]),
2081 BIO_printf(bio_err, mr ? "+R7:%ld:%d:%.2f\n" :"%ld %d-bit ECDH ops in %.2fs\n",
2082 count, test_curves_bits[j], d);
2083 ecdh_results[j][0]=d/(double)count;
2091 /* if longer than 10s, don't do any more */
2092 for (j++; j<EC_NUM; j++)
2096 if (rnd_fake) RAND_cleanup();
2103 fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_VERSION));
2104 fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_BUILT_ON));
2106 printf("%s ",BN_options());
2107 #ifndef OPENSSL_NO_MD2
2108 printf("%s ",MD2_options());
2110 #ifndef OPENSSL_NO_RC4
2111 printf("%s ",RC4_options());
2113 #ifndef OPENSSL_NO_DES
2114 printf("%s ",DES_options());
2116 #ifndef OPENSSL_NO_AES
2117 printf("%s ",AES_options());
2119 #ifndef OPENSSL_NO_IDEA
2120 printf("%s ",idea_options());
2122 #ifndef OPENSSL_NO_BF
2123 printf("%s ",BF_options());
2125 fprintf(stdout,"\n%s\n",SSLeay_version(SSLEAY_CFLAGS));
2131 fprintf(stdout,"+H");
2134 fprintf(stdout,"The 'numbers' are in 1000s of bytes per second processed.\n");
2135 fprintf(stdout,"type ");
2137 for (j=0; j<SIZE_NUM; j++)
2138 fprintf(stdout,mr ? ":%d" : "%7d bytes",lengths[j]);
2139 fprintf(stdout,"\n");
2142 for (k=0; k<ALGOR_NUM; k++)
2144 if (!doit[k]) continue;
2146 fprintf(stdout,"+F:%d:%s",k,names[k]);
2148 fprintf(stdout,"%-13s",names[k]);
2149 for (j=0; j<SIZE_NUM; j++)
2151 if (results[k][j] > 10000 && !mr)
2152 fprintf(stdout," %11.2fk",results[k][j]/1e3);
2154 fprintf(stdout,mr ? ":%.2f" : " %11.2f ",results[k][j]);
2156 fprintf(stdout,"\n");
2158 #ifndef OPENSSL_NO_RSA
2160 for (k=0; k<RSA_NUM; k++)
2162 if (!rsa_doit[k]) continue;
2165 printf("%18ssign verify sign/s verify/s\n"," ");
2169 fprintf(stdout,"+F2:%u:%u:%f:%f\n",
2170 k,rsa_bits[k],rsa_results[k][0],
2173 fprintf(stdout,"rsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
2174 rsa_bits[k],rsa_results[k][0],rsa_results[k][1],
2175 1.0/rsa_results[k][0],1.0/rsa_results[k][1]);
2178 #ifndef OPENSSL_NO_DSA
2180 for (k=0; k<DSA_NUM; k++)
2182 if (!dsa_doit[k]) continue;
2185 printf("%18ssign verify sign/s verify/s\n"," ");
2189 fprintf(stdout,"+F3:%u:%u:%f:%f\n",
2190 k,dsa_bits[k],dsa_results[k][0],dsa_results[k][1]);
2192 fprintf(stdout,"dsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
2193 dsa_bits[k],dsa_results[k][0],dsa_results[k][1],
2194 1.0/dsa_results[k][0],1.0/dsa_results[k][1]);
2197 #ifndef OPENSSL_NO_ECDSA
2199 for (k=0; k<EC_NUM; k++)
2201 if (!ecdsa_doit[k]) continue;
2204 printf("%30ssign verify sign/s verify/s\n"," ");
2209 fprintf(stdout,"+F4:%u:%u:%f:%f\n",
2210 k, test_curves_bits[k],
2211 ecdsa_results[k][0],ecdsa_results[k][1]);
2214 "%4u bit ecdsa (%s) %8.4fs %8.4fs %8.1f %8.1f\n",
2215 test_curves_bits[k],
2216 test_curves_names[k],
2217 ecdsa_results[k][0],ecdsa_results[k][1],
2218 1.0/ecdsa_results[k][0],1.0/ecdsa_results[k][1]);
2223 #ifndef OPENSSL_NO_ECDH
2225 for (k=0; k<EC_NUM; k++)
2227 if (!ecdh_doit[k]) continue;
2230 printf("%30sop op/s\n"," ");
2234 fprintf(stdout,"+F5:%u:%u:%f:%f\n",
2235 k, test_curves_bits[k],
2236 ecdh_results[k][0], 1.0/ecdh_results[k][0]);
2239 fprintf(stdout,"%4u bit ecdh (%s) %8.4fs %8.1f\n",
2240 test_curves_bits[k],
2241 test_curves_names[k],
2242 ecdh_results[k][0], 1.0/ecdh_results[k][0]);
2249 ERR_print_errors(bio_err);
2250 if (buf != NULL) OPENSSL_free(buf);
2251 if (buf2 != NULL) OPENSSL_free(buf2);
2252 #ifndef OPENSSL_NO_RSA
2253 for (i=0; i<RSA_NUM; i++)
2254 if (rsa_key[i] != NULL)
2255 RSA_free(rsa_key[i]);
2257 #ifndef OPENSSL_NO_DSA
2258 for (i=0; i<DSA_NUM; i++)
2259 if (dsa_key[i] != NULL)
2260 DSA_free(dsa_key[i]);
2263 #ifndef OPENSSL_NO_ECDSA
2264 for (i=0; i<EC_NUM; i++)
2265 if (ecdsa[i] != NULL)
2266 EC_KEY_free(ecdsa[i]);
2268 #ifndef OPENSSL_NO_ECDH
2269 for (i=0; i<EC_NUM; i++)
2271 if (ecdh_a[i] != NULL)
2272 EC_KEY_free(ecdh_a[i]);
2273 if (ecdh_b[i] != NULL)
2274 EC_KEY_free(ecdh_b[i]);
2282 static void print_message(const char *s, long num, int length)
2285 BIO_printf(bio_err,mr ? "+DT:%s:%d:%d\n"
2286 : "Doing %s for %ds on %d size blocks: ",s,SECONDS,length);
2287 (void)BIO_flush(bio_err);
2290 BIO_printf(bio_err,mr ? "+DN:%s:%ld:%d\n"
2291 : "Doing %s %ld times on %d size blocks: ",s,num,length);
2292 (void)BIO_flush(bio_err);
2299 static void pkey_print_message(const char *str, const char *str2, long num,
2303 BIO_printf(bio_err,mr ? "+DTP:%d:%s:%s:%d\n"
2304 : "Doing %d bit %s %s's for %ds: ",bits,str,str2,tm);
2305 (void)BIO_flush(bio_err);
2308 BIO_printf(bio_err,mr ? "+DNP:%ld:%d:%s:%s\n"
2309 : "Doing %ld %d bit %s %s's: ",num,bits,str,str2);
2310 (void)BIO_flush(bio_err);
2317 static void print_result(int alg,int run_no,int count,double time_used)
2319 BIO_printf(bio_err,mr ? "+R:%d:%s:%f\n"
2320 : "%d %s's in %.2fs\n",count,names[alg],time_used);
2321 results[alg][run_no]=((double)count)/time_used*lengths[run_no];
2325 static char *sstrsep(char **string, const char *delim)
2328 char *token = *string;
2333 memset(isdelim, 0, sizeof isdelim);
2338 isdelim[(unsigned char)(*delim)] = 1;
2342 while (!isdelim[(unsigned char)(**string)])
2356 static int do_multi(int multi)
2361 static char sep[]=":";
2363 fds=malloc(multi*sizeof *fds);
2364 for(n=0 ; n < multi ; ++n)
2382 printf("Forked child %d\n",n);
2385 /* for now, assume the pipe is long enough to take all the output */
2386 for(n=0 ; n < multi ; ++n)
2392 f=fdopen(fds[n],"r");
2393 while(fgets(buf,sizeof buf,f))
2400 fprintf(stderr,"Don't understand line '%s' from child %d\n",
2404 printf("Got: %s from %d\n",buf,n);
2405 if(!strncmp(buf,"+F:",3))
2411 alg=atoi(sstrsep(&p,sep));
2413 for(j=0 ; j < SIZE_NUM ; ++j)
2414 results[alg][j]+=atof(sstrsep(&p,sep));
2416 else if(!strncmp(buf,"+F2:",4))
2422 k=atoi(sstrsep(&p,sep));
2425 d=atof(sstrsep(&p,sep));
2427 rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
2429 rsa_results[k][0]=d;
2431 d=atof(sstrsep(&p,sep));
2433 rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
2435 rsa_results[k][1]=d;
2437 else if(!strncmp(buf,"+F2:",4))
2443 k=atoi(sstrsep(&p,sep));
2446 d=atof(sstrsep(&p,sep));
2448 rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
2450 rsa_results[k][0]=d;
2452 d=atof(sstrsep(&p,sep));
2454 rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
2456 rsa_results[k][1]=d;
2458 else if(!strncmp(buf,"+F3:",4))
2464 k=atoi(sstrsep(&p,sep));
2467 d=atof(sstrsep(&p,sep));
2469 dsa_results[k][0]=1/(1/dsa_results[k][0]+1/d);
2471 dsa_results[k][0]=d;
2473 d=atof(sstrsep(&p,sep));
2475 dsa_results[k][1]=1/(1/dsa_results[k][1]+1/d);
2477 dsa_results[k][1]=d;
2479 #ifndef OPENSSL_NO_ECDSA
2480 else if(!strncmp(buf,"+F4:",4))
2486 k=atoi(sstrsep(&p,sep));
2489 d=atof(sstrsep(&p,sep));
2491 ecdsa_results[k][0]=1/(1/ecdsa_results[k][0]+1/d);
2493 ecdsa_results[k][0]=d;
2495 d=atof(sstrsep(&p,sep));
2497 ecdsa_results[k][1]=1/(1/ecdsa_results[k][1]+1/d);
2499 ecdsa_results[k][1]=d;
2503 #ifndef OPENSSL_NO_ECDH
2504 else if(!strncmp(buf,"+F5:",4))
2510 k=atoi(sstrsep(&p,sep));
2513 d=atof(sstrsep(&p,sep));
2515 ecdh_results[k][0]=1/(1/ecdh_results[k][0]+1/d);
2517 ecdh_results[k][0]=d;
2522 else if(!strncmp(buf,"+H:",3))
2526 fprintf(stderr,"Unknown type '%s' from child %d\n",buf,n);