Fix typo in error message.
[openssl.git] / apps / speed.c
index a8371fb4246853301a0b8550e05be1c548aa0b32..e769ca2310aebde92386bf902ef158b22bdba5c3 100644 (file)
 #endif
 #ifndef NO_MD5
 #include <openssl/md5.h>
+#endif
+#ifndef NO_HMAC
 #include <openssl/hmac.h>
-#include <openssl/evp.h>
 #endif
+#include <openssl/evp.h>
 #ifndef NO_SHA
 #include <openssl/sha.h>
 #endif
@@ -285,6 +287,7 @@ int MAIN(int argc, char **argv)
                 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
        unsigned char iv[8];
 #ifndef NO_DES
+       des_cblock *buf_as_des_cblock = NULL;
        static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
        static des_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
        static des_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
@@ -341,6 +344,7 @@ int MAIN(int argc, char **argv)
        int pr_header=0;
 
        apps_startup();
+       memset(results, 0, sizeof(results));
 #ifndef NO_DSA
        memset(dsa_key,0,sizeof(dsa_key));
 #endif
@@ -360,6 +364,9 @@ int MAIN(int argc, char **argv)
                BIO_printf(bio_err,"out of memory\n");
                goto end;
                }
+#ifndef NO_DES
+       buf_as_des_cblock = (des_cblock *)buf;
+#endif
        if ((buf2=(unsigned char *)Malloc((int)BUFSIZE)) == NULL)
                {
                BIO_printf(bio_err,"out of memory\n");
@@ -415,7 +422,7 @@ int MAIN(int argc, char **argv)
                        if (strcmp(*argv,"rc4") == 0) doit[D_RC4]=1;
                else 
 #endif
-#ifndef NO_DEF
+#ifndef NO_DES
                        if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1;
                else    if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1;
                else
@@ -429,12 +436,14 @@ int MAIN(int argc, char **argv)
                        }
                else
 #endif
+#ifndef RSA_NULL
                        if (strcmp(*argv,"openssl") == 0) 
                        {
                        RSA_set_default_method(RSA_PKCS1_SSLeay());
                        j--;
                        }
                else
+#endif
 #endif /* !NO_RSA */
                     if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2;
                else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2;
@@ -613,7 +622,8 @@ int MAIN(int argc, char **argv)
                count*=2;
                Time_F(START);
                for (i=count; i; i--)
-                       des_ecb_encrypt(buf,buf, &(sch[0]),DES_ENCRYPT);
+                       des_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock,
+                               &(sch[0]),DES_ENCRYPT);
                d=Time_F(STOP);
                } while (d <3);
        c[D_MD2][0]=count/10;
@@ -751,7 +761,7 @@ int MAIN(int argc, char **argv)
                }
 #endif
 
-#ifndef NO_MD5
+#if !defined(NO_MD5) && !defined(NO_HMAC)
        if (doit[D_HMAC])
                {
                HMAC_CTX hctx;
@@ -868,7 +878,7 @@ int MAIN(int argc, char **argv)
                        for (count=0,run=1; COND(c[D_CBC_IDEA][j]); count++)
                                idea_cbc_encrypt(buf,buf,
                                        (unsigned long)lengths[j],&idea_ks,
-                                       (unsigned char *)&(iv[0]),IDEA_ENCRYPT);
+                                       iv,IDEA_ENCRYPT);
                        d=Time_F(STOP);
                        BIO_printf(bio_err,"%ld %s's in %.2fs\n",
                                count,names[D_CBC_IDEA],d);
@@ -886,7 +896,7 @@ int MAIN(int argc, char **argv)
                        for (count=0,run=1; COND(c[D_CBC_RC2][j]); count++)
                                RC2_cbc_encrypt(buf,buf,
                                        (unsigned long)lengths[j],&rc2_ks,
-                                       (unsigned char *)&(iv[0]),RC2_ENCRYPT);
+                                       iv,RC2_ENCRYPT);
                        d=Time_F(STOP);
                        BIO_printf(bio_err,"%ld %s's in %.2fs\n",
                                count,names[D_CBC_RC2],d);
@@ -904,7 +914,7 @@ int MAIN(int argc, char **argv)
                        for (count=0,run=1; COND(c[D_CBC_RC5][j]); count++)
                                RC5_32_cbc_encrypt(buf,buf,
                                        (unsigned long)lengths[j],&rc5_ks,
-                                       (unsigned char *)&(iv[0]),RC5_ENCRYPT);
+                                       iv,RC5_ENCRYPT);
                        d=Time_F(STOP);
                        BIO_printf(bio_err,"%ld %s's in %.2fs\n",
                                count,names[D_CBC_RC5],d);
@@ -922,7 +932,7 @@ int MAIN(int argc, char **argv)
                        for (count=0,run=1; COND(c[D_CBC_BF][j]); count++)
                                BF_cbc_encrypt(buf,buf,
                                        (unsigned long)lengths[j],&bf_ks,
-                                       (unsigned char *)&(iv[0]),BF_ENCRYPT);
+                                       iv,BF_ENCRYPT);
                        d=Time_F(STOP);
                        BIO_printf(bio_err,"%ld %s's in %.2fs\n",
                                count,names[D_CBC_BF],d);
@@ -940,7 +950,7 @@ int MAIN(int argc, char **argv)
                        for (count=0,run=1; COND(c[D_CBC_CAST][j]); count++)
                                CAST_cbc_encrypt(buf,buf,
                                        (unsigned long)lengths[j],&cast_ks,
-                                       (unsigned char *)&(iv[0]),CAST_ENCRYPT);
+                                       iv,CAST_ENCRYPT);
                        d=Time_F(STOP);
                        BIO_printf(bio_err,"%ld %s's in %.2fs\n",
                                count,names[D_CBC_CAST],d);
@@ -990,7 +1000,7 @@ int MAIN(int argc, char **argv)
                                RSA_PKCS1_PADDING);
                        if (rsa_num2 <= 0)
                                {
-                               BIO_printf(bio_err,"RSA public encrypt failure\n");
+                               BIO_printf(bio_err,"RSA public decrypt failure\n");
                                ERR_print_errors(bio_err);
                                count=1;
                                break;
@@ -1127,7 +1137,7 @@ int MAIN(int argc, char **argv)
                        printf("%18ssign    verify    sign/s verify/s\n"," ");
                        j=0;
                        }
-               fprintf(stdout,"rsa %4d bits %8.4fs %8.4fs %8.1f %8.1f",
+               fprintf(stdout,"rsa %4u bits %8.4fs %8.4fs %8.1f %8.1f",
                        rsa_bits[k],rsa_results[k][0],rsa_results[k][1],
                        1.0/rsa_results[k][0],1.0/rsa_results[k][1]);
                fprintf(stdout,"\n");
@@ -1142,7 +1152,7 @@ int MAIN(int argc, char **argv)
                        printf("%18ssign    verify    sign/s verify/s\n"," ");
                        j=0;
                        }
-               fprintf(stdout,"dsa %4d bits %8.4fs %8.4fs %8.1f %8.1f",
+               fprintf(stdout,"dsa %4u bits %8.4fs %8.4fs %8.1f %8.1f",
                        dsa_bits[k],dsa_results[k][0],dsa_results[k][1],
                        1.0/dsa_results[k][0],1.0/dsa_results[k][1]);
                fprintf(stdout,"\n");
@@ -1169,11 +1179,11 @@ static void print_message(char *s, long num, int length)
        {
 #ifdef SIGALRM
        BIO_printf(bio_err,"Doing %s for %ds on %d size blocks: ",s,SECONDS,length);
-       BIO_flush(bio_err);
+       (void)BIO_flush(bio_err);
        alarm(SECONDS);
 #else
        BIO_printf(bio_err,"Doing %s %ld times on %d size blocks: ",s,num,length);
-       BIO_flush(bio_err);
+       (void)BIO_flush(bio_err);
 #endif
 #ifdef LINT
        num=num;
@@ -1185,11 +1195,11 @@ static void pkey_print_message(char *str, char *str2, long num, int bits,
        {
 #ifdef SIGALRM
        BIO_printf(bio_err,"Doing %d bit %s %s's for %ds: ",bits,str,str2,tm);
-       BIO_flush(bio_err);
+       (void)BIO_flush(bio_err);
        alarm(RSA_SECONDS);
 #else
        BIO_printf(bio_err,"Doing %ld %d bit %s %s's: ",num,bits,str,str2);
-       BIO_flush(bio_err);
+       (void)BIO_flush(bio_err);
 #endif
 #ifdef LINT
        num=num;