X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Fspeed.c;h=ee520baa97d7896ff05ab6c8e1eb57a099006ba1;hb=470fa98f8aa5ca37e7e6720be7ca1abda8f906f0;hp=5ff2ade6e44e76e8e02484812cff24a88e45efb0;hpb=5660eb489e807bf30b94f46bd0ddfaf740aeb226;p=oweals%2Fopenssl.git diff --git a/apps/speed.c b/apps/speed.c index 5ff2ade6e4..ee520baa97 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -82,6 +82,8 @@ #include #include #include +#include +#include #if defined(__FreeBSD__) # define USE_TOD @@ -196,7 +198,7 @@ int run=0; static double Time_F(int s, int usertime); -static void print_message(char *s,long num,int length); +static void print_message(const char *s,long num,int length); static void pkey_print_message(char *str,char *str2,long num,int bits,int sec); #ifdef SIGALRM #if defined(__STDC__) || defined(sgi) || defined(_AIX) @@ -314,11 +316,11 @@ int MAIN(int argc, char **argv) ENGINE *e; unsigned char *buf=NULL,*buf2=NULL; int mret=1; -#define ALGOR_NUM 15 +#define ALGOR_NUM 16 #define SIZE_NUM 5 #define RSA_NUM 4 #define DSA_NUM 3 - long count,rsa_count; + long count,rsa_count,save_count=0; int i,j,k; unsigned rsa_num; #ifndef NO_MD2 @@ -384,10 +386,11 @@ int MAIN(int argc, char **argv) #define D_CBC_RC5 12 #define D_CBC_BF 13 #define D_CBC_CAST 14 +#define D_EVP 15 double d,results[ALGOR_NUM][SIZE_NUM]; static int lengths[SIZE_NUM]={8,64,256,1024,8*1024}; long c[ALGOR_NUM][SIZE_NUM]; - static char *names[ALGOR_NUM]={ + static const char *names[ALGOR_NUM]={ "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4", "des cbc","des ede3","idea cbc", "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc"}; @@ -420,6 +423,7 @@ int MAIN(int argc, char **argv) int doit[ALGOR_NUM]; int pr_header=0; int usertime=1; + const EVP_CIPHER *evp=NULL; #ifndef TIMES usertime=-1; @@ -472,6 +476,23 @@ int MAIN(int argc, char **argv) { if ((argc > 0) && (strcmp(*argv,"-elapsed") == 0)) usertime = 0; + else if ((argc > 0) && (strcmp(*argv,"-evp") == 0)) + { + argc--; + argv++; + if(argc == 0) + { + BIO_printf(bio_err,"no EVP given\n"); + goto end; + } + evp=EVP_get_cipherbyname(*argv); + if(!evp) + { + BIO_printf(bio_err,"%s is an unknown cipher\n",*argv); + goto end; + } + doit[D_EVP]=1; + } else if ((argc > 0) && (strcmp(*argv,"-engine") == 0)) { @@ -547,7 +568,7 @@ int MAIN(int argc, char **argv) else #endif #ifndef NO_RSA -#ifdef RSAref +#if 0 /* was: #ifdef RSAref */ if (strcmp(*argv,"rsaref") == 0) { RSA_set_default_openssl_method(RSA_PKCS1_RSAref()); @@ -719,7 +740,10 @@ int MAIN(int argc, char **argv) if (j == 0) { for (i=0; inid); + print_message(names[D_EVP],save_count, + lengths[j]); + EVP_EncryptInit(&ctx,evp,key16,iv); + Time_F(START,usertime); + for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++) + EVP_EncryptUpdate(&ctx,buf,&outl,buf,lengths[j]); + EVP_EncryptFinal(&ctx,buf,&outl); + d=Time_F(STOP,usertime); + BIO_printf(bio_err,"%ld %s's in %.2fs\n", + count,names[D_EVP],d); + results[D_EVP][j]=((double)count)/d*lengths[j]; + } + } + RAND_pseudo_bytes(buf,36); #ifndef NO_RSA for (j=0; j