X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fbf%2Fbfspeed.c;h=9b893e92cc54379a5631daeb94ed2ab231139b90;hb=b52d109518e507136177cefd150b505aa1f3b856;hp=ee20bd00f71a815484e4322c5d5b12c00f2b757b;hpb=b7896b3cb86d80206af14a14d69b0717786f2729;p=oweals%2Fopenssl.git diff --git a/crypto/bf/bfspeed.c b/crypto/bf/bfspeed.c index ee20bd00f7..9b893e92cc 100644 --- a/crypto/bf/bfspeed.c +++ b/crypto/bf/bfspeed.c @@ -1,5 +1,5 @@ /* crypto/bf/bfspeed.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written @@ -59,19 +59,17 @@ /* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ /* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */ -#ifndef MSDOS +#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) #define TIMES #endif #include -#ifndef MSDOS -#include -#else -#include -extern int exit(); -#endif + +#include +#include OPENSSL_UNISTD_IO +OPENSSL_DECLARE_EXIT + #include -#ifndef VMS #ifndef _IRIX #include #endif @@ -79,34 +77,31 @@ extern int exit(); #include #include #endif -#else /* VMS */ -#include -struct tms { - time_t tms_utime; - time_t tms_stime; - time_t tms_uchild; /* I dunno... */ - time_t tms_uchildsys; /* so these names are a guess :-) */ - } + +/* Depending on the VMS version, the tms structure is perhaps defined. + The __TMS macro will show if it was. If it wasn't defined, we should + undefine TIMES, since that tells the rest of the program how things + should be handled. -- Richard Levitte */ +#if defined(VMS) && defined(__DECC) && !defined(__TMS) +#undef TIMES #endif + #ifndef TIMES #include #endif -#ifdef sun +#if defined(sun) || defined(__ultrix) +#define _POSIX_SOURCE #include #include #endif -#include "blowfish.h" +#include /* The following if from times(3) man page. It may need to be changed */ #ifndef HZ #ifndef CLK_TCK -#ifndef VMS -#define HZ 100.0 -#else /* VMS */ #define HZ 100.0 -#endif #else /* CLK_TCK */ #define HZ ((double)CLK_TCK) #endif @@ -115,12 +110,7 @@ struct tms { #define BUFSIZE ((long)1024) long run=0; -#ifndef NOPROTO double Time_F(int s); -#else -double Time_F(); -#endif - #ifdef SIGALRM #if defined(__STDC__) || defined(sgi) || defined(_AIX) #define SIGRETTYPE void @@ -128,14 +118,8 @@ double Time_F(); #define SIGRETTYPE int #endif -#ifndef NOPROTO SIGRETTYPE sig_done(int sig); -#else -SIGRETTYPE sig_done(); -#endif - -SIGRETTYPE sig_done(sig) -int sig; +SIGRETTYPE sig_done(int sig) { signal(SIGALRM,sig_done); run=0; @@ -148,8 +132,7 @@ int sig; #define START 0 #define STOP 1 -double Time_F(s) -int s; +double Time_F(int s) { double ret; #ifdef TIMES @@ -185,9 +168,7 @@ int s; #endif } -int main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { long count; static unsigned char buf[BUFSIZE]; @@ -217,7 +198,7 @@ char **argv; count*=2; Time_F(START); for (i=count; i; i--) - BF_encrypt(data,&sch,BF_ENCRYPT); + BF_encrypt(data,&sch); d=Time_F(STOP); } while (d < 3.0); ca=count/512; @@ -235,10 +216,15 @@ char **argv; #endif Time_F(START); - for (count=0,run=1; COND(ca); count++) + for (count=0,run=1; COND(ca); count+=4) + { + BF_set_key(&sch,16,key); + BF_set_key(&sch,16,key); BF_set_key(&sch,16,key); + BF_set_key(&sch,16,key); + } d=Time_F(STOP); - printf("%ld blowfish set_key's in %.2f seconds\n",count,d); + printf("%ld BF_set_key's in %.2f seconds\n",count,d); a=((double)COUNT(ca))/d; #ifdef SIGALRM @@ -248,11 +234,14 @@ char **argv; printf("Doing BF_encrypt %ld times\n",cb); #endif Time_F(START); - for (count=0,run=1; COND(cb); count++) + for (count=0,run=1; COND(cb); count+=4) { BF_LONG data[2]; - BF_encrypt(data,&sch,BF_ENCRYPT); + BF_encrypt(data,&sch); + BF_encrypt(data,&sch); + BF_encrypt(data,&sch); + BF_encrypt(data,&sch); } d=Time_F(STOP); printf("%ld BF_encrypt's in %.2f second\n",count,d); @@ -275,9 +264,9 @@ char **argv; count,BUFSIZE,d); c=((double)COUNT(cc)*BUFSIZE)/d; - printf("blowfish set_key per sec = %12.2f (%7.1fuS)\n",a,1.0e6/a); - printf("Blowfish raw ecb bytes per sec = %12.2f (%7.1fuS)\n",b,8.0e6/b); - printf("Blowfish cbc bytes per sec = %12.2f (%7.1fuS)\n",c,8.0e6/c); + printf("Blowfish set_key per sec = %12.3f (%9.3fuS)\n",a,1.0e6/a); + printf("Blowfish raw ecb bytes per sec = %12.3f (%9.3fuS)\n",b,8.0e6/b); + printf("Blowfish cbc bytes per sec = %12.3f (%9.3fuS)\n",c,8.0e6/c); exit(0); #if defined(LINT) || defined(MSDOS) return(0);