diff --git a/apps/speed.c b/apps/speed.c index fca6618f7e..08d00beddb 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -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]; @@ -396,10 +400,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}; @@ -409,6 +428,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 @@ -424,8 +446,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 @@ -495,6 +520,7 @@ int MAIN(int argc, char **argv) } memset(c,0,sizeof(c)); + memset(DES_iv,0,sizeof(DES_iv)); memset(iv,0,sizeof(iv)); 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]); @@ -1483,6 +1584,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 @@ -1502,7 +1606,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