diff options
author | beck <> | 1999-09-29 04:37:45 +0000 |
---|---|---|
committer | beck <> | 1999-09-29 04:37:45 +0000 |
commit | de8f24ea083384bb66b32ec105dc4743c5663cdf (patch) | |
tree | 1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/bn/bnspeed.c | |
parent | cb929d29896bcb87c2a97417fbd03e50078fc178 (diff) | |
download | openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2 openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip |
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/bn/bnspeed.c')
-rw-r--r-- | src/lib/libcrypto/bn/bnspeed.c | 67 |
1 files changed, 25 insertions, 42 deletions
diff --git a/src/lib/libcrypto/bn/bnspeed.c b/src/lib/libcrypto/bn/bnspeed.c index f7c2790fff..0922aa3e16 100644 --- a/src/lib/libcrypto/bn/bnspeed.c +++ b/src/lib/libcrypto/bn/bnspeed.c | |||
@@ -66,14 +66,13 @@ | |||
66 | #include <stdlib.h> | 66 | #include <stdlib.h> |
67 | #include <signal.h> | 67 | #include <signal.h> |
68 | #include <string.h> | 68 | #include <string.h> |
69 | #include "crypto.h" | 69 | #include <openssl/crypto.h> |
70 | #include "err.h" | 70 | #include <openssl/err.h> |
71 | 71 | ||
72 | #ifndef MSDOS | 72 | #if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) |
73 | #define TIMES | 73 | #define TIMES |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | #ifndef VMS | ||
77 | #ifndef _IRIX | 76 | #ifndef _IRIX |
78 | #include <time.h> | 77 | #include <time.h> |
79 | #endif | 78 | #endif |
@@ -81,36 +80,33 @@ | |||
81 | #include <sys/types.h> | 80 | #include <sys/types.h> |
82 | #include <sys/times.h> | 81 | #include <sys/times.h> |
83 | #endif | 82 | #endif |
84 | #else /* VMS */ | 83 | |
85 | #include <types.h> | 84 | /* Depending on the VMS version, the tms structure is perhaps defined. |
86 | struct tms { | 85 | The __TMS macro will show if it was. If it wasn't defined, we should |
87 | time_t tms_utime; | 86 | undefine TIMES, since that tells the rest of the program how things |
88 | time_t tms_stime; | 87 | should be handled. -- Richard Levitte */ |
89 | time_t tms_uchild; /* I dunno... */ | 88 | #if defined(VMS) && defined(__DECC) && !defined(__TMS) |
90 | time_t tms_uchildsys; /* so these names are a guess :-) */ | 89 | #undef TIMES |
91 | } | ||
92 | #endif | 90 | #endif |
91 | |||
93 | #ifndef TIMES | 92 | #ifndef TIMES |
94 | #include <sys/timeb.h> | 93 | #include <sys/timeb.h> |
95 | #endif | 94 | #endif |
96 | 95 | ||
97 | #ifdef sun | 96 | #if defined(sun) || defined(__ultrix) |
97 | #define _POSIX_SOURCE | ||
98 | #include <limits.h> | 98 | #include <limits.h> |
99 | #include <sys/param.h> | 99 | #include <sys/param.h> |
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | #include "bn.h" | 102 | #include <openssl/bn.h> |
103 | #include "x509.h" | 103 | #include <openssl/x509.h> |
104 | 104 | ||
105 | /* The following if from times(3) man page. It may need to be changed */ | 105 | /* The following if from times(3) man page. It may need to be changed */ |
106 | #ifndef HZ | 106 | #ifndef HZ |
107 | # ifndef CLK_TCK | 107 | # ifndef CLK_TCK |
108 | # ifndef _BSD_CLK_TCK_ /* FreeBSD hack */ | 108 | # ifndef _BSD_CLK_TCK_ /* FreeBSD hack */ |
109 | # ifndef VMS | 109 | # define HZ 100.0 |
110 | # define HZ 100.0 | ||
111 | # else /* VMS */ | ||
112 | # define HZ 100.0 | ||
113 | # endif | ||
114 | # else /* _BSD_CLK_TCK_ */ | 110 | # else /* _BSD_CLK_TCK_ */ |
115 | # define HZ ((double)_BSD_CLK_TCK_) | 111 | # define HZ ((double)_BSD_CLK_TCK_) |
116 | # endif | 112 | # endif |
@@ -123,17 +119,11 @@ struct tms { | |||
123 | #define BUFSIZE ((long)1024*8) | 119 | #define BUFSIZE ((long)1024*8) |
124 | int run=0; | 120 | int run=0; |
125 | 121 | ||
126 | #ifndef NOPROTO | ||
127 | static double Time_F(int s); | 122 | static double Time_F(int s); |
128 | #else | ||
129 | static double Time_F(); | ||
130 | #endif | ||
131 | |||
132 | #define START 0 | 123 | #define START 0 |
133 | #define STOP 1 | 124 | #define STOP 1 |
134 | 125 | ||
135 | static double Time_F(s) | 126 | static double Time_F(int s) |
136 | int s; | ||
137 | { | 127 | { |
138 | double ret; | 128 | double ret; |
139 | #ifdef TIMES | 129 | #ifdef TIMES |
@@ -175,27 +165,20 @@ static int sizes[NUM_SIZES]={128,256,512,1024,2048}; | |||
175 | 165 | ||
176 | void do_mul(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_CTX *ctx); | 166 | void do_mul(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_CTX *ctx); |
177 | 167 | ||
178 | int main(argc,argv) | 168 | int main(int argc, char **argv) |
179 | int argc; | ||
180 | char **argv; | ||
181 | { | 169 | { |
182 | BN_CTX *ctx; | 170 | BN_CTX *ctx; |
183 | BIGNUM *a,*b,*c,*r; | 171 | BIGNUM a,b,c; |
184 | 172 | ||
185 | ctx=BN_CTX_new(); | 173 | ctx=BN_CTX_new(); |
186 | a=BN_new(); | 174 | BN_init(&a); |
187 | b=BN_new(); | 175 | BN_init(&b); |
188 | c=BN_new(); | 176 | BN_init(&c); |
189 | r=BN_new(); | ||
190 | 177 | ||
191 | do_mul(a,b,c,ctx); | 178 | do_mul(&a,&b,&c,ctx); |
192 | } | 179 | } |
193 | 180 | ||
194 | void do_mul(r,a,b,ctx) | 181 | void do_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) |
195 | BIGNUM *r; | ||
196 | BIGNUM *a; | ||
197 | BIGNUM *b; | ||
198 | BN_CTX *ctx; | ||
199 | { | 182 | { |
200 | int i,j,k; | 183 | int i,j,k; |
201 | double tm; | 184 | double tm; |
@@ -211,7 +194,7 @@ BN_CTX *ctx; | |||
211 | BN_rand(b,sizes[j],1,0); | 194 | BN_rand(b,sizes[j],1,0); |
212 | Time_F(START); | 195 | Time_F(START); |
213 | for (k=0; k<num; k++) | 196 | for (k=0; k<num; k++) |
214 | BN_mul(r,b,a); | 197 | BN_mul(r,b,a,ctx); |
215 | tm=Time_F(STOP); | 198 | tm=Time_F(STOP); |
216 | printf("mul %4d x %4d -> %8.3fms\n",sizes[i],sizes[j],tm*1000.0/num); | 199 | printf("mul %4d x %4d -> %8.3fms\n",sizes[i],sizes[j],tm*1000.0/num); |
217 | } | 200 | } |