xref: /onnv-gate/usr/src/common/openssl/apps/speed.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /* apps/speed.c -*- mode:C; c-file-style: "eay" -*- */
2*0Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3*0Sstevel@tonic-gate  * All rights reserved.
4*0Sstevel@tonic-gate  *
5*0Sstevel@tonic-gate  * This package is an SSL implementation written
6*0Sstevel@tonic-gate  * by Eric Young (eay@cryptsoft.com).
7*0Sstevel@tonic-gate  * The implementation was written so as to conform with Netscapes SSL.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * This library is free for commercial and non-commercial use as long as
10*0Sstevel@tonic-gate  * the following conditions are aheared to.  The following conditions
11*0Sstevel@tonic-gate  * apply to all code found in this distribution, be it the RC4, RSA,
12*0Sstevel@tonic-gate  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13*0Sstevel@tonic-gate  * included with this distribution is covered by the same copyright terms
14*0Sstevel@tonic-gate  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15*0Sstevel@tonic-gate  *
16*0Sstevel@tonic-gate  * Copyright remains Eric Young's, and as such any Copyright notices in
17*0Sstevel@tonic-gate  * the code are not to be removed.
18*0Sstevel@tonic-gate  * If this package is used in a product, Eric Young should be given attribution
19*0Sstevel@tonic-gate  * as the author of the parts of the library used.
20*0Sstevel@tonic-gate  * This can be in the form of a textual message at program startup or
21*0Sstevel@tonic-gate  * in documentation (online or textual) provided with the package.
22*0Sstevel@tonic-gate  *
23*0Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
24*0Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
25*0Sstevel@tonic-gate  * are met:
26*0Sstevel@tonic-gate  * 1. Redistributions of source code must retain the copyright
27*0Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
28*0Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
29*0Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
30*0Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
31*0Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
32*0Sstevel@tonic-gate  *    must display the following acknowledgement:
33*0Sstevel@tonic-gate  *    "This product includes cryptographic software written by
34*0Sstevel@tonic-gate  *     Eric Young (eay@cryptsoft.com)"
35*0Sstevel@tonic-gate  *    The word 'cryptographic' can be left out if the rouines from the library
36*0Sstevel@tonic-gate  *    being used are not cryptographic related :-).
37*0Sstevel@tonic-gate  * 4. If you include any Windows specific code (or a derivative thereof) from
38*0Sstevel@tonic-gate  *    the apps directory (application code) you must include an acknowledgement:
39*0Sstevel@tonic-gate  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40*0Sstevel@tonic-gate  *
41*0Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42*0Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43*0Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44*0Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45*0Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46*0Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47*0Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48*0Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49*0Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50*0Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51*0Sstevel@tonic-gate  * SUCH DAMAGE.
52*0Sstevel@tonic-gate  *
53*0Sstevel@tonic-gate  * The licence and distribution terms for any publically available version or
54*0Sstevel@tonic-gate  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55*0Sstevel@tonic-gate  * copied and put under another distribution licence
56*0Sstevel@tonic-gate  * [including the GNU Public Licence.]
57*0Sstevel@tonic-gate  */
58*0Sstevel@tonic-gate /*
59*0Sstevel@tonic-gate  * The portions of this code that are #ifdef SOLARIS_OPENSSL are
60*0Sstevel@tonic-gate  *
61*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
62*0Sstevel@tonic-gate  * Use is subject to license terms.
63*0Sstevel@tonic-gate  *
64*0Sstevel@tonic-gate  */
65*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
66*0Sstevel@tonic-gate 
67*0Sstevel@tonic-gate /* most of this code has been pilfered from my libdes speed.c program */
68*0Sstevel@tonic-gate 
69*0Sstevel@tonic-gate #ifndef OPENSSL_NO_SPEED
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate #undef SECONDS
72*0Sstevel@tonic-gate #define SECONDS		3
73*0Sstevel@tonic-gate #define RSA_SECONDS	10
74*0Sstevel@tonic-gate #define DSA_SECONDS	10
75*0Sstevel@tonic-gate 
76*0Sstevel@tonic-gate /* 11-Sep-92 Andrew Daviel   Support for Silicon Graphics IRIX added */
77*0Sstevel@tonic-gate /* 06-Apr-92 Luke Brennan    Support for VMS and add extra signal calls */
78*0Sstevel@tonic-gate 
79*0Sstevel@tonic-gate #undef PROG
80*0Sstevel@tonic-gate #define PROG speed_main
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate #include <stdio.h>
83*0Sstevel@tonic-gate #include <stdlib.h>
84*0Sstevel@tonic-gate #include <signal.h>
85*0Sstevel@tonic-gate #include <string.h>
86*0Sstevel@tonic-gate #include <math.h>
87*0Sstevel@tonic-gate #include "apps.h"
88*0Sstevel@tonic-gate #ifdef OPENSSL_NO_STDIO
89*0Sstevel@tonic-gate #define APPS_WIN16
90*0Sstevel@tonic-gate #endif
91*0Sstevel@tonic-gate #include <openssl/crypto.h>
92*0Sstevel@tonic-gate #include <openssl/rand.h>
93*0Sstevel@tonic-gate #include <openssl/err.h>
94*0Sstevel@tonic-gate #include <openssl/evp.h>
95*0Sstevel@tonic-gate #include <openssl/objects.h>
96*0Sstevel@tonic-gate #if !defined(OPENSSL_SYS_MSDOS)
97*0Sstevel@tonic-gate #include OPENSSL_UNISTD
98*0Sstevel@tonic-gate #endif
99*0Sstevel@tonic-gate #ifdef SOLARIS_OPENSSL
100*0Sstevel@tonic-gate extern int SUNWcry_installed(void);
101*0Sstevel@tonic-gate #endif
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(OPENSSL_SYS_MACOSX)
104*0Sstevel@tonic-gate # define USE_TOD
105*0Sstevel@tonic-gate #elif !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
106*0Sstevel@tonic-gate # define TIMES
107*0Sstevel@tonic-gate #endif
108*0Sstevel@tonic-gate #if !defined(_UNICOS) && !defined(__OpenBSD__) && !defined(sgi) && !defined(__FreeBSD__) && !(defined(__bsdi) || defined(__bsdi__)) && !defined(_AIX) && !defined(OPENSSL_SYS_MPE) && !defined(__NetBSD__) && !defined(OPENSSL_SYS_VXWORKS) /* FIXME */
109*0Sstevel@tonic-gate # define TIMEB
110*0Sstevel@tonic-gate #endif
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate #ifndef _IRIX
113*0Sstevel@tonic-gate # include <time.h>
114*0Sstevel@tonic-gate #endif
115*0Sstevel@tonic-gate #ifdef TIMES
116*0Sstevel@tonic-gate # include <sys/types.h>
117*0Sstevel@tonic-gate # include <sys/times.h>
118*0Sstevel@tonic-gate #endif
119*0Sstevel@tonic-gate #ifdef USE_TOD
120*0Sstevel@tonic-gate # include <sys/time.h>
121*0Sstevel@tonic-gate # include <sys/resource.h>
122*0Sstevel@tonic-gate #endif
123*0Sstevel@tonic-gate 
124*0Sstevel@tonic-gate /* Depending on the VMS version, the tms structure is perhaps defined.
125*0Sstevel@tonic-gate    The __TMS macro will show if it was.  If it wasn't defined, we should
126*0Sstevel@tonic-gate    undefine TIMES, since that tells the rest of the program how things
127*0Sstevel@tonic-gate    should be handled.				-- Richard Levitte */
128*0Sstevel@tonic-gate #if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
129*0Sstevel@tonic-gate #undef TIMES
130*0Sstevel@tonic-gate #endif
131*0Sstevel@tonic-gate 
132*0Sstevel@tonic-gate #ifdef TIMEB
133*0Sstevel@tonic-gate #include <sys/timeb.h>
134*0Sstevel@tonic-gate #endif
135*0Sstevel@tonic-gate 
136*0Sstevel@tonic-gate #if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD) && !defined(OPENSSL_SYS_VXWORKS)
137*0Sstevel@tonic-gate #error "It seems neither struct tms nor struct timeb is supported in this platform!"
138*0Sstevel@tonic-gate #endif
139*0Sstevel@tonic-gate 
140*0Sstevel@tonic-gate #if defined(sun) || defined(__ultrix)
141*0Sstevel@tonic-gate #define _POSIX_SOURCE
142*0Sstevel@tonic-gate #include <limits.h>
143*0Sstevel@tonic-gate #include <sys/param.h>
144*0Sstevel@tonic-gate #endif
145*0Sstevel@tonic-gate 
146*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
147*0Sstevel@tonic-gate #include <openssl/des.h>
148*0Sstevel@tonic-gate #endif
149*0Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
150*0Sstevel@tonic-gate #include <openssl/aes.h>
151*0Sstevel@tonic-gate #endif
152*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD2
153*0Sstevel@tonic-gate #include <openssl/md2.h>
154*0Sstevel@tonic-gate #endif
155*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MDC2
156*0Sstevel@tonic-gate #include <openssl/mdc2.h>
157*0Sstevel@tonic-gate #endif
158*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD4
159*0Sstevel@tonic-gate #include <openssl/md4.h>
160*0Sstevel@tonic-gate #endif
161*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD5
162*0Sstevel@tonic-gate #include <openssl/md5.h>
163*0Sstevel@tonic-gate #endif
164*0Sstevel@tonic-gate #ifndef OPENSSL_NO_HMAC
165*0Sstevel@tonic-gate #include <openssl/hmac.h>
166*0Sstevel@tonic-gate #endif
167*0Sstevel@tonic-gate #include <openssl/evp.h>
168*0Sstevel@tonic-gate #ifndef OPENSSL_NO_SHA
169*0Sstevel@tonic-gate #include <openssl/sha.h>
170*0Sstevel@tonic-gate #endif
171*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RIPEMD
172*0Sstevel@tonic-gate #include <openssl/ripemd.h>
173*0Sstevel@tonic-gate #endif
174*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
175*0Sstevel@tonic-gate #include <openssl/rc4.h>
176*0Sstevel@tonic-gate #endif
177*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC5
178*0Sstevel@tonic-gate #include <openssl/rc5.h>
179*0Sstevel@tonic-gate #endif
180*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
181*0Sstevel@tonic-gate #include <openssl/rc2.h>
182*0Sstevel@tonic-gate #endif
183*0Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
184*0Sstevel@tonic-gate #include <openssl/idea.h>
185*0Sstevel@tonic-gate #endif
186*0Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
187*0Sstevel@tonic-gate #include <openssl/blowfish.h>
188*0Sstevel@tonic-gate #endif
189*0Sstevel@tonic-gate #ifndef OPENSSL_NO_CAST
190*0Sstevel@tonic-gate #include <openssl/cast.h>
191*0Sstevel@tonic-gate #endif
192*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
193*0Sstevel@tonic-gate #include <openssl/rsa.h>
194*0Sstevel@tonic-gate #include "./testrsa.h"
195*0Sstevel@tonic-gate #endif
196*0Sstevel@tonic-gate #include <openssl/x509.h>
197*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
198*0Sstevel@tonic-gate #include "./testdsa.h"
199*0Sstevel@tonic-gate #endif
200*0Sstevel@tonic-gate 
201*0Sstevel@tonic-gate /* The following if from times(3) man page.  It may need to be changed */
202*0Sstevel@tonic-gate #ifndef HZ
203*0Sstevel@tonic-gate # if defined(_SC_CLK_TCK) \
204*0Sstevel@tonic-gate      && (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000)
205*0Sstevel@tonic-gate #  define HZ ((double)sysconf(_SC_CLK_TCK))
206*0Sstevel@tonic-gate # else
207*0Sstevel@tonic-gate #  ifndef CLK_TCK
208*0Sstevel@tonic-gate #   ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
209*0Sstevel@tonic-gate #    define HZ	100.0
210*0Sstevel@tonic-gate #   else /* _BSD_CLK_TCK_ */
211*0Sstevel@tonic-gate #    define HZ ((double)_BSD_CLK_TCK_)
212*0Sstevel@tonic-gate #   endif
213*0Sstevel@tonic-gate #  else /* CLK_TCK */
214*0Sstevel@tonic-gate #   define HZ ((double)CLK_TCK)
215*0Sstevel@tonic-gate #  endif
216*0Sstevel@tonic-gate # endif
217*0Sstevel@tonic-gate #endif
218*0Sstevel@tonic-gate 
219*0Sstevel@tonic-gate #if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2)
220*0Sstevel@tonic-gate # define HAVE_FORK 1
221*0Sstevel@tonic-gate #endif
222*0Sstevel@tonic-gate 
223*0Sstevel@tonic-gate #undef BUFSIZE
224*0Sstevel@tonic-gate #define BUFSIZE	((long)1024*8+1)
225*0Sstevel@tonic-gate int run=0;
226*0Sstevel@tonic-gate 
227*0Sstevel@tonic-gate static char ftime_used = 0, times_used = 0, gettimeofday_used = 0, getrusage_used = 0;
228*0Sstevel@tonic-gate static int mr=0;
229*0Sstevel@tonic-gate static int usertime=1;
230*0Sstevel@tonic-gate 
231*0Sstevel@tonic-gate static double Time_F(int s);
232*0Sstevel@tonic-gate static void print_message(const char *s,long num,int length);
233*0Sstevel@tonic-gate static void pkey_print_message(char *str,char *str2,long num,int bits,int sec);
234*0Sstevel@tonic-gate static void print_result(int alg,int run_no,int count,double time_used);
235*0Sstevel@tonic-gate #ifdef HAVE_FORK
236*0Sstevel@tonic-gate static int do_multi(int multi);
237*0Sstevel@tonic-gate #endif
238*0Sstevel@tonic-gate 
239*0Sstevel@tonic-gate #define ALGOR_NUM	19
240*0Sstevel@tonic-gate #define SIZE_NUM	5
241*0Sstevel@tonic-gate #define RSA_NUM		4
242*0Sstevel@tonic-gate #define DSA_NUM		3
243*0Sstevel@tonic-gate static const char *names[ALGOR_NUM]={
244*0Sstevel@tonic-gate   "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4",
245*0Sstevel@tonic-gate   "des cbc","des ede3","idea cbc",
246*0Sstevel@tonic-gate   "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc",
247*0Sstevel@tonic-gate   "aes-128 cbc","aes-192 cbc","aes-256 cbc"};
248*0Sstevel@tonic-gate static double results[ALGOR_NUM][SIZE_NUM];
249*0Sstevel@tonic-gate static int lengths[SIZE_NUM]={16,64,256,1024,8*1024};
250*0Sstevel@tonic-gate static double rsa_results[RSA_NUM][2];
251*0Sstevel@tonic-gate static double dsa_results[DSA_NUM][2];
252*0Sstevel@tonic-gate 
253*0Sstevel@tonic-gate #ifdef SIGALRM
254*0Sstevel@tonic-gate #if defined(__STDC__) || defined(sgi) || defined(_AIX)
255*0Sstevel@tonic-gate #define SIGRETTYPE void
256*0Sstevel@tonic-gate #else
257*0Sstevel@tonic-gate #define SIGRETTYPE int
258*0Sstevel@tonic-gate #endif
259*0Sstevel@tonic-gate 
260*0Sstevel@tonic-gate static SIGRETTYPE sig_done(int sig);
261*0Sstevel@tonic-gate static SIGRETTYPE sig_done(int sig)
262*0Sstevel@tonic-gate 	{
263*0Sstevel@tonic-gate 	signal(SIGALRM,sig_done);
264*0Sstevel@tonic-gate 	run=0;
265*0Sstevel@tonic-gate #ifdef LINT
266*0Sstevel@tonic-gate 	sig=sig;
267*0Sstevel@tonic-gate #endif
268*0Sstevel@tonic-gate 	}
269*0Sstevel@tonic-gate #endif
270*0Sstevel@tonic-gate 
271*0Sstevel@tonic-gate #define START	0
272*0Sstevel@tonic-gate #define STOP	1
273*0Sstevel@tonic-gate 
274*0Sstevel@tonic-gate static double Time_F(int s)
275*0Sstevel@tonic-gate 	{
276*0Sstevel@tonic-gate 	double ret;
277*0Sstevel@tonic-gate 
278*0Sstevel@tonic-gate #ifdef USE_TOD
279*0Sstevel@tonic-gate 	if(usertime)
280*0Sstevel@tonic-gate 	    {
281*0Sstevel@tonic-gate 		static struct rusage tstart,tend;
282*0Sstevel@tonic-gate 
283*0Sstevel@tonic-gate 		getrusage_used = 1;
284*0Sstevel@tonic-gate 		if (s == START)
285*0Sstevel@tonic-gate 			{
286*0Sstevel@tonic-gate 			getrusage(RUSAGE_SELF,&tstart);
287*0Sstevel@tonic-gate 			return(0);
288*0Sstevel@tonic-gate 			}
289*0Sstevel@tonic-gate 		else
290*0Sstevel@tonic-gate 			{
291*0Sstevel@tonic-gate 			long i;
292*0Sstevel@tonic-gate 
293*0Sstevel@tonic-gate 			getrusage(RUSAGE_SELF,&tend);
294*0Sstevel@tonic-gate 			i=(long)tend.ru_utime.tv_usec-(long)tstart.ru_utime.tv_usec;
295*0Sstevel@tonic-gate 			ret=((double)(tend.ru_utime.tv_sec-tstart.ru_utime.tv_sec))
296*0Sstevel@tonic-gate 			  +((double)i)/1000000.0;
297*0Sstevel@tonic-gate 			return((ret < 0.001)?0.001:ret);
298*0Sstevel@tonic-gate 			}
299*0Sstevel@tonic-gate 		}
300*0Sstevel@tonic-gate 	else
301*0Sstevel@tonic-gate 		{
302*0Sstevel@tonic-gate 		static struct timeval tstart,tend;
303*0Sstevel@tonic-gate 		long i;
304*0Sstevel@tonic-gate 
305*0Sstevel@tonic-gate 		gettimeofday_used = 1;
306*0Sstevel@tonic-gate 		if (s == START)
307*0Sstevel@tonic-gate 			{
308*0Sstevel@tonic-gate 			gettimeofday(&tstart,NULL);
309*0Sstevel@tonic-gate 			return(0);
310*0Sstevel@tonic-gate 			}
311*0Sstevel@tonic-gate 		else
312*0Sstevel@tonic-gate 			{
313*0Sstevel@tonic-gate 			gettimeofday(&tend,NULL);
314*0Sstevel@tonic-gate 			i=(long)tend.tv_usec-(long)tstart.tv_usec;
315*0Sstevel@tonic-gate 			ret=((double)(tend.tv_sec-tstart.tv_sec))+((double)i)/1000000.0;
316*0Sstevel@tonic-gate 			return((ret < 0.001)?0.001:ret);
317*0Sstevel@tonic-gate 			}
318*0Sstevel@tonic-gate 		}
319*0Sstevel@tonic-gate #else  /* ndef USE_TOD */
320*0Sstevel@tonic-gate 
321*0Sstevel@tonic-gate # ifdef TIMES
322*0Sstevel@tonic-gate 	if (usertime)
323*0Sstevel@tonic-gate 		{
324*0Sstevel@tonic-gate 		static struct tms tstart,tend;
325*0Sstevel@tonic-gate 
326*0Sstevel@tonic-gate 		times_used = 1;
327*0Sstevel@tonic-gate 		if (s == START)
328*0Sstevel@tonic-gate 			{
329*0Sstevel@tonic-gate 			times(&tstart);
330*0Sstevel@tonic-gate 			return(0);
331*0Sstevel@tonic-gate 			}
332*0Sstevel@tonic-gate 		else
333*0Sstevel@tonic-gate 			{
334*0Sstevel@tonic-gate 			times(&tend);
335*0Sstevel@tonic-gate 			ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
336*0Sstevel@tonic-gate 			return((ret < 1e-3)?1e-3:ret);
337*0Sstevel@tonic-gate 			}
338*0Sstevel@tonic-gate 		}
339*0Sstevel@tonic-gate # endif /* times() */
340*0Sstevel@tonic-gate # if defined(TIMES) && defined(TIMEB)
341*0Sstevel@tonic-gate 	else
342*0Sstevel@tonic-gate # endif
343*0Sstevel@tonic-gate # ifdef OPENSSL_SYS_VXWORKS
344*0Sstevel@tonic-gate                 {
345*0Sstevel@tonic-gate 		static unsigned long tick_start, tick_end;
346*0Sstevel@tonic-gate 
347*0Sstevel@tonic-gate 		if( s == START )
348*0Sstevel@tonic-gate 			{
349*0Sstevel@tonic-gate 			tick_start = tickGet();
350*0Sstevel@tonic-gate 			return 0;
351*0Sstevel@tonic-gate 			}
352*0Sstevel@tonic-gate 		else
353*0Sstevel@tonic-gate 			{
354*0Sstevel@tonic-gate 			tick_end = tickGet();
355*0Sstevel@tonic-gate 			ret = (double)(tick_end - tick_start) / (double)sysClkRateGet();
356*0Sstevel@tonic-gate 			return((ret < 0.001)?0.001:ret);
357*0Sstevel@tonic-gate 			}
358*0Sstevel@tonic-gate                 }
359*0Sstevel@tonic-gate # elif defined(TIMEB)
360*0Sstevel@tonic-gate 		{
361*0Sstevel@tonic-gate 		static struct timeb tstart,tend;
362*0Sstevel@tonic-gate 		long i;
363*0Sstevel@tonic-gate 
364*0Sstevel@tonic-gate 		ftime_used = 1;
365*0Sstevel@tonic-gate 		if (s == START)
366*0Sstevel@tonic-gate 			{
367*0Sstevel@tonic-gate 			ftime(&tstart);
368*0Sstevel@tonic-gate 			return(0);
369*0Sstevel@tonic-gate 			}
370*0Sstevel@tonic-gate 		else
371*0Sstevel@tonic-gate 			{
372*0Sstevel@tonic-gate 			ftime(&tend);
373*0Sstevel@tonic-gate 			i=(long)tend.millitm-(long)tstart.millitm;
374*0Sstevel@tonic-gate 			ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
375*0Sstevel@tonic-gate 			return((ret < 0.001)?0.001:ret);
376*0Sstevel@tonic-gate 			}
377*0Sstevel@tonic-gate 		}
378*0Sstevel@tonic-gate # endif
379*0Sstevel@tonic-gate #endif
380*0Sstevel@tonic-gate 	}
381*0Sstevel@tonic-gate 
382*0Sstevel@tonic-gate int MAIN(int, char **);
383*0Sstevel@tonic-gate 
384*0Sstevel@tonic-gate int MAIN(int argc, char **argv)
385*0Sstevel@tonic-gate 	{
386*0Sstevel@tonic-gate #ifndef OPENSSL_NO_ENGINE
387*0Sstevel@tonic-gate 	ENGINE *e = NULL;
388*0Sstevel@tonic-gate #endif
389*0Sstevel@tonic-gate 	unsigned char *buf=NULL,*buf2=NULL;
390*0Sstevel@tonic-gate 	int mret=1;
391*0Sstevel@tonic-gate 	long count=0,save_count=0;
392*0Sstevel@tonic-gate 	int i,j,k;
393*0Sstevel@tonic-gate #if !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_DSA)
394*0Sstevel@tonic-gate 	long rsa_count;
395*0Sstevel@tonic-gate #endif
396*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
397*0Sstevel@tonic-gate 	unsigned rsa_num;
398*0Sstevel@tonic-gate #endif
399*0Sstevel@tonic-gate 	unsigned char md[EVP_MAX_MD_SIZE];
400*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD2
401*0Sstevel@tonic-gate 	unsigned char md2[MD2_DIGEST_LENGTH];
402*0Sstevel@tonic-gate #endif
403*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MDC2
404*0Sstevel@tonic-gate 	unsigned char mdc2[MDC2_DIGEST_LENGTH];
405*0Sstevel@tonic-gate #endif
406*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD4
407*0Sstevel@tonic-gate 	unsigned char md4[MD4_DIGEST_LENGTH];
408*0Sstevel@tonic-gate #endif
409*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD5
410*0Sstevel@tonic-gate 	unsigned char md5[MD5_DIGEST_LENGTH];
411*0Sstevel@tonic-gate 	unsigned char hmac[MD5_DIGEST_LENGTH];
412*0Sstevel@tonic-gate #endif
413*0Sstevel@tonic-gate #ifndef OPENSSL_NO_SHA
414*0Sstevel@tonic-gate 	unsigned char sha[SHA_DIGEST_LENGTH];
415*0Sstevel@tonic-gate #endif
416*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RIPEMD
417*0Sstevel@tonic-gate 	unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];
418*0Sstevel@tonic-gate #endif
419*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
420*0Sstevel@tonic-gate 	RC4_KEY rc4_ks;
421*0Sstevel@tonic-gate #endif
422*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC5
423*0Sstevel@tonic-gate 	RC5_32_KEY rc5_ks;
424*0Sstevel@tonic-gate #endif
425*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
426*0Sstevel@tonic-gate 	RC2_KEY rc2_ks;
427*0Sstevel@tonic-gate #endif
428*0Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
429*0Sstevel@tonic-gate 	IDEA_KEY_SCHEDULE idea_ks;
430*0Sstevel@tonic-gate #endif
431*0Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
432*0Sstevel@tonic-gate 	BF_KEY bf_ks;
433*0Sstevel@tonic-gate #endif
434*0Sstevel@tonic-gate #ifndef OPENSSL_NO_CAST
435*0Sstevel@tonic-gate 	CAST_KEY cast_ks;
436*0Sstevel@tonic-gate #endif
437*0Sstevel@tonic-gate 	static const unsigned char key16[16]=
438*0Sstevel@tonic-gate 		{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
439*0Sstevel@tonic-gate 		 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
440*0Sstevel@tonic-gate 	static const unsigned char key24[24]=
441*0Sstevel@tonic-gate 		{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
442*0Sstevel@tonic-gate 		 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
443*0Sstevel@tonic-gate 		 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
444*0Sstevel@tonic-gate 	static const unsigned char key32[32]=
445*0Sstevel@tonic-gate 		{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
446*0Sstevel@tonic-gate 		 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
447*0Sstevel@tonic-gate 		 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,
448*0Sstevel@tonic-gate 		 0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56};
449*0Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
450*0Sstevel@tonic-gate #define MAX_BLOCK_SIZE 128
451*0Sstevel@tonic-gate #else
452*0Sstevel@tonic-gate #define MAX_BLOCK_SIZE 64
453*0Sstevel@tonic-gate #endif
454*0Sstevel@tonic-gate 	unsigned char DES_iv[8];
455*0Sstevel@tonic-gate 	unsigned char iv[MAX_BLOCK_SIZE/8];
456*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
457*0Sstevel@tonic-gate 	DES_cblock *buf_as_des_cblock = NULL;
458*0Sstevel@tonic-gate 	static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
459*0Sstevel@tonic-gate 	static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
460*0Sstevel@tonic-gate 	static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
461*0Sstevel@tonic-gate 	DES_key_schedule sch;
462*0Sstevel@tonic-gate 	DES_key_schedule sch2;
463*0Sstevel@tonic-gate 	DES_key_schedule sch3;
464*0Sstevel@tonic-gate #endif
465*0Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
466*0Sstevel@tonic-gate 	AES_KEY aes_ks1, aes_ks2, aes_ks3;
467*0Sstevel@tonic-gate #endif
468*0Sstevel@tonic-gate #define	D_MD2		0
469*0Sstevel@tonic-gate #define	D_MDC2		1
470*0Sstevel@tonic-gate #define	D_MD4		2
471*0Sstevel@tonic-gate #define	D_MD5		3
472*0Sstevel@tonic-gate #define	D_HMAC		4
473*0Sstevel@tonic-gate #define	D_SHA1		5
474*0Sstevel@tonic-gate #define D_RMD160	6
475*0Sstevel@tonic-gate #define	D_RC4		7
476*0Sstevel@tonic-gate #define	D_CBC_DES	8
477*0Sstevel@tonic-gate #define	D_EDE3_DES	9
478*0Sstevel@tonic-gate #define	D_CBC_IDEA	10
479*0Sstevel@tonic-gate #define	D_CBC_RC2	11
480*0Sstevel@tonic-gate #define	D_CBC_RC5	12
481*0Sstevel@tonic-gate #define	D_CBC_BF	13
482*0Sstevel@tonic-gate #define	D_CBC_CAST	14
483*0Sstevel@tonic-gate #define D_CBC_128_AES	15
484*0Sstevel@tonic-gate #define D_CBC_192_AES	16
485*0Sstevel@tonic-gate #define D_CBC_256_AES	17
486*0Sstevel@tonic-gate #define D_EVP		18
487*0Sstevel@tonic-gate 	double d=0.0;
488*0Sstevel@tonic-gate 	long c[ALGOR_NUM][SIZE_NUM];
489*0Sstevel@tonic-gate #define	R_DSA_512	0
490*0Sstevel@tonic-gate #define	R_DSA_1024	1
491*0Sstevel@tonic-gate #define	R_DSA_2048	2
492*0Sstevel@tonic-gate #define	R_RSA_512	0
493*0Sstevel@tonic-gate #define	R_RSA_1024	1
494*0Sstevel@tonic-gate #define	R_RSA_2048	2
495*0Sstevel@tonic-gate #define	R_RSA_4096	3
496*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
497*0Sstevel@tonic-gate 	RSA *rsa_key[RSA_NUM];
498*0Sstevel@tonic-gate 	long rsa_c[RSA_NUM][2];
499*0Sstevel@tonic-gate 	static unsigned int rsa_bits[RSA_NUM]={512,1024,2048,4096};
500*0Sstevel@tonic-gate 	static unsigned char *rsa_data[RSA_NUM]=
501*0Sstevel@tonic-gate 		{test512,test1024,test2048,test4096};
502*0Sstevel@tonic-gate 	static int rsa_data_length[RSA_NUM]={
503*0Sstevel@tonic-gate 		sizeof(test512),sizeof(test1024),
504*0Sstevel@tonic-gate 		sizeof(test2048),sizeof(test4096)};
505*0Sstevel@tonic-gate #endif
506*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
507*0Sstevel@tonic-gate 	DSA *dsa_key[DSA_NUM];
508*0Sstevel@tonic-gate 	long dsa_c[DSA_NUM][2];
509*0Sstevel@tonic-gate 	static unsigned int dsa_bits[DSA_NUM]={512,1024,2048};
510*0Sstevel@tonic-gate #endif
511*0Sstevel@tonic-gate 	int rsa_doit[RSA_NUM];
512*0Sstevel@tonic-gate 	int dsa_doit[DSA_NUM];
513*0Sstevel@tonic-gate 	int doit[ALGOR_NUM];
514*0Sstevel@tonic-gate 	int pr_header=0;
515*0Sstevel@tonic-gate 	const EVP_CIPHER *evp_cipher=NULL;
516*0Sstevel@tonic-gate 	const EVP_MD *evp_md=NULL;
517*0Sstevel@tonic-gate 	int decrypt=0;
518*0Sstevel@tonic-gate #ifdef HAVE_FORK
519*0Sstevel@tonic-gate 	int multi=0;
520*0Sstevel@tonic-gate #endif
521*0Sstevel@tonic-gate 
522*0Sstevel@tonic-gate #ifndef TIMES
523*0Sstevel@tonic-gate 	usertime=-1;
524*0Sstevel@tonic-gate #endif
525*0Sstevel@tonic-gate 
526*0Sstevel@tonic-gate 	apps_startup();
527*0Sstevel@tonic-gate 	memset(results, 0, sizeof(results));
528*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
529*0Sstevel@tonic-gate 	memset(dsa_key,0,sizeof(dsa_key));
530*0Sstevel@tonic-gate #endif
531*0Sstevel@tonic-gate 
532*0Sstevel@tonic-gate 	if (bio_err == NULL)
533*0Sstevel@tonic-gate 		if ((bio_err=BIO_new(BIO_s_file())) != NULL)
534*0Sstevel@tonic-gate 			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
535*0Sstevel@tonic-gate 
536*0Sstevel@tonic-gate 	if (!load_config(bio_err, NULL))
537*0Sstevel@tonic-gate 		goto end;
538*0Sstevel@tonic-gate 
539*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
540*0Sstevel@tonic-gate 	memset(rsa_key,0,sizeof(rsa_key));
541*0Sstevel@tonic-gate 	for (i=0; i<RSA_NUM; i++)
542*0Sstevel@tonic-gate 		rsa_key[i]=NULL;
543*0Sstevel@tonic-gate #endif
544*0Sstevel@tonic-gate 
545*0Sstevel@tonic-gate 	if ((buf=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
546*0Sstevel@tonic-gate 		{
547*0Sstevel@tonic-gate 		BIO_printf(bio_err,"out of memory\n");
548*0Sstevel@tonic-gate 		goto end;
549*0Sstevel@tonic-gate 		}
550*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
551*0Sstevel@tonic-gate 	buf_as_des_cblock = (DES_cblock *)buf;
552*0Sstevel@tonic-gate #endif
553*0Sstevel@tonic-gate 	if ((buf2=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
554*0Sstevel@tonic-gate 		{
555*0Sstevel@tonic-gate 		BIO_printf(bio_err,"out of memory\n");
556*0Sstevel@tonic-gate 		goto end;
557*0Sstevel@tonic-gate 		}
558*0Sstevel@tonic-gate 
559*0Sstevel@tonic-gate 	memset(c,0,sizeof(c));
560*0Sstevel@tonic-gate 	memset(DES_iv,0,sizeof(DES_iv));
561*0Sstevel@tonic-gate 	memset(iv,0,sizeof(iv));
562*0Sstevel@tonic-gate 
563*0Sstevel@tonic-gate 	for (i=0; i<ALGOR_NUM; i++)
564*0Sstevel@tonic-gate 		doit[i]=0;
565*0Sstevel@tonic-gate 	for (i=0; i<RSA_NUM; i++)
566*0Sstevel@tonic-gate 		rsa_doit[i]=0;
567*0Sstevel@tonic-gate 	for (i=0; i<DSA_NUM; i++)
568*0Sstevel@tonic-gate 		dsa_doit[i]=0;
569*0Sstevel@tonic-gate 
570*0Sstevel@tonic-gate 	j=0;
571*0Sstevel@tonic-gate 	argc--;
572*0Sstevel@tonic-gate 	argv++;
573*0Sstevel@tonic-gate 	while (argc)
574*0Sstevel@tonic-gate 		{
575*0Sstevel@tonic-gate 		if	((argc > 0) && (strcmp(*argv,"-elapsed") == 0))
576*0Sstevel@tonic-gate 			{
577*0Sstevel@tonic-gate 			usertime = 0;
578*0Sstevel@tonic-gate 			j--;	/* Otherwise, -elapsed gets confused with
579*0Sstevel@tonic-gate 				   an algorithm. */
580*0Sstevel@tonic-gate 			}
581*0Sstevel@tonic-gate 		else if	((argc > 0) && (strcmp(*argv,"-evp") == 0))
582*0Sstevel@tonic-gate 			{
583*0Sstevel@tonic-gate 			argc--;
584*0Sstevel@tonic-gate 			argv++;
585*0Sstevel@tonic-gate 			if(argc == 0)
586*0Sstevel@tonic-gate 				{
587*0Sstevel@tonic-gate 				BIO_printf(bio_err,"no EVP given\n");
588*0Sstevel@tonic-gate 				goto end;
589*0Sstevel@tonic-gate 				}
590*0Sstevel@tonic-gate 			evp_cipher=EVP_get_cipherbyname(*argv);
591*0Sstevel@tonic-gate 			if(!evp_cipher)
592*0Sstevel@tonic-gate 				{
593*0Sstevel@tonic-gate 				evp_md=EVP_get_digestbyname(*argv);
594*0Sstevel@tonic-gate 				}
595*0Sstevel@tonic-gate 			if(!evp_cipher && !evp_md)
596*0Sstevel@tonic-gate 				{
597*0Sstevel@tonic-gate 				BIO_printf(bio_err,"%s is an unknown cipher or digest\n",*argv);
598*0Sstevel@tonic-gate 				goto end;
599*0Sstevel@tonic-gate 				}
600*0Sstevel@tonic-gate 			doit[D_EVP]=1;
601*0Sstevel@tonic-gate 			}
602*0Sstevel@tonic-gate 		else if (argc > 0 && !strcmp(*argv,"-decrypt"))
603*0Sstevel@tonic-gate 			{
604*0Sstevel@tonic-gate 			decrypt=1;
605*0Sstevel@tonic-gate 			j--;	/* Otherwise, -elapsed gets confused with
606*0Sstevel@tonic-gate 				   an algorithm. */
607*0Sstevel@tonic-gate 			}
608*0Sstevel@tonic-gate #ifndef OPENSSL_NO_ENGINE
609*0Sstevel@tonic-gate 		else if	((argc > 0) && (strcmp(*argv,"-engine") == 0))
610*0Sstevel@tonic-gate 			{
611*0Sstevel@tonic-gate 			argc--;
612*0Sstevel@tonic-gate 			argv++;
613*0Sstevel@tonic-gate 			if(argc == 0)
614*0Sstevel@tonic-gate 				{
615*0Sstevel@tonic-gate 				BIO_printf(bio_err,"no engine given\n");
616*0Sstevel@tonic-gate 				goto end;
617*0Sstevel@tonic-gate 				}
618*0Sstevel@tonic-gate                         e = setup_engine(bio_err, *argv, 0);
619*0Sstevel@tonic-gate 			/* j will be increased again further down.  We just
620*0Sstevel@tonic-gate 			   don't want speed to confuse an engine with an
621*0Sstevel@tonic-gate 			   algorithm, especially when none is given (which
622*0Sstevel@tonic-gate 			   means all of them should be run) */
623*0Sstevel@tonic-gate 			j--;
624*0Sstevel@tonic-gate 			}
625*0Sstevel@tonic-gate #endif
626*0Sstevel@tonic-gate #ifdef HAVE_FORK
627*0Sstevel@tonic-gate 		else if	((argc > 0) && (strcmp(*argv,"-multi") == 0))
628*0Sstevel@tonic-gate 			{
629*0Sstevel@tonic-gate 			argc--;
630*0Sstevel@tonic-gate 			argv++;
631*0Sstevel@tonic-gate 			if(argc == 0)
632*0Sstevel@tonic-gate 				{
633*0Sstevel@tonic-gate 				BIO_printf(bio_err,"no multi count given\n");
634*0Sstevel@tonic-gate 				goto end;
635*0Sstevel@tonic-gate 				}
636*0Sstevel@tonic-gate 			multi=atoi(argv[0]);
637*0Sstevel@tonic-gate 			if(multi <= 0)
638*0Sstevel@tonic-gate 			    {
639*0Sstevel@tonic-gate 				BIO_printf(bio_err,"bad multi count\n");
640*0Sstevel@tonic-gate 				goto end;
641*0Sstevel@tonic-gate 				}
642*0Sstevel@tonic-gate 			j--;	/* Otherwise, -mr gets confused with
643*0Sstevel@tonic-gate 				   an algorithm. */
644*0Sstevel@tonic-gate 			}
645*0Sstevel@tonic-gate #endif
646*0Sstevel@tonic-gate 		else if (argc > 0 && !strcmp(*argv,"-mr"))
647*0Sstevel@tonic-gate 			{
648*0Sstevel@tonic-gate 			mr=1;
649*0Sstevel@tonic-gate 			j--;	/* Otherwise, -mr gets confused with
650*0Sstevel@tonic-gate 				   an algorithm. */
651*0Sstevel@tonic-gate 			}
652*0Sstevel@tonic-gate 		else
653*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD2
654*0Sstevel@tonic-gate 		if	(strcmp(*argv,"md2") == 0) doit[D_MD2]=1;
655*0Sstevel@tonic-gate 		else
656*0Sstevel@tonic-gate #endif
657*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MDC2
658*0Sstevel@tonic-gate 			if (strcmp(*argv,"mdc2") == 0) doit[D_MDC2]=1;
659*0Sstevel@tonic-gate 		else
660*0Sstevel@tonic-gate #endif
661*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD4
662*0Sstevel@tonic-gate 			if (strcmp(*argv,"md4") == 0) doit[D_MD4]=1;
663*0Sstevel@tonic-gate 		else
664*0Sstevel@tonic-gate #endif
665*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD5
666*0Sstevel@tonic-gate 			if (strcmp(*argv,"md5") == 0) doit[D_MD5]=1;
667*0Sstevel@tonic-gate 		else
668*0Sstevel@tonic-gate #endif
669*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD5
670*0Sstevel@tonic-gate 			if (strcmp(*argv,"hmac") == 0) doit[D_HMAC]=1;
671*0Sstevel@tonic-gate 		else
672*0Sstevel@tonic-gate #endif
673*0Sstevel@tonic-gate #ifndef OPENSSL_NO_SHA
674*0Sstevel@tonic-gate 			if (strcmp(*argv,"sha1") == 0) doit[D_SHA1]=1;
675*0Sstevel@tonic-gate 		else
676*0Sstevel@tonic-gate 			if (strcmp(*argv,"sha") == 0) doit[D_SHA1]=1;
677*0Sstevel@tonic-gate 		else
678*0Sstevel@tonic-gate #endif
679*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RIPEMD
680*0Sstevel@tonic-gate 			if (strcmp(*argv,"ripemd") == 0) doit[D_RMD160]=1;
681*0Sstevel@tonic-gate 		else
682*0Sstevel@tonic-gate 			if (strcmp(*argv,"rmd160") == 0) doit[D_RMD160]=1;
683*0Sstevel@tonic-gate 		else
684*0Sstevel@tonic-gate 			if (strcmp(*argv,"ripemd160") == 0) doit[D_RMD160]=1;
685*0Sstevel@tonic-gate 		else
686*0Sstevel@tonic-gate #endif
687*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
688*0Sstevel@tonic-gate 			if (strcmp(*argv,"rc4") == 0) doit[D_RC4]=1;
689*0Sstevel@tonic-gate 		else
690*0Sstevel@tonic-gate #endif
691*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
692*0Sstevel@tonic-gate 			if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1;
693*0Sstevel@tonic-gate 		else	if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1;
694*0Sstevel@tonic-gate 		else
695*0Sstevel@tonic-gate #endif
696*0Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
697*0Sstevel@tonic-gate 			if (strcmp(*argv,"aes-128-cbc") == 0) doit[D_CBC_128_AES]=1;
698*0Sstevel@tonic-gate #ifdef SOLARIS_OPENSSL
699*0Sstevel@tonic-gate 		else	if (strcmp(*argv,"aes-192-cbc") == 0)
700*0Sstevel@tonic-gate 				if (!SUNWcry_installed())
701*0Sstevel@tonic-gate 					{
702*0Sstevel@tonic-gate 					BIO_printf(bio_err,
703*0Sstevel@tonic-gate 					  "aes-192-cbc not available."
704*0Sstevel@tonic-gate 					  " SUNWcry not installed.\n");
705*0Sstevel@tonic-gate 					goto end;
706*0Sstevel@tonic-gate 					}
707*0Sstevel@tonic-gate 				else
708*0Sstevel@tonic-gate 					doit[D_CBC_192_AES]=1;
709*0Sstevel@tonic-gate 		else	if (strcmp(*argv,"aes-256-cbc") == 0)
710*0Sstevel@tonic-gate 				if (!SUNWcry_installed())
711*0Sstevel@tonic-gate 					{
712*0Sstevel@tonic-gate 					BIO_printf(bio_err,
713*0Sstevel@tonic-gate 					  "aes-256-cbc not available."
714*0Sstevel@tonic-gate 					  " SUNWcry not installed.\n");
715*0Sstevel@tonic-gate 					goto end;
716*0Sstevel@tonic-gate 					}
717*0Sstevel@tonic-gate 				else
718*0Sstevel@tonic-gate 					doit[D_CBC_256_AES]=1;
719*0Sstevel@tonic-gate #else
720*0Sstevel@tonic-gate 		else	if (strcmp(*argv,"aes-192-cbc") == 0) doit[D_CBC_192_AES]=1;
721*0Sstevel@tonic-gate 		else	if (strcmp(*argv,"aes-256-cbc") == 0) doit[D_CBC_256_AES]=1;
722*0Sstevel@tonic-gate #endif
723*0Sstevel@tonic-gate 		else
724*0Sstevel@tonic-gate #endif
725*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
726*0Sstevel@tonic-gate #if 0 /* was: #ifdef RSAref */
727*0Sstevel@tonic-gate 			if (strcmp(*argv,"rsaref") == 0)
728*0Sstevel@tonic-gate 			{
729*0Sstevel@tonic-gate 			RSA_set_default_openssl_method(RSA_PKCS1_RSAref());
730*0Sstevel@tonic-gate 			j--;
731*0Sstevel@tonic-gate 			}
732*0Sstevel@tonic-gate 		else
733*0Sstevel@tonic-gate #endif
734*0Sstevel@tonic-gate #ifndef RSA_NULL
735*0Sstevel@tonic-gate 			if (strcmp(*argv,"openssl") == 0)
736*0Sstevel@tonic-gate 			{
737*0Sstevel@tonic-gate 			RSA_set_default_method(RSA_PKCS1_SSLeay());
738*0Sstevel@tonic-gate 			j--;
739*0Sstevel@tonic-gate 			}
740*0Sstevel@tonic-gate 		else
741*0Sstevel@tonic-gate #endif
742*0Sstevel@tonic-gate #endif /* !OPENSSL_NO_RSA */
743*0Sstevel@tonic-gate 		     if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2;
744*0Sstevel@tonic-gate 		else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2;
745*0Sstevel@tonic-gate 		else if (strcmp(*argv,"dsa2048") == 0) dsa_doit[R_DSA_2048]=2;
746*0Sstevel@tonic-gate 		else if (strcmp(*argv,"rsa512") == 0) rsa_doit[R_RSA_512]=2;
747*0Sstevel@tonic-gate 		else if (strcmp(*argv,"rsa1024") == 0) rsa_doit[R_RSA_1024]=2;
748*0Sstevel@tonic-gate 		else if (strcmp(*argv,"rsa2048") == 0) rsa_doit[R_RSA_2048]=2;
749*0Sstevel@tonic-gate 		else if (strcmp(*argv,"rsa4096") == 0) rsa_doit[R_RSA_4096]=2;
750*0Sstevel@tonic-gate 		else
751*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
752*0Sstevel@tonic-gate 		     if (strcmp(*argv,"rc2-cbc") == 0) doit[D_CBC_RC2]=1;
753*0Sstevel@tonic-gate 		else if (strcmp(*argv,"rc2") == 0) doit[D_CBC_RC2]=1;
754*0Sstevel@tonic-gate 		else
755*0Sstevel@tonic-gate #endif
756*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC5
757*0Sstevel@tonic-gate 		     if (strcmp(*argv,"rc5-cbc") == 0) doit[D_CBC_RC5]=1;
758*0Sstevel@tonic-gate 		else if (strcmp(*argv,"rc5") == 0) doit[D_CBC_RC5]=1;
759*0Sstevel@tonic-gate 		else
760*0Sstevel@tonic-gate #endif
761*0Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
762*0Sstevel@tonic-gate 		     if (strcmp(*argv,"idea-cbc") == 0) doit[D_CBC_IDEA]=1;
763*0Sstevel@tonic-gate 		else if (strcmp(*argv,"idea") == 0) doit[D_CBC_IDEA]=1;
764*0Sstevel@tonic-gate 		else
765*0Sstevel@tonic-gate #endif
766*0Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
767*0Sstevel@tonic-gate 		     if (strcmp(*argv,"bf-cbc") == 0) doit[D_CBC_BF]=1;
768*0Sstevel@tonic-gate 		else if (strcmp(*argv,"blowfish") == 0) doit[D_CBC_BF]=1;
769*0Sstevel@tonic-gate 		else if (strcmp(*argv,"bf") == 0) doit[D_CBC_BF]=1;
770*0Sstevel@tonic-gate 		else
771*0Sstevel@tonic-gate #endif
772*0Sstevel@tonic-gate #ifndef OPENSSL_NO_CAST
773*0Sstevel@tonic-gate 		     if (strcmp(*argv,"cast-cbc") == 0) doit[D_CBC_CAST]=1;
774*0Sstevel@tonic-gate 		else if (strcmp(*argv,"cast") == 0) doit[D_CBC_CAST]=1;
775*0Sstevel@tonic-gate 		else if (strcmp(*argv,"cast5") == 0) doit[D_CBC_CAST]=1;
776*0Sstevel@tonic-gate 		else
777*0Sstevel@tonic-gate #endif
778*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
779*0Sstevel@tonic-gate 			if (strcmp(*argv,"des") == 0)
780*0Sstevel@tonic-gate 			{
781*0Sstevel@tonic-gate 			doit[D_CBC_DES]=1;
782*0Sstevel@tonic-gate 			doit[D_EDE3_DES]=1;
783*0Sstevel@tonic-gate 			}
784*0Sstevel@tonic-gate 		else
785*0Sstevel@tonic-gate #endif
786*0Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
787*0Sstevel@tonic-gate 			if (strcmp(*argv,"aes") == 0)
788*0Sstevel@tonic-gate 			{
789*0Sstevel@tonic-gate 			doit[D_CBC_128_AES]=1;
790*0Sstevel@tonic-gate #ifdef SOLARIS_OPENSSL
791*0Sstevel@tonic-gate 			doit[D_CBC_192_AES]= SUNWcry_installed();
792*0Sstevel@tonic-gate 			doit[D_CBC_256_AES]= SUNWcry_installed();
793*0Sstevel@tonic-gate #else
794*0Sstevel@tonic-gate 			doit[D_CBC_192_AES]=1;
795*0Sstevel@tonic-gate 			doit[D_CBC_256_AES]=1;
796*0Sstevel@tonic-gate #endif
797*0Sstevel@tonic-gate 			}
798*0Sstevel@tonic-gate 		else
799*0Sstevel@tonic-gate #endif
800*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
801*0Sstevel@tonic-gate 			if (strcmp(*argv,"rsa") == 0)
802*0Sstevel@tonic-gate 			{
803*0Sstevel@tonic-gate 			rsa_doit[R_RSA_512]=1;
804*0Sstevel@tonic-gate 			rsa_doit[R_RSA_1024]=1;
805*0Sstevel@tonic-gate 			rsa_doit[R_RSA_2048]=1;
806*0Sstevel@tonic-gate 			rsa_doit[R_RSA_4096]=1;
807*0Sstevel@tonic-gate 			}
808*0Sstevel@tonic-gate 		else
809*0Sstevel@tonic-gate #endif
810*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
811*0Sstevel@tonic-gate 			if (strcmp(*argv,"dsa") == 0)
812*0Sstevel@tonic-gate 			{
813*0Sstevel@tonic-gate 			dsa_doit[R_DSA_512]=1;
814*0Sstevel@tonic-gate 			dsa_doit[R_DSA_1024]=1;
815*0Sstevel@tonic-gate 			dsa_doit[R_DSA_2048]=1;
816*0Sstevel@tonic-gate 			}
817*0Sstevel@tonic-gate 		else
818*0Sstevel@tonic-gate #endif
819*0Sstevel@tonic-gate 			{
820*0Sstevel@tonic-gate 			BIO_printf(bio_err,"Error: bad option or value\n");
821*0Sstevel@tonic-gate 			BIO_printf(bio_err,"\n");
822*0Sstevel@tonic-gate 			BIO_printf(bio_err,"Available values:\n");
823*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD2
824*0Sstevel@tonic-gate 			BIO_printf(bio_err,"md2      ");
825*0Sstevel@tonic-gate #endif
826*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MDC2
827*0Sstevel@tonic-gate 			BIO_printf(bio_err,"mdc2     ");
828*0Sstevel@tonic-gate #endif
829*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD4
830*0Sstevel@tonic-gate 			BIO_printf(bio_err,"md4      ");
831*0Sstevel@tonic-gate #endif
832*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD5
833*0Sstevel@tonic-gate 			BIO_printf(bio_err,"md5      ");
834*0Sstevel@tonic-gate #ifndef OPENSSL_NO_HMAC
835*0Sstevel@tonic-gate 			BIO_printf(bio_err,"hmac     ");
836*0Sstevel@tonic-gate #endif
837*0Sstevel@tonic-gate #endif
838*0Sstevel@tonic-gate #ifndef OPENSSL_NO_SHA1
839*0Sstevel@tonic-gate 			BIO_printf(bio_err,"sha1     ");
840*0Sstevel@tonic-gate #endif
841*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RIPEMD160
842*0Sstevel@tonic-gate 			BIO_printf(bio_err,"rmd160");
843*0Sstevel@tonic-gate #endif
844*0Sstevel@tonic-gate #if !defined(OPENSSL_NO_MD2) || !defined(OPENSSL_NO_MDC2) || \
845*0Sstevel@tonic-gate     !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \
846*0Sstevel@tonic-gate     !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160)
847*0Sstevel@tonic-gate 			BIO_printf(bio_err,"\n");
848*0Sstevel@tonic-gate #endif
849*0Sstevel@tonic-gate 
850*0Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
851*0Sstevel@tonic-gate 			BIO_printf(bio_err,"idea-cbc ");
852*0Sstevel@tonic-gate #endif
853*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
854*0Sstevel@tonic-gate 			BIO_printf(bio_err,"rc2-cbc  ");
855*0Sstevel@tonic-gate #endif
856*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC5
857*0Sstevel@tonic-gate 			BIO_printf(bio_err,"rc5-cbc  ");
858*0Sstevel@tonic-gate #endif
859*0Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
860*0Sstevel@tonic-gate 			BIO_printf(bio_err,"bf-cbc");
861*0Sstevel@tonic-gate #endif
862*0Sstevel@tonic-gate #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
863*0Sstevel@tonic-gate     !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_RC5)
864*0Sstevel@tonic-gate 			BIO_printf(bio_err,"\n");
865*0Sstevel@tonic-gate #endif
866*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
867*0Sstevel@tonic-gate 			BIO_printf(bio_err,"des-cbc  des-ede3 ");
868*0Sstevel@tonic-gate #endif
869*0Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
870*0Sstevel@tonic-gate #ifdef SOLARIS_OPENSSL
871*0Sstevel@tonic-gate 			if (SUNWcry_installed())
872*0Sstevel@tonic-gate 				BIO_printf(bio_err,
873*0Sstevel@tonic-gate 				  "aes-128-cbc aes-192-cbc aes-256-cbc ");
874*0Sstevel@tonic-gate 			else
875*0Sstevel@tonic-gate 				BIO_printf(bio_err, "aes-128-cbc ");
876*0Sstevel@tonic-gate #else
877*0Sstevel@tonic-gate 			BIO_printf(bio_err,"aes-128-cbc aes-192-cbc aes-256-cbc ");
878*0Sstevel@tonic-gate #endif
879*0Sstevel@tonic-gate #endif
880*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
881*0Sstevel@tonic-gate 			BIO_printf(bio_err,"rc4");
882*0Sstevel@tonic-gate #endif
883*0Sstevel@tonic-gate 			BIO_printf(bio_err,"\n");
884*0Sstevel@tonic-gate 
885*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
886*0Sstevel@tonic-gate 			BIO_printf(bio_err,"rsa512   rsa1024  rsa2048  rsa4096\n");
887*0Sstevel@tonic-gate #endif
888*0Sstevel@tonic-gate 
889*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
890*0Sstevel@tonic-gate 			BIO_printf(bio_err,"dsa512   dsa1024  dsa2048\n");
891*0Sstevel@tonic-gate #endif
892*0Sstevel@tonic-gate 
893*0Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
894*0Sstevel@tonic-gate 			BIO_printf(bio_err,"idea     ");
895*0Sstevel@tonic-gate #endif
896*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
897*0Sstevel@tonic-gate 			BIO_printf(bio_err,"rc2      ");
898*0Sstevel@tonic-gate #endif
899*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
900*0Sstevel@tonic-gate 			BIO_printf(bio_err,"des      ");
901*0Sstevel@tonic-gate #endif
902*0Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
903*0Sstevel@tonic-gate 			BIO_printf(bio_err,"aes      ");
904*0Sstevel@tonic-gate #endif
905*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
906*0Sstevel@tonic-gate 			BIO_printf(bio_err,"rsa      ");
907*0Sstevel@tonic-gate #endif
908*0Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
909*0Sstevel@tonic-gate 			BIO_printf(bio_err,"blowfish");
910*0Sstevel@tonic-gate #endif
911*0Sstevel@tonic-gate #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
912*0Sstevel@tonic-gate     !defined(OPENSSL_NO_DES) || !defined(OPENSSL_NO_RSA) || \
913*0Sstevel@tonic-gate     !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_AES)
914*0Sstevel@tonic-gate 			BIO_printf(bio_err,"\n");
915*0Sstevel@tonic-gate #endif
916*0Sstevel@tonic-gate 
917*0Sstevel@tonic-gate 			BIO_printf(bio_err,"\n");
918*0Sstevel@tonic-gate 			BIO_printf(bio_err,"Available options:\n");
919*0Sstevel@tonic-gate #if defined(TIMES) || defined(USE_TOD)
920*0Sstevel@tonic-gate 			BIO_printf(bio_err,"-elapsed        measure time in real time instead of CPU user time.\n");
921*0Sstevel@tonic-gate #endif
922*0Sstevel@tonic-gate #ifndef OPENSSL_NO_ENGINE
923*0Sstevel@tonic-gate 			BIO_printf(bio_err,"-engine e       use engine e, possibly a hardware device.\n");
924*0Sstevel@tonic-gate #endif
925*0Sstevel@tonic-gate 			BIO_printf(bio_err,"-evp e          use EVP e.\n");
926*0Sstevel@tonic-gate 			BIO_printf(bio_err,"-decrypt        time decryption instead of encryption (only EVP).\n");
927*0Sstevel@tonic-gate 			BIO_printf(bio_err,"-mr             produce machine readable output.\n");
928*0Sstevel@tonic-gate #ifdef HAVE_FORK
929*0Sstevel@tonic-gate 			BIO_printf(bio_err,"-multi n        run n benchmarks in parallel.\n");
930*0Sstevel@tonic-gate #endif
931*0Sstevel@tonic-gate 			goto end;
932*0Sstevel@tonic-gate 			}
933*0Sstevel@tonic-gate 		argc--;
934*0Sstevel@tonic-gate 		argv++;
935*0Sstevel@tonic-gate 		j++;
936*0Sstevel@tonic-gate 		}
937*0Sstevel@tonic-gate 
938*0Sstevel@tonic-gate #ifdef HAVE_FORK
939*0Sstevel@tonic-gate 	if(multi && do_multi(multi))
940*0Sstevel@tonic-gate 		goto show_res;
941*0Sstevel@tonic-gate #endif
942*0Sstevel@tonic-gate 
943*0Sstevel@tonic-gate 	if (j == 0)
944*0Sstevel@tonic-gate 		{
945*0Sstevel@tonic-gate 		for (i=0; i<ALGOR_NUM; i++)
946*0Sstevel@tonic-gate 			{
947*0Sstevel@tonic-gate 			if (i != D_EVP)
948*0Sstevel@tonic-gate 				doit[i]=1;
949*0Sstevel@tonic-gate 			}
950*0Sstevel@tonic-gate 		for (i=0; i<RSA_NUM; i++)
951*0Sstevel@tonic-gate 			rsa_doit[i]=1;
952*0Sstevel@tonic-gate 		for (i=0; i<DSA_NUM; i++)
953*0Sstevel@tonic-gate 			dsa_doit[i]=1;
954*0Sstevel@tonic-gate 		}
955*0Sstevel@tonic-gate 	for (i=0; i<ALGOR_NUM; i++)
956*0Sstevel@tonic-gate 		if (doit[i]) pr_header++;
957*0Sstevel@tonic-gate 
958*0Sstevel@tonic-gate 	if (usertime == 0 && !mr)
959*0Sstevel@tonic-gate 		BIO_printf(bio_err,"You have chosen to measure elapsed time instead of user CPU time.\n");
960*0Sstevel@tonic-gate 	if (usertime <= 0 && !mr)
961*0Sstevel@tonic-gate 		{
962*0Sstevel@tonic-gate 		BIO_printf(bio_err,"To get the most accurate results, try to run this\n");
963*0Sstevel@tonic-gate 		BIO_printf(bio_err,"program when this computer is idle.\n");
964*0Sstevel@tonic-gate 		}
965*0Sstevel@tonic-gate 
966*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
967*0Sstevel@tonic-gate 	for (i=0; i<RSA_NUM; i++)
968*0Sstevel@tonic-gate 		{
969*0Sstevel@tonic-gate 		const unsigned char *p;
970*0Sstevel@tonic-gate 
971*0Sstevel@tonic-gate 		p=rsa_data[i];
972*0Sstevel@tonic-gate 		rsa_key[i]=d2i_RSAPrivateKey(NULL,&p,rsa_data_length[i]);
973*0Sstevel@tonic-gate 		if (rsa_key[i] == NULL)
974*0Sstevel@tonic-gate 			{
975*0Sstevel@tonic-gate 			BIO_printf(bio_err,"internal error loading RSA key number %d\n",i);
976*0Sstevel@tonic-gate 			goto end;
977*0Sstevel@tonic-gate 			}
978*0Sstevel@tonic-gate #if 0
979*0Sstevel@tonic-gate 		else
980*0Sstevel@tonic-gate 			{
981*0Sstevel@tonic-gate 			BIO_printf(bio_err,mr ? "+RK:%d:"
982*0Sstevel@tonic-gate 				   : "Loaded RSA key, %d bit modulus and e= 0x",
983*0Sstevel@tonic-gate 				   BN_num_bits(rsa_key[i]->n));
984*0Sstevel@tonic-gate 			BN_print(bio_err,rsa_key[i]->e);
985*0Sstevel@tonic-gate 			BIO_printf(bio_err,"\n");
986*0Sstevel@tonic-gate 			}
987*0Sstevel@tonic-gate #endif
988*0Sstevel@tonic-gate 		}
989*0Sstevel@tonic-gate #endif
990*0Sstevel@tonic-gate 
991*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
992*0Sstevel@tonic-gate 	dsa_key[0]=get_dsa512();
993*0Sstevel@tonic-gate 	dsa_key[1]=get_dsa1024();
994*0Sstevel@tonic-gate 	dsa_key[2]=get_dsa2048();
995*0Sstevel@tonic-gate #endif
996*0Sstevel@tonic-gate 
997*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
998*0Sstevel@tonic-gate 	DES_set_key_unchecked(&key,&sch);
999*0Sstevel@tonic-gate 	DES_set_key_unchecked(&key2,&sch2);
1000*0Sstevel@tonic-gate 	DES_set_key_unchecked(&key3,&sch3);
1001*0Sstevel@tonic-gate #endif
1002*0Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
1003*0Sstevel@tonic-gate 	AES_set_encrypt_key(key16,128,&aes_ks1);
1004*0Sstevel@tonic-gate 	AES_set_encrypt_key(key24,192,&aes_ks2);
1005*0Sstevel@tonic-gate 	AES_set_encrypt_key(key32,256,&aes_ks3);
1006*0Sstevel@tonic-gate #endif
1007*0Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
1008*0Sstevel@tonic-gate 	idea_set_encrypt_key(key16,&idea_ks);
1009*0Sstevel@tonic-gate #endif
1010*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
1011*0Sstevel@tonic-gate 	RC4_set_key(&rc4_ks,16,key16);
1012*0Sstevel@tonic-gate #endif
1013*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
1014*0Sstevel@tonic-gate 	RC2_set_key(&rc2_ks,16,key16,128);
1015*0Sstevel@tonic-gate #endif
1016*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC5
1017*0Sstevel@tonic-gate 	RC5_32_set_key(&rc5_ks,16,key16,12);
1018*0Sstevel@tonic-gate #endif
1019*0Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
1020*0Sstevel@tonic-gate 	BF_set_key(&bf_ks,16,key16);
1021*0Sstevel@tonic-gate #endif
1022*0Sstevel@tonic-gate #ifndef OPENSSL_NO_CAST
1023*0Sstevel@tonic-gate 	CAST_set_key(&cast_ks,16,key16);
1024*0Sstevel@tonic-gate #endif
1025*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
1026*0Sstevel@tonic-gate 	memset(rsa_c,0,sizeof(rsa_c));
1027*0Sstevel@tonic-gate #endif
1028*0Sstevel@tonic-gate #ifndef SIGALRM
1029*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
1030*0Sstevel@tonic-gate 	BIO_printf(bio_err,"First we calculate the approximate speed ...\n");
1031*0Sstevel@tonic-gate 	count=10;
1032*0Sstevel@tonic-gate 	do	{
1033*0Sstevel@tonic-gate 		long i;
1034*0Sstevel@tonic-gate 		count*=2;
1035*0Sstevel@tonic-gate 		Time_F(START);
1036*0Sstevel@tonic-gate 		for (i=count; i; i--)
1037*0Sstevel@tonic-gate 			DES_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock,
1038*0Sstevel@tonic-gate 				&sch,DES_ENCRYPT);
1039*0Sstevel@tonic-gate 		d=Time_F(STOP);
1040*0Sstevel@tonic-gate 		} while (d <3);
1041*0Sstevel@tonic-gate 	save_count=count;
1042*0Sstevel@tonic-gate 	c[D_MD2][0]=count/10;
1043*0Sstevel@tonic-gate 	c[D_MDC2][0]=count/10;
1044*0Sstevel@tonic-gate 	c[D_MD4][0]=count;
1045*0Sstevel@tonic-gate 	c[D_MD5][0]=count;
1046*0Sstevel@tonic-gate 	c[D_HMAC][0]=count;
1047*0Sstevel@tonic-gate 	c[D_SHA1][0]=count;
1048*0Sstevel@tonic-gate 	c[D_RMD160][0]=count;
1049*0Sstevel@tonic-gate 	c[D_RC4][0]=count*5;
1050*0Sstevel@tonic-gate 	c[D_CBC_DES][0]=count;
1051*0Sstevel@tonic-gate 	c[D_EDE3_DES][0]=count/3;
1052*0Sstevel@tonic-gate 	c[D_CBC_IDEA][0]=count;
1053*0Sstevel@tonic-gate 	c[D_CBC_RC2][0]=count;
1054*0Sstevel@tonic-gate 	c[D_CBC_RC5][0]=count;
1055*0Sstevel@tonic-gate 	c[D_CBC_BF][0]=count;
1056*0Sstevel@tonic-gate 	c[D_CBC_CAST][0]=count;
1057*0Sstevel@tonic-gate 	c[D_CBC_128_AES][0]=count;
1058*0Sstevel@tonic-gate 	c[D_CBC_192_AES][0]=count;
1059*0Sstevel@tonic-gate 	c[D_CBC_256_AES][0]=count;
1060*0Sstevel@tonic-gate 
1061*0Sstevel@tonic-gate 	for (i=1; i<SIZE_NUM; i++)
1062*0Sstevel@tonic-gate 		{
1063*0Sstevel@tonic-gate 		c[D_MD2][i]=c[D_MD2][0]*4*lengths[0]/lengths[i];
1064*0Sstevel@tonic-gate 		c[D_MDC2][i]=c[D_MDC2][0]*4*lengths[0]/lengths[i];
1065*0Sstevel@tonic-gate 		c[D_MD4][i]=c[D_MD4][0]*4*lengths[0]/lengths[i];
1066*0Sstevel@tonic-gate 		c[D_MD5][i]=c[D_MD5][0]*4*lengths[0]/lengths[i];
1067*0Sstevel@tonic-gate 		c[D_HMAC][i]=c[D_HMAC][0]*4*lengths[0]/lengths[i];
1068*0Sstevel@tonic-gate 		c[D_SHA1][i]=c[D_SHA1][0]*4*lengths[0]/lengths[i];
1069*0Sstevel@tonic-gate 		c[D_RMD160][i]=c[D_RMD160][0]*4*lengths[0]/lengths[i];
1070*0Sstevel@tonic-gate 		}
1071*0Sstevel@tonic-gate 	for (i=1; i<SIZE_NUM; i++)
1072*0Sstevel@tonic-gate 		{
1073*0Sstevel@tonic-gate 		long l0,l1;
1074*0Sstevel@tonic-gate 
1075*0Sstevel@tonic-gate 		l0=(long)lengths[i-1];
1076*0Sstevel@tonic-gate 		l1=(long)lengths[i];
1077*0Sstevel@tonic-gate 		c[D_RC4][i]=c[D_RC4][i-1]*l0/l1;
1078*0Sstevel@tonic-gate 		c[D_CBC_DES][i]=c[D_CBC_DES][i-1]*l0/l1;
1079*0Sstevel@tonic-gate 		c[D_EDE3_DES][i]=c[D_EDE3_DES][i-1]*l0/l1;
1080*0Sstevel@tonic-gate 		c[D_CBC_IDEA][i]=c[D_CBC_IDEA][i-1]*l0/l1;
1081*0Sstevel@tonic-gate 		c[D_CBC_RC2][i]=c[D_CBC_RC2][i-1]*l0/l1;
1082*0Sstevel@tonic-gate 		c[D_CBC_RC5][i]=c[D_CBC_RC5][i-1]*l0/l1;
1083*0Sstevel@tonic-gate 		c[D_CBC_BF][i]=c[D_CBC_BF][i-1]*l0/l1;
1084*0Sstevel@tonic-gate 		c[D_CBC_CAST][i]=c[D_CBC_CAST][i-1]*l0/l1;
1085*0Sstevel@tonic-gate 		c[D_CBC_128_AES][i]=c[D_CBC_128_AES][i-1]*l0/l1;
1086*0Sstevel@tonic-gate 		c[D_CBC_192_AES][i]=c[D_CBC_192_AES][i-1]*l0/l1;
1087*0Sstevel@tonic-gate 		c[D_CBC_256_AES][i]=c[D_CBC_256_AES][i-1]*l0/l1;
1088*0Sstevel@tonic-gate 		}
1089*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
1090*0Sstevel@tonic-gate 	rsa_c[R_RSA_512][0]=count/2000;
1091*0Sstevel@tonic-gate 	rsa_c[R_RSA_512][1]=count/400;
1092*0Sstevel@tonic-gate 	for (i=1; i<RSA_NUM; i++)
1093*0Sstevel@tonic-gate 		{
1094*0Sstevel@tonic-gate 		rsa_c[i][0]=rsa_c[i-1][0]/8;
1095*0Sstevel@tonic-gate 		rsa_c[i][1]=rsa_c[i-1][1]/4;
1096*0Sstevel@tonic-gate 		if ((rsa_doit[i] <= 1) && (rsa_c[i][0] == 0))
1097*0Sstevel@tonic-gate 			rsa_doit[i]=0;
1098*0Sstevel@tonic-gate 		else
1099*0Sstevel@tonic-gate 			{
1100*0Sstevel@tonic-gate 			if (rsa_c[i][0] == 0)
1101*0Sstevel@tonic-gate 				{
1102*0Sstevel@tonic-gate 				rsa_c[i][0]=1;
1103*0Sstevel@tonic-gate 				rsa_c[i][1]=20;
1104*0Sstevel@tonic-gate 				}
1105*0Sstevel@tonic-gate 			}
1106*0Sstevel@tonic-gate 		}
1107*0Sstevel@tonic-gate #endif
1108*0Sstevel@tonic-gate 
1109*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
1110*0Sstevel@tonic-gate 	dsa_c[R_DSA_512][0]=count/1000;
1111*0Sstevel@tonic-gate 	dsa_c[R_DSA_512][1]=count/1000/2;
1112*0Sstevel@tonic-gate 	for (i=1; i<DSA_NUM; i++)
1113*0Sstevel@tonic-gate 		{
1114*0Sstevel@tonic-gate 		dsa_c[i][0]=dsa_c[i-1][0]/4;
1115*0Sstevel@tonic-gate 		dsa_c[i][1]=dsa_c[i-1][1]/4;
1116*0Sstevel@tonic-gate 		if ((dsa_doit[i] <= 1) && (dsa_c[i][0] == 0))
1117*0Sstevel@tonic-gate 			dsa_doit[i]=0;
1118*0Sstevel@tonic-gate 		else
1119*0Sstevel@tonic-gate 			{
1120*0Sstevel@tonic-gate 			if (dsa_c[i] == 0)
1121*0Sstevel@tonic-gate 				{
1122*0Sstevel@tonic-gate 				dsa_c[i][0]=1;
1123*0Sstevel@tonic-gate 				dsa_c[i][1]=1;
1124*0Sstevel@tonic-gate 				}
1125*0Sstevel@tonic-gate 			}
1126*0Sstevel@tonic-gate 		}
1127*0Sstevel@tonic-gate #endif
1128*0Sstevel@tonic-gate 
1129*0Sstevel@tonic-gate #define COND(d)	(count < (d))
1130*0Sstevel@tonic-gate #define COUNT(d) (d)
1131*0Sstevel@tonic-gate #else
1132*0Sstevel@tonic-gate /* not worth fixing */
1133*0Sstevel@tonic-gate # error "You cannot disable DES on systems without SIGALRM."
1134*0Sstevel@tonic-gate #endif /* OPENSSL_NO_DES */
1135*0Sstevel@tonic-gate #else
1136*0Sstevel@tonic-gate #define COND(c)	(run)
1137*0Sstevel@tonic-gate #define COUNT(d) (count)
1138*0Sstevel@tonic-gate 	signal(SIGALRM,sig_done);
1139*0Sstevel@tonic-gate #endif /* SIGALRM */
1140*0Sstevel@tonic-gate 
1141*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD2
1142*0Sstevel@tonic-gate 	if (doit[D_MD2])
1143*0Sstevel@tonic-gate 		{
1144*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1145*0Sstevel@tonic-gate 			{
1146*0Sstevel@tonic-gate 			print_message(names[D_MD2],c[D_MD2][j],lengths[j]);
1147*0Sstevel@tonic-gate 			Time_F(START);
1148*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_MD2][j]); count++)
1149*0Sstevel@tonic-gate 				EVP_Digest(buf,(unsigned long)lengths[j],&(md2[0]),NULL,EVP_md2(),NULL);
1150*0Sstevel@tonic-gate 			d=Time_F(STOP);
1151*0Sstevel@tonic-gate 			print_result(D_MD2,j,count,d);
1152*0Sstevel@tonic-gate 			}
1153*0Sstevel@tonic-gate 		}
1154*0Sstevel@tonic-gate #endif
1155*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MDC2
1156*0Sstevel@tonic-gate 	if (doit[D_MDC2])
1157*0Sstevel@tonic-gate 		{
1158*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1159*0Sstevel@tonic-gate 			{
1160*0Sstevel@tonic-gate 			print_message(names[D_MDC2],c[D_MDC2][j],lengths[j]);
1161*0Sstevel@tonic-gate 			Time_F(START);
1162*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_MDC2][j]); count++)
1163*0Sstevel@tonic-gate 				EVP_Digest(buf,(unsigned long)lengths[j],&(mdc2[0]),NULL,EVP_mdc2(),NULL);
1164*0Sstevel@tonic-gate 			d=Time_F(STOP);
1165*0Sstevel@tonic-gate 			print_result(D_MDC2,j,count,d);
1166*0Sstevel@tonic-gate 			}
1167*0Sstevel@tonic-gate 		}
1168*0Sstevel@tonic-gate #endif
1169*0Sstevel@tonic-gate 
1170*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD4
1171*0Sstevel@tonic-gate 	if (doit[D_MD4])
1172*0Sstevel@tonic-gate 		{
1173*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1174*0Sstevel@tonic-gate 			{
1175*0Sstevel@tonic-gate 			print_message(names[D_MD4],c[D_MD4][j],lengths[j]);
1176*0Sstevel@tonic-gate 			Time_F(START);
1177*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_MD4][j]); count++)
1178*0Sstevel@tonic-gate 				EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md4[0]),NULL,EVP_md4(),NULL);
1179*0Sstevel@tonic-gate 			d=Time_F(STOP);
1180*0Sstevel@tonic-gate 			print_result(D_MD4,j,count,d);
1181*0Sstevel@tonic-gate 			}
1182*0Sstevel@tonic-gate 		}
1183*0Sstevel@tonic-gate #endif
1184*0Sstevel@tonic-gate 
1185*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD5
1186*0Sstevel@tonic-gate 	if (doit[D_MD5])
1187*0Sstevel@tonic-gate 		{
1188*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1189*0Sstevel@tonic-gate 			{
1190*0Sstevel@tonic-gate 			print_message(names[D_MD5],c[D_MD5][j],lengths[j]);
1191*0Sstevel@tonic-gate 			Time_F(START);
1192*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_MD5][j]); count++)
1193*0Sstevel@tonic-gate 				EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md5[0]),NULL,EVP_get_digestbyname("md5"),NULL);
1194*0Sstevel@tonic-gate 			d=Time_F(STOP);
1195*0Sstevel@tonic-gate 			print_result(D_MD5,j,count,d);
1196*0Sstevel@tonic-gate 			}
1197*0Sstevel@tonic-gate 		}
1198*0Sstevel@tonic-gate #endif
1199*0Sstevel@tonic-gate 
1200*0Sstevel@tonic-gate #if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC)
1201*0Sstevel@tonic-gate 	if (doit[D_HMAC])
1202*0Sstevel@tonic-gate 		{
1203*0Sstevel@tonic-gate 		HMAC_CTX hctx;
1204*0Sstevel@tonic-gate 
1205*0Sstevel@tonic-gate 		HMAC_CTX_init(&hctx);
1206*0Sstevel@tonic-gate 		HMAC_Init_ex(&hctx,(unsigned char *)"This is a key...",
1207*0Sstevel@tonic-gate 			16,EVP_md5(), NULL);
1208*0Sstevel@tonic-gate 
1209*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1210*0Sstevel@tonic-gate 			{
1211*0Sstevel@tonic-gate 			print_message(names[D_HMAC],c[D_HMAC][j],lengths[j]);
1212*0Sstevel@tonic-gate 			Time_F(START);
1213*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_HMAC][j]); count++)
1214*0Sstevel@tonic-gate 				{
1215*0Sstevel@tonic-gate 				HMAC_Init_ex(&hctx,NULL,0,NULL,NULL);
1216*0Sstevel@tonic-gate 				HMAC_Update(&hctx,buf,lengths[j]);
1217*0Sstevel@tonic-gate 				HMAC_Final(&hctx,&(hmac[0]),NULL);
1218*0Sstevel@tonic-gate 				}
1219*0Sstevel@tonic-gate 			d=Time_F(STOP);
1220*0Sstevel@tonic-gate 			print_result(D_HMAC,j,count,d);
1221*0Sstevel@tonic-gate 			}
1222*0Sstevel@tonic-gate 		HMAC_CTX_cleanup(&hctx);
1223*0Sstevel@tonic-gate 		}
1224*0Sstevel@tonic-gate #endif
1225*0Sstevel@tonic-gate #ifndef OPENSSL_NO_SHA
1226*0Sstevel@tonic-gate 	if (doit[D_SHA1])
1227*0Sstevel@tonic-gate 		{
1228*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1229*0Sstevel@tonic-gate 			{
1230*0Sstevel@tonic-gate 			print_message(names[D_SHA1],c[D_SHA1][j],lengths[j]);
1231*0Sstevel@tonic-gate 			Time_F(START);
1232*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_SHA1][j]); count++)
1233*0Sstevel@tonic-gate 				EVP_Digest(buf,(unsigned long)lengths[j],&(sha[0]),NULL,EVP_sha1(),NULL);
1234*0Sstevel@tonic-gate 			d=Time_F(STOP);
1235*0Sstevel@tonic-gate 			print_result(D_SHA1,j,count,d);
1236*0Sstevel@tonic-gate 			}
1237*0Sstevel@tonic-gate 		}
1238*0Sstevel@tonic-gate #endif
1239*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RIPEMD
1240*0Sstevel@tonic-gate 	if (doit[D_RMD160])
1241*0Sstevel@tonic-gate 		{
1242*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1243*0Sstevel@tonic-gate 			{
1244*0Sstevel@tonic-gate 			print_message(names[D_RMD160],c[D_RMD160][j],lengths[j]);
1245*0Sstevel@tonic-gate 			Time_F(START);
1246*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_RMD160][j]); count++)
1247*0Sstevel@tonic-gate 				EVP_Digest(buf,(unsigned long)lengths[j],&(rmd160[0]),NULL,EVP_ripemd160(),NULL);
1248*0Sstevel@tonic-gate 			d=Time_F(STOP);
1249*0Sstevel@tonic-gate 			print_result(D_RMD160,j,count,d);
1250*0Sstevel@tonic-gate 			}
1251*0Sstevel@tonic-gate 		}
1252*0Sstevel@tonic-gate #endif
1253*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
1254*0Sstevel@tonic-gate 	if (doit[D_RC4])
1255*0Sstevel@tonic-gate 		{
1256*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1257*0Sstevel@tonic-gate 			{
1258*0Sstevel@tonic-gate 			print_message(names[D_RC4],c[D_RC4][j],lengths[j]);
1259*0Sstevel@tonic-gate 			Time_F(START);
1260*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_RC4][j]); count++)
1261*0Sstevel@tonic-gate 				RC4(&rc4_ks,(unsigned int)lengths[j],
1262*0Sstevel@tonic-gate 					buf,buf);
1263*0Sstevel@tonic-gate 			d=Time_F(STOP);
1264*0Sstevel@tonic-gate 			print_result(D_RC4,j,count,d);
1265*0Sstevel@tonic-gate 			}
1266*0Sstevel@tonic-gate 		}
1267*0Sstevel@tonic-gate #endif
1268*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
1269*0Sstevel@tonic-gate 	if (doit[D_CBC_DES])
1270*0Sstevel@tonic-gate 		{
1271*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1272*0Sstevel@tonic-gate 			{
1273*0Sstevel@tonic-gate 			print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
1274*0Sstevel@tonic-gate 			Time_F(START);
1275*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
1276*0Sstevel@tonic-gate 				DES_ncbc_encrypt(buf,buf,lengths[j],&sch,
1277*0Sstevel@tonic-gate 						 &DES_iv,DES_ENCRYPT);
1278*0Sstevel@tonic-gate 			d=Time_F(STOP);
1279*0Sstevel@tonic-gate 			print_result(D_CBC_DES,j,count,d);
1280*0Sstevel@tonic-gate 			}
1281*0Sstevel@tonic-gate 		}
1282*0Sstevel@tonic-gate 
1283*0Sstevel@tonic-gate 	if (doit[D_EDE3_DES])
1284*0Sstevel@tonic-gate 		{
1285*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1286*0Sstevel@tonic-gate 			{
1287*0Sstevel@tonic-gate 			print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
1288*0Sstevel@tonic-gate 			Time_F(START);
1289*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
1290*0Sstevel@tonic-gate 				DES_ede3_cbc_encrypt(buf,buf,lengths[j],
1291*0Sstevel@tonic-gate 						     &sch,&sch2,&sch3,
1292*0Sstevel@tonic-gate 						     &DES_iv,DES_ENCRYPT);
1293*0Sstevel@tonic-gate 			d=Time_F(STOP);
1294*0Sstevel@tonic-gate 			print_result(D_EDE3_DES,j,count,d);
1295*0Sstevel@tonic-gate 			}
1296*0Sstevel@tonic-gate 		}
1297*0Sstevel@tonic-gate #endif
1298*0Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
1299*0Sstevel@tonic-gate 	if (doit[D_CBC_128_AES])
1300*0Sstevel@tonic-gate 		{
1301*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1302*0Sstevel@tonic-gate 			{
1303*0Sstevel@tonic-gate 			print_message(names[D_CBC_128_AES],c[D_CBC_128_AES][j],lengths[j]);
1304*0Sstevel@tonic-gate 			Time_F(START);
1305*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_CBC_128_AES][j]); count++)
1306*0Sstevel@tonic-gate 				AES_cbc_encrypt(buf,buf,
1307*0Sstevel@tonic-gate 					(unsigned long)lengths[j],&aes_ks1,
1308*0Sstevel@tonic-gate 					iv,AES_ENCRYPT);
1309*0Sstevel@tonic-gate 			d=Time_F(STOP);
1310*0Sstevel@tonic-gate 			print_result(D_CBC_128_AES,j,count,d);
1311*0Sstevel@tonic-gate 			}
1312*0Sstevel@tonic-gate 		}
1313*0Sstevel@tonic-gate 	if (doit[D_CBC_192_AES])
1314*0Sstevel@tonic-gate 		{
1315*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1316*0Sstevel@tonic-gate 			{
1317*0Sstevel@tonic-gate 			print_message(names[D_CBC_192_AES],c[D_CBC_192_AES][j],lengths[j]);
1318*0Sstevel@tonic-gate 			Time_F(START);
1319*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_CBC_192_AES][j]); count++)
1320*0Sstevel@tonic-gate 				AES_cbc_encrypt(buf,buf,
1321*0Sstevel@tonic-gate 					(unsigned long)lengths[j],&aes_ks2,
1322*0Sstevel@tonic-gate 					iv,AES_ENCRYPT);
1323*0Sstevel@tonic-gate 			d=Time_F(STOP);
1324*0Sstevel@tonic-gate 			print_result(D_CBC_192_AES,j,count,d);
1325*0Sstevel@tonic-gate 			}
1326*0Sstevel@tonic-gate 		}
1327*0Sstevel@tonic-gate 	if (doit[D_CBC_256_AES])
1328*0Sstevel@tonic-gate 		{
1329*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1330*0Sstevel@tonic-gate 			{
1331*0Sstevel@tonic-gate 			print_message(names[D_CBC_256_AES],c[D_CBC_256_AES][j],lengths[j]);
1332*0Sstevel@tonic-gate 			Time_F(START);
1333*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_CBC_256_AES][j]); count++)
1334*0Sstevel@tonic-gate 				AES_cbc_encrypt(buf,buf,
1335*0Sstevel@tonic-gate 					(unsigned long)lengths[j],&aes_ks3,
1336*0Sstevel@tonic-gate 					iv,AES_ENCRYPT);
1337*0Sstevel@tonic-gate 			d=Time_F(STOP);
1338*0Sstevel@tonic-gate 			print_result(D_CBC_256_AES,j,count,d);
1339*0Sstevel@tonic-gate 			}
1340*0Sstevel@tonic-gate 		}
1341*0Sstevel@tonic-gate 
1342*0Sstevel@tonic-gate #endif
1343*0Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
1344*0Sstevel@tonic-gate 	if (doit[D_CBC_IDEA])
1345*0Sstevel@tonic-gate 		{
1346*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1347*0Sstevel@tonic-gate 			{
1348*0Sstevel@tonic-gate 			print_message(names[D_CBC_IDEA],c[D_CBC_IDEA][j],lengths[j]);
1349*0Sstevel@tonic-gate 			Time_F(START);
1350*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_CBC_IDEA][j]); count++)
1351*0Sstevel@tonic-gate 				idea_cbc_encrypt(buf,buf,
1352*0Sstevel@tonic-gate 					(unsigned long)lengths[j],&idea_ks,
1353*0Sstevel@tonic-gate 					iv,IDEA_ENCRYPT);
1354*0Sstevel@tonic-gate 			d=Time_F(STOP);
1355*0Sstevel@tonic-gate 			print_result(D_CBC_IDEA,j,count,d);
1356*0Sstevel@tonic-gate 			}
1357*0Sstevel@tonic-gate 		}
1358*0Sstevel@tonic-gate #endif
1359*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
1360*0Sstevel@tonic-gate 	if (doit[D_CBC_RC2])
1361*0Sstevel@tonic-gate 		{
1362*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1363*0Sstevel@tonic-gate 			{
1364*0Sstevel@tonic-gate 			print_message(names[D_CBC_RC2],c[D_CBC_RC2][j],lengths[j]);
1365*0Sstevel@tonic-gate 			Time_F(START);
1366*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_CBC_RC2][j]); count++)
1367*0Sstevel@tonic-gate 				RC2_cbc_encrypt(buf,buf,
1368*0Sstevel@tonic-gate 					(unsigned long)lengths[j],&rc2_ks,
1369*0Sstevel@tonic-gate 					iv,RC2_ENCRYPT);
1370*0Sstevel@tonic-gate 			d=Time_F(STOP);
1371*0Sstevel@tonic-gate 			print_result(D_CBC_RC2,j,count,d);
1372*0Sstevel@tonic-gate 			}
1373*0Sstevel@tonic-gate 		}
1374*0Sstevel@tonic-gate #endif
1375*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC5
1376*0Sstevel@tonic-gate 	if (doit[D_CBC_RC5])
1377*0Sstevel@tonic-gate 		{
1378*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1379*0Sstevel@tonic-gate 			{
1380*0Sstevel@tonic-gate 			print_message(names[D_CBC_RC5],c[D_CBC_RC5][j],lengths[j]);
1381*0Sstevel@tonic-gate 			Time_F(START);
1382*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_CBC_RC5][j]); count++)
1383*0Sstevel@tonic-gate 				RC5_32_cbc_encrypt(buf,buf,
1384*0Sstevel@tonic-gate 					(unsigned long)lengths[j],&rc5_ks,
1385*0Sstevel@tonic-gate 					iv,RC5_ENCRYPT);
1386*0Sstevel@tonic-gate 			d=Time_F(STOP);
1387*0Sstevel@tonic-gate 			print_result(D_CBC_RC5,j,count,d);
1388*0Sstevel@tonic-gate 			}
1389*0Sstevel@tonic-gate 		}
1390*0Sstevel@tonic-gate #endif
1391*0Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
1392*0Sstevel@tonic-gate 	if (doit[D_CBC_BF])
1393*0Sstevel@tonic-gate 		{
1394*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1395*0Sstevel@tonic-gate 			{
1396*0Sstevel@tonic-gate 			print_message(names[D_CBC_BF],c[D_CBC_BF][j],lengths[j]);
1397*0Sstevel@tonic-gate 			Time_F(START);
1398*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_CBC_BF][j]); count++)
1399*0Sstevel@tonic-gate 				BF_cbc_encrypt(buf,buf,
1400*0Sstevel@tonic-gate 					(unsigned long)lengths[j],&bf_ks,
1401*0Sstevel@tonic-gate 					iv,BF_ENCRYPT);
1402*0Sstevel@tonic-gate 			d=Time_F(STOP);
1403*0Sstevel@tonic-gate 			print_result(D_CBC_BF,j,count,d);
1404*0Sstevel@tonic-gate 			}
1405*0Sstevel@tonic-gate 		}
1406*0Sstevel@tonic-gate #endif
1407*0Sstevel@tonic-gate #ifndef OPENSSL_NO_CAST
1408*0Sstevel@tonic-gate 	if (doit[D_CBC_CAST])
1409*0Sstevel@tonic-gate 		{
1410*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1411*0Sstevel@tonic-gate 			{
1412*0Sstevel@tonic-gate 			print_message(names[D_CBC_CAST],c[D_CBC_CAST][j],lengths[j]);
1413*0Sstevel@tonic-gate 			Time_F(START);
1414*0Sstevel@tonic-gate 			for (count=0,run=1; COND(c[D_CBC_CAST][j]); count++)
1415*0Sstevel@tonic-gate 				CAST_cbc_encrypt(buf,buf,
1416*0Sstevel@tonic-gate 					(unsigned long)lengths[j],&cast_ks,
1417*0Sstevel@tonic-gate 					iv,CAST_ENCRYPT);
1418*0Sstevel@tonic-gate 			d=Time_F(STOP);
1419*0Sstevel@tonic-gate 			print_result(D_CBC_CAST,j,count,d);
1420*0Sstevel@tonic-gate 			}
1421*0Sstevel@tonic-gate 		}
1422*0Sstevel@tonic-gate #endif
1423*0Sstevel@tonic-gate 
1424*0Sstevel@tonic-gate 	if (doit[D_EVP])
1425*0Sstevel@tonic-gate 		{
1426*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1427*0Sstevel@tonic-gate 			{
1428*0Sstevel@tonic-gate 			if (evp_cipher)
1429*0Sstevel@tonic-gate 				{
1430*0Sstevel@tonic-gate 				EVP_CIPHER_CTX ctx;
1431*0Sstevel@tonic-gate 				int outl;
1432*0Sstevel@tonic-gate 
1433*0Sstevel@tonic-gate 				names[D_EVP]=OBJ_nid2ln(evp_cipher->nid);
1434*0Sstevel@tonic-gate 				/* -O3 -fschedule-insns messes up an
1435*0Sstevel@tonic-gate 				 * optimization here!  names[D_EVP]
1436*0Sstevel@tonic-gate 				 * somehow becomes NULL */
1437*0Sstevel@tonic-gate 				print_message(names[D_EVP],save_count,
1438*0Sstevel@tonic-gate 					lengths[j]);
1439*0Sstevel@tonic-gate 
1440*0Sstevel@tonic-gate 				EVP_CIPHER_CTX_init(&ctx);
1441*0Sstevel@tonic-gate 				if(decrypt)
1442*0Sstevel@tonic-gate 					EVP_DecryptInit_ex(&ctx,evp_cipher,NULL,key16,iv);
1443*0Sstevel@tonic-gate 				else
1444*0Sstevel@tonic-gate 					EVP_EncryptInit_ex(&ctx,evp_cipher,NULL,key16,iv);
1445*0Sstevel@tonic-gate 
1446*0Sstevel@tonic-gate 				Time_F(START);
1447*0Sstevel@tonic-gate 				if(decrypt)
1448*0Sstevel@tonic-gate 					for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1449*0Sstevel@tonic-gate 						EVP_DecryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
1450*0Sstevel@tonic-gate 				else
1451*0Sstevel@tonic-gate 					for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1452*0Sstevel@tonic-gate 						EVP_EncryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
1453*0Sstevel@tonic-gate 				if(decrypt)
1454*0Sstevel@tonic-gate 					EVP_DecryptFinal_ex(&ctx,buf,&outl);
1455*0Sstevel@tonic-gate 				else
1456*0Sstevel@tonic-gate 					EVP_EncryptFinal_ex(&ctx,buf,&outl);
1457*0Sstevel@tonic-gate 				d=Time_F(STOP);
1458*0Sstevel@tonic-gate 				EVP_CIPHER_CTX_cleanup(&ctx);
1459*0Sstevel@tonic-gate 				}
1460*0Sstevel@tonic-gate 			if (evp_md)
1461*0Sstevel@tonic-gate 				{
1462*0Sstevel@tonic-gate 				names[D_EVP]=OBJ_nid2ln(evp_md->type);
1463*0Sstevel@tonic-gate 				print_message(names[D_EVP],save_count,
1464*0Sstevel@tonic-gate 					lengths[j]);
1465*0Sstevel@tonic-gate 
1466*0Sstevel@tonic-gate 				Time_F(START);
1467*0Sstevel@tonic-gate 				for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
1468*0Sstevel@tonic-gate 					EVP_Digest(buf,lengths[j],&(md[0]),NULL,evp_md,NULL);
1469*0Sstevel@tonic-gate 
1470*0Sstevel@tonic-gate 				d=Time_F(STOP);
1471*0Sstevel@tonic-gate 				}
1472*0Sstevel@tonic-gate 			print_result(D_EVP,j,count,d);
1473*0Sstevel@tonic-gate 			}
1474*0Sstevel@tonic-gate 		}
1475*0Sstevel@tonic-gate 
1476*0Sstevel@tonic-gate 	RAND_pseudo_bytes(buf,36);
1477*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
1478*0Sstevel@tonic-gate 	for (j=0; j<RSA_NUM; j++)
1479*0Sstevel@tonic-gate 		{
1480*0Sstevel@tonic-gate 		int ret;
1481*0Sstevel@tonic-gate 		if (!rsa_doit[j]) continue;
1482*0Sstevel@tonic-gate 		ret=RSA_sign(NID_md5_sha1, buf,36, buf2, &rsa_num, rsa_key[j]);
1483*0Sstevel@tonic-gate 		if (ret == 0)
1484*0Sstevel@tonic-gate 			{
1485*0Sstevel@tonic-gate 			BIO_printf(bio_err,"RSA sign failure.  No RSA sign will be done.\n");
1486*0Sstevel@tonic-gate 			ERR_print_errors(bio_err);
1487*0Sstevel@tonic-gate 			rsa_count=1;
1488*0Sstevel@tonic-gate 			}
1489*0Sstevel@tonic-gate 		else
1490*0Sstevel@tonic-gate 			{
1491*0Sstevel@tonic-gate 			pkey_print_message("private","rsa",
1492*0Sstevel@tonic-gate 				rsa_c[j][0],rsa_bits[j],
1493*0Sstevel@tonic-gate 				RSA_SECONDS);
1494*0Sstevel@tonic-gate /*			RSA_blinding_on(rsa_key[j],NULL); */
1495*0Sstevel@tonic-gate 			Time_F(START);
1496*0Sstevel@tonic-gate 			for (count=0,run=1; COND(rsa_c[j][0]); count++)
1497*0Sstevel@tonic-gate 				{
1498*0Sstevel@tonic-gate 				ret=RSA_sign(NID_md5_sha1, buf,36, buf2,
1499*0Sstevel@tonic-gate 					&rsa_num, rsa_key[j]);
1500*0Sstevel@tonic-gate 				if (ret == 0)
1501*0Sstevel@tonic-gate 					{
1502*0Sstevel@tonic-gate 					BIO_printf(bio_err,
1503*0Sstevel@tonic-gate 						"RSA sign failure\n");
1504*0Sstevel@tonic-gate 					ERR_print_errors(bio_err);
1505*0Sstevel@tonic-gate 					count=1;
1506*0Sstevel@tonic-gate 					break;
1507*0Sstevel@tonic-gate 					}
1508*0Sstevel@tonic-gate 				}
1509*0Sstevel@tonic-gate 			d=Time_F(STOP);
1510*0Sstevel@tonic-gate 			BIO_printf(bio_err,mr ? "+R1:%ld:%d:%.2f\n"
1511*0Sstevel@tonic-gate 				   : "%ld %d bit private RSA's in %.2fs\n",
1512*0Sstevel@tonic-gate 				   count,rsa_bits[j],d);
1513*0Sstevel@tonic-gate 			rsa_results[j][0]=d/(double)count;
1514*0Sstevel@tonic-gate 			rsa_count=count;
1515*0Sstevel@tonic-gate 			}
1516*0Sstevel@tonic-gate 
1517*0Sstevel@tonic-gate #if 1
1518*0Sstevel@tonic-gate 		ret=RSA_verify(NID_md5_sha1, buf,36, buf2, rsa_num, rsa_key[j]);
1519*0Sstevel@tonic-gate 		if (ret <= 0)
1520*0Sstevel@tonic-gate 			{
1521*0Sstevel@tonic-gate 			BIO_printf(bio_err,"RSA verify failure.  No RSA verify will be done.\n");
1522*0Sstevel@tonic-gate 			ERR_print_errors(bio_err);
1523*0Sstevel@tonic-gate 			rsa_doit[j] = 0;
1524*0Sstevel@tonic-gate 			}
1525*0Sstevel@tonic-gate 		else
1526*0Sstevel@tonic-gate 			{
1527*0Sstevel@tonic-gate 			pkey_print_message("public","rsa",
1528*0Sstevel@tonic-gate 				rsa_c[j][1],rsa_bits[j],
1529*0Sstevel@tonic-gate 				RSA_SECONDS);
1530*0Sstevel@tonic-gate 			Time_F(START);
1531*0Sstevel@tonic-gate 			for (count=0,run=1; COND(rsa_c[j][1]); count++)
1532*0Sstevel@tonic-gate 				{
1533*0Sstevel@tonic-gate 				ret=RSA_verify(NID_md5_sha1, buf,36, buf2,
1534*0Sstevel@tonic-gate 					rsa_num, rsa_key[j]);
1535*0Sstevel@tonic-gate 				if (ret == 0)
1536*0Sstevel@tonic-gate 					{
1537*0Sstevel@tonic-gate 					BIO_printf(bio_err,
1538*0Sstevel@tonic-gate 						"RSA verify failure\n");
1539*0Sstevel@tonic-gate 					ERR_print_errors(bio_err);
1540*0Sstevel@tonic-gate 					count=1;
1541*0Sstevel@tonic-gate 					break;
1542*0Sstevel@tonic-gate 					}
1543*0Sstevel@tonic-gate 				}
1544*0Sstevel@tonic-gate 			d=Time_F(STOP);
1545*0Sstevel@tonic-gate 			BIO_printf(bio_err,mr ? "+R2:%ld:%d:%.2f\n"
1546*0Sstevel@tonic-gate 				   : "%ld %d bit public RSA's in %.2fs\n",
1547*0Sstevel@tonic-gate 				   count,rsa_bits[j],d);
1548*0Sstevel@tonic-gate 			rsa_results[j][1]=d/(double)count;
1549*0Sstevel@tonic-gate 			}
1550*0Sstevel@tonic-gate #endif
1551*0Sstevel@tonic-gate 
1552*0Sstevel@tonic-gate 		if (rsa_count <= 1)
1553*0Sstevel@tonic-gate 			{
1554*0Sstevel@tonic-gate 			/* if longer than 10s, don't do any more */
1555*0Sstevel@tonic-gate 			for (j++; j<RSA_NUM; j++)
1556*0Sstevel@tonic-gate 				rsa_doit[j]=0;
1557*0Sstevel@tonic-gate 			}
1558*0Sstevel@tonic-gate 		}
1559*0Sstevel@tonic-gate #endif
1560*0Sstevel@tonic-gate 
1561*0Sstevel@tonic-gate 	RAND_pseudo_bytes(buf,20);
1562*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
1563*0Sstevel@tonic-gate 	if (RAND_status() != 1)
1564*0Sstevel@tonic-gate 		{
1565*0Sstevel@tonic-gate 		RAND_seed(rnd_seed, sizeof rnd_seed);
1566*0Sstevel@tonic-gate 		rnd_fake = 1;
1567*0Sstevel@tonic-gate 		}
1568*0Sstevel@tonic-gate 	for (j=0; j<DSA_NUM; j++)
1569*0Sstevel@tonic-gate 		{
1570*0Sstevel@tonic-gate 		unsigned int kk;
1571*0Sstevel@tonic-gate 		int ret;
1572*0Sstevel@tonic-gate 
1573*0Sstevel@tonic-gate 		if (!dsa_doit[j]) continue;
1574*0Sstevel@tonic-gate /*		DSA_generate_key(dsa_key[j]); */
1575*0Sstevel@tonic-gate /*		DSA_sign_setup(dsa_key[j],NULL); */
1576*0Sstevel@tonic-gate 		ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1577*0Sstevel@tonic-gate 			&kk,dsa_key[j]);
1578*0Sstevel@tonic-gate 		if (ret == 0)
1579*0Sstevel@tonic-gate 			{
1580*0Sstevel@tonic-gate 			BIO_printf(bio_err,"DSA sign failure.  No DSA sign will be done.\n");
1581*0Sstevel@tonic-gate 			ERR_print_errors(bio_err);
1582*0Sstevel@tonic-gate 			rsa_count=1;
1583*0Sstevel@tonic-gate 			}
1584*0Sstevel@tonic-gate 		else
1585*0Sstevel@tonic-gate 			{
1586*0Sstevel@tonic-gate 			pkey_print_message("sign","dsa",
1587*0Sstevel@tonic-gate 				dsa_c[j][0],dsa_bits[j],
1588*0Sstevel@tonic-gate 				DSA_SECONDS);
1589*0Sstevel@tonic-gate 			Time_F(START);
1590*0Sstevel@tonic-gate 			for (count=0,run=1; COND(dsa_c[j][0]); count++)
1591*0Sstevel@tonic-gate 				{
1592*0Sstevel@tonic-gate 				ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
1593*0Sstevel@tonic-gate 					&kk,dsa_key[j]);
1594*0Sstevel@tonic-gate 				if (ret == 0)
1595*0Sstevel@tonic-gate 					{
1596*0Sstevel@tonic-gate 					BIO_printf(bio_err,
1597*0Sstevel@tonic-gate 						"DSA sign failure\n");
1598*0Sstevel@tonic-gate 					ERR_print_errors(bio_err);
1599*0Sstevel@tonic-gate 					count=1;
1600*0Sstevel@tonic-gate 					break;
1601*0Sstevel@tonic-gate 					}
1602*0Sstevel@tonic-gate 				}
1603*0Sstevel@tonic-gate 			d=Time_F(STOP);
1604*0Sstevel@tonic-gate 			BIO_printf(bio_err,mr ? "+R3:%ld:%d:%.2f\n"
1605*0Sstevel@tonic-gate 				   : "%ld %d bit DSA signs in %.2fs\n",
1606*0Sstevel@tonic-gate 				   count,dsa_bits[j],d);
1607*0Sstevel@tonic-gate 			dsa_results[j][0]=d/(double)count;
1608*0Sstevel@tonic-gate 			rsa_count=count;
1609*0Sstevel@tonic-gate 			}
1610*0Sstevel@tonic-gate 
1611*0Sstevel@tonic-gate 		ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1612*0Sstevel@tonic-gate 			kk,dsa_key[j]);
1613*0Sstevel@tonic-gate 		if (ret <= 0)
1614*0Sstevel@tonic-gate 			{
1615*0Sstevel@tonic-gate 			BIO_printf(bio_err,"DSA verify failure.  No DSA verify will be done.\n");
1616*0Sstevel@tonic-gate 			ERR_print_errors(bio_err);
1617*0Sstevel@tonic-gate 			dsa_doit[j] = 0;
1618*0Sstevel@tonic-gate 			}
1619*0Sstevel@tonic-gate 		else
1620*0Sstevel@tonic-gate 			{
1621*0Sstevel@tonic-gate 			pkey_print_message("verify","dsa",
1622*0Sstevel@tonic-gate 				dsa_c[j][1],dsa_bits[j],
1623*0Sstevel@tonic-gate 				DSA_SECONDS);
1624*0Sstevel@tonic-gate 			Time_F(START);
1625*0Sstevel@tonic-gate 			for (count=0,run=1; COND(dsa_c[j][1]); count++)
1626*0Sstevel@tonic-gate 				{
1627*0Sstevel@tonic-gate 				ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
1628*0Sstevel@tonic-gate 					kk,dsa_key[j]);
1629*0Sstevel@tonic-gate 				if (ret <= 0)
1630*0Sstevel@tonic-gate 					{
1631*0Sstevel@tonic-gate 					BIO_printf(bio_err,
1632*0Sstevel@tonic-gate 						"DSA verify failure\n");
1633*0Sstevel@tonic-gate 					ERR_print_errors(bio_err);
1634*0Sstevel@tonic-gate 					count=1;
1635*0Sstevel@tonic-gate 					break;
1636*0Sstevel@tonic-gate 					}
1637*0Sstevel@tonic-gate 				}
1638*0Sstevel@tonic-gate 			d=Time_F(STOP);
1639*0Sstevel@tonic-gate 			BIO_printf(bio_err,mr ? "+R4:%ld:%d:%.2f\n"
1640*0Sstevel@tonic-gate 				   : "%ld %d bit DSA verify in %.2fs\n",
1641*0Sstevel@tonic-gate 				   count,dsa_bits[j],d);
1642*0Sstevel@tonic-gate 			dsa_results[j][1]=d/(double)count;
1643*0Sstevel@tonic-gate 			}
1644*0Sstevel@tonic-gate 
1645*0Sstevel@tonic-gate 		if (rsa_count <= 1)
1646*0Sstevel@tonic-gate 			{
1647*0Sstevel@tonic-gate 			/* if longer than 10s, don't do any more */
1648*0Sstevel@tonic-gate 			for (j++; j<DSA_NUM; j++)
1649*0Sstevel@tonic-gate 				dsa_doit[j]=0;
1650*0Sstevel@tonic-gate 			}
1651*0Sstevel@tonic-gate 		}
1652*0Sstevel@tonic-gate 	if (rnd_fake) RAND_cleanup();
1653*0Sstevel@tonic-gate #endif
1654*0Sstevel@tonic-gate #ifdef HAVE_FORK
1655*0Sstevel@tonic-gate show_res:
1656*0Sstevel@tonic-gate #endif
1657*0Sstevel@tonic-gate 	if(!mr)
1658*0Sstevel@tonic-gate 		{
1659*0Sstevel@tonic-gate 		fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_VERSION));
1660*0Sstevel@tonic-gate         fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_BUILT_ON));
1661*0Sstevel@tonic-gate 		printf("options:");
1662*0Sstevel@tonic-gate 		printf("%s ",BN_options());
1663*0Sstevel@tonic-gate #ifndef OPENSSL_NO_MD2
1664*0Sstevel@tonic-gate 		printf("%s ",MD2_options());
1665*0Sstevel@tonic-gate #endif
1666*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
1667*0Sstevel@tonic-gate 		printf("%s ",RC4_options());
1668*0Sstevel@tonic-gate #endif
1669*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
1670*0Sstevel@tonic-gate 		printf("%s ",DES_options());
1671*0Sstevel@tonic-gate #endif
1672*0Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
1673*0Sstevel@tonic-gate 		printf("%s ",AES_options());
1674*0Sstevel@tonic-gate #endif
1675*0Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
1676*0Sstevel@tonic-gate 		printf("%s ",idea_options());
1677*0Sstevel@tonic-gate #endif
1678*0Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
1679*0Sstevel@tonic-gate 		printf("%s ",BF_options());
1680*0Sstevel@tonic-gate #endif
1681*0Sstevel@tonic-gate 		fprintf(stdout,"\n%s\n",SSLeay_version(SSLEAY_CFLAGS));
1682*0Sstevel@tonic-gate 		printf("available timing options: ");
1683*0Sstevel@tonic-gate #ifdef TIMES
1684*0Sstevel@tonic-gate 		printf("TIMES ");
1685*0Sstevel@tonic-gate #endif
1686*0Sstevel@tonic-gate #ifdef TIMEB
1687*0Sstevel@tonic-gate 		printf("TIMEB ");
1688*0Sstevel@tonic-gate #endif
1689*0Sstevel@tonic-gate #ifdef USE_TOD
1690*0Sstevel@tonic-gate 		printf("USE_TOD ");
1691*0Sstevel@tonic-gate #endif
1692*0Sstevel@tonic-gate #ifdef HZ
1693*0Sstevel@tonic-gate #define as_string(s) (#s)
1694*0Sstevel@tonic-gate 		printf("HZ=%g", (double)HZ);
1695*0Sstevel@tonic-gate # ifdef _SC_CLK_TCK
1696*0Sstevel@tonic-gate 		printf(" [sysconf value]");
1697*0Sstevel@tonic-gate # endif
1698*0Sstevel@tonic-gate #endif
1699*0Sstevel@tonic-gate 		printf("\n");
1700*0Sstevel@tonic-gate 		printf("timing function used: %s%s%s%s%s%s%s\n",
1701*0Sstevel@tonic-gate 		       (ftime_used ? "ftime" : ""),
1702*0Sstevel@tonic-gate 		       (ftime_used + times_used > 1 ? "," : ""),
1703*0Sstevel@tonic-gate 		       (times_used ? "times" : ""),
1704*0Sstevel@tonic-gate 		       (ftime_used + times_used + gettimeofday_used > 1 ? "," : ""),
1705*0Sstevel@tonic-gate 		       (gettimeofday_used ? "gettimeofday" : ""),
1706*0Sstevel@tonic-gate 		       (ftime_used + times_used + gettimeofday_used + getrusage_used > 1 ? "," : ""),
1707*0Sstevel@tonic-gate 		       (getrusage_used ? "getrusage" : ""));
1708*0Sstevel@tonic-gate 		}
1709*0Sstevel@tonic-gate 
1710*0Sstevel@tonic-gate 	if (pr_header)
1711*0Sstevel@tonic-gate 		{
1712*0Sstevel@tonic-gate 		if(mr)
1713*0Sstevel@tonic-gate 			fprintf(stdout,"+H");
1714*0Sstevel@tonic-gate 		else
1715*0Sstevel@tonic-gate 			{
1716*0Sstevel@tonic-gate 			fprintf(stdout,"The 'numbers' are in 1000s of bytes per second processed.\n");
1717*0Sstevel@tonic-gate 			fprintf(stdout,"type        ");
1718*0Sstevel@tonic-gate 			}
1719*0Sstevel@tonic-gate 		for (j=0;  j<SIZE_NUM; j++)
1720*0Sstevel@tonic-gate 			fprintf(stdout,mr ? ":%d" : "%7d bytes",lengths[j]);
1721*0Sstevel@tonic-gate 		fprintf(stdout,"\n");
1722*0Sstevel@tonic-gate 		}
1723*0Sstevel@tonic-gate 
1724*0Sstevel@tonic-gate 	for (k=0; k<ALGOR_NUM; k++)
1725*0Sstevel@tonic-gate 		{
1726*0Sstevel@tonic-gate 		if (!doit[k]) continue;
1727*0Sstevel@tonic-gate 		if(mr)
1728*0Sstevel@tonic-gate 			fprintf(stdout,"+F:%d:%s",k,names[k]);
1729*0Sstevel@tonic-gate 		else
1730*0Sstevel@tonic-gate 			fprintf(stdout,"%-13s",names[k]);
1731*0Sstevel@tonic-gate 		for (j=0; j<SIZE_NUM; j++)
1732*0Sstevel@tonic-gate 			{
1733*0Sstevel@tonic-gate 			if (results[k][j] > 10000 && !mr)
1734*0Sstevel@tonic-gate 				fprintf(stdout," %11.2fk",results[k][j]/1e3);
1735*0Sstevel@tonic-gate 			else
1736*0Sstevel@tonic-gate 				fprintf(stdout,mr ? ":%.2f" : " %11.2f ",results[k][j]);
1737*0Sstevel@tonic-gate 			}
1738*0Sstevel@tonic-gate 		fprintf(stdout,"\n");
1739*0Sstevel@tonic-gate 		}
1740*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
1741*0Sstevel@tonic-gate 	j=1;
1742*0Sstevel@tonic-gate 	for (k=0; k<RSA_NUM; k++)
1743*0Sstevel@tonic-gate 		{
1744*0Sstevel@tonic-gate 		if (!rsa_doit[k]) continue;
1745*0Sstevel@tonic-gate 		if (j && !mr)
1746*0Sstevel@tonic-gate 			{
1747*0Sstevel@tonic-gate 			printf("%18ssign    verify    sign/s verify/s\n"," ");
1748*0Sstevel@tonic-gate 			j=0;
1749*0Sstevel@tonic-gate 			}
1750*0Sstevel@tonic-gate 		if(mr)
1751*0Sstevel@tonic-gate 			fprintf(stdout,"+F2:%u:%u:%f:%f\n",
1752*0Sstevel@tonic-gate 				k,rsa_bits[k],rsa_results[k][0],
1753*0Sstevel@tonic-gate 				rsa_results[k][1]);
1754*0Sstevel@tonic-gate 		else
1755*0Sstevel@tonic-gate 			fprintf(stdout,"rsa %4u bits %8.4fs %8.4fs %8.1f %8.1f\n",
1756*0Sstevel@tonic-gate 				rsa_bits[k],rsa_results[k][0],rsa_results[k][1],
1757*0Sstevel@tonic-gate 				1.0/rsa_results[k][0],1.0/rsa_results[k][1]);
1758*0Sstevel@tonic-gate 		}
1759*0Sstevel@tonic-gate #endif
1760*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
1761*0Sstevel@tonic-gate 	j=1;
1762*0Sstevel@tonic-gate 	for (k=0; k<DSA_NUM; k++)
1763*0Sstevel@tonic-gate 		{
1764*0Sstevel@tonic-gate 		if (!dsa_doit[k]) continue;
1765*0Sstevel@tonic-gate 		if (j && !mr)
1766*0Sstevel@tonic-gate 			{
1767*0Sstevel@tonic-gate 			printf("%18ssign    verify    sign/s verify/s\n"," ");
1768*0Sstevel@tonic-gate 			j=0;
1769*0Sstevel@tonic-gate 			}
1770*0Sstevel@tonic-gate 		if(mr)
1771*0Sstevel@tonic-gate 			fprintf(stdout,"+F3:%u:%u:%f:%f\n",
1772*0Sstevel@tonic-gate 				k,dsa_bits[k],dsa_results[k][0],dsa_results[k][1]);
1773*0Sstevel@tonic-gate 		else
1774*0Sstevel@tonic-gate 			fprintf(stdout,"dsa %4u bits %8.4fs %8.4fs %8.1f %8.1f\n",
1775*0Sstevel@tonic-gate 				dsa_bits[k],dsa_results[k][0],dsa_results[k][1],
1776*0Sstevel@tonic-gate 				1.0/dsa_results[k][0],1.0/dsa_results[k][1]);
1777*0Sstevel@tonic-gate 		}
1778*0Sstevel@tonic-gate #endif
1779*0Sstevel@tonic-gate 	mret=0;
1780*0Sstevel@tonic-gate end:
1781*0Sstevel@tonic-gate 	ERR_print_errors(bio_err);
1782*0Sstevel@tonic-gate 	if (buf != NULL) OPENSSL_free(buf);
1783*0Sstevel@tonic-gate 	if (buf2 != NULL) OPENSSL_free(buf2);
1784*0Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
1785*0Sstevel@tonic-gate 	for (i=0; i<RSA_NUM; i++)
1786*0Sstevel@tonic-gate 		if (rsa_key[i] != NULL)
1787*0Sstevel@tonic-gate 			RSA_free(rsa_key[i]);
1788*0Sstevel@tonic-gate #endif
1789*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
1790*0Sstevel@tonic-gate 	for (i=0; i<DSA_NUM; i++)
1791*0Sstevel@tonic-gate 		if (dsa_key[i] != NULL)
1792*0Sstevel@tonic-gate 			DSA_free(dsa_key[i]);
1793*0Sstevel@tonic-gate #endif
1794*0Sstevel@tonic-gate 	apps_shutdown();
1795*0Sstevel@tonic-gate 	OPENSSL_EXIT(mret);
1796*0Sstevel@tonic-gate 	}
1797*0Sstevel@tonic-gate 
1798*0Sstevel@tonic-gate static void print_message(const char *s, long num, int length)
1799*0Sstevel@tonic-gate 	{
1800*0Sstevel@tonic-gate #ifdef SIGALRM
1801*0Sstevel@tonic-gate 	BIO_printf(bio_err,mr ? "+DT:%s:%d:%d\n"
1802*0Sstevel@tonic-gate 		   : "Doing %s for %ds on %d size blocks: ",s,SECONDS,length);
1803*0Sstevel@tonic-gate 	(void)BIO_flush(bio_err);
1804*0Sstevel@tonic-gate 	alarm(SECONDS);
1805*0Sstevel@tonic-gate #else
1806*0Sstevel@tonic-gate 	BIO_printf(bio_err,mr ? "+DN:%s:%ld:%d\n"
1807*0Sstevel@tonic-gate 		   : "Doing %s %ld times on %d size blocks: ",s,num,length);
1808*0Sstevel@tonic-gate 	(void)BIO_flush(bio_err);
1809*0Sstevel@tonic-gate #endif
1810*0Sstevel@tonic-gate #ifdef LINT
1811*0Sstevel@tonic-gate 	num=num;
1812*0Sstevel@tonic-gate #endif
1813*0Sstevel@tonic-gate 	}
1814*0Sstevel@tonic-gate 
1815*0Sstevel@tonic-gate static void pkey_print_message(char *str, char *str2, long num, int bits,
1816*0Sstevel@tonic-gate 	     int tm)
1817*0Sstevel@tonic-gate 	{
1818*0Sstevel@tonic-gate #ifdef SIGALRM
1819*0Sstevel@tonic-gate 	BIO_printf(bio_err,mr ? "+DTP:%d:%s:%s:%d\n"
1820*0Sstevel@tonic-gate 			   : "Doing %d bit %s %s's for %ds: ",bits,str,str2,tm);
1821*0Sstevel@tonic-gate 	(void)BIO_flush(bio_err);
1822*0Sstevel@tonic-gate 	alarm(RSA_SECONDS);
1823*0Sstevel@tonic-gate #else
1824*0Sstevel@tonic-gate 	BIO_printf(bio_err,mr ? "+DNP:%ld:%d:%s:%s\n"
1825*0Sstevel@tonic-gate 			   : "Doing %ld %d bit %s %s's: ",num,bits,str,str2);
1826*0Sstevel@tonic-gate 	(void)BIO_flush(bio_err);
1827*0Sstevel@tonic-gate #endif
1828*0Sstevel@tonic-gate #ifdef LINT
1829*0Sstevel@tonic-gate 	num=num;
1830*0Sstevel@tonic-gate #endif
1831*0Sstevel@tonic-gate 	}
1832*0Sstevel@tonic-gate 
1833*0Sstevel@tonic-gate static void print_result(int alg,int run_no,int count,double time_used)
1834*0Sstevel@tonic-gate 	{
1835*0Sstevel@tonic-gate 	BIO_printf(bio_err,mr ? "+R:%ld:%s:%f\n"
1836*0Sstevel@tonic-gate 		   : "%ld %s's in %.2fs\n",count,names[alg],time_used);
1837*0Sstevel@tonic-gate 	results[alg][run_no]=((double)count)/time_used*lengths[run_no];
1838*0Sstevel@tonic-gate 	}
1839*0Sstevel@tonic-gate 
1840*0Sstevel@tonic-gate static char *sstrsep(char **string, const char *delim)
1841*0Sstevel@tonic-gate     {
1842*0Sstevel@tonic-gate     char isdelim[256];
1843*0Sstevel@tonic-gate     char *token = *string;
1844*0Sstevel@tonic-gate 
1845*0Sstevel@tonic-gate     if (**string == 0)
1846*0Sstevel@tonic-gate         return NULL;
1847*0Sstevel@tonic-gate 
1848*0Sstevel@tonic-gate     memset(isdelim, 0, sizeof isdelim);
1849*0Sstevel@tonic-gate     isdelim[0] = 1;
1850*0Sstevel@tonic-gate 
1851*0Sstevel@tonic-gate     while (*delim)
1852*0Sstevel@tonic-gate         {
1853*0Sstevel@tonic-gate         isdelim[(unsigned char)(*delim)] = 1;
1854*0Sstevel@tonic-gate         delim++;
1855*0Sstevel@tonic-gate         }
1856*0Sstevel@tonic-gate 
1857*0Sstevel@tonic-gate     while (!isdelim[(unsigned char)(**string)])
1858*0Sstevel@tonic-gate         {
1859*0Sstevel@tonic-gate         (*string)++;
1860*0Sstevel@tonic-gate         }
1861*0Sstevel@tonic-gate 
1862*0Sstevel@tonic-gate     if (**string)
1863*0Sstevel@tonic-gate         {
1864*0Sstevel@tonic-gate         **string = 0;
1865*0Sstevel@tonic-gate         (*string)++;
1866*0Sstevel@tonic-gate         }
1867*0Sstevel@tonic-gate 
1868*0Sstevel@tonic-gate     return token;
1869*0Sstevel@tonic-gate     }
1870*0Sstevel@tonic-gate 
1871*0Sstevel@tonic-gate #ifdef HAVE_FORK
1872*0Sstevel@tonic-gate static int do_multi(int multi)
1873*0Sstevel@tonic-gate 	{
1874*0Sstevel@tonic-gate 	int n;
1875*0Sstevel@tonic-gate 	int fd[2];
1876*0Sstevel@tonic-gate 	int *fds;
1877*0Sstevel@tonic-gate 	static char sep[]=":";
1878*0Sstevel@tonic-gate 
1879*0Sstevel@tonic-gate 	fds=malloc(multi*sizeof *fds);
1880*0Sstevel@tonic-gate 	for(n=0 ; n < multi ; ++n)
1881*0Sstevel@tonic-gate 		{
1882*0Sstevel@tonic-gate 		pipe(fd);
1883*0Sstevel@tonic-gate 		if(fork())
1884*0Sstevel@tonic-gate 			{
1885*0Sstevel@tonic-gate 			close(fd[1]);
1886*0Sstevel@tonic-gate 			fds[n]=fd[0];
1887*0Sstevel@tonic-gate 			}
1888*0Sstevel@tonic-gate 		else
1889*0Sstevel@tonic-gate 			{
1890*0Sstevel@tonic-gate 			close(fd[0]);
1891*0Sstevel@tonic-gate 			close(1);
1892*0Sstevel@tonic-gate 			dup(fd[1]);
1893*0Sstevel@tonic-gate 			close(fd[1]);
1894*0Sstevel@tonic-gate 			mr=1;
1895*0Sstevel@tonic-gate 			usertime=0;
1896*0Sstevel@tonic-gate 			return 0;
1897*0Sstevel@tonic-gate 			}
1898*0Sstevel@tonic-gate 		printf("Forked child %d\n",n);
1899*0Sstevel@tonic-gate 		}
1900*0Sstevel@tonic-gate 
1901*0Sstevel@tonic-gate 	/* for now, assume the pipe is long enough to take all the output */
1902*0Sstevel@tonic-gate 	for(n=0 ; n < multi ; ++n)
1903*0Sstevel@tonic-gate 		{
1904*0Sstevel@tonic-gate 		FILE *f;
1905*0Sstevel@tonic-gate 		char buf[1024];
1906*0Sstevel@tonic-gate 		char *p;
1907*0Sstevel@tonic-gate 
1908*0Sstevel@tonic-gate 		f=fdopen(fds[n],"r");
1909*0Sstevel@tonic-gate 		while(fgets(buf,sizeof buf,f))
1910*0Sstevel@tonic-gate 			{
1911*0Sstevel@tonic-gate 			p=strchr(buf,'\n');
1912*0Sstevel@tonic-gate 			if(p)
1913*0Sstevel@tonic-gate 				*p='\0';
1914*0Sstevel@tonic-gate 			if(buf[0] != '+')
1915*0Sstevel@tonic-gate 				{
1916*0Sstevel@tonic-gate 				fprintf(stderr,"Don't understand line '%s' from child %d\n",
1917*0Sstevel@tonic-gate 						buf,n);
1918*0Sstevel@tonic-gate 				continue;
1919*0Sstevel@tonic-gate 				}
1920*0Sstevel@tonic-gate 			printf("Got: %s from %d\n",buf,n);
1921*0Sstevel@tonic-gate 			if(!strncmp(buf,"+F:",3))
1922*0Sstevel@tonic-gate 				{
1923*0Sstevel@tonic-gate 				int alg;
1924*0Sstevel@tonic-gate 				int j;
1925*0Sstevel@tonic-gate 
1926*0Sstevel@tonic-gate 				p=buf+3;
1927*0Sstevel@tonic-gate 				alg=atoi(sstrsep(&p,sep));
1928*0Sstevel@tonic-gate 				sstrsep(&p,sep);
1929*0Sstevel@tonic-gate 				for(j=0 ; j < SIZE_NUM ; ++j)
1930*0Sstevel@tonic-gate 					results[alg][j]+=atof(sstrsep(&p,sep));
1931*0Sstevel@tonic-gate 				}
1932*0Sstevel@tonic-gate 			else if(!strncmp(buf,"+F2:",4))
1933*0Sstevel@tonic-gate 				{
1934*0Sstevel@tonic-gate 				int k;
1935*0Sstevel@tonic-gate 				double d;
1936*0Sstevel@tonic-gate 
1937*0Sstevel@tonic-gate 				p=buf+4;
1938*0Sstevel@tonic-gate 				k=atoi(sstrsep(&p,sep));
1939*0Sstevel@tonic-gate 				sstrsep(&p,sep);
1940*0Sstevel@tonic-gate 
1941*0Sstevel@tonic-gate 				d=atof(sstrsep(&p,sep));
1942*0Sstevel@tonic-gate 				if(n)
1943*0Sstevel@tonic-gate 					rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
1944*0Sstevel@tonic-gate 				else
1945*0Sstevel@tonic-gate 					rsa_results[k][0]=d;
1946*0Sstevel@tonic-gate 
1947*0Sstevel@tonic-gate 				d=atof(sstrsep(&p,sep));
1948*0Sstevel@tonic-gate 				if(n)
1949*0Sstevel@tonic-gate 					rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
1950*0Sstevel@tonic-gate 				else
1951*0Sstevel@tonic-gate 					rsa_results[k][1]=d;
1952*0Sstevel@tonic-gate 				}
1953*0Sstevel@tonic-gate 			else if(!strncmp(buf,"+F2:",4))
1954*0Sstevel@tonic-gate 				{
1955*0Sstevel@tonic-gate 				int k;
1956*0Sstevel@tonic-gate 				double d;
1957*0Sstevel@tonic-gate 
1958*0Sstevel@tonic-gate 				p=buf+4;
1959*0Sstevel@tonic-gate 				k=atoi(sstrsep(&p,sep));
1960*0Sstevel@tonic-gate 				sstrsep(&p,sep);
1961*0Sstevel@tonic-gate 
1962*0Sstevel@tonic-gate 				d=atof(sstrsep(&p,sep));
1963*0Sstevel@tonic-gate 				if(n)
1964*0Sstevel@tonic-gate 					rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
1965*0Sstevel@tonic-gate 				else
1966*0Sstevel@tonic-gate 					rsa_results[k][0]=d;
1967*0Sstevel@tonic-gate 
1968*0Sstevel@tonic-gate 				d=atof(sstrsep(&p,sep));
1969*0Sstevel@tonic-gate 				if(n)
1970*0Sstevel@tonic-gate 					rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
1971*0Sstevel@tonic-gate 				else
1972*0Sstevel@tonic-gate 					rsa_results[k][1]=d;
1973*0Sstevel@tonic-gate 				}
1974*0Sstevel@tonic-gate 			else if(!strncmp(buf,"+F3:",4))
1975*0Sstevel@tonic-gate 				{
1976*0Sstevel@tonic-gate 				int k;
1977*0Sstevel@tonic-gate 				double d;
1978*0Sstevel@tonic-gate 
1979*0Sstevel@tonic-gate 				p=buf+4;
1980*0Sstevel@tonic-gate 				k=atoi(sstrsep(&p,sep));
1981*0Sstevel@tonic-gate 				sstrsep(&p,sep);
1982*0Sstevel@tonic-gate 
1983*0Sstevel@tonic-gate 				d=atof(sstrsep(&p,sep));
1984*0Sstevel@tonic-gate 				if(n)
1985*0Sstevel@tonic-gate 					dsa_results[k][0]=1/(1/dsa_results[k][0]+1/d);
1986*0Sstevel@tonic-gate 				else
1987*0Sstevel@tonic-gate 					dsa_results[k][0]=d;
1988*0Sstevel@tonic-gate 
1989*0Sstevel@tonic-gate 				d=atof(sstrsep(&p,sep));
1990*0Sstevel@tonic-gate 				if(n)
1991*0Sstevel@tonic-gate 					dsa_results[k][1]=1/(1/dsa_results[k][1]+1/d);
1992*0Sstevel@tonic-gate 				else
1993*0Sstevel@tonic-gate 					dsa_results[k][1]=d;
1994*0Sstevel@tonic-gate 				}
1995*0Sstevel@tonic-gate 			else if(!strncmp(buf,"+H:",3))
1996*0Sstevel@tonic-gate 				{
1997*0Sstevel@tonic-gate 				}
1998*0Sstevel@tonic-gate 			else
1999*0Sstevel@tonic-gate 				fprintf(stderr,"Unknown type '%s' from child %d\n",buf,n);
2000*0Sstevel@tonic-gate 			}
2001*0Sstevel@tonic-gate 		}
2002*0Sstevel@tonic-gate 	return 1;
2003*0Sstevel@tonic-gate 	}
2004*0Sstevel@tonic-gate #endif
2005*0Sstevel@tonic-gate #endif
2006