X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=apps%2Fspeed.c;h=1c2b4eeda297b5c97dc88452e7d92a24eb4e5e94;hp=795a1430c809159c16b752c6a897f852b2a33188;hb=a08ee55e2d265f3c73964baef8cefc5ecbe79a02;hpb=87166e1fb6941280fc0827909d944b806461727d diff --git a/apps/speed.c b/apps/speed.c index 795a1430c8..1c2b4eeda2 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -89,10 +89,10 @@ #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(OPENSSL_SYS_MACOSX) # define USE_TOD -#elif !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) +#elif !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) # define TIMES #endif -#if !defined(_UNICOS) && !defined(__OpenBSD__) && !defined(sgi) && !defined(__FreeBSD__) && !(defined(__bsdi) || defined(__bsdi__)) && !defined(_AIX) && !defined(OPENSSL_SYS_MPE) && !defined(__NetBSD__) /* FIXME */ +#if !defined(_UNICOS) && !defined(__OpenBSD__) && !defined(sgi) && !defined(__FreeBSD__) && !(defined(__bsdi) || defined(__bsdi__)) && !defined(_AIX) && !defined(OPENSSL_SYS_MPE) && !defined(__NetBSD__) && !defined(OPENSSL_SYS_VXWORKS) /* FIXME */ # define TIMEB #endif @@ -120,7 +120,7 @@ #include #endif -#if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD) +#if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD) && !defined(OPENSSL_SYS_VXWORKS) #error "It seems neither struct tms nor struct timeb is supported in this platform!" #endif @@ -133,6 +133,9 @@ #ifndef OPENSSL_NO_DES #include #endif +#ifndef OPENSSL_NO_AES +#include +#endif #ifndef OPENSSL_NO_MD2 #include #endif @@ -219,16 +222,17 @@ static void print_result(int alg,int run_no,int count,double time_used); static int do_multi(int multi); #endif -#define ALGOR_NUM 16 +#define ALGOR_NUM 19 #define SIZE_NUM 5 #define RSA_NUM 4 #define DSA_NUM 3 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"}; + "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc", + "aes-128 cbc","aes-192 cbc","aes-256 cbc"}; static double results[ALGOR_NUM][SIZE_NUM]; -static int lengths[SIZE_NUM]={8,64,256,1024,8*1024}; +static int lengths[SIZE_NUM]={16,64,256,1024,8*1024}; static double rsa_results[RSA_NUM][2]; static double dsa_results[DSA_NUM][2]; @@ -322,7 +326,23 @@ static double Time_F(int s) # if defined(TIMES) && defined(TIMEB) else # endif -# ifdef TIMEB +# ifdef OPENSSL_SYS_VXWORKS + { + static unsigned long tick_start, tick_end; + + if( s == START ) + { + tick_start = tickGet(); + return 0; + } + else + { + tick_end = tickGet(); + ret = (double)(tick_end - tick_start) / (double)sysClkRateGet(); + return((ret < 0.001)?0.001:ret); + } + } +# elif defined(TIMEB) { static struct timeb tstart,tend; long i; @@ -349,13 +369,14 @@ int MAIN(int, char **); int MAIN(int argc, char **argv) { - ENGINE *e; + ENGINE *e = NULL; unsigned char *buf=NULL,*buf2=NULL; int mret=1; - long count=0,rsa_count,save_count=0; + long count=0,save_count=0; int i,j,k; #ifndef OPENSSL_NO_RSA unsigned rsa_num; + long rsa_count; #endif unsigned char md[EVP_MAX_MD_SIZE]; #ifndef OPENSSL_NO_MD2 @@ -395,10 +416,25 @@ int MAIN(int argc, char **argv) #ifndef OPENSSL_NO_CAST CAST_KEY cast_ks; #endif - static unsigned char key16[16]= + static const unsigned char key16[16]= {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0, 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12}; - unsigned char iv[8]; + static const unsigned char key24[24]= + {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0, + 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12, + 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34}; + static const unsigned char key32[32]= + {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0, + 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12, + 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34, + 0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56}; +#ifndef OPENSSL_NO_AES +#define MAX_BLOCK_SIZE 128 +#else +#define MAX_BLOCK_SIZE 64 +#endif + unsigned char DES_iv[8]; + unsigned char iv[MAX_BLOCK_SIZE/8]; #ifndef OPENSSL_NO_DES DES_cblock *buf_as_des_cblock = NULL; static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0}; @@ -408,6 +444,9 @@ int MAIN(int argc, char **argv) DES_key_schedule sch2; DES_key_schedule sch3; #endif +#ifndef OPENSSL_NO_AES + AES_KEY aes_ks1, aes_ks2, aes_ks3; +#endif #define D_MD2 0 #define D_MDC2 1 #define D_MD4 2 @@ -423,8 +462,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=0; +#define D_CBC_128_AES 15 +#define D_CBC_192_AES 16 +#define D_CBC_256_AES 17 +#define D_EVP 18 + double d=0.0; long c[ALGOR_NUM][SIZE_NUM]; #define R_DSA_512 0 #define R_DSA_1024 1 @@ -473,6 +515,9 @@ int MAIN(int argc, char **argv) if ((bio_err=BIO_new(BIO_s_file())) != NULL) BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); + if (!load_config(bio_err, NULL)) + goto end; + #ifndef OPENSSL_NO_RSA memset(rsa_key,0,sizeof(rsa_key)); for (i=0; inid); + /* -O3 -fschedule-insns messes up an + * optimization here! names[D_EVP] + * somehow becomes NULL */ print_message(names[D_EVP],save_count, lengths[j]); @@ -1482,6 +1603,9 @@ show_res: #ifndef OPENSSL_NO_DES printf("%s ",des_options()); #endif +#ifndef OPENSSL_NO_AES + printf("%s ",AES_options()); +#endif #ifndef OPENSSL_NO_IDEA printf("%s ",idea_options()); #endif @@ -1501,7 +1625,7 @@ show_res: #endif #ifdef HZ #define as_string(s) (#s) - printf("HZ=%g", (double)HZ); + printf("HZ=%g", HZ); # ifdef _SC_CLK_TCK printf(" [sysconf value]"); # endif