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
87 #define PROG speed_main
95 #ifdef OPENSSL_NO_STDIO
103 #if !defined(OPENSSL_SYS_MSDOS)
104 #include OPENSSL_UNISTD
107 #ifndef OPENSSL_SYS_NETWARE
111 #if defined(_WIN32) || defined(__CYGWIN__)
113 # if defined(__CYGWIN__) && !defined(_WIN32)
122 #ifndef OPENSSL_NO_DES
125 #ifndef OPENSSL_NO_AES
128 #ifndef OPENSSL_NO_CAMELLIA
131 #ifndef OPENSSL_NO_MD2
132 #include <openssl/md2.h>
134 #ifndef OPENSSL_NO_MDC2
137 #ifndef OPENSSL_NO_MD4
140 #ifndef OPENSSL_NO_MD5
143 #ifndef OPENSSL_NO_HMAC
147 #ifndef OPENSSL_NO_SHA
150 #ifndef OPENSSL_NO_RIPEMD
153 #ifndef OPENSSL_NO_WHIRLPOOL
156 #ifndef OPENSSL_NO_RC4
159 #ifndef OPENSSL_NO_RC5
160 #include <openssl/rc5.h>
162 #ifndef OPENSSL_NO_RC2
165 #ifndef OPENSSL_NO_IDEA
168 #ifndef OPENSSL_NO_SEED
171 #ifndef OPENSSL_NO_BF
174 #ifndef OPENSSL_NO_CAST
177 #ifndef OPENSSL_NO_RSA
182 #ifndef OPENSSL_NO_DSA
186 #ifndef OPENSSL_NO_ECDSA
189 #ifndef OPENSSL_NO_ECDH
195 #ifdef OPENSSL_DOING_MAKEDEPEND
196 #undef AES_set_encrypt_key
197 #undef AES_set_decrypt_key
198 #undef DES_set_key_unchecked
200 #define BF_set_key private_BF_set_key
201 #define CAST_set_key private_CAST_set_key
202 #define idea_set_encrypt_key private_idea_set_encrypt_key
203 #define SEED_set_key private_SEED_set_key
204 #define RC2_set_key private_RC2_set_key
205 #define RC4_set_key private_RC4_set_key
206 #define DES_set_key_unchecked private_DES_set_key_unchecked
207 #define AES_set_encrypt_key private_AES_set_encrypt_key
208 #define AES_set_decrypt_key private_AES_set_decrypt_key
209 #define Camellia_set_key private_Camellia_set_key
213 # if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_NETWARE)
227 #define BUFSIZE ((long)1024*8+1)
231 static int usertime=1;
233 static double Time_F(
int s);
234 static void print_message(
const char *s,
long num,
int length);
235 static void pkey_print_message(
const char *str,
const char *str2,
237 static void print_result(
int alg,
int run_no,
int count,
double time_used);
239 static int do_multi(
int multi);
248 #define MAX_ECDH_SIZE 256
251 "md2",
"mdc2",
"md4",
"md5",
"hmac(md5)",
"sha1",
"rmd160",
"rc4",
252 "des cbc",
"des ede3",
"idea cbc",
"seed cbc",
253 "rc2 cbc",
"rc5-32/12 cbc",
"blowfish cbc",
"cast cbc",
254 "aes-128 cbc",
"aes-192 cbc",
"aes-256 cbc",
255 "camellia-128 cbc",
"camellia-192 cbc",
"camellia-256 cbc",
256 "evp",
"sha256",
"sha512",
"whirlpool",
257 "aes-128 ige",
"aes-192 ige",
"aes-256 ige",
"ghash"};
259 static int lengths[
SIZE_NUM]={16,64,256,1024,8*1024};
260 #ifndef OPENSSL_NO_RSA
261 static double rsa_results[
RSA_NUM][2];
263 #ifndef OPENSSL_NO_DSA
264 static double dsa_results[
DSA_NUM][2];
266 #ifndef OPENSSL_NO_ECDSA
267 static double ecdsa_results[
EC_NUM][2];
269 #ifndef OPENSSL_NO_ECDH
270 static double ecdh_results[
EC_NUM][1];
273 #if defined(OPENSSL_NO_DSA) && !(defined(OPENSSL_NO_ECDSA) && defined(OPENSSL_NO_ECDH))
274 static const char rnd_seed[] =
"string to make the random number generator think it has entropy";
275 static int rnd_fake = 0;
279 #if defined(__STDC__) || defined(sgi) || defined(_AIX)
280 #define SIGRETTYPE void
282 #define SIGRETTYPE int
285 static SIGRETTYPE sig_done(
int sig);
286 static SIGRETTYPE sig_done(
int sig)
288 signal(SIGALRM,sig_done);
301 #if !defined(SIGALRM)
304 static unsigned int lapse,schlock;
305 static void alarm_win32(
unsigned int secs) { lapse = secs*1000; }
306 #define alarm alarm_win32
308 static DWORD WINAPI sleepy(VOID *
arg)
316 static double Time_F(
int s)
322 thr = CreateThread(NULL,4096,sleepy,NULL,0,NULL);
325 DWORD ret=GetLastError();
330 while (!schlock) Sleep(0);
337 static double Time_F(
int s)
344 #ifndef OPENSSL_NO_ECDH
345 static const int KDF1_SHA1_len = 20;
346 static void *KDF1_SHA1(
const void *in,
size_t inlen,
void *out,
size_t *outlen)
348 #ifndef OPENSSL_NO_SHA
353 return SHA1(in, inlen, out);
361 int MAIN(
int,
char **);
363 int MAIN(
int argc,
char **argv)
365 unsigned char *buf=NULL,*buf2=NULL;
367 long count=0,save_count=0;
369 #if !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_DSA)
372 #ifndef OPENSSL_NO_RSA
376 #ifndef OPENSSL_NO_MD2
379 #ifndef OPENSSL_NO_MDC2
382 #ifndef OPENSSL_NO_MD4
385 #ifndef OPENSSL_NO_MD5
389 #ifndef OPENSSL_NO_SHA
391 #ifndef OPENSSL_NO_SHA256
394 #ifndef OPENSSL_NO_SHA512
398 #ifndef OPENSSL_NO_WHIRLPOOL
401 #ifndef OPENSSL_NO_RIPEMD
404 #ifndef OPENSSL_NO_RC4
407 #ifndef OPENSSL_NO_RC5
410 #ifndef OPENSSL_NO_RC2
413 #ifndef OPENSSL_NO_IDEA
416 #ifndef OPENSSL_NO_SEED
419 #ifndef OPENSSL_NO_BF
422 #ifndef OPENSSL_NO_CAST
425 static const unsigned char key16[16]=
426 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
427 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
428 #ifndef OPENSSL_NO_AES
429 static const unsigned char key24[24]=
430 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
431 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
432 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
433 static const unsigned char key32[32]=
434 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
435 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
436 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,
437 0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56};
439 #ifndef OPENSSL_NO_CAMELLIA
440 static const unsigned char ckey24[24]=
441 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
442 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
443 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
444 static const unsigned char ckey32[32]=
445 {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
446 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
447 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,
448 0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56};
450 #ifndef OPENSSL_NO_AES
451 #define MAX_BLOCK_SIZE 128
453 #define MAX_BLOCK_SIZE 64
455 unsigned char DES_iv[8];
457 #ifndef OPENSSL_NO_DES
458 static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
459 static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
460 static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
465 #ifndef OPENSSL_NO_AES
466 AES_KEY aes_ks1, aes_ks2, aes_ks3;
468 #ifndef OPENSSL_NO_CAMELLIA
481 #define D_CBC_IDEA 10
482 #define D_CBC_SEED 11
486 #define D_CBC_CAST 15
487 #define D_CBC_128_AES 16
488 #define D_CBC_192_AES 17
489 #define D_CBC_256_AES 18
490 #define D_CBC_128_CML 19
491 #define D_CBC_192_CML 20
492 #define D_CBC_256_CML 21
496 #define D_WHIRLPOOL 25
497 #define D_IGE_128_AES 26
498 #define D_IGE_192_AES 27
499 #define D_IGE_256_AES 28
528 #ifndef OPENSSL_NO_RSA
531 static unsigned int rsa_bits[
RSA_NUM]={512,1024,2048,4096};
532 static unsigned char *rsa_data[
RSA_NUM]=
533 {test512,test1024,test2048,test4096};
534 static int rsa_data_length[
RSA_NUM]={
535 sizeof(test512),
sizeof(test1024),
536 sizeof(test2048),
sizeof(test4096)};
538 #ifndef OPENSSL_NO_DSA
541 static unsigned int dsa_bits[
DSA_NUM]={512,1024,2048};
543 #ifndef OPENSSL_NO_EC
549 static unsigned int test_curves[
EC_NUM] =
570 static const char * test_curves_names[
EC_NUM] =
591 static int test_curves_bits[
EC_NUM] =
593 160, 192, 224, 256, 384, 521,
594 163, 233, 283, 409, 571,
595 163, 233, 283, 409, 571
600 #ifndef OPENSSL_NO_ECDSA
601 unsigned char ecdsasig[256];
602 unsigned int ecdsasiglen;
607 #ifndef OPENSSL_NO_ECDH
610 int secret_size_a, secret_size_b;
618 #ifndef OPENSSL_NO_ECDSA
621 #ifndef OPENSSL_NO_ECDH
627 const EVP_MD *evp_md=NULL;
638 memset(results, 0,
sizeof(results));
639 #ifndef OPENSSL_NO_DSA
640 memset(dsa_key,0,
sizeof(dsa_key));
642 #ifndef OPENSSL_NO_ECDSA
643 for (i=0; i<
EC_NUM; i++) ecdsa[i] = NULL;
645 #ifndef OPENSSL_NO_ECDH
661 #ifndef OPENSSL_NO_RSA
662 memset(rsa_key,0,
sizeof(rsa_key));
678 memset(c,0,
sizeof(c));
679 memset(DES_iv,0,
sizeof(DES_iv));
680 memset(iv,0,
sizeof(iv));
688 #ifndef OPENSSL_NO_ECDSA
692 #ifndef OPENSSL_NO_ECDH
703 if ((argc > 0) && (strcmp(*argv,
"-elapsed") == 0))
709 else if ((argc > 0) && (strcmp(*argv,
"-evp") == 0))
723 if(!evp_cipher && !evp_md)
730 else if (argc > 0 && !strcmp(*argv,
"-decrypt"))
736 #ifndef OPENSSL_NO_ENGINE
737 else if ((argc > 0) && (strcmp(*argv,
"-engine") == 0))
755 else if ((argc > 0) && (strcmp(*argv,
"-multi") == 0))
774 else if (argc > 0 && !strcmp(*argv,
"-mr"))
781 #ifndef OPENSSL_NO_MD2
782 if (strcmp(*argv,
"md2") == 0) doit[
D_MD2]=1;
785 #ifndef OPENSSL_NO_MDC2
786 if (strcmp(*argv,
"mdc2") == 0) doit[
D_MDC2]=1;
789 #ifndef OPENSSL_NO_MD4
790 if (strcmp(*argv,
"md4") == 0) doit[
D_MD4]=1;
793 #ifndef OPENSSL_NO_MD5
794 if (strcmp(*argv,
"md5") == 0) doit[
D_MD5]=1;
797 #ifndef OPENSSL_NO_MD5
798 if (strcmp(*argv,
"hmac") == 0) doit[
D_HMAC]=1;
801 #ifndef OPENSSL_NO_SHA
802 if (strcmp(*argv,
"sha1") == 0) doit[
D_SHA1]=1;
804 if (strcmp(*argv,
"sha") == 0) doit[
D_SHA1]=1,
808 #ifndef OPENSSL_NO_SHA256
809 if (strcmp(*argv,
"sha256") == 0) doit[
D_SHA256]=1;
812 #ifndef OPENSSL_NO_SHA512
813 if (strcmp(*argv,
"sha512") == 0) doit[
D_SHA512]=1;
817 #ifndef OPENSSL_NO_WHIRLPOOL
818 if (strcmp(*argv,
"whirlpool") == 0) doit[
D_WHIRLPOOL]=1;
821 #ifndef OPENSSL_NO_RIPEMD
822 if (strcmp(*argv,
"ripemd") == 0) doit[
D_RMD160]=1;
824 if (strcmp(*argv,
"rmd160") == 0) doit[
D_RMD160]=1;
826 if (strcmp(*argv,
"ripemd160") == 0) doit[
D_RMD160]=1;
829 #ifndef OPENSSL_NO_RC4
830 if (strcmp(*argv,
"rc4") == 0) doit[
D_RC4]=1;
833 #ifndef OPENSSL_NO_DES
834 if (strcmp(*argv,
"des-cbc") == 0) doit[
D_CBC_DES]=1;
835 else if (strcmp(*argv,
"des-ede3") == 0) doit[
D_EDE3_DES]=1;
838 #ifndef OPENSSL_NO_AES
840 else if (strcmp(*argv,
"aes-192-cbc") == 0) doit[
D_CBC_192_AES]=1;
841 else if (strcmp(*argv,
"aes-256-cbc") == 0) doit[
D_CBC_256_AES]=1;
842 else if (strcmp(*argv,
"aes-128-ige") == 0) doit[
D_IGE_128_AES]=1;
843 else if (strcmp(*argv,
"aes-192-ige") == 0) doit[
D_IGE_192_AES]=1;
844 else if (strcmp(*argv,
"aes-256-ige") == 0) doit[
D_IGE_256_AES]=1;
847 #ifndef OPENSSL_NO_CAMELLIA
848 if (strcmp(*argv,
"camellia-128-cbc") == 0) doit[
D_CBC_128_CML]=1;
849 else if (strcmp(*argv,
"camellia-192-cbc") == 0) doit[
D_CBC_192_CML]=1;
850 else if (strcmp(*argv,
"camellia-256-cbc") == 0) doit[
D_CBC_256_CML]=1;
853 #ifndef OPENSSL_NO_RSA
855 if (strcmp(*argv,
"rsaref") == 0)
857 RSA_set_default_openssl_method(RSA_PKCS1_RSAref());
863 if (strcmp(*argv,
"openssl") == 0)
871 if (strcmp(*argv,
"dsa512") == 0) dsa_doit[
R_DSA_512]=2;
872 else if (strcmp(*argv,
"dsa1024") == 0) dsa_doit[
R_DSA_1024]=2;
873 else if (strcmp(*argv,
"dsa2048") == 0) dsa_doit[
R_DSA_2048]=2;
874 else if (strcmp(*argv,
"rsa512") == 0) rsa_doit[
R_RSA_512]=2;
875 else if (strcmp(*argv,
"rsa1024") == 0) rsa_doit[
R_RSA_1024]=2;
876 else if (strcmp(*argv,
"rsa2048") == 0) rsa_doit[
R_RSA_2048]=2;
877 else if (strcmp(*argv,
"rsa4096") == 0) rsa_doit[
R_RSA_4096]=2;
879 #ifndef OPENSSL_NO_RC2
880 if (strcmp(*argv,
"rc2-cbc") == 0) doit[
D_CBC_RC2]=1;
881 else if (strcmp(*argv,
"rc2") == 0) doit[
D_CBC_RC2]=1;
884 #ifndef OPENSSL_NO_RC5
885 if (strcmp(*argv,
"rc5-cbc") == 0) doit[
D_CBC_RC5]=1;
886 else if (strcmp(*argv,
"rc5") == 0) doit[
D_CBC_RC5]=1;
889 #ifndef OPENSSL_NO_IDEA
890 if (strcmp(*argv,
"idea-cbc") == 0) doit[
D_CBC_IDEA]=1;
891 else if (strcmp(*argv,
"idea") == 0) doit[
D_CBC_IDEA]=1;
894 #ifndef OPENSSL_NO_SEED
895 if (strcmp(*argv,
"seed-cbc") == 0) doit[
D_CBC_SEED]=1;
896 else if (strcmp(*argv,
"seed") == 0) doit[
D_CBC_SEED]=1;
899 #ifndef OPENSSL_NO_BF
900 if (strcmp(*argv,
"bf-cbc") == 0) doit[
D_CBC_BF]=1;
901 else if (strcmp(*argv,
"blowfish") == 0) doit[
D_CBC_BF]=1;
902 else if (strcmp(*argv,
"bf") == 0) doit[
D_CBC_BF]=1;
905 #ifndef OPENSSL_NO_CAST
906 if (strcmp(*argv,
"cast-cbc") == 0) doit[
D_CBC_CAST]=1;
907 else if (strcmp(*argv,
"cast") == 0) doit[
D_CBC_CAST]=1;
908 else if (strcmp(*argv,
"cast5") == 0) doit[
D_CBC_CAST]=1;
911 #ifndef OPENSSL_NO_DES
912 if (strcmp(*argv,
"des") == 0)
919 #ifndef OPENSSL_NO_AES
920 if (strcmp(*argv,
"aes") == 0)
926 else if (strcmp(*argv,
"ghash") == 0)
932 #ifndef OPENSSL_NO_CAMELLIA
933 if (strcmp(*argv,
"camellia") == 0)
941 #ifndef OPENSSL_NO_RSA
942 if (strcmp(*argv,
"rsa") == 0)
951 #ifndef OPENSSL_NO_DSA
952 if (strcmp(*argv,
"dsa") == 0)
960 #ifndef OPENSSL_NO_ECDSA
961 if (strcmp(*argv,
"ecdsap160") == 0) ecdsa_doit[
R_EC_P160]=2;
962 else if (strcmp(*argv,
"ecdsap192") == 0) ecdsa_doit[
R_EC_P192]=2;
963 else if (strcmp(*argv,
"ecdsap224") == 0) ecdsa_doit[
R_EC_P224]=2;
964 else if (strcmp(*argv,
"ecdsap256") == 0) ecdsa_doit[
R_EC_P256]=2;
965 else if (strcmp(*argv,
"ecdsap384") == 0) ecdsa_doit[
R_EC_P384]=2;
966 else if (strcmp(*argv,
"ecdsap521") == 0) ecdsa_doit[
R_EC_P521]=2;
967 else if (strcmp(*argv,
"ecdsak163") == 0) ecdsa_doit[
R_EC_K163]=2;
968 else if (strcmp(*argv,
"ecdsak233") == 0) ecdsa_doit[
R_EC_K233]=2;
969 else if (strcmp(*argv,
"ecdsak283") == 0) ecdsa_doit[
R_EC_K283]=2;
970 else if (strcmp(*argv,
"ecdsak409") == 0) ecdsa_doit[
R_EC_K409]=2;
971 else if (strcmp(*argv,
"ecdsak571") == 0) ecdsa_doit[
R_EC_K571]=2;
972 else if (strcmp(*argv,
"ecdsab163") == 0) ecdsa_doit[
R_EC_B163]=2;
973 else if (strcmp(*argv,
"ecdsab233") == 0) ecdsa_doit[
R_EC_B233]=2;
974 else if (strcmp(*argv,
"ecdsab283") == 0) ecdsa_doit[
R_EC_B283]=2;
975 else if (strcmp(*argv,
"ecdsab409") == 0) ecdsa_doit[
R_EC_B409]=2;
976 else if (strcmp(*argv,
"ecdsab571") == 0) ecdsa_doit[
R_EC_B571]=2;
977 else if (strcmp(*argv,
"ecdsa") == 0)
979 for (i=0; i <
EC_NUM; i++)
984 #ifndef OPENSSL_NO_ECDH
985 if (strcmp(*argv,
"ecdhp160") == 0) ecdh_doit[
R_EC_P160]=2;
986 else if (strcmp(*argv,
"ecdhp192") == 0) ecdh_doit[
R_EC_P192]=2;
987 else if (strcmp(*argv,
"ecdhp224") == 0) ecdh_doit[
R_EC_P224]=2;
988 else if (strcmp(*argv,
"ecdhp256") == 0) ecdh_doit[
R_EC_P256]=2;
989 else if (strcmp(*argv,
"ecdhp384") == 0) ecdh_doit[
R_EC_P384]=2;
990 else if (strcmp(*argv,
"ecdhp521") == 0) ecdh_doit[
R_EC_P521]=2;
991 else if (strcmp(*argv,
"ecdhk163") == 0) ecdh_doit[
R_EC_K163]=2;
992 else if (strcmp(*argv,
"ecdhk233") == 0) ecdh_doit[
R_EC_K233]=2;
993 else if (strcmp(*argv,
"ecdhk283") == 0) ecdh_doit[
R_EC_K283]=2;
994 else if (strcmp(*argv,
"ecdhk409") == 0) ecdh_doit[
R_EC_K409]=2;
995 else if (strcmp(*argv,
"ecdhk571") == 0) ecdh_doit[
R_EC_K571]=2;
996 else if (strcmp(*argv,
"ecdhb163") == 0) ecdh_doit[
R_EC_B163]=2;
997 else if (strcmp(*argv,
"ecdhb233") == 0) ecdh_doit[
R_EC_B233]=2;
998 else if (strcmp(*argv,
"ecdhb283") == 0) ecdh_doit[
R_EC_B283]=2;
999 else if (strcmp(*argv,
"ecdhb409") == 0) ecdh_doit[
R_EC_B409]=2;
1000 else if (strcmp(*argv,
"ecdhb571") == 0) ecdh_doit[
R_EC_B571]=2;
1001 else if (strcmp(*argv,
"ecdh") == 0)
1003 for (i=0; i <
EC_NUM; i++)
1012 #ifndef OPENSSL_NO_MD2
1015 #ifndef OPENSSL_NO_MDC2
1018 #ifndef OPENSSL_NO_MD4
1021 #ifndef OPENSSL_NO_MD5
1023 #ifndef OPENSSL_NO_HMAC
1027 #ifndef OPENSSL_NO_SHA1
1030 #ifndef OPENSSL_NO_SHA256
1033 #ifndef OPENSSL_NO_SHA512
1036 #ifndef OPENSSL_NO_WHIRLPOOL
1039 #ifndef OPENSSL_NO_RIPEMD160
1042 #if !defined(OPENSSL_NO_MD2) || !defined(OPENSSL_NO_MDC2) || \
1043 !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \
1044 !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160) || \
1045 !defined(OPENSSL_NO_WHIRLPOOL)
1049 #ifndef OPENSSL_NO_IDEA
1052 #ifndef OPENSSL_NO_SEED
1055 #ifndef OPENSSL_NO_RC2
1058 #ifndef OPENSSL_NO_RC5
1061 #ifndef OPENSSL_NO_BF
1064 #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_SEED) || !defined(OPENSSL_NO_RC2) || \
1065 !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_RC5)
1068 #ifndef OPENSSL_NO_DES
1071 #ifndef OPENSSL_NO_AES
1075 #ifndef OPENSSL_NO_CAMELLIA
1079 #ifndef OPENSSL_NO_RC4
1084 #ifndef OPENSSL_NO_RSA
1088 #ifndef OPENSSL_NO_DSA
1091 #ifndef OPENSSL_NO_ECDSA
1092 BIO_printf(
bio_err,
"ecdsap160 ecdsap192 ecdsap224 ecdsap256 ecdsap384 ecdsap521\n");
1097 #ifndef OPENSSL_NO_ECDH
1104 #ifndef OPENSSL_NO_IDEA
1107 #ifndef OPENSSL_NO_SEED
1110 #ifndef OPENSSL_NO_RC2
1113 #ifndef OPENSSL_NO_DES
1116 #ifndef OPENSSL_NO_AES
1119 #ifndef OPENSSL_NO_CAMELLIA
1122 #ifndef OPENSSL_NO_RSA
1125 #ifndef OPENSSL_NO_BF
1128 #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_SEED) || \
1129 !defined(OPENSSL_NO_RC2) || !defined(OPENSSL_NO_DES) || \
1130 !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_BF) || \
1131 !defined(OPENSSL_NO_AES) || !defined(OPENSSL_NO_CAMELLIA)
1137 #if defined(TIMES) || defined(USE_TOD)
1138 BIO_printf(
bio_err,
"-elapsed measure time in real time instead of CPU user time.\n");
1140 #ifndef OPENSSL_NO_ENGINE
1144 BIO_printf(
bio_err,
"-decrypt time decryption instead of encryption (only EVP).\n");
1157 if(multi && do_multi(multi))
1172 #ifndef OPENSSL_NO_ECDSA
1176 #ifndef OPENSSL_NO_ECDH
1182 if (doit[i]) pr_header++;
1184 if (usertime == 0 && !mr)
1185 BIO_printf(
bio_err,
"You have chosen to measure elapsed time instead of user CPU time.\n");
1187 #ifndef OPENSSL_NO_RSA
1190 const unsigned char *
p;
1193 rsa_key[i]=d2i_RSAPrivateKey(NULL,&p,rsa_data_length[i]);
1194 if (rsa_key[i] == NULL)
1203 :
"Loaded RSA key, %d bit modulus and e= 0x",
1212 #ifndef OPENSSL_NO_DSA
1218 #ifndef OPENSSL_NO_DES
1223 #ifndef OPENSSL_NO_AES
1228 #ifndef OPENSSL_NO_CAMELLIA
1233 #ifndef OPENSSL_NO_IDEA
1236 #ifndef OPENSSL_NO_SEED
1239 #ifndef OPENSSL_NO_RC4
1242 #ifndef OPENSSL_NO_RC2
1245 #ifndef OPENSSL_NO_RC5
1248 #ifndef OPENSSL_NO_BF
1251 #ifndef OPENSSL_NO_CAST
1254 #ifndef OPENSSL_NO_RSA
1255 memset(rsa_c,0,
sizeof(rsa_c));
1258 #ifndef OPENSSL_NO_DES
1265 for (it=count; it; it--)
1272 c[
D_MD2][0]=count/10;
1279 c[
D_RC4][0]=count*5;
1304 c[
D_MD2][i]=c[
D_MD2][0]*4*lengths[0]/lengths[i];
1306 c[
D_MD4][i]=c[
D_MD4][0]*4*lengths[0]/lengths[i];
1307 c[
D_MD5][i]=c[
D_MD5][0]*4*lengths[0]/lengths[i];
1319 l0=(long)lengths[i-1];
1320 l1=(long)lengths[i];
1340 #ifndef OPENSSL_NO_RSA
1345 rsa_c[i][0]=rsa_c[i-1][0]/8;
1346 rsa_c[i][1]=rsa_c[i-1][1]/4;
1347 if ((rsa_doit[i] <= 1) && (rsa_c[i][0] == 0))
1351 if (rsa_c[i][0] == 0)
1360 #ifndef OPENSSL_NO_DSA
1365 dsa_c[i][0]=dsa_c[i-1][0]/4;
1366 dsa_c[i][1]=dsa_c[i-1][1]/4;
1367 if ((dsa_doit[i] <= 1) && (dsa_c[i][0] == 0))
1380 #ifndef OPENSSL_NO_ECDSA
1385 ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
1386 ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
1387 if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
1391 if (ecdsa_c[i] == 0)
1402 ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
1403 ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
1404 if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
1408 if (ecdsa_c[i] == 0)
1419 ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
1420 ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
1421 if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
1425 if (ecdsa_c[i] == 0)
1434 #ifndef OPENSSL_NO_ECDH
1439 ecdh_c[i][0]=ecdh_c[i-1][0]/2;
1440 ecdh_c[i][1]=ecdh_c[i-1][1]/2;
1441 if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
1456 ecdh_c[i][0]=ecdh_c[i-1][0]/2;
1457 ecdh_c[i][1]=ecdh_c[i-1][1]/2;
1458 if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
1473 ecdh_c[i][0]=ecdh_c[i-1][0]/2;
1474 ecdh_c[i][1]=ecdh_c[i-1][1]/2;
1475 if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
1488 #define COND(d) (count < (d))
1489 #define COUNT(d) (d)
1492 # error "You cannot disable DES on systems without SIGALRM."
1495 #define COND(c) (run && count<0x7fffffff)
1496 #define COUNT(d) (count)
1498 signal(SIGALRM,sig_done);
1502 #ifndef OPENSSL_NO_MD2
1507 print_message(names[D_MD2],c[D_MD2][j],lengths[j]);
1509 for (count=0,
run=1;
COND(c[D_MD2][j]); count++)
1512 print_result(D_MD2,j,count,d);
1516 #ifndef OPENSSL_NO_MDC2
1521 print_message(names[D_MDC2],c[D_MDC2][j],lengths[j]);
1523 for (count=0,
run=1;
COND(c[D_MDC2][j]); count++)
1526 print_result(D_MDC2,j,count,d);
1531 #ifndef OPENSSL_NO_MD4
1536 print_message(names[D_MD4],c[D_MD4][j],lengths[j]);
1538 for (count=0,
run=1;
COND(c[D_MD4][j]); count++)
1541 print_result(D_MD4,j,count,d);
1546 #ifndef OPENSSL_NO_MD5
1551 print_message(names[D_MD5],c[D_MD5][j],lengths[j]);
1553 for (count=0,
run=1;
COND(c[D_MD5][j]); count++)
1556 print_result(D_MD5,j,count,d);
1561 #if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC)
1567 HMAC_Init_ex(&hctx,(
unsigned char *)
"This is a key...",
1572 print_message(names[D_HMAC],c[D_HMAC][j],lengths[j]);
1574 for (count=0,
run=1;
COND(c[D_HMAC][j]); count++)
1581 print_result(D_HMAC,j,count,d);
1586 #ifndef OPENSSL_NO_SHA
1591 print_message(names[D_SHA1],c[D_SHA1][j],lengths[j]);
1593 for (count=0,
run=1;
COND(c[D_SHA1][j]); count++)
1596 print_result(D_SHA1,j,count,d);
1600 #ifndef OPENSSL_NO_SHA256
1605 print_message(names[D_SHA256],c[D_SHA256][j],lengths[j]);
1607 for (count=0,
run=1;
COND(c[D_SHA256][j]); count++)
1608 SHA256(buf,lengths[j],sha256);
1610 print_result(D_SHA256,j,count,d);
1615 #ifndef OPENSSL_NO_SHA512
1620 print_message(names[D_SHA512],c[D_SHA512][j],lengths[j]);
1622 for (count=0,
run=1;
COND(c[D_SHA512][j]); count++)
1623 SHA512(buf,lengths[j],sha512);
1625 print_result(D_SHA512,j,count,d);
1631 #ifndef OPENSSL_NO_WHIRLPOOL
1632 if (doit[D_WHIRLPOOL])
1636 print_message(names[D_WHIRLPOOL],c[D_WHIRLPOOL][j],lengths[j]);
1638 for (count=0,
run=1;
COND(c[D_WHIRLPOOL][j]); count++)
1641 print_result(D_WHIRLPOOL,j,count,d);
1646 #ifndef OPENSSL_NO_RIPEMD
1651 print_message(names[D_RMD160],c[D_RMD160][j],lengths[j]);
1653 for (count=0,
run=1;
COND(c[D_RMD160][j]); count++)
1656 print_result(D_RMD160,j,count,d);
1660 #ifndef OPENSSL_NO_RC4
1665 print_message(names[D_RC4],c[D_RC4][j],lengths[j]);
1667 for (count=0,
run=1;
COND(c[D_RC4][j]); count++)
1668 RC4(&rc4_ks,(
unsigned int)lengths[j],
1671 print_result(D_RC4,j,count,d);
1675 #ifndef OPENSSL_NO_DES
1676 if (doit[D_CBC_DES])
1680 print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
1682 for (count=0,
run=1;
COND(c[D_CBC_DES][j]); count++)
1686 print_result(D_CBC_DES,j,count,d);
1690 if (doit[D_EDE3_DES])
1694 print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
1696 for (count=0,
run=1;
COND(c[D_EDE3_DES][j]); count++)
1701 print_result(D_EDE3_DES,j,count,d);
1705 #ifndef OPENSSL_NO_AES
1706 if (doit[D_CBC_128_AES])
1710 print_message(names[D_CBC_128_AES],c[D_CBC_128_AES][j],lengths[j]);
1712 for (count=0,
run=1;
COND(c[D_CBC_128_AES][j]); count++)
1714 (
unsigned long)lengths[j],&aes_ks1,
1717 print_result(D_CBC_128_AES,j,count,d);
1720 if (doit[D_CBC_192_AES])
1724 print_message(names[D_CBC_192_AES],c[D_CBC_192_AES][j],lengths[j]);
1726 for (count=0,
run=1;
COND(c[D_CBC_192_AES][j]); count++)
1728 (
unsigned long)lengths[j],&aes_ks2,
1731 print_result(D_CBC_192_AES,j,count,d);
1734 if (doit[D_CBC_256_AES])
1738 print_message(names[D_CBC_256_AES],c[D_CBC_256_AES][j],lengths[j]);
1740 for (count=0,
run=1;
COND(c[D_CBC_256_AES][j]); count++)
1742 (
unsigned long)lengths[j],&aes_ks3,
1745 print_result(D_CBC_256_AES,j,count,d);
1749 if (doit[D_IGE_128_AES])
1753 print_message(names[D_IGE_128_AES],c[D_IGE_128_AES][j],lengths[j]);
1755 for (count=0,
run=1;
COND(c[D_IGE_128_AES][j]); count++)
1757 (
unsigned long)lengths[j],&aes_ks1,
1760 print_result(D_IGE_128_AES,j,count,d);
1763 if (doit[D_IGE_192_AES])
1767 print_message(names[D_IGE_192_AES],c[D_IGE_192_AES][j],lengths[j]);
1769 for (count=0,
run=1;
COND(c[D_IGE_192_AES][j]); count++)
1771 (
unsigned long)lengths[j],&aes_ks2,
1774 print_result(D_IGE_192_AES,j,count,d);
1777 if (doit[D_IGE_256_AES])
1781 print_message(names[D_IGE_256_AES],c[D_IGE_256_AES][j],lengths[j]);
1783 for (count=0,
run=1;
COND(c[D_IGE_256_AES][j]); count++)
1785 (
unsigned long)lengths[j],&aes_ks3,
1788 print_result(D_IGE_256_AES,j,count,d);
1798 print_message(names[D_GHASH],c[D_GHASH][j],lengths[j]);
1800 for (count=0,
run=1;
COND(c[D_GHASH][j]); count++)
1803 print_result(D_GHASH,j,count,d);
1809 #ifndef OPENSSL_NO_CAMELLIA
1810 if (doit[D_CBC_128_CML])
1814 print_message(names[D_CBC_128_CML],c[D_CBC_128_CML][j],lengths[j]);
1816 for (count=0,
run=1;
COND(c[D_CBC_128_CML][j]); count++)
1818 (
unsigned long)lengths[j],&camellia_ks1,
1821 print_result(D_CBC_128_CML,j,count,d);
1824 if (doit[D_CBC_192_CML])
1828 print_message(names[D_CBC_192_CML],c[D_CBC_192_CML][j],lengths[j]);
1830 for (count=0,
run=1;
COND(c[D_CBC_192_CML][j]); count++)
1832 (
unsigned long)lengths[j],&camellia_ks2,
1835 print_result(D_CBC_192_CML,j,count,d);
1838 if (doit[D_CBC_256_CML])
1842 print_message(names[D_CBC_256_CML],c[D_CBC_256_CML][j],lengths[j]);
1844 for (count=0,
run=1;
COND(c[D_CBC_256_CML][j]); count++)
1846 (
unsigned long)lengths[j],&camellia_ks3,
1849 print_result(D_CBC_256_CML,j,count,d);
1854 #ifndef OPENSSL_NO_IDEA
1855 if (doit[D_CBC_IDEA])
1859 print_message(names[D_CBC_IDEA],c[D_CBC_IDEA][j],lengths[j]);
1861 for (count=0,
run=1;
COND(c[D_CBC_IDEA][j]); count++)
1863 (
unsigned long)lengths[j],&idea_ks,
1866 print_result(D_CBC_IDEA,j,count,d);
1870 #ifndef OPENSSL_NO_SEED
1871 if (doit[D_CBC_SEED])
1875 print_message(names[D_CBC_SEED],c[D_CBC_SEED][j],lengths[j]);
1877 for (count=0,
run=1;
COND(c[D_CBC_SEED][j]); count++)
1879 (
unsigned long)lengths[j],&seed_ks,iv,1);
1881 print_result(D_CBC_SEED,j,count,d);
1885 #ifndef OPENSSL_NO_RC2
1886 if (doit[D_CBC_RC2])
1890 print_message(names[D_CBC_RC2],c[D_CBC_RC2][j],lengths[j]);
1892 for (count=0,
run=1;
COND(c[D_CBC_RC2][j]); count++)
1894 (
unsigned long)lengths[j],&rc2_ks,
1897 print_result(D_CBC_RC2,j,count,d);
1901 #ifndef OPENSSL_NO_RC5
1902 if (doit[D_CBC_RC5])
1906 print_message(names[D_CBC_RC5],c[D_CBC_RC5][j],lengths[j]);
1908 for (count=0,
run=1;
COND(c[D_CBC_RC5][j]); count++)
1910 (
unsigned long)lengths[j],&rc5_ks,
1913 print_result(D_CBC_RC5,j,count,d);
1917 #ifndef OPENSSL_NO_BF
1922 print_message(names[D_CBC_BF],c[D_CBC_BF][j],lengths[j]);
1924 for (count=0,
run=1;
COND(c[D_CBC_BF][j]); count++)
1926 (
unsigned long)lengths[j],&bf_ks,
1929 print_result(D_CBC_BF,j,count,d);
1933 #ifndef OPENSSL_NO_CAST
1934 if (doit[D_CBC_CAST])
1938 print_message(names[D_CBC_CAST],c[D_CBC_CAST][j],lengths[j]);
1940 for (count=0,
run=1;
COND(c[D_CBC_CAST][j]); count++)
1942 (
unsigned long)lengths[j],&cast_ks,
1945 print_result(D_CBC_CAST,j,count,d);
1963 print_message(names[D_EVP],save_count,
1975 for (count=0,
run=1;
COND(save_count*4*lengths[0]/lengths[j]); count++)
1978 for (count=0,
run=1;
COND(save_count*4*lengths[0]/lengths[j]); count++)
1990 print_message(names[D_EVP],save_count,
1994 for (count=0,
run=1;
COND(save_count*4*lengths[0]/lengths[j]); count++)
1995 EVP_Digest(buf,lengths[j],&(md[0]),NULL,evp_md,NULL);
1999 print_result(D_EVP,j,count,d);
2004 #ifndef OPENSSL_NO_RSA
2008 if (!rsa_doit[j])
continue;
2018 pkey_print_message(
"private",
"rsa",
2019 rsa_c[j][0],rsa_bits[j],
2023 for (count=0,
run=1;
COND(rsa_c[j][0]); count++)
2026 &rsa_num, rsa_key[j]);
2030 "RSA sign failure\n");
2038 :
"%ld %d bit private RSA's in %.2fs\n",
2039 count,rsa_bits[j],d);
2040 rsa_results[j][0]=d/(double)count;
2054 pkey_print_message(
"public",
"rsa",
2055 rsa_c[j][1],rsa_bits[j],
2058 for (count=0,
run=1;
COND(rsa_c[j][1]); count++)
2061 rsa_num, rsa_key[j]);
2065 "RSA verify failure\n");
2073 :
"%ld %d bit public RSA's in %.2fs\n",
2074 count,rsa_bits[j],d);
2075 rsa_results[j][1]=d/(double)count;
2089 #ifndef OPENSSL_NO_DSA
2100 if (!dsa_doit[j])
continue;
2113 pkey_print_message(
"sign",
"dsa",
2114 dsa_c[j][0],dsa_bits[j],
2117 for (count=0,
run=1;
COND(dsa_c[j][0]); count++)
2124 "DSA sign failure\n");
2132 :
"%ld %d bit DSA signs in %.2fs\n",
2133 count,dsa_bits[j],d);
2134 dsa_results[j][0]=d/(double)count;
2148 pkey_print_message(
"verify",
"dsa",
2149 dsa_c[j][1],dsa_bits[j],
2152 for (count=0,
run=1;
COND(dsa_c[j][1]); count++)
2159 "DSA verify failure\n");
2167 :
"%ld %d bit DSA verify in %.2fs\n",
2168 count,dsa_bits[j],d);
2169 dsa_results[j][1]=d/(double)count;
2182 #ifndef OPENSSL_NO_ECDSA
2192 if (!ecdsa_doit[j])
continue;
2194 if (ecdsa[j] == NULL)
2208 &ecdsasiglen, ecdsa[j]);
2217 pkey_print_message(
"sign",
"ecdsa",
2219 test_curves_bits[j],
2223 for (count=0,
run=1;
COND(ecdsa_c[j][0]);
2227 ecdsasig, &ecdsasiglen,
2240 "%ld %d bit ECDSA signs in %.2fs \n",
2241 count, test_curves_bits[j], d);
2242 ecdsa_results[j][0]=d/(double)count;
2248 ecdsasiglen, ecdsa[j]);
2257 pkey_print_message(
"verify",
"ecdsa",
2259 test_curves_bits[j],
2262 for (count=0,
run=1;
COND(ecdsa_c[j][1]); count++)
2264 ret=
ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]);
2275 :
"%ld %d bit ECDSA verify in %.2fs\n",
2276 count, test_curves_bits[j], d);
2277 ecdsa_results[j][1]=d/(double)count;
2291 #ifndef OPENSSL_NO_ECDH
2299 if (!ecdh_doit[j])
continue;
2302 if ((ecdh_a[j] == NULL) || (ecdh_b[j] == NULL))
2323 int field_size, outlen;
2324 void *(*kdf)(
const void *in,
size_t inlen,
void *out,
size_t *xoutlen);
2326 if (field_size <= 24 * 8)
2328 outlen = KDF1_SHA1_len;
2333 outlen = (field_size+7)/8;
2342 if (secret_size_a != secret_size_b)
2347 for (secret_idx = 0;
2348 (secret_idx < secret_size_a)
2349 && (ecdh_checks == 1);
2352 if (secret_a[secret_idx] != secret_b[secret_idx])
2356 if (ecdh_checks == 0)
2363 pkey_print_message(
"",
"ecdh",
2365 test_curves_bits[j],
2368 for (count=0,
run=1;
COND(ecdh_c[j][0]); count++)
2376 count, test_curves_bits[j], d);
2377 ecdh_results[j][0]=d/(double)count;
2401 #ifndef OPENSSL_NO_MD2
2404 #ifndef OPENSSL_NO_RC4
2407 #ifndef OPENSSL_NO_DES
2410 #ifndef OPENSSL_NO_AES
2413 #ifndef OPENSSL_NO_IDEA
2416 #ifndef OPENSSL_NO_BF
2425 fprintf(stdout,
"+H");
2428 fprintf(stdout,
"The 'numbers' are in 1000s of bytes per second processed.\n");
2429 fprintf(stdout,
"type ");
2432 fprintf(stdout,mr ?
":%d" :
"%7d bytes",lengths[j]);
2433 fprintf(stdout,
"\n");
2438 if (!doit[k])
continue;
2440 fprintf(stdout,
"+F:%d:%s",k,names[k]);
2442 fprintf(stdout,
"%-13s",names[k]);
2445 if (results[k][j] > 10000 && !mr)
2446 fprintf(stdout,
" %11.2fk",results[k][j]/1e3);
2448 fprintf(stdout,mr ?
":%.2f" :
" %11.2f ",results[k][j]);
2450 fprintf(stdout,
"\n");
2452 #ifndef OPENSSL_NO_RSA
2456 if (!rsa_doit[k])
continue;
2459 printf(
"%18ssign verify sign/s verify/s\n",
" ");
2463 fprintf(stdout,
"+F2:%u:%u:%f:%f\n",
2464 k,rsa_bits[k],rsa_results[k][0],
2467 fprintf(stdout,
"rsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
2468 rsa_bits[k],rsa_results[k][0],rsa_results[k][1],
2469 1.0/rsa_results[k][0],1.0/rsa_results[k][1]);
2472 #ifndef OPENSSL_NO_DSA
2476 if (!dsa_doit[k])
continue;
2479 printf(
"%18ssign verify sign/s verify/s\n",
" ");
2483 fprintf(stdout,
"+F3:%u:%u:%f:%f\n",
2484 k,dsa_bits[k],dsa_results[k][0],dsa_results[k][1]);
2486 fprintf(stdout,
"dsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
2487 dsa_bits[k],dsa_results[k][0],dsa_results[k][1],
2488 1.0/dsa_results[k][0],1.0/dsa_results[k][1]);
2491 #ifndef OPENSSL_NO_ECDSA
2495 if (!ecdsa_doit[k])
continue;
2498 printf(
"%30ssign verify sign/s verify/s\n",
" ");
2503 fprintf(stdout,
"+F4:%u:%u:%f:%f\n",
2504 k, test_curves_bits[k],
2505 ecdsa_results[k][0],ecdsa_results[k][1]);
2508 "%4u bit ecdsa (%s) %8.4fs %8.4fs %8.1f %8.1f\n",
2509 test_curves_bits[k],
2510 test_curves_names[k],
2511 ecdsa_results[k][0],ecdsa_results[k][1],
2512 1.0/ecdsa_results[k][0],1.0/ecdsa_results[k][1]);
2517 #ifndef OPENSSL_NO_ECDH
2521 if (!ecdh_doit[k])
continue;
2524 printf(
"%30sop op/s\n",
" ");
2528 fprintf(stdout,
"+F5:%u:%u:%f:%f\n",
2529 k, test_curves_bits[k],
2530 ecdh_results[k][0], 1.0/ecdh_results[k][0]);
2533 fprintf(stdout,
"%4u bit ecdh (%s) %8.4fs %8.1f\n",
2534 test_curves_bits[k],
2535 test_curves_names[k],
2536 ecdh_results[k][0], 1.0/ecdh_results[k][0]);
2546 #ifndef OPENSSL_NO_RSA
2548 if (rsa_key[i] != NULL)
2551 #ifndef OPENSSL_NO_DSA
2553 if (dsa_key[i] != NULL)
2557 #ifndef OPENSSL_NO_ECDSA
2559 if (ecdsa[i] != NULL)
2562 #ifndef OPENSSL_NO_ECDH
2565 if (ecdh_a[i] != NULL)
2567 if (ecdh_b[i] != NULL)
2576 static void print_message(
const char *s,
long num,
int length)
2580 :
"Doing %s for %ds on %d size blocks: ",s,
SECONDS,length);
2585 :
"Doing %s %ld times on %d size blocks: ",s,num,length);
2593 static void pkey_print_message(
const char *str,
const char *str2,
long num,
2598 :
"Doing %d bit %s %s's for %ds: ",bits,str,str2,tm);
2603 :
"Doing %ld %d bit %s %s's: ",num,bits,str,str2);
2611 static void print_result(
int alg,
int run_no,
int count,
double time_used)
2614 :
"%d %s's in %.2fs\n",count,names[alg],time_used);
2615 results[alg][run_no]=((double)count)/time_used*lengths[run_no];
2619 static char *sstrsep(
char **
string,
const char *delim)
2622 char *token = *string;
2627 memset(isdelim, 0,
sizeof isdelim);
2632 isdelim[(
unsigned char)(*delim)] = 1;
2636 while (!isdelim[(
unsigned char)(**string)])
2650 static int do_multi(
int multi)
2655 static char sep[]=
":";
2657 fds=malloc(multi*
sizeof *fds);
2658 for(n=0 ; n < multi ; ++n)
2662 fprintf(stderr,
"pipe failure\n");
2676 if (dup(fd[1]) == -1)
2678 fprintf(stderr,
"dup failed\n");
2687 printf(
"Forked child %d\n",n);
2691 for(n=0 ; n < multi ; ++n)
2697 f=fdopen(fds[n],
"r");
2698 while(fgets(buf,
sizeof buf,f))
2705 fprintf(stderr,
"Don't understand line '%s' from child %d\n",
2709 printf(
"Got: %s from %d\n",buf,n);
2710 if(!strncmp(buf,
"+F:",3))
2716 alg=atoi(sstrsep(&p,sep));
2719 results[alg][j]+=atof(sstrsep(&p,sep));
2721 else if(!strncmp(buf,
"+F2:",4))
2727 k=atoi(sstrsep(&p,sep));
2730 d=atof(sstrsep(&p,sep));
2732 rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
2734 rsa_results[k][0]=d;
2736 d=atof(sstrsep(&p,sep));
2738 rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
2740 rsa_results[k][1]=d;
2742 else if(!strncmp(buf,
"+F2:",4))
2748 k=atoi(sstrsep(&p,sep));
2751 d=atof(sstrsep(&p,sep));
2753 rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
2755 rsa_results[k][0]=d;
2757 d=atof(sstrsep(&p,sep));
2759 rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
2761 rsa_results[k][1]=d;
2763 #ifndef OPENSSL_NO_DSA
2764 else if(!strncmp(buf,
"+F3:",4))
2770 k=atoi(sstrsep(&p,sep));
2773 d=atof(sstrsep(&p,sep));
2775 dsa_results[k][0]=1/(1/dsa_results[k][0]+1/d);
2777 dsa_results[k][0]=d;
2779 d=atof(sstrsep(&p,sep));
2781 dsa_results[k][1]=1/(1/dsa_results[k][1]+1/d);
2783 dsa_results[k][1]=d;
2786 #ifndef OPENSSL_NO_ECDSA
2787 else if(!strncmp(buf,
"+F4:",4))
2793 k=atoi(sstrsep(&p,sep));
2796 d=atof(sstrsep(&p,sep));
2798 ecdsa_results[k][0]=1/(1/ecdsa_results[k][0]+1/d);
2800 ecdsa_results[k][0]=d;
2802 d=atof(sstrsep(&p,sep));
2804 ecdsa_results[k][1]=1/(1/ecdsa_results[k][1]+1/d);
2806 ecdsa_results[k][1]=d;
2810 #ifndef OPENSSL_NO_ECDH
2811 else if(!strncmp(buf,
"+F5:",4))
2817 k=atoi(sstrsep(&p,sep));
2820 d=atof(sstrsep(&p,sep));
2822 ecdh_results[k][0]=1/(1/ecdh_results[k][0]+1/d);
2824 ecdh_results[k][0]=d;
2829 else if(!strncmp(buf,
"+H:",3))
2833 fprintf(stderr,
"Unknown type '%s' from child %d\n",buf,n);