summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/des/speed.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/des/speed.c')
-rw-r--r--src/lib/libcrypto/des/speed.c77
1 files changed, 29 insertions, 48 deletions
diff --git a/src/lib/libcrypto/des/speed.c b/src/lib/libcrypto/des/speed.c
index 5bbe8b01d6..da41abcb03 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(MSDOS) && (!defined(VMS) || defined(__DECC))
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> 70OPENSSL_DECLARE_EXIT
71extern 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.
84struct 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(VMS) && defined(__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)
120long run=0; 115long run=0;
121 116
122#ifndef NOPROTO
123double Time_F(int s); 117double Time_F(int s);
124#else
125double 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
136SIGRETTYPE sig_done(int sig); 125SIGRETTYPE sig_done(int sig);
137#else 126SIGRETTYPE sig_done(int sig)
138SIGRETTYPE sig_done();
139#endif
140
141SIGRETTYPE sig_done(sig)
142int 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
155double Time_F(s) 139double Time_F(int s)
156int s;
157 { 140 {
158 double ret; 141 double ret;
159#ifdef TIMES 142#ifdef TIMES
@@ -189,9 +172,7 @@ int s;
189#endif 172#endif
190 } 173 }
191 174
192int main(argc,argv) 175int main(int argc, char **argv)
193int argc;
194char **argv;
195 { 176 {
196 long count; 177 long count;
197 static unsigned char buf[BUFSIZE]; 178 static unsigned char buf[BUFSIZE];
@@ -209,12 +190,12 @@ char **argv;
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(&key2,sch2);
213 des_set_key((C_Block *)key3,sch3); 194 des_set_key(&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(&key,sch);
218 count=10; 199 count=10;
219 do { 200 do {
220 long i; 201 long i;
@@ -244,7 +225,7 @@ 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(&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;
@@ -276,8 +257,8 @@ char **argv;
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[0]),
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);
@@ -293,11 +274,11 @@ char **argv;
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[0]),
298 &(sch2[0]), 279 &(sch2[0]),
299 &(sch3[0]), 280 &(sch3[0]),
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",