diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/des/speed.c | 117 |
1 files changed, 49 insertions, 68 deletions
diff --git a/src/lib/libcrypto/des/speed.c b/src/lib/libcrypto/des/speed.c index 5bbe8b01d6..48fc1d49fc 100644 --- a/src/lib/libcrypto/des/speed.c +++ b/src/lib/libcrypto/des/speed.c | |||
| @@ -59,19 +59,17 @@ | |||
| 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 | #ifndef MSDOS | 62 | #if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX) |
| 63 | #define TIMES | 63 | #define TIMES |
| 64 | #endif | 64 | #endif |
| 65 | 65 | ||
| 66 | #include <stdio.h> | 66 | #include <stdio.h> |
| 67 | #ifndef MSDOS | 67 | |
| 68 | #include <unistd.h> | 68 | #include <openssl/e_os2.h> |
| 69 | #else | 69 | #include OPENSSL_UNISTD_IO |
| 70 | #include <io.h> | 70 | OPENSSL_DECLARE_EXIT |
| 71 | extern int exit(); | 71 | |
| 72 | #endif | ||
| 73 | #include <signal.h> | 72 | #include <signal.h> |
| 74 | #ifndef VMS | ||
| 75 | #ifndef _IRIX | 73 | #ifndef _IRIX |
| 76 | #include <time.h> | 74 | #include <time.h> |
| 77 | #endif | 75 | #endif |
| @@ -79,35 +77,32 @@ extern int exit(); | |||
| 79 | #include <sys/types.h> | 77 | #include <sys/types.h> |
| 80 | #include <sys/times.h> | 78 | #include <sys/times.h> |
| 81 | #endif | 79 | #endif |
| 82 | #else /* VMS */ | 80 | |
| 83 | #include <types.h> | 81 | /* Depending on the VMS version, the tms structure is perhaps defined. |
| 84 | struct tms { | 82 | The __TMS macro will show if it was. If it wasn't defined, we should |
| 85 | time_t tms_utime; | 83 | undefine TIMES, since that tells the rest of the program how things |
| 86 | time_t tms_stime; | 84 | should be handled. -- Richard Levitte */ |
| 87 | time_t tms_uchild; /* I dunno... */ | 85 | #if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS) |
| 88 | time_t tms_uchildsys; /* so these names are a guess :-) */ | 86 | #undef TIMES |
| 89 | } | ||
| 90 | #endif | 87 | #endif |
| 88 | |||
| 91 | #ifndef TIMES | 89 | #ifndef TIMES |
| 92 | #include <sys/timeb.h> | 90 | #include <sys/timeb.h> |
| 93 | #endif | 91 | #endif |
| 94 | 92 | ||
| 95 | #ifdef sun | 93 | #if defined(sun) || defined(__ultrix) |
| 94 | #define _POSIX_SOURCE | ||
| 96 | #include <limits.h> | 95 | #include <limits.h> |
| 97 | #include <sys/param.h> | 96 | #include <sys/param.h> |
| 98 | #endif | 97 | #endif |
| 99 | 98 | ||
| 100 | #include "des.h" | 99 | #include <openssl/des.h> |
| 101 | 100 | ||
| 102 | /* The following if from times(3) man page. It may need to be changed */ | 101 | /* The following if from times(3) man page. It may need to be changed */ |
| 103 | #ifndef HZ | 102 | #ifndef HZ |
| 104 | # ifndef CLK_TCK | 103 | # ifndef CLK_TCK |
| 105 | # ifndef _BSD_CLK_TCK_ /* FreeBSD fix */ | 104 | # ifndef _BSD_CLK_TCK_ /* FreeBSD fix */ |
| 106 | # ifndef VMS | 105 | # define HZ 100.0 |
| 107 | # define HZ 100.0 | ||
| 108 | # else /* VMS */ | ||
| 109 | # define HZ 100.0 | ||
| 110 | # endif | ||
| 111 | # else /* _BSD_CLK_TCK_ */ | 106 | # else /* _BSD_CLK_TCK_ */ |
| 112 | # define HZ ((double)_BSD_CLK_TCK_) | 107 | # define HZ ((double)_BSD_CLK_TCK_) |
| 113 | # endif | 108 | # endif |
| @@ -119,12 +114,7 @@ struct tms { | |||
| 119 | #define BUFSIZE ((long)1024) | 114 | #define BUFSIZE ((long)1024) |
| 120 | long run=0; | 115 | long run=0; |
| 121 | 116 | ||
| 122 | #ifndef NOPROTO | ||
| 123 | double Time_F(int s); | 117 | double Time_F(int s); |
| 124 | #else | ||
| 125 | double Time_F(); | ||
| 126 | #endif | ||
| 127 | |||
| 128 | #ifdef SIGALRM | 118 | #ifdef SIGALRM |
| 129 | #if defined(__STDC__) || defined(sgi) || defined(_AIX) | 119 | #if defined(__STDC__) || defined(sgi) || defined(_AIX) |
| 130 | #define SIGRETTYPE void | 120 | #define SIGRETTYPE void |
| @@ -132,14 +122,8 @@ double Time_F(); | |||
| 132 | #define SIGRETTYPE int | 122 | #define SIGRETTYPE int |
| 133 | #endif | 123 | #endif |
| 134 | 124 | ||
| 135 | #ifndef NOPROTO | ||
| 136 | SIGRETTYPE sig_done(int sig); | 125 | SIGRETTYPE sig_done(int sig); |
| 137 | #else | 126 | SIGRETTYPE sig_done(int sig) |
| 138 | SIGRETTYPE sig_done(); | ||
| 139 | #endif | ||
| 140 | |||
| 141 | SIGRETTYPE sig_done(sig) | ||
| 142 | int sig; | ||
| 143 | { | 127 | { |
| 144 | signal(SIGALRM,sig_done); | 128 | signal(SIGALRM,sig_done); |
| 145 | run=0; | 129 | run=0; |
| @@ -152,8 +136,7 @@ int sig; | |||
| 152 | #define START 0 | 136 | #define START 0 |
| 153 | #define STOP 1 | 137 | #define STOP 1 |
| 154 | 138 | ||
| 155 | double Time_F(s) | 139 | double Time_F(int s) |
| 156 | int s; | ||
| 157 | { | 140 | { |
| 158 | double ret; | 141 | double ret; |
| 159 | #ifdef TIMES | 142 | #ifdef TIMES |
| @@ -189,32 +172,30 @@ int s; | |||
| 189 | #endif | 172 | #endif |
| 190 | } | 173 | } |
| 191 | 174 | ||
| 192 | int main(argc,argv) | 175 | int main(int argc, char **argv) |
| 193 | int argc; | ||
| 194 | char **argv; | ||
| 195 | { | 176 | { |
| 196 | long count; | 177 | long count; |
| 197 | static unsigned char buf[BUFSIZE]; | 178 | static unsigned char buf[BUFSIZE]; |
| 198 | static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0}; | 179 | static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0}; |
| 199 | static des_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12}; | 180 | static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12}; |
| 200 | static des_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34}; | 181 | static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34}; |
| 201 | des_key_schedule sch,sch2,sch3; | 182 | DES_key_schedule sch,sch2,sch3; |
| 202 | double a,b,c,d,e; | 183 | double a,b,c,d,e; |
| 203 | #ifndef SIGALRM | 184 | #ifndef SIGALRM |
| 204 | long ca,cb,cc,cd,ce; | 185 | long ca,cb,cc,cd,ce; |
| 205 | #endif | 186 | #endif |
| 206 | 187 | ||
| 207 | #ifndef TIMES | 188 | #ifndef TIMES |
| 208 | printf("To get the most acurate results, try to run this\n"); | 189 | printf("To get the most accurate results, try to run this\n"); |
| 209 | printf("program when this computer is idle.\n"); | 190 | printf("program when this computer is idle.\n"); |
| 210 | #endif | 191 | #endif |
| 211 | 192 | ||
| 212 | des_set_key((C_Block *)key2,sch2); | 193 | DES_set_key_unchecked(&key2,&sch2); |
| 213 | des_set_key((C_Block *)key3,sch3); | 194 | DES_set_key_unchecked(&key3,&sch3); |
| 214 | 195 | ||
| 215 | #ifndef SIGALRM | 196 | #ifndef SIGALRM |
| 216 | printf("First we calculate the approximate speed ...\n"); | 197 | printf("First we calculate the approximate speed ...\n"); |
| 217 | des_set_key((C_Block *)key,sch); | 198 | DES_set_key_unchecked(&key,&sch); |
| 218 | count=10; | 199 | count=10; |
| 219 | do { | 200 | do { |
| 220 | long i; | 201 | long i; |
| @@ -223,7 +204,7 @@ char **argv; | |||
| 223 | count*=2; | 204 | count*=2; |
| 224 | Time_F(START); | 205 | Time_F(START); |
| 225 | for (i=count; i; i--) | 206 | for (i=count; i; i--) |
| 226 | des_encrypt(data,&(sch[0]),DES_ENCRYPT); | 207 | DES_encrypt1(data,&sch,DES_ENCRYPT); |
| 227 | d=Time_F(STOP); | 208 | d=Time_F(STOP); |
| 228 | } while (d < 3.0); | 209 | } while (d < 3.0); |
| 229 | ca=count; | 210 | ca=count; |
| @@ -244,63 +225,63 @@ char **argv; | |||
| 244 | 225 | ||
| 245 | Time_F(START); | 226 | Time_F(START); |
| 246 | for (count=0,run=1; COND(ca); count++) | 227 | for (count=0,run=1; COND(ca); count++) |
| 247 | des_set_key((C_Block *)key,sch); | 228 | DES_set_key_unchecked(&key,&sch); |
| 248 | d=Time_F(STOP); | 229 | d=Time_F(STOP); |
| 249 | printf("%ld set_key's in %.2f seconds\n",count,d); | 230 | printf("%ld set_key's in %.2f seconds\n",count,d); |
| 250 | a=((double)COUNT(ca))/d; | 231 | a=((double)COUNT(ca))/d; |
| 251 | 232 | ||
| 252 | #ifdef SIGALRM | 233 | #ifdef SIGALRM |
| 253 | printf("Doing des_encrypt's for 10 seconds\n"); | 234 | printf("Doing DES_encrypt's for 10 seconds\n"); |
| 254 | alarm(10); | 235 | alarm(10); |
| 255 | #else | 236 | #else |
| 256 | printf("Doing des_encrypt %ld times\n",cb); | 237 | printf("Doing DES_encrypt %ld times\n",cb); |
| 257 | #endif | 238 | #endif |
| 258 | Time_F(START); | 239 | Time_F(START); |
| 259 | for (count=0,run=1; COND(cb); count++) | 240 | for (count=0,run=1; COND(cb); count++) |
| 260 | { | 241 | { |
| 261 | DES_LONG data[2]; | 242 | DES_LONG data[2]; |
| 262 | 243 | ||
| 263 | des_encrypt(data,&(sch[0]),DES_ENCRYPT); | 244 | DES_encrypt1(data,&sch,DES_ENCRYPT); |
| 264 | } | 245 | } |
| 265 | d=Time_F(STOP); | 246 | d=Time_F(STOP); |
| 266 | printf("%ld des_encrypt's in %.2f second\n",count,d); | 247 | printf("%ld DES_encrypt's in %.2f second\n",count,d); |
| 267 | b=((double)COUNT(cb)*8)/d; | 248 | b=((double)COUNT(cb)*8)/d; |
| 268 | 249 | ||
| 269 | #ifdef SIGALRM | 250 | #ifdef SIGALRM |
| 270 | printf("Doing des_cbc_encrypt on %ld byte blocks for 10 seconds\n", | 251 | printf("Doing DES_cbc_encrypt on %ld byte blocks for 10 seconds\n", |
| 271 | BUFSIZE); | 252 | BUFSIZE); |
| 272 | alarm(10); | 253 | alarm(10); |
| 273 | #else | 254 | #else |
| 274 | printf("Doing des_cbc_encrypt %ld times on %ld byte blocks\n",cc, | 255 | printf("Doing DES_cbc_encrypt %ld times on %ld byte blocks\n",cc, |
| 275 | BUFSIZE); | 256 | BUFSIZE); |
| 276 | #endif | 257 | #endif |
| 277 | Time_F(START); | 258 | Time_F(START); |
| 278 | for (count=0,run=1; COND(cc); count++) | 259 | for (count=0,run=1; COND(cc); count++) |
| 279 | des_ncbc_encrypt((C_Block *)buf,(C_Block *)buf,BUFSIZE,&(sch[0]), | 260 | DES_ncbc_encrypt(buf,buf,BUFSIZE,&sch, |
| 280 | (C_Block *)&(key[0]),DES_ENCRYPT); | 261 | &key,DES_ENCRYPT); |
| 281 | d=Time_F(STOP); | 262 | d=Time_F(STOP); |
| 282 | printf("%ld des_cbc_encrypt's of %ld byte blocks in %.2f second\n", | 263 | printf("%ld DES_cbc_encrypt's of %ld byte blocks in %.2f second\n", |
| 283 | count,BUFSIZE,d); | 264 | count,BUFSIZE,d); |
| 284 | c=((double)COUNT(cc)*BUFSIZE)/d; | 265 | c=((double)COUNT(cc)*BUFSIZE)/d; |
| 285 | 266 | ||
| 286 | #ifdef SIGALRM | 267 | #ifdef SIGALRM |
| 287 | printf("Doing des_ede_cbc_encrypt on %ld byte blocks for 10 seconds\n", | 268 | printf("Doing DES_ede_cbc_encrypt on %ld byte blocks for 10 seconds\n", |
| 288 | BUFSIZE); | 269 | BUFSIZE); |
| 289 | alarm(10); | 270 | alarm(10); |
| 290 | #else | 271 | #else |
| 291 | printf("Doing des_ede_cbc_encrypt %ld times on %ld byte blocks\n",cd, | 272 | printf("Doing DES_ede_cbc_encrypt %ld times on %ld byte blocks\n",cd, |
| 292 | BUFSIZE); | 273 | BUFSIZE); |
| 293 | #endif | 274 | #endif |
| 294 | Time_F(START); | 275 | Time_F(START); |
| 295 | for (count=0,run=1; COND(cd); count++) | 276 | for (count=0,run=1; COND(cd); count++) |
| 296 | des_ede3_cbc_encrypt((C_Block *)buf,(C_Block *)buf,BUFSIZE, | 277 | DES_ede3_cbc_encrypt(buf,buf,BUFSIZE, |
| 297 | &(sch[0]), | 278 | &sch, |
| 298 | &(sch2[0]), | 279 | &sch2, |
| 299 | &(sch3[0]), | 280 | &sch3, |
| 300 | (C_Block *)&(key[0]), | 281 | &key, |
| 301 | DES_ENCRYPT); | 282 | DES_ENCRYPT); |
| 302 | d=Time_F(STOP); | 283 | d=Time_F(STOP); |
| 303 | printf("%ld des_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n", | 284 | printf("%ld DES_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n", |
| 304 | count,BUFSIZE,d); | 285 | count,BUFSIZE,d); |
| 305 | d=((double)COUNT(cd)*BUFSIZE)/d; | 286 | d=((double)COUNT(cd)*BUFSIZE)/d; |
| 306 | 287 | ||
| @@ -323,7 +304,7 @@ char **argv; | |||
| 323 | printf("DES ede cbc bytes per sec = %12.2f (%9.3fuS)\n",d,8.0e6/d); | 304 | printf("DES ede cbc bytes per sec = %12.2f (%9.3fuS)\n",d,8.0e6/d); |
| 324 | printf("crypt per sec = %12.2f (%9.3fuS)\n",e,1.0e6/e); | 305 | printf("crypt per sec = %12.2f (%9.3fuS)\n",e,1.0e6/e); |
| 325 | exit(0); | 306 | exit(0); |
| 326 | #if defined(LINT) || defined(MSDOS) | 307 | #if defined(LINT) || defined(OPENSSL_SYS_MSDOS) |
| 327 | return(0); | 308 | return(0); |
| 328 | #endif | 309 | #endif |
| 329 | } | 310 | } |
