diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/rc5/rc5speed.c | 93 |
1 files changed, 9 insertions, 84 deletions
diff --git a/src/lib/libcrypto/rc5/rc5speed.c b/src/lib/libcrypto/rc5/rc5speed.c index 2e17321ebc..b5a8c285da 100644 --- a/src/lib/libcrypto/rc5/rc5speed.c +++ b/src/lib/libcrypto/rc5/rc5speed.c | |||
| @@ -59,77 +59,30 @@ | |||
| 59 | /* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ | 59 | /* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ |
| 60 | /* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */ | 60 | /* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */ |
| 61 | 61 | ||
| 62 | #if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX) | ||
| 63 | #define TIMES | ||
| 64 | #endif | ||
| 65 | |||
| 66 | #include <stdio.h> | ||
| 67 | |||
| 68 | #include <openssl/e_os2.h> | ||
| 69 | #include <unistd.h> | ||
| 70 | |||
| 71 | #ifndef OPENSSL_SYS_NETWARE | ||
| 72 | #include <signal.h> | ||
| 73 | #endif | ||
| 74 | |||
| 75 | #ifndef _IRIX | ||
| 76 | #include <time.h> | ||
| 77 | #endif | ||
| 78 | #ifdef TIMES | ||
| 79 | #include <sys/types.h> | 62 | #include <sys/types.h> |
| 80 | #include <sys/times.h> | 63 | #include <sys/times.h> |
| 81 | #endif | ||
| 82 | 64 | ||
| 83 | /* Depending on the VMS version, the tms structure is perhaps defined. | 65 | #include <signal.h> |
| 84 | The __TMS macro will show if it was. If it wasn't defined, we should | 66 | #include <stdio.h> |
| 85 | undefine TIMES, since that tells the rest of the program how things | 67 | #include <stdlib.h> |
| 86 | should be handled. -- Richard Levitte */ | 68 | #include <time.h> |
| 87 | #if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS) | 69 | #include <unistd.h> |
| 88 | #undef TIMES | ||
| 89 | #endif | ||
| 90 | |||
| 91 | #ifndef TIMES | ||
| 92 | #include <sys/timeb.h> | ||
| 93 | #endif | ||
| 94 | |||
| 95 | #if defined(sun) || defined(__ultrix) | ||
| 96 | #define _POSIX_SOURCE | ||
| 97 | #include <limits.h> | ||
| 98 | #include <sys/param.h> | ||
| 99 | #endif | ||
| 100 | 70 | ||
| 101 | #include <openssl/rc5.h> | 71 | #include <openssl/rc5.h> |
| 102 | 72 | ||
| 103 | /* The following if from times(3) man page. It may need to be changed */ | ||
| 104 | #ifndef HZ | ||
| 105 | #ifndef CLK_TCK | ||
| 106 | #define HZ 100.0 | ||
| 107 | #else /* CLK_TCK */ | ||
| 108 | #define HZ ((double)CLK_TCK) | 73 | #define HZ ((double)CLK_TCK) |
| 109 | #endif | ||
| 110 | #endif | ||
| 111 | 74 | ||
| 112 | #define BUFSIZE ((long)1024) | 75 | #define BUFSIZE ((long)1024) |
| 113 | long run=0; | 76 | long run=0; |
| 114 | 77 | ||
| 115 | double Time_F(int s); | 78 | double Time_F(int s); |
| 116 | #ifdef SIGALRM | ||
| 117 | #if defined(__STDC__) || defined(sgi) || defined(_AIX) | ||
| 118 | #define SIGRETTYPE void | ||
| 119 | #else | ||
| 120 | #define SIGRETTYPE int | ||
| 121 | #endif | ||
| 122 | 79 | ||
| 123 | SIGRETTYPE sig_done(int sig); | 80 | void sig_done(int sig); |
| 124 | SIGRETTYPE sig_done(int sig) | 81 | void sig_done(int sig) |
| 125 | { | 82 | { |
| 126 | signal(SIGALRM,sig_done); | 83 | signal(SIGALRM,sig_done); |
| 127 | run=0; | 84 | run=0; |
| 128 | #ifdef LINT | ||
| 129 | sig=sig; | ||
| 130 | #endif | ||
| 131 | } | 85 | } |
| 132 | #endif | ||
| 133 | 86 | ||
| 134 | #define START 0 | 87 | #define START 0 |
| 135 | #define STOP 1 | 88 | #define STOP 1 |
| @@ -137,7 +90,6 @@ SIGRETTYPE sig_done(int sig) | |||
| 137 | double Time_F(int s) | 90 | double Time_F(int s) |
| 138 | { | 91 | { |
| 139 | double ret; | 92 | double ret; |
| 140 | #ifdef TIMES | ||
| 141 | static struct tms tstart,tend; | 93 | static struct tms tstart,tend; |
| 142 | 94 | ||
| 143 | if (s == START) | 95 | if (s == START) |
| @@ -151,23 +103,6 @@ double Time_F(int s) | |||
| 151 | ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ; | 103 | ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ; |
| 152 | return((ret == 0.0)?1e-6:ret); | 104 | return((ret == 0.0)?1e-6:ret); |
| 153 | } | 105 | } |
| 154 | #else /* !times() */ | ||
| 155 | static struct timeb tstart,tend; | ||
| 156 | long i; | ||
| 157 | |||
| 158 | if (s == START) | ||
| 159 | { | ||
| 160 | ftime(&tstart); | ||
| 161 | return(0); | ||
| 162 | } | ||
| 163 | else | ||
| 164 | { | ||
| 165 | ftime(&tend); | ||
| 166 | i=(long)tend.millitm-(long)tstart.millitm; | ||
| 167 | ret=((double)(tend.time-tstart.time))+((double)i)/1e3; | ||
| 168 | return((ret == 0.0)?1e-6:ret); | ||
| 169 | } | ||
| 170 | #endif | ||
| 171 | } | 106 | } |
| 172 | 107 | ||
| 173 | int main(int argc, char **argv) | 108 | int main(int argc, char **argv) |
| @@ -229,12 +164,9 @@ int main(int argc, char **argv) | |||
| 229 | printf("%ld RC5_32_set_key's in %.2f seconds\n",count,d); | 164 | printf("%ld RC5_32_set_key's in %.2f seconds\n",count,d); |
| 230 | a=((double)COUNT(ca))/d; | 165 | a=((double)COUNT(ca))/d; |
| 231 | 166 | ||
| 232 | #ifdef SIGALRM | ||
| 233 | printf("Doing RC5_32_encrypt's for 10 seconds\n"); | 167 | printf("Doing RC5_32_encrypt's for 10 seconds\n"); |
| 234 | alarm(10); | 168 | alarm(10); |
| 235 | #else | 169 | |
| 236 | printf("Doing RC5_32_encrypt %ld times\n",cb); | ||
| 237 | #endif | ||
| 238 | Time_F(START); | 170 | Time_F(START); |
| 239 | for (count=0,run=1; COND(cb); count+=4) | 171 | for (count=0,run=1; COND(cb); count+=4) |
| 240 | { | 172 | { |
| @@ -249,14 +181,10 @@ int main(int argc, char **argv) | |||
| 249 | printf("%ld RC5_32_encrypt's in %.2f second\n",count,d); | 181 | printf("%ld RC5_32_encrypt's in %.2f second\n",count,d); |
| 250 | b=((double)COUNT(cb)*8)/d; | 182 | b=((double)COUNT(cb)*8)/d; |
| 251 | 183 | ||
| 252 | #ifdef SIGALRM | ||
| 253 | printf("Doing RC5_32_cbc_encrypt on %ld byte blocks for 10 seconds\n", | 184 | printf("Doing RC5_32_cbc_encrypt on %ld byte blocks for 10 seconds\n", |
| 254 | BUFSIZE); | 185 | BUFSIZE); |
| 255 | alarm(10); | 186 | alarm(10); |
| 256 | #else | 187 | |
| 257 | printf("Doing RC5_32_cbc_encrypt %ld times on %ld byte blocks\n",cc, | ||
| 258 | BUFSIZE); | ||
| 259 | #endif | ||
| 260 | Time_F(START); | 188 | Time_F(START); |
| 261 | for (count=0,run=1; COND(cc); count++) | 189 | for (count=0,run=1; COND(cc); count++) |
| 262 | RC5_32_cbc_encrypt(buf,buf,BUFSIZE,&sch, | 190 | RC5_32_cbc_encrypt(buf,buf,BUFSIZE,&sch, |
| @@ -270,7 +198,4 @@ int main(int argc, char **argv) | |||
| 270 | printf("RC5_32/12/16 raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b); | 198 | printf("RC5_32/12/16 raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b); |
| 271 | printf("RC5_32/12/16 cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c); | 199 | printf("RC5_32/12/16 cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c); |
| 272 | exit(0); | 200 | exit(0); |
| 273 | #if defined(LINT) || defined(OPENSSL_SYS_MSDOS) | ||
| 274 | return(0); | ||
| 275 | #endif | ||
| 276 | } | 201 | } |
