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