10Sstevel@tonic-gate /* apps/speed.c -*- mode:C; c-file-style: "eay" -*- */
20Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
30Sstevel@tonic-gate * All rights reserved.
40Sstevel@tonic-gate *
50Sstevel@tonic-gate * This package is an SSL implementation written
60Sstevel@tonic-gate * by Eric Young (eay@cryptsoft.com).
70Sstevel@tonic-gate * The implementation was written so as to conform with Netscapes SSL.
80Sstevel@tonic-gate *
90Sstevel@tonic-gate * This library is free for commercial and non-commercial use as long as
100Sstevel@tonic-gate * the following conditions are aheared to. The following conditions
110Sstevel@tonic-gate * apply to all code found in this distribution, be it the RC4, RSA,
120Sstevel@tonic-gate * lhash, DES, etc., code; not just the SSL code. The SSL documentation
130Sstevel@tonic-gate * included with this distribution is covered by the same copyright terms
140Sstevel@tonic-gate * except that the holder is Tim Hudson (tjh@cryptsoft.com).
150Sstevel@tonic-gate *
160Sstevel@tonic-gate * Copyright remains Eric Young's, and as such any Copyright notices in
170Sstevel@tonic-gate * the code are not to be removed.
180Sstevel@tonic-gate * If this package is used in a product, Eric Young should be given attribution
190Sstevel@tonic-gate * as the author of the parts of the library used.
200Sstevel@tonic-gate * This can be in the form of a textual message at program startup or
210Sstevel@tonic-gate * in documentation (online or textual) provided with the package.
220Sstevel@tonic-gate *
230Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without
240Sstevel@tonic-gate * modification, are permitted provided that the following conditions
250Sstevel@tonic-gate * are met:
260Sstevel@tonic-gate * 1. Redistributions of source code must retain the copyright
270Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer.
280Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright
290Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the
300Sstevel@tonic-gate * documentation and/or other materials provided with the distribution.
310Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software
320Sstevel@tonic-gate * must display the following acknowledgement:
330Sstevel@tonic-gate * "This product includes cryptographic software written by
340Sstevel@tonic-gate * Eric Young (eay@cryptsoft.com)"
350Sstevel@tonic-gate * The word 'cryptographic' can be left out if the rouines from the library
360Sstevel@tonic-gate * being used are not cryptographic related :-).
370Sstevel@tonic-gate * 4. If you include any Windows specific code (or a derivative thereof) from
380Sstevel@tonic-gate * the apps directory (application code) you must include an acknowledgement:
390Sstevel@tonic-gate * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
400Sstevel@tonic-gate *
410Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
420Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
430Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
440Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
450Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
460Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
470Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
480Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
490Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
500Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
510Sstevel@tonic-gate * SUCH DAMAGE.
520Sstevel@tonic-gate *
530Sstevel@tonic-gate * The licence and distribution terms for any publically available version or
540Sstevel@tonic-gate * derivative of this code cannot be changed. i.e. this code cannot simply be
550Sstevel@tonic-gate * copied and put under another distribution licence
560Sstevel@tonic-gate * [including the GNU Public Licence.]
570Sstevel@tonic-gate */
582139Sjp161948 /* ====================================================================
592139Sjp161948 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
602139Sjp161948 *
612139Sjp161948 * Portions of the attached software ("Contribution") are developed by
622139Sjp161948 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
632139Sjp161948 *
642139Sjp161948 * The Contribution is licensed pursuant to the OpenSSL open source
652139Sjp161948 * license provided above.
662139Sjp161948 *
672139Sjp161948 * The ECDH and ECDSA speed test software is originally written by
682139Sjp161948 * Sumit Gupta of Sun Microsystems Laboratories.
692139Sjp161948 *
702139Sjp161948 */
710Sstevel@tonic-gate
720Sstevel@tonic-gate /* most of this code has been pilfered from my libdes speed.c program */
730Sstevel@tonic-gate
740Sstevel@tonic-gate #ifndef OPENSSL_NO_SPEED
750Sstevel@tonic-gate
760Sstevel@tonic-gate #undef SECONDS
770Sstevel@tonic-gate #define SECONDS 3
780Sstevel@tonic-gate #define RSA_SECONDS 10
790Sstevel@tonic-gate #define DSA_SECONDS 10
802139Sjp161948 #define ECDSA_SECONDS 10
812139Sjp161948 #define ECDH_SECONDS 10
820Sstevel@tonic-gate
830Sstevel@tonic-gate /* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
840Sstevel@tonic-gate /* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
850Sstevel@tonic-gate
860Sstevel@tonic-gate #undef PROG
870Sstevel@tonic-gate #define PROG speed_main
880Sstevel@tonic-gate
890Sstevel@tonic-gate #include <stdio.h>
900Sstevel@tonic-gate #include <stdlib.h>
912139Sjp161948
920Sstevel@tonic-gate #include <string.h>
930Sstevel@tonic-gate #include <math.h>
940Sstevel@tonic-gate #include "apps.h"
950Sstevel@tonic-gate #ifdef OPENSSL_NO_STDIO
960Sstevel@tonic-gate #define APPS_WIN16
970Sstevel@tonic-gate #endif
980Sstevel@tonic-gate #include <openssl/crypto.h>
990Sstevel@tonic-gate #include <openssl/rand.h>
1000Sstevel@tonic-gate #include <openssl/err.h>
1010Sstevel@tonic-gate #include <openssl/evp.h>
1020Sstevel@tonic-gate #include <openssl/objects.h>
1030Sstevel@tonic-gate #if !defined(OPENSSL_SYS_MSDOS)
1040Sstevel@tonic-gate #include OPENSSL_UNISTD
1050Sstevel@tonic-gate #endif
1060Sstevel@tonic-gate
1072139Sjp161948 #ifndef OPENSSL_SYS_NETWARE
1082139Sjp161948 #include <signal.h>
1092139Sjp161948 #endif
1102139Sjp161948
1110Sstevel@tonic-gate #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(OPENSSL_SYS_MACOSX)
1120Sstevel@tonic-gate # define USE_TOD
1130Sstevel@tonic-gate #elif !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
1140Sstevel@tonic-gate # define TIMES
1150Sstevel@tonic-gate #endif
1160Sstevel@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 */
1170Sstevel@tonic-gate # define TIMEB
1180Sstevel@tonic-gate #endif
1190Sstevel@tonic-gate
1202139Sjp161948 #if defined(OPENSSL_SYS_NETWARE)
1212139Sjp161948 #undef TIMES
1222139Sjp161948 #undef TIMEB
1232139Sjp161948 #include <time.h>
1242139Sjp161948 #endif
1252139Sjp161948
1260Sstevel@tonic-gate #ifndef _IRIX
1270Sstevel@tonic-gate # include <time.h>
1280Sstevel@tonic-gate #endif
1290Sstevel@tonic-gate #ifdef TIMES
1300Sstevel@tonic-gate # include <sys/types.h>
1310Sstevel@tonic-gate # include <sys/times.h>
1320Sstevel@tonic-gate #endif
1330Sstevel@tonic-gate #ifdef USE_TOD
1340Sstevel@tonic-gate # include <sys/time.h>
1350Sstevel@tonic-gate # include <sys/resource.h>
1360Sstevel@tonic-gate #endif
1370Sstevel@tonic-gate
1380Sstevel@tonic-gate /* Depending on the VMS version, the tms structure is perhaps defined.
1390Sstevel@tonic-gate The __TMS macro will show if it was. If it wasn't defined, we should
1400Sstevel@tonic-gate undefine TIMES, since that tells the rest of the program how things
1410Sstevel@tonic-gate should be handled. -- Richard Levitte */
1420Sstevel@tonic-gate #if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
1430Sstevel@tonic-gate #undef TIMES
1440Sstevel@tonic-gate #endif
1450Sstevel@tonic-gate
1460Sstevel@tonic-gate #ifdef TIMEB
1470Sstevel@tonic-gate #include <sys/timeb.h>
1480Sstevel@tonic-gate #endif
1490Sstevel@tonic-gate
1502139Sjp161948 #if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD) && !defined(OPENSSL_SYS_VXWORKS) && !defined(OPENSSL_SYS_NETWARE)
1510Sstevel@tonic-gate #error "It seems neither struct tms nor struct timeb is supported in this platform!"
1520Sstevel@tonic-gate #endif
1530Sstevel@tonic-gate
1540Sstevel@tonic-gate #if defined(sun) || defined(__ultrix)
1550Sstevel@tonic-gate #define _POSIX_SOURCE
1560Sstevel@tonic-gate #include <limits.h>
1570Sstevel@tonic-gate #include <sys/param.h>
1580Sstevel@tonic-gate #endif
1590Sstevel@tonic-gate
1602139Sjp161948 #include <openssl/bn.h>
1610Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
1620Sstevel@tonic-gate #include <openssl/des.h>
1630Sstevel@tonic-gate #endif
1640Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
1650Sstevel@tonic-gate #include <openssl/aes.h>
1660Sstevel@tonic-gate #endif
1670Sstevel@tonic-gate #ifndef OPENSSL_NO_MD2
1680Sstevel@tonic-gate #include <openssl/md2.h>
1690Sstevel@tonic-gate #endif
1700Sstevel@tonic-gate #ifndef OPENSSL_NO_MDC2
1710Sstevel@tonic-gate #include <openssl/mdc2.h>
1720Sstevel@tonic-gate #endif
1730Sstevel@tonic-gate #ifndef OPENSSL_NO_MD4
1740Sstevel@tonic-gate #include <openssl/md4.h>
1750Sstevel@tonic-gate #endif
1760Sstevel@tonic-gate #ifndef OPENSSL_NO_MD5
1770Sstevel@tonic-gate #include <openssl/md5.h>
1780Sstevel@tonic-gate #endif
1790Sstevel@tonic-gate #ifndef OPENSSL_NO_HMAC
1800Sstevel@tonic-gate #include <openssl/hmac.h>
1810Sstevel@tonic-gate #endif
1820Sstevel@tonic-gate #include <openssl/evp.h>
1830Sstevel@tonic-gate #ifndef OPENSSL_NO_SHA
1840Sstevel@tonic-gate #include <openssl/sha.h>
1850Sstevel@tonic-gate #endif
1860Sstevel@tonic-gate #ifndef OPENSSL_NO_RIPEMD
1870Sstevel@tonic-gate #include <openssl/ripemd.h>
1880Sstevel@tonic-gate #endif
1890Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
1900Sstevel@tonic-gate #include <openssl/rc4.h>
1910Sstevel@tonic-gate #endif
1920Sstevel@tonic-gate #ifndef OPENSSL_NO_RC5
1930Sstevel@tonic-gate #include <openssl/rc5.h>
1940Sstevel@tonic-gate #endif
1950Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
1960Sstevel@tonic-gate #include <openssl/rc2.h>
1970Sstevel@tonic-gate #endif
1980Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
1990Sstevel@tonic-gate #include <openssl/idea.h>
2000Sstevel@tonic-gate #endif
2010Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
2020Sstevel@tonic-gate #include <openssl/blowfish.h>
2030Sstevel@tonic-gate #endif
2040Sstevel@tonic-gate #ifndef OPENSSL_NO_CAST
2050Sstevel@tonic-gate #include <openssl/cast.h>
2060Sstevel@tonic-gate #endif
2070Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
2080Sstevel@tonic-gate #include <openssl/rsa.h>
2090Sstevel@tonic-gate #include "./testrsa.h"
2100Sstevel@tonic-gate #endif
2110Sstevel@tonic-gate #include <openssl/x509.h>
2120Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
2132139Sjp161948 #include <openssl/dsa.h>
2140Sstevel@tonic-gate #include "./testdsa.h"
2150Sstevel@tonic-gate #endif
2162139Sjp161948 #ifndef OPENSSL_NO_ECDSA
2172139Sjp161948 #include <openssl/ecdsa.h>
2182139Sjp161948 #endif
2192139Sjp161948 #ifndef OPENSSL_NO_ECDH
2202139Sjp161948 #include <openssl/ecdh.h>
2212139Sjp161948 #endif
2222139Sjp161948
2232139Sjp161948 /*
2242139Sjp161948 * The following "HZ" timing stuff should be sync'd up with the code in
2252139Sjp161948 * crypto/tmdiff.[ch]. That appears to try to do the same job, though I think
2262139Sjp161948 * this code is more up to date than libcrypto's so there may be features to
2272139Sjp161948 * migrate over first. This is used in two places further down AFAICS.
2282139Sjp161948 * The point is that nothing in openssl actually *uses* that tmdiff stuff, so
2292139Sjp161948 * either speed.c should be using it or it should go because it's obviously not
2302139Sjp161948 * useful enough. Anyone want to do a janitorial job on this?
2312139Sjp161948 */
2320Sstevel@tonic-gate
2330Sstevel@tonic-gate /* The following if from times(3) man page. It may need to be changed */
2340Sstevel@tonic-gate #ifndef HZ
2350Sstevel@tonic-gate # if defined(_SC_CLK_TCK) \
2360Sstevel@tonic-gate && (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000)
2372139Sjp161948 # define HZ sysconf(_SC_CLK_TCK)
2380Sstevel@tonic-gate # else
2390Sstevel@tonic-gate # ifndef CLK_TCK
2400Sstevel@tonic-gate # ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
2410Sstevel@tonic-gate # define HZ 100.0
2420Sstevel@tonic-gate # else /* _BSD_CLK_TCK_ */
2430Sstevel@tonic-gate # define HZ ((double)_BSD_CLK_TCK_)
2440Sstevel@tonic-gate # endif
2450Sstevel@tonic-gate # else /* CLK_TCK */
2460Sstevel@tonic-gate # define HZ ((double)CLK_TCK)
2470Sstevel@tonic-gate # endif
2480Sstevel@tonic-gate # endif
2490Sstevel@tonic-gate #endif
2500Sstevel@tonic-gate
2512139Sjp161948 #if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2) && !defined(OPENSSL_SYS_NETWARE)
2520Sstevel@tonic-gate # define HAVE_FORK 1
2530Sstevel@tonic-gate #endif
2540Sstevel@tonic-gate
2550Sstevel@tonic-gate #undef BUFSIZE
2560Sstevel@tonic-gate #define BUFSIZE ((long)1024*8+1)
2570Sstevel@tonic-gate int run=0;
2580Sstevel@tonic-gate
2590Sstevel@tonic-gate static char ftime_used = 0, times_used = 0, gettimeofday_used = 0, getrusage_used = 0;
2600Sstevel@tonic-gate static int mr=0;
2610Sstevel@tonic-gate static int usertime=1;
2620Sstevel@tonic-gate
2630Sstevel@tonic-gate static double Time_F(int s);
2640Sstevel@tonic-gate static void print_message(const char *s,long num,int length);
2652139Sjp161948 static void pkey_print_message(const char *str, const char *str2,
2662139Sjp161948 long num, int bits, int sec);
2670Sstevel@tonic-gate static void print_result(int alg,int run_no,int count,double time_used);
2680Sstevel@tonic-gate #ifdef HAVE_FORK
2690Sstevel@tonic-gate static int do_multi(int multi);
2700Sstevel@tonic-gate #endif
2710Sstevel@tonic-gate
2722139Sjp161948 #define ALGOR_NUM 21
2730Sstevel@tonic-gate #define SIZE_NUM 5
2740Sstevel@tonic-gate #define RSA_NUM 4
2750Sstevel@tonic-gate #define DSA_NUM 3
2762139Sjp161948
2772139Sjp161948 #define EC_NUM 16
2782139Sjp161948 #define MAX_ECDH_SIZE 256
2792139Sjp161948
2800Sstevel@tonic-gate static const char *names[ALGOR_NUM]={
2810Sstevel@tonic-gate "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4",
2820Sstevel@tonic-gate "des cbc","des ede3","idea cbc",
2830Sstevel@tonic-gate "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc",
2842139Sjp161948 "aes-128 cbc","aes-192 cbc","aes-256 cbc","evp","sha256","sha512"};
2850Sstevel@tonic-gate static double results[ALGOR_NUM][SIZE_NUM];
2860Sstevel@tonic-gate static int lengths[SIZE_NUM]={16,64,256,1024,8*1024};
2870Sstevel@tonic-gate static double rsa_results[RSA_NUM][2];
2880Sstevel@tonic-gate static double dsa_results[DSA_NUM][2];
2892139Sjp161948 #ifndef OPENSSL_NO_ECDSA
2902139Sjp161948 static double ecdsa_results[EC_NUM][2];
2912139Sjp161948 #endif
2922139Sjp161948 #ifndef OPENSSL_NO_ECDH
2932139Sjp161948 static double ecdh_results[EC_NUM][1];
2942139Sjp161948 #endif
2952139Sjp161948
2962139Sjp161948 #if defined(OPENSSL_NO_DSA) && !(defined(OPENSSL_NO_ECDSA) && defined(OPENSSL_NO_ECDH))
2972139Sjp161948 static const char rnd_seed[] = "string to make the random number generator think it has entropy";
2982139Sjp161948 static int rnd_fake = 0;
2992139Sjp161948 #endif
3000Sstevel@tonic-gate
3010Sstevel@tonic-gate #ifdef SIGALRM
3020Sstevel@tonic-gate #if defined(__STDC__) || defined(sgi) || defined(_AIX)
3030Sstevel@tonic-gate #define SIGRETTYPE void
3040Sstevel@tonic-gate #else
3050Sstevel@tonic-gate #define SIGRETTYPE int
3060Sstevel@tonic-gate #endif
3070Sstevel@tonic-gate
3080Sstevel@tonic-gate static SIGRETTYPE sig_done(int sig);
sig_done(int sig)3090Sstevel@tonic-gate static SIGRETTYPE sig_done(int sig)
3100Sstevel@tonic-gate {
3110Sstevel@tonic-gate signal(SIGALRM,sig_done);
3120Sstevel@tonic-gate run=0;
3130Sstevel@tonic-gate #ifdef LINT
3140Sstevel@tonic-gate sig=sig;
3150Sstevel@tonic-gate #endif
3160Sstevel@tonic-gate }
3170Sstevel@tonic-gate #endif
3180Sstevel@tonic-gate
3190Sstevel@tonic-gate #define START 0
3200Sstevel@tonic-gate #define STOP 1
3210Sstevel@tonic-gate
3222139Sjp161948 #if defined(OPENSSL_SYS_NETWARE)
3232139Sjp161948
3242139Sjp161948 /* for NetWare the best we can do is use clock() which returns the
3252139Sjp161948 * time, in hundredths of a second, since the NLM began executing
3262139Sjp161948 */
Time_F(int s)3272139Sjp161948 static double Time_F(int s)
3282139Sjp161948 {
3292139Sjp161948 double ret;
3302139Sjp161948
3312139Sjp161948 static clock_t tstart,tend;
3322139Sjp161948
3332139Sjp161948 if (s == START)
3342139Sjp161948 {
3352139Sjp161948 tstart=clock();
3362139Sjp161948 return(0);
3372139Sjp161948 }
3382139Sjp161948 else
3392139Sjp161948 {
3402139Sjp161948 tend=clock();
3412139Sjp161948 ret=(double)((double)(tend)-(double)(tstart));
3422139Sjp161948 return((ret < 0.001)?0.001:ret);
3432139Sjp161948 }
3442139Sjp161948 }
3452139Sjp161948
3462139Sjp161948 #else
3472139Sjp161948
Time_F(int s)3480Sstevel@tonic-gate static double Time_F(int s)
3490Sstevel@tonic-gate {
3500Sstevel@tonic-gate double ret;
3510Sstevel@tonic-gate
3520Sstevel@tonic-gate #ifdef USE_TOD
3530Sstevel@tonic-gate if(usertime)
3542139Sjp161948 {
3550Sstevel@tonic-gate static struct rusage tstart,tend;
3560Sstevel@tonic-gate
3570Sstevel@tonic-gate getrusage_used = 1;
3580Sstevel@tonic-gate if (s == START)
3590Sstevel@tonic-gate {
3600Sstevel@tonic-gate getrusage(RUSAGE_SELF,&tstart);
3610Sstevel@tonic-gate return(0);
3620Sstevel@tonic-gate }
3630Sstevel@tonic-gate else
3640Sstevel@tonic-gate {
3650Sstevel@tonic-gate long i;
3660Sstevel@tonic-gate
3670Sstevel@tonic-gate getrusage(RUSAGE_SELF,&tend);
3680Sstevel@tonic-gate i=(long)tend.ru_utime.tv_usec-(long)tstart.ru_utime.tv_usec;
3690Sstevel@tonic-gate ret=((double)(tend.ru_utime.tv_sec-tstart.ru_utime.tv_sec))
3700Sstevel@tonic-gate +((double)i)/1000000.0;
3710Sstevel@tonic-gate return((ret < 0.001)?0.001:ret);
3720Sstevel@tonic-gate }
3730Sstevel@tonic-gate }
3740Sstevel@tonic-gate else
3750Sstevel@tonic-gate {
3760Sstevel@tonic-gate static struct timeval tstart,tend;
3770Sstevel@tonic-gate long i;
3780Sstevel@tonic-gate
3790Sstevel@tonic-gate gettimeofday_used = 1;
3800Sstevel@tonic-gate if (s == START)
3810Sstevel@tonic-gate {
3820Sstevel@tonic-gate gettimeofday(&tstart,NULL);
3830Sstevel@tonic-gate return(0);
3840Sstevel@tonic-gate }
3850Sstevel@tonic-gate else
3860Sstevel@tonic-gate {
3870Sstevel@tonic-gate gettimeofday(&tend,NULL);
3880Sstevel@tonic-gate i=(long)tend.tv_usec-(long)tstart.tv_usec;
3890Sstevel@tonic-gate ret=((double)(tend.tv_sec-tstart.tv_sec))+((double)i)/1000000.0;
3900Sstevel@tonic-gate return((ret < 0.001)?0.001:ret);
3910Sstevel@tonic-gate }
3920Sstevel@tonic-gate }
3930Sstevel@tonic-gate #else /* ndef USE_TOD */
3940Sstevel@tonic-gate
3950Sstevel@tonic-gate # ifdef TIMES
3960Sstevel@tonic-gate if (usertime)
3970Sstevel@tonic-gate {
3980Sstevel@tonic-gate static struct tms tstart,tend;
3990Sstevel@tonic-gate
4000Sstevel@tonic-gate times_used = 1;
4010Sstevel@tonic-gate if (s == START)
4020Sstevel@tonic-gate {
4030Sstevel@tonic-gate times(&tstart);
4040Sstevel@tonic-gate return(0);
4050Sstevel@tonic-gate }
4060Sstevel@tonic-gate else
4070Sstevel@tonic-gate {
4080Sstevel@tonic-gate times(&tend);
4092139Sjp161948 ret = HZ;
4102139Sjp161948 ret=(double)(tend.tms_utime-tstart.tms_utime) / ret;
4110Sstevel@tonic-gate return((ret < 1e-3)?1e-3:ret);
4120Sstevel@tonic-gate }
4130Sstevel@tonic-gate }
4140Sstevel@tonic-gate # endif /* times() */
4150Sstevel@tonic-gate # if defined(TIMES) && defined(TIMEB)
4160Sstevel@tonic-gate else
4170Sstevel@tonic-gate # endif
4180Sstevel@tonic-gate # ifdef OPENSSL_SYS_VXWORKS
4190Sstevel@tonic-gate {
4200Sstevel@tonic-gate static unsigned long tick_start, tick_end;
4210Sstevel@tonic-gate
4220Sstevel@tonic-gate if( s == START )
4230Sstevel@tonic-gate {
4240Sstevel@tonic-gate tick_start = tickGet();
4250Sstevel@tonic-gate return 0;
4260Sstevel@tonic-gate }
4270Sstevel@tonic-gate else
4280Sstevel@tonic-gate {
4290Sstevel@tonic-gate tick_end = tickGet();
4300Sstevel@tonic-gate ret = (double)(tick_end - tick_start) / (double)sysClkRateGet();
4310Sstevel@tonic-gate return((ret < 0.001)?0.001:ret);
4320Sstevel@tonic-gate }
4330Sstevel@tonic-gate }
4340Sstevel@tonic-gate # elif defined(TIMEB)
4350Sstevel@tonic-gate {
4360Sstevel@tonic-gate static struct timeb tstart,tend;
4370Sstevel@tonic-gate long i;
4380Sstevel@tonic-gate
4390Sstevel@tonic-gate ftime_used = 1;
4400Sstevel@tonic-gate if (s == START)
4410Sstevel@tonic-gate {
4420Sstevel@tonic-gate ftime(&tstart);
4430Sstevel@tonic-gate return(0);
4440Sstevel@tonic-gate }
4450Sstevel@tonic-gate else
4460Sstevel@tonic-gate {
4470Sstevel@tonic-gate ftime(&tend);
4480Sstevel@tonic-gate i=(long)tend.millitm-(long)tstart.millitm;
4490Sstevel@tonic-gate ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
4500Sstevel@tonic-gate return((ret < 0.001)?0.001:ret);
4510Sstevel@tonic-gate }
4520Sstevel@tonic-gate }
4530Sstevel@tonic-gate # endif
4540Sstevel@tonic-gate #endif
4550Sstevel@tonic-gate }
4562139Sjp161948 #endif /* if defined(OPENSSL_SYS_NETWARE) */
4572139Sjp161948
4582139Sjp161948
4592139Sjp161948 #ifndef OPENSSL_NO_ECDH
4602139Sjp161948 static const int KDF1_SHA1_len = 20;
KDF1_SHA1(const void * in,size_t inlen,void * out,size_t * outlen)4612139Sjp161948 static void *KDF1_SHA1(const void *in, size_t inlen, void *out, size_t *outlen)
4622139Sjp161948 {
4632139Sjp161948 #ifndef OPENSSL_NO_SHA
4642139Sjp161948 if (*outlen < SHA_DIGEST_LENGTH)
4652139Sjp161948 return NULL;
4662139Sjp161948 else
4672139Sjp161948 *outlen = SHA_DIGEST_LENGTH;
4682139Sjp161948 return SHA1(in, inlen, out);
4692139Sjp161948 #else
4702139Sjp161948 return NULL;
4712139Sjp161948 #endif /* OPENSSL_NO_SHA */
4722139Sjp161948 }
4732139Sjp161948 #endif /* OPENSSL_NO_ECDH */
4742139Sjp161948
4750Sstevel@tonic-gate
4760Sstevel@tonic-gate int MAIN(int, char **);
4770Sstevel@tonic-gate
MAIN(int argc,char ** argv)4780Sstevel@tonic-gate int MAIN(int argc, char **argv)
4790Sstevel@tonic-gate {
4800Sstevel@tonic-gate #ifndef OPENSSL_NO_ENGINE
4810Sstevel@tonic-gate ENGINE *e = NULL;
4820Sstevel@tonic-gate #endif
4830Sstevel@tonic-gate unsigned char *buf=NULL,*buf2=NULL;
4840Sstevel@tonic-gate int mret=1;
4850Sstevel@tonic-gate long count=0,save_count=0;
4860Sstevel@tonic-gate int i,j,k;
4870Sstevel@tonic-gate #if !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_DSA)
4880Sstevel@tonic-gate long rsa_count;
4890Sstevel@tonic-gate #endif
4900Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
4910Sstevel@tonic-gate unsigned rsa_num;
4920Sstevel@tonic-gate #endif
4930Sstevel@tonic-gate unsigned char md[EVP_MAX_MD_SIZE];
4940Sstevel@tonic-gate #ifndef OPENSSL_NO_MD2
4950Sstevel@tonic-gate unsigned char md2[MD2_DIGEST_LENGTH];
4960Sstevel@tonic-gate #endif
4970Sstevel@tonic-gate #ifndef OPENSSL_NO_MDC2
4980Sstevel@tonic-gate unsigned char mdc2[MDC2_DIGEST_LENGTH];
4990Sstevel@tonic-gate #endif
5000Sstevel@tonic-gate #ifndef OPENSSL_NO_MD4
5010Sstevel@tonic-gate unsigned char md4[MD4_DIGEST_LENGTH];
5020Sstevel@tonic-gate #endif
5030Sstevel@tonic-gate #ifndef OPENSSL_NO_MD5
5040Sstevel@tonic-gate unsigned char md5[MD5_DIGEST_LENGTH];
5050Sstevel@tonic-gate unsigned char hmac[MD5_DIGEST_LENGTH];
5060Sstevel@tonic-gate #endif
5070Sstevel@tonic-gate #ifndef OPENSSL_NO_SHA
5080Sstevel@tonic-gate unsigned char sha[SHA_DIGEST_LENGTH];
5092139Sjp161948 #ifndef OPENSSL_NO_SHA256
5102139Sjp161948 unsigned char sha256[SHA256_DIGEST_LENGTH];
5112139Sjp161948 #endif
5122139Sjp161948 #ifndef OPENSSL_NO_SHA512
5132139Sjp161948 unsigned char sha512[SHA512_DIGEST_LENGTH];
5142139Sjp161948 #endif
5150Sstevel@tonic-gate #endif
5160Sstevel@tonic-gate #ifndef OPENSSL_NO_RIPEMD
5170Sstevel@tonic-gate unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];
5180Sstevel@tonic-gate #endif
5190Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
5200Sstevel@tonic-gate RC4_KEY rc4_ks;
5210Sstevel@tonic-gate #endif
5220Sstevel@tonic-gate #ifndef OPENSSL_NO_RC5
5230Sstevel@tonic-gate RC5_32_KEY rc5_ks;
5240Sstevel@tonic-gate #endif
5250Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
5260Sstevel@tonic-gate RC2_KEY rc2_ks;
5270Sstevel@tonic-gate #endif
5280Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
5290Sstevel@tonic-gate IDEA_KEY_SCHEDULE idea_ks;
5300Sstevel@tonic-gate #endif
5310Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
5320Sstevel@tonic-gate BF_KEY bf_ks;
5330Sstevel@tonic-gate #endif
5340Sstevel@tonic-gate #ifndef OPENSSL_NO_CAST
5350Sstevel@tonic-gate CAST_KEY cast_ks;
5360Sstevel@tonic-gate #endif
5370Sstevel@tonic-gate static const unsigned char key16[16]=
5380Sstevel@tonic-gate {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
5390Sstevel@tonic-gate 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
5402139Sjp161948 #ifndef OPENSSL_NO_AES
5410Sstevel@tonic-gate static const unsigned char key24[24]=
5420Sstevel@tonic-gate {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
5430Sstevel@tonic-gate 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
5440Sstevel@tonic-gate 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
5450Sstevel@tonic-gate static const unsigned char key32[32]=
5460Sstevel@tonic-gate {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
5470Sstevel@tonic-gate 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
5480Sstevel@tonic-gate 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,
5490Sstevel@tonic-gate 0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56};
5502139Sjp161948 #endif
5510Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
5520Sstevel@tonic-gate #define MAX_BLOCK_SIZE 128
5530Sstevel@tonic-gate #else
5540Sstevel@tonic-gate #define MAX_BLOCK_SIZE 64
5550Sstevel@tonic-gate #endif
5560Sstevel@tonic-gate unsigned char DES_iv[8];
5570Sstevel@tonic-gate unsigned char iv[MAX_BLOCK_SIZE/8];
5580Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
5590Sstevel@tonic-gate DES_cblock *buf_as_des_cblock = NULL;
5600Sstevel@tonic-gate static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
5610Sstevel@tonic-gate static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
5620Sstevel@tonic-gate static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
5630Sstevel@tonic-gate DES_key_schedule sch;
5640Sstevel@tonic-gate DES_key_schedule sch2;
5650Sstevel@tonic-gate DES_key_schedule sch3;
5660Sstevel@tonic-gate #endif
5670Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
5680Sstevel@tonic-gate AES_KEY aes_ks1, aes_ks2, aes_ks3;
5690Sstevel@tonic-gate #endif
5700Sstevel@tonic-gate #define D_MD2 0
5710Sstevel@tonic-gate #define D_MDC2 1
5720Sstevel@tonic-gate #define D_MD4 2
5730Sstevel@tonic-gate #define D_MD5 3
5740Sstevel@tonic-gate #define D_HMAC 4
5750Sstevel@tonic-gate #define D_SHA1 5
5760Sstevel@tonic-gate #define D_RMD160 6
5770Sstevel@tonic-gate #define D_RC4 7
5780Sstevel@tonic-gate #define D_CBC_DES 8
5790Sstevel@tonic-gate #define D_EDE3_DES 9
5800Sstevel@tonic-gate #define D_CBC_IDEA 10
5810Sstevel@tonic-gate #define D_CBC_RC2 11
5820Sstevel@tonic-gate #define D_CBC_RC5 12
5830Sstevel@tonic-gate #define D_CBC_BF 13
5840Sstevel@tonic-gate #define D_CBC_CAST 14
5850Sstevel@tonic-gate #define D_CBC_128_AES 15
5860Sstevel@tonic-gate #define D_CBC_192_AES 16
5870Sstevel@tonic-gate #define D_CBC_256_AES 17
5880Sstevel@tonic-gate #define D_EVP 18
5892139Sjp161948 #define D_SHA256 19
5902139Sjp161948 #define D_SHA512 20
5910Sstevel@tonic-gate double d=0.0;
5920Sstevel@tonic-gate long c[ALGOR_NUM][SIZE_NUM];
5930Sstevel@tonic-gate #define R_DSA_512 0
5940Sstevel@tonic-gate #define R_DSA_1024 1
5950Sstevel@tonic-gate #define R_DSA_2048 2
5960Sstevel@tonic-gate #define R_RSA_512 0
5970Sstevel@tonic-gate #define R_RSA_1024 1
5980Sstevel@tonic-gate #define R_RSA_2048 2
5990Sstevel@tonic-gate #define R_RSA_4096 3
6002139Sjp161948
6012139Sjp161948 #define R_EC_P160 0
6022139Sjp161948 #define R_EC_P192 1
6032139Sjp161948 #define R_EC_P224 2
6042139Sjp161948 #define R_EC_P256 3
6052139Sjp161948 #define R_EC_P384 4
6062139Sjp161948 #define R_EC_P521 5
6072139Sjp161948 #define R_EC_K163 6
6082139Sjp161948 #define R_EC_K233 7
6092139Sjp161948 #define R_EC_K283 8
6102139Sjp161948 #define R_EC_K409 9
6112139Sjp161948 #define R_EC_K571 10
6122139Sjp161948 #define R_EC_B163 11
6132139Sjp161948 #define R_EC_B233 12
6142139Sjp161948 #define R_EC_B283 13
6152139Sjp161948 #define R_EC_B409 14
6162139Sjp161948 #define R_EC_B571 15
6172139Sjp161948
6180Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
6190Sstevel@tonic-gate RSA *rsa_key[RSA_NUM];
6200Sstevel@tonic-gate long rsa_c[RSA_NUM][2];
6210Sstevel@tonic-gate static unsigned int rsa_bits[RSA_NUM]={512,1024,2048,4096};
6220Sstevel@tonic-gate static unsigned char *rsa_data[RSA_NUM]=
6230Sstevel@tonic-gate {test512,test1024,test2048,test4096};
6240Sstevel@tonic-gate static int rsa_data_length[RSA_NUM]={
6250Sstevel@tonic-gate sizeof(test512),sizeof(test1024),
6260Sstevel@tonic-gate sizeof(test2048),sizeof(test4096)};
6270Sstevel@tonic-gate #endif
6280Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
6290Sstevel@tonic-gate DSA *dsa_key[DSA_NUM];
6300Sstevel@tonic-gate long dsa_c[DSA_NUM][2];
6310Sstevel@tonic-gate static unsigned int dsa_bits[DSA_NUM]={512,1024,2048};
6320Sstevel@tonic-gate #endif
6332139Sjp161948 #ifndef OPENSSL_NO_EC
6342139Sjp161948 /* We only test over the following curves as they are representative,
6352139Sjp161948 * To add tests over more curves, simply add the curve NID
6362139Sjp161948 * and curve name to the following arrays and increase the
6372139Sjp161948 * EC_NUM value accordingly.
6382139Sjp161948 */
6392139Sjp161948 static unsigned int test_curves[EC_NUM] =
6402139Sjp161948 {
6412139Sjp161948 /* Prime Curves */
6422139Sjp161948 NID_secp160r1,
6432139Sjp161948 NID_X9_62_prime192v1,
6442139Sjp161948 NID_secp224r1,
6452139Sjp161948 NID_X9_62_prime256v1,
6462139Sjp161948 NID_secp384r1,
6472139Sjp161948 NID_secp521r1,
6482139Sjp161948 /* Binary Curves */
6492139Sjp161948 NID_sect163k1,
6502139Sjp161948 NID_sect233k1,
6512139Sjp161948 NID_sect283k1,
6522139Sjp161948 NID_sect409k1,
6532139Sjp161948 NID_sect571k1,
6542139Sjp161948 NID_sect163r2,
6552139Sjp161948 NID_sect233r1,
6562139Sjp161948 NID_sect283r1,
6572139Sjp161948 NID_sect409r1,
6582139Sjp161948 NID_sect571r1
6592139Sjp161948 };
6602139Sjp161948 static const char * test_curves_names[EC_NUM] =
6612139Sjp161948 {
6622139Sjp161948 /* Prime Curves */
6632139Sjp161948 "secp160r1",
6642139Sjp161948 "nistp192",
6652139Sjp161948 "nistp224",
6662139Sjp161948 "nistp256",
6672139Sjp161948 "nistp384",
6682139Sjp161948 "nistp521",
6692139Sjp161948 /* Binary Curves */
6702139Sjp161948 "nistk163",
6712139Sjp161948 "nistk233",
6722139Sjp161948 "nistk283",
6732139Sjp161948 "nistk409",
6742139Sjp161948 "nistk571",
6752139Sjp161948 "nistb163",
6762139Sjp161948 "nistb233",
6772139Sjp161948 "nistb283",
6782139Sjp161948 "nistb409",
6792139Sjp161948 "nistb571"
6802139Sjp161948 };
6812139Sjp161948 static int test_curves_bits[EC_NUM] =
6822139Sjp161948 {
6832139Sjp161948 160, 192, 224, 256, 384, 521,
6842139Sjp161948 163, 233, 283, 409, 571,
6852139Sjp161948 163, 233, 283, 409, 571
6862139Sjp161948 };
6872139Sjp161948
6882139Sjp161948 #endif
6892139Sjp161948
6902139Sjp161948 #ifndef OPENSSL_NO_ECDSA
6912139Sjp161948 unsigned char ecdsasig[256];
6922139Sjp161948 unsigned int ecdsasiglen;
6932139Sjp161948 EC_KEY *ecdsa[EC_NUM];
6942139Sjp161948 long ecdsa_c[EC_NUM][2];
6952139Sjp161948 #endif
6962139Sjp161948
6972139Sjp161948 #ifndef OPENSSL_NO_ECDH
6982139Sjp161948 EC_KEY *ecdh_a[EC_NUM], *ecdh_b[EC_NUM];
6992139Sjp161948 unsigned char secret_a[MAX_ECDH_SIZE], secret_b[MAX_ECDH_SIZE];
7002139Sjp161948 int secret_size_a, secret_size_b;
7012139Sjp161948 int ecdh_checks = 0;
7022139Sjp161948 int secret_idx = 0;
7032139Sjp161948 long ecdh_c[EC_NUM][2];
7042139Sjp161948 #endif
7052139Sjp161948
7060Sstevel@tonic-gate int rsa_doit[RSA_NUM];
7070Sstevel@tonic-gate int dsa_doit[DSA_NUM];
7082139Sjp161948 #ifndef OPENSSL_NO_ECDSA
7092139Sjp161948 int ecdsa_doit[EC_NUM];
7102139Sjp161948 #endif
7112139Sjp161948 #ifndef OPENSSL_NO_ECDH
7122139Sjp161948 int ecdh_doit[EC_NUM];
7132139Sjp161948 #endif
7140Sstevel@tonic-gate int doit[ALGOR_NUM];
7150Sstevel@tonic-gate int pr_header=0;
7160Sstevel@tonic-gate const EVP_CIPHER *evp_cipher=NULL;
7170Sstevel@tonic-gate const EVP_MD *evp_md=NULL;
7180Sstevel@tonic-gate int decrypt=0;
7190Sstevel@tonic-gate #ifdef HAVE_FORK
7200Sstevel@tonic-gate int multi=0;
7210Sstevel@tonic-gate #endif
7220Sstevel@tonic-gate
7230Sstevel@tonic-gate #ifndef TIMES
7240Sstevel@tonic-gate usertime=-1;
7250Sstevel@tonic-gate #endif
7260Sstevel@tonic-gate
7270Sstevel@tonic-gate apps_startup();
7280Sstevel@tonic-gate memset(results, 0, sizeof(results));
7290Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
7300Sstevel@tonic-gate memset(dsa_key,0,sizeof(dsa_key));
7310Sstevel@tonic-gate #endif
7322139Sjp161948 #ifndef OPENSSL_NO_ECDSA
7332139Sjp161948 for (i=0; i<EC_NUM; i++) ecdsa[i] = NULL;
7342139Sjp161948 #endif
7352139Sjp161948 #ifndef OPENSSL_NO_ECDH
7362139Sjp161948 for (i=0; i<EC_NUM; i++)
7372139Sjp161948 {
7382139Sjp161948 ecdh_a[i] = NULL;
7392139Sjp161948 ecdh_b[i] = NULL;
7402139Sjp161948 }
7412139Sjp161948 #endif
7422139Sjp161948
7430Sstevel@tonic-gate
7440Sstevel@tonic-gate if (bio_err == NULL)
7450Sstevel@tonic-gate if ((bio_err=BIO_new(BIO_s_file())) != NULL)
7460Sstevel@tonic-gate BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
7470Sstevel@tonic-gate
7480Sstevel@tonic-gate if (!load_config(bio_err, NULL))
7490Sstevel@tonic-gate goto end;
7500Sstevel@tonic-gate
7510Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
7520Sstevel@tonic-gate memset(rsa_key,0,sizeof(rsa_key));
7530Sstevel@tonic-gate for (i=0; i<RSA_NUM; i++)
7540Sstevel@tonic-gate rsa_key[i]=NULL;
7550Sstevel@tonic-gate #endif
7560Sstevel@tonic-gate
7570Sstevel@tonic-gate if ((buf=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
7580Sstevel@tonic-gate {
7590Sstevel@tonic-gate BIO_printf(bio_err,"out of memory\n");
7600Sstevel@tonic-gate goto end;
7610Sstevel@tonic-gate }
7620Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
7630Sstevel@tonic-gate buf_as_des_cblock = (DES_cblock *)buf;
7640Sstevel@tonic-gate #endif
7650Sstevel@tonic-gate if ((buf2=(unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL)
7660Sstevel@tonic-gate {
7670Sstevel@tonic-gate BIO_printf(bio_err,"out of memory\n");
7680Sstevel@tonic-gate goto end;
7690Sstevel@tonic-gate }
7700Sstevel@tonic-gate
7710Sstevel@tonic-gate memset(c,0,sizeof(c));
7720Sstevel@tonic-gate memset(DES_iv,0,sizeof(DES_iv));
7730Sstevel@tonic-gate memset(iv,0,sizeof(iv));
7740Sstevel@tonic-gate
7750Sstevel@tonic-gate for (i=0; i<ALGOR_NUM; i++)
7760Sstevel@tonic-gate doit[i]=0;
7770Sstevel@tonic-gate for (i=0; i<RSA_NUM; i++)
7780Sstevel@tonic-gate rsa_doit[i]=0;
7790Sstevel@tonic-gate for (i=0; i<DSA_NUM; i++)
7800Sstevel@tonic-gate dsa_doit[i]=0;
7812139Sjp161948 #ifndef OPENSSL_NO_ECDSA
7822139Sjp161948 for (i=0; i<EC_NUM; i++)
7832139Sjp161948 ecdsa_doit[i]=0;
7842139Sjp161948 #endif
7852139Sjp161948 #ifndef OPENSSL_NO_ECDH
7862139Sjp161948 for (i=0; i<EC_NUM; i++)
7872139Sjp161948 ecdh_doit[i]=0;
7882139Sjp161948 #endif
7892139Sjp161948
7900Sstevel@tonic-gate
7910Sstevel@tonic-gate j=0;
7920Sstevel@tonic-gate argc--;
7930Sstevel@tonic-gate argv++;
7940Sstevel@tonic-gate while (argc)
7950Sstevel@tonic-gate {
7960Sstevel@tonic-gate if ((argc > 0) && (strcmp(*argv,"-elapsed") == 0))
7970Sstevel@tonic-gate {
7980Sstevel@tonic-gate usertime = 0;
7990Sstevel@tonic-gate j--; /* Otherwise, -elapsed gets confused with
8000Sstevel@tonic-gate an algorithm. */
8010Sstevel@tonic-gate }
8020Sstevel@tonic-gate else if ((argc > 0) && (strcmp(*argv,"-evp") == 0))
8030Sstevel@tonic-gate {
8040Sstevel@tonic-gate argc--;
8050Sstevel@tonic-gate argv++;
8060Sstevel@tonic-gate if(argc == 0)
8070Sstevel@tonic-gate {
8080Sstevel@tonic-gate BIO_printf(bio_err,"no EVP given\n");
8090Sstevel@tonic-gate goto end;
8100Sstevel@tonic-gate }
8110Sstevel@tonic-gate evp_cipher=EVP_get_cipherbyname(*argv);
8120Sstevel@tonic-gate if(!evp_cipher)
8130Sstevel@tonic-gate {
8140Sstevel@tonic-gate evp_md=EVP_get_digestbyname(*argv);
8150Sstevel@tonic-gate }
8160Sstevel@tonic-gate if(!evp_cipher && !evp_md)
8170Sstevel@tonic-gate {
8180Sstevel@tonic-gate BIO_printf(bio_err,"%s is an unknown cipher or digest\n",*argv);
8190Sstevel@tonic-gate goto end;
8200Sstevel@tonic-gate }
8210Sstevel@tonic-gate doit[D_EVP]=1;
8220Sstevel@tonic-gate }
8230Sstevel@tonic-gate else if (argc > 0 && !strcmp(*argv,"-decrypt"))
8240Sstevel@tonic-gate {
8250Sstevel@tonic-gate decrypt=1;
8260Sstevel@tonic-gate j--; /* Otherwise, -elapsed gets confused with
8270Sstevel@tonic-gate an algorithm. */
8280Sstevel@tonic-gate }
8290Sstevel@tonic-gate #ifndef OPENSSL_NO_ENGINE
8300Sstevel@tonic-gate else if ((argc > 0) && (strcmp(*argv,"-engine") == 0))
8310Sstevel@tonic-gate {
8320Sstevel@tonic-gate argc--;
8330Sstevel@tonic-gate argv++;
8340Sstevel@tonic-gate if(argc == 0)
8350Sstevel@tonic-gate {
8360Sstevel@tonic-gate BIO_printf(bio_err,"no engine given\n");
8370Sstevel@tonic-gate goto end;
8380Sstevel@tonic-gate }
8390Sstevel@tonic-gate e = setup_engine(bio_err, *argv, 0);
8400Sstevel@tonic-gate /* j will be increased again further down. We just
8410Sstevel@tonic-gate don't want speed to confuse an engine with an
8420Sstevel@tonic-gate algorithm, especially when none is given (which
8430Sstevel@tonic-gate means all of them should be run) */
8440Sstevel@tonic-gate j--;
8450Sstevel@tonic-gate }
8460Sstevel@tonic-gate #endif
8470Sstevel@tonic-gate #ifdef HAVE_FORK
8480Sstevel@tonic-gate else if ((argc > 0) && (strcmp(*argv,"-multi") == 0))
8490Sstevel@tonic-gate {
8500Sstevel@tonic-gate argc--;
8510Sstevel@tonic-gate argv++;
8520Sstevel@tonic-gate if(argc == 0)
8530Sstevel@tonic-gate {
8540Sstevel@tonic-gate BIO_printf(bio_err,"no multi count given\n");
8550Sstevel@tonic-gate goto end;
8560Sstevel@tonic-gate }
8570Sstevel@tonic-gate multi=atoi(argv[0]);
8580Sstevel@tonic-gate if(multi <= 0)
8590Sstevel@tonic-gate {
8600Sstevel@tonic-gate BIO_printf(bio_err,"bad multi count\n");
8610Sstevel@tonic-gate goto end;
8620Sstevel@tonic-gate }
8630Sstevel@tonic-gate j--; /* Otherwise, -mr gets confused with
8640Sstevel@tonic-gate an algorithm. */
8650Sstevel@tonic-gate }
8660Sstevel@tonic-gate #endif
8670Sstevel@tonic-gate else if (argc > 0 && !strcmp(*argv,"-mr"))
8680Sstevel@tonic-gate {
8690Sstevel@tonic-gate mr=1;
8700Sstevel@tonic-gate j--; /* Otherwise, -mr gets confused with
8710Sstevel@tonic-gate an algorithm. */
8720Sstevel@tonic-gate }
8730Sstevel@tonic-gate else
8740Sstevel@tonic-gate #ifndef OPENSSL_NO_MD2
8750Sstevel@tonic-gate if (strcmp(*argv,"md2") == 0) doit[D_MD2]=1;
8760Sstevel@tonic-gate else
8770Sstevel@tonic-gate #endif
8780Sstevel@tonic-gate #ifndef OPENSSL_NO_MDC2
8790Sstevel@tonic-gate if (strcmp(*argv,"mdc2") == 0) doit[D_MDC2]=1;
8800Sstevel@tonic-gate else
8810Sstevel@tonic-gate #endif
8820Sstevel@tonic-gate #ifndef OPENSSL_NO_MD4
8830Sstevel@tonic-gate if (strcmp(*argv,"md4") == 0) doit[D_MD4]=1;
8840Sstevel@tonic-gate else
8850Sstevel@tonic-gate #endif
8860Sstevel@tonic-gate #ifndef OPENSSL_NO_MD5
8870Sstevel@tonic-gate if (strcmp(*argv,"md5") == 0) doit[D_MD5]=1;
8880Sstevel@tonic-gate else
8890Sstevel@tonic-gate #endif
8900Sstevel@tonic-gate #ifndef OPENSSL_NO_MD5
8910Sstevel@tonic-gate if (strcmp(*argv,"hmac") == 0) doit[D_HMAC]=1;
8920Sstevel@tonic-gate else
8930Sstevel@tonic-gate #endif
8940Sstevel@tonic-gate #ifndef OPENSSL_NO_SHA
8950Sstevel@tonic-gate if (strcmp(*argv,"sha1") == 0) doit[D_SHA1]=1;
8960Sstevel@tonic-gate else
8972139Sjp161948 if (strcmp(*argv,"sha") == 0) doit[D_SHA1]=1,
8982139Sjp161948 doit[D_SHA256]=1,
8992139Sjp161948 doit[D_SHA512]=1;
9000Sstevel@tonic-gate else
9012139Sjp161948 #ifndef OPENSSL_NO_SHA256
9022139Sjp161948 if (strcmp(*argv,"sha256") == 0) doit[D_SHA256]=1;
9032139Sjp161948 else
9042139Sjp161948 #endif
9052139Sjp161948 #ifndef OPENSSL_NO_SHA512
9062139Sjp161948 if (strcmp(*argv,"sha512") == 0) doit[D_SHA512]=1;
9072139Sjp161948 else
9082139Sjp161948 #endif
9090Sstevel@tonic-gate #endif
9100Sstevel@tonic-gate #ifndef OPENSSL_NO_RIPEMD
9110Sstevel@tonic-gate if (strcmp(*argv,"ripemd") == 0) doit[D_RMD160]=1;
9120Sstevel@tonic-gate else
9130Sstevel@tonic-gate if (strcmp(*argv,"rmd160") == 0) doit[D_RMD160]=1;
9140Sstevel@tonic-gate else
9150Sstevel@tonic-gate if (strcmp(*argv,"ripemd160") == 0) doit[D_RMD160]=1;
9160Sstevel@tonic-gate else
9170Sstevel@tonic-gate #endif
9180Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
9190Sstevel@tonic-gate if (strcmp(*argv,"rc4") == 0) doit[D_RC4]=1;
9200Sstevel@tonic-gate else
9210Sstevel@tonic-gate #endif
9220Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
9230Sstevel@tonic-gate if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1;
9240Sstevel@tonic-gate else if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1;
9250Sstevel@tonic-gate else
9260Sstevel@tonic-gate #endif
9270Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
9280Sstevel@tonic-gate if (strcmp(*argv,"aes-128-cbc") == 0) doit[D_CBC_128_AES]=1;
9290Sstevel@tonic-gate else if (strcmp(*argv,"aes-192-cbc") == 0) doit[D_CBC_192_AES]=1;
9300Sstevel@tonic-gate else if (strcmp(*argv,"aes-256-cbc") == 0) doit[D_CBC_256_AES]=1;
9310Sstevel@tonic-gate else
9320Sstevel@tonic-gate #endif
9330Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
9340Sstevel@tonic-gate #if 0 /* was: #ifdef RSAref */
9350Sstevel@tonic-gate if (strcmp(*argv,"rsaref") == 0)
9360Sstevel@tonic-gate {
9370Sstevel@tonic-gate RSA_set_default_openssl_method(RSA_PKCS1_RSAref());
9380Sstevel@tonic-gate j--;
9390Sstevel@tonic-gate }
9400Sstevel@tonic-gate else
9410Sstevel@tonic-gate #endif
9420Sstevel@tonic-gate #ifndef RSA_NULL
9430Sstevel@tonic-gate if (strcmp(*argv,"openssl") == 0)
9440Sstevel@tonic-gate {
9450Sstevel@tonic-gate RSA_set_default_method(RSA_PKCS1_SSLeay());
9460Sstevel@tonic-gate j--;
9470Sstevel@tonic-gate }
9480Sstevel@tonic-gate else
9490Sstevel@tonic-gate #endif
9500Sstevel@tonic-gate #endif /* !OPENSSL_NO_RSA */
9510Sstevel@tonic-gate if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2;
9520Sstevel@tonic-gate else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2;
9530Sstevel@tonic-gate else if (strcmp(*argv,"dsa2048") == 0) dsa_doit[R_DSA_2048]=2;
9540Sstevel@tonic-gate else if (strcmp(*argv,"rsa512") == 0) rsa_doit[R_RSA_512]=2;
9550Sstevel@tonic-gate else if (strcmp(*argv,"rsa1024") == 0) rsa_doit[R_RSA_1024]=2;
9560Sstevel@tonic-gate else if (strcmp(*argv,"rsa2048") == 0) rsa_doit[R_RSA_2048]=2;
9570Sstevel@tonic-gate else if (strcmp(*argv,"rsa4096") == 0) rsa_doit[R_RSA_4096]=2;
9580Sstevel@tonic-gate else
9590Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
9600Sstevel@tonic-gate if (strcmp(*argv,"rc2-cbc") == 0) doit[D_CBC_RC2]=1;
9610Sstevel@tonic-gate else if (strcmp(*argv,"rc2") == 0) doit[D_CBC_RC2]=1;
9620Sstevel@tonic-gate else
9630Sstevel@tonic-gate #endif
9640Sstevel@tonic-gate #ifndef OPENSSL_NO_RC5
9650Sstevel@tonic-gate if (strcmp(*argv,"rc5-cbc") == 0) doit[D_CBC_RC5]=1;
9660Sstevel@tonic-gate else if (strcmp(*argv,"rc5") == 0) doit[D_CBC_RC5]=1;
9670Sstevel@tonic-gate else
9680Sstevel@tonic-gate #endif
9690Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
9700Sstevel@tonic-gate if (strcmp(*argv,"idea-cbc") == 0) doit[D_CBC_IDEA]=1;
9710Sstevel@tonic-gate else if (strcmp(*argv,"idea") == 0) doit[D_CBC_IDEA]=1;
9720Sstevel@tonic-gate else
9730Sstevel@tonic-gate #endif
9740Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
9750Sstevel@tonic-gate if (strcmp(*argv,"bf-cbc") == 0) doit[D_CBC_BF]=1;
9760Sstevel@tonic-gate else if (strcmp(*argv,"blowfish") == 0) doit[D_CBC_BF]=1;
9770Sstevel@tonic-gate else if (strcmp(*argv,"bf") == 0) doit[D_CBC_BF]=1;
9780Sstevel@tonic-gate else
9790Sstevel@tonic-gate #endif
9800Sstevel@tonic-gate #ifndef OPENSSL_NO_CAST
9810Sstevel@tonic-gate if (strcmp(*argv,"cast-cbc") == 0) doit[D_CBC_CAST]=1;
9820Sstevel@tonic-gate else if (strcmp(*argv,"cast") == 0) doit[D_CBC_CAST]=1;
9830Sstevel@tonic-gate else if (strcmp(*argv,"cast5") == 0) doit[D_CBC_CAST]=1;
9840Sstevel@tonic-gate else
9850Sstevel@tonic-gate #endif
9860Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
9870Sstevel@tonic-gate if (strcmp(*argv,"des") == 0)
9880Sstevel@tonic-gate {
9890Sstevel@tonic-gate doit[D_CBC_DES]=1;
9900Sstevel@tonic-gate doit[D_EDE3_DES]=1;
9910Sstevel@tonic-gate }
9920Sstevel@tonic-gate else
9930Sstevel@tonic-gate #endif
9940Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
9950Sstevel@tonic-gate if (strcmp(*argv,"aes") == 0)
9960Sstevel@tonic-gate {
9970Sstevel@tonic-gate doit[D_CBC_128_AES]=1;
9980Sstevel@tonic-gate doit[D_CBC_192_AES]=1;
9990Sstevel@tonic-gate doit[D_CBC_256_AES]=1;
10000Sstevel@tonic-gate }
10010Sstevel@tonic-gate else
10020Sstevel@tonic-gate #endif
10030Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
10040Sstevel@tonic-gate if (strcmp(*argv,"rsa") == 0)
10050Sstevel@tonic-gate {
10060Sstevel@tonic-gate rsa_doit[R_RSA_512]=1;
10070Sstevel@tonic-gate rsa_doit[R_RSA_1024]=1;
10080Sstevel@tonic-gate rsa_doit[R_RSA_2048]=1;
10090Sstevel@tonic-gate rsa_doit[R_RSA_4096]=1;
10100Sstevel@tonic-gate }
10110Sstevel@tonic-gate else
10120Sstevel@tonic-gate #endif
10130Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
10140Sstevel@tonic-gate if (strcmp(*argv,"dsa") == 0)
10150Sstevel@tonic-gate {
10160Sstevel@tonic-gate dsa_doit[R_DSA_512]=1;
10170Sstevel@tonic-gate dsa_doit[R_DSA_1024]=1;
10180Sstevel@tonic-gate dsa_doit[R_DSA_2048]=1;
10190Sstevel@tonic-gate }
10200Sstevel@tonic-gate else
10210Sstevel@tonic-gate #endif
10222139Sjp161948 #ifndef OPENSSL_NO_ECDSA
10232139Sjp161948 if (strcmp(*argv,"ecdsap160") == 0) ecdsa_doit[R_EC_P160]=2;
10242139Sjp161948 else if (strcmp(*argv,"ecdsap192") == 0) ecdsa_doit[R_EC_P192]=2;
10252139Sjp161948 else if (strcmp(*argv,"ecdsap224") == 0) ecdsa_doit[R_EC_P224]=2;
10262139Sjp161948 else if (strcmp(*argv,"ecdsap256") == 0) ecdsa_doit[R_EC_P256]=2;
10272139Sjp161948 else if (strcmp(*argv,"ecdsap384") == 0) ecdsa_doit[R_EC_P384]=2;
10282139Sjp161948 else if (strcmp(*argv,"ecdsap521") == 0) ecdsa_doit[R_EC_P521]=2;
10292139Sjp161948 else if (strcmp(*argv,"ecdsak163") == 0) ecdsa_doit[R_EC_K163]=2;
10302139Sjp161948 else if (strcmp(*argv,"ecdsak233") == 0) ecdsa_doit[R_EC_K233]=2;
10312139Sjp161948 else if (strcmp(*argv,"ecdsak283") == 0) ecdsa_doit[R_EC_K283]=2;
10322139Sjp161948 else if (strcmp(*argv,"ecdsak409") == 0) ecdsa_doit[R_EC_K409]=2;
10332139Sjp161948 else if (strcmp(*argv,"ecdsak571") == 0) ecdsa_doit[R_EC_K571]=2;
10342139Sjp161948 else if (strcmp(*argv,"ecdsab163") == 0) ecdsa_doit[R_EC_B163]=2;
10352139Sjp161948 else if (strcmp(*argv,"ecdsab233") == 0) ecdsa_doit[R_EC_B233]=2;
10362139Sjp161948 else if (strcmp(*argv,"ecdsab283") == 0) ecdsa_doit[R_EC_B283]=2;
10372139Sjp161948 else if (strcmp(*argv,"ecdsab409") == 0) ecdsa_doit[R_EC_B409]=2;
10382139Sjp161948 else if (strcmp(*argv,"ecdsab571") == 0) ecdsa_doit[R_EC_B571]=2;
10392139Sjp161948 else if (strcmp(*argv,"ecdsa") == 0)
10402139Sjp161948 {
10412139Sjp161948 for (i=0; i < EC_NUM; i++)
10422139Sjp161948 ecdsa_doit[i]=1;
10432139Sjp161948 }
10442139Sjp161948 else
10452139Sjp161948 #endif
10462139Sjp161948 #ifndef OPENSSL_NO_ECDH
10472139Sjp161948 if (strcmp(*argv,"ecdhp160") == 0) ecdh_doit[R_EC_P160]=2;
10482139Sjp161948 else if (strcmp(*argv,"ecdhp192") == 0) ecdh_doit[R_EC_P192]=2;
10492139Sjp161948 else if (strcmp(*argv,"ecdhp224") == 0) ecdh_doit[R_EC_P224]=2;
10502139Sjp161948 else if (strcmp(*argv,"ecdhp256") == 0) ecdh_doit[R_EC_P256]=2;
10512139Sjp161948 else if (strcmp(*argv,"ecdhp384") == 0) ecdh_doit[R_EC_P384]=2;
10522139Sjp161948 else if (strcmp(*argv,"ecdhp521") == 0) ecdh_doit[R_EC_P521]=2;
10532139Sjp161948 else if (strcmp(*argv,"ecdhk163") == 0) ecdh_doit[R_EC_K163]=2;
10542139Sjp161948 else if (strcmp(*argv,"ecdhk233") == 0) ecdh_doit[R_EC_K233]=2;
10552139Sjp161948 else if (strcmp(*argv,"ecdhk283") == 0) ecdh_doit[R_EC_K283]=2;
10562139Sjp161948 else if (strcmp(*argv,"ecdhk409") == 0) ecdh_doit[R_EC_K409]=2;
10572139Sjp161948 else if (strcmp(*argv,"ecdhk571") == 0) ecdh_doit[R_EC_K571]=2;
10582139Sjp161948 else if (strcmp(*argv,"ecdhb163") == 0) ecdh_doit[R_EC_B163]=2;
10592139Sjp161948 else if (strcmp(*argv,"ecdhb233") == 0) ecdh_doit[R_EC_B233]=2;
10602139Sjp161948 else if (strcmp(*argv,"ecdhb283") == 0) ecdh_doit[R_EC_B283]=2;
10612139Sjp161948 else if (strcmp(*argv,"ecdhb409") == 0) ecdh_doit[R_EC_B409]=2;
10622139Sjp161948 else if (strcmp(*argv,"ecdhb571") == 0) ecdh_doit[R_EC_B571]=2;
10632139Sjp161948 else if (strcmp(*argv,"ecdh") == 0)
10642139Sjp161948 {
10652139Sjp161948 for (i=0; i < EC_NUM; i++)
10662139Sjp161948 ecdh_doit[i]=1;
10672139Sjp161948 }
10682139Sjp161948 else
10692139Sjp161948 #endif
10700Sstevel@tonic-gate {
10710Sstevel@tonic-gate BIO_printf(bio_err,"Error: bad option or value\n");
10720Sstevel@tonic-gate BIO_printf(bio_err,"\n");
10730Sstevel@tonic-gate BIO_printf(bio_err,"Available values:\n");
10740Sstevel@tonic-gate #ifndef OPENSSL_NO_MD2
10750Sstevel@tonic-gate BIO_printf(bio_err,"md2 ");
10760Sstevel@tonic-gate #endif
10770Sstevel@tonic-gate #ifndef OPENSSL_NO_MDC2
10780Sstevel@tonic-gate BIO_printf(bio_err,"mdc2 ");
10790Sstevel@tonic-gate #endif
10800Sstevel@tonic-gate #ifndef OPENSSL_NO_MD4
10810Sstevel@tonic-gate BIO_printf(bio_err,"md4 ");
10820Sstevel@tonic-gate #endif
10830Sstevel@tonic-gate #ifndef OPENSSL_NO_MD5
10840Sstevel@tonic-gate BIO_printf(bio_err,"md5 ");
10850Sstevel@tonic-gate #ifndef OPENSSL_NO_HMAC
10860Sstevel@tonic-gate BIO_printf(bio_err,"hmac ");
10870Sstevel@tonic-gate #endif
10880Sstevel@tonic-gate #endif
10890Sstevel@tonic-gate #ifndef OPENSSL_NO_SHA1
10900Sstevel@tonic-gate BIO_printf(bio_err,"sha1 ");
10910Sstevel@tonic-gate #endif
10922139Sjp161948 #ifndef OPENSSL_NO_SHA256
10932139Sjp161948 BIO_printf(bio_err,"sha256 ");
10942139Sjp161948 #endif
10952139Sjp161948 #ifndef OPENSSL_NO_SHA512
10962139Sjp161948 BIO_printf(bio_err,"sha512 ");
10972139Sjp161948 #endif
10980Sstevel@tonic-gate #ifndef OPENSSL_NO_RIPEMD160
10990Sstevel@tonic-gate BIO_printf(bio_err,"rmd160");
11000Sstevel@tonic-gate #endif
11010Sstevel@tonic-gate #if !defined(OPENSSL_NO_MD2) || !defined(OPENSSL_NO_MDC2) || \
11020Sstevel@tonic-gate !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \
11030Sstevel@tonic-gate !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160)
11040Sstevel@tonic-gate BIO_printf(bio_err,"\n");
11050Sstevel@tonic-gate #endif
11060Sstevel@tonic-gate
11070Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
11080Sstevel@tonic-gate BIO_printf(bio_err,"idea-cbc ");
11090Sstevel@tonic-gate #endif
11100Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
11110Sstevel@tonic-gate BIO_printf(bio_err,"rc2-cbc ");
11120Sstevel@tonic-gate #endif
11130Sstevel@tonic-gate #ifndef OPENSSL_NO_RC5
11140Sstevel@tonic-gate BIO_printf(bio_err,"rc5-cbc ");
11150Sstevel@tonic-gate #endif
11160Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
11170Sstevel@tonic-gate BIO_printf(bio_err,"bf-cbc");
11180Sstevel@tonic-gate #endif
11190Sstevel@tonic-gate #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
11200Sstevel@tonic-gate !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_RC5)
11210Sstevel@tonic-gate BIO_printf(bio_err,"\n");
11220Sstevel@tonic-gate #endif
11230Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
11240Sstevel@tonic-gate BIO_printf(bio_err,"des-cbc des-ede3 ");
11250Sstevel@tonic-gate #endif
11260Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
11270Sstevel@tonic-gate BIO_printf(bio_err,"aes-128-cbc aes-192-cbc aes-256-cbc ");
11280Sstevel@tonic-gate #endif
11290Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
11300Sstevel@tonic-gate BIO_printf(bio_err,"rc4");
11310Sstevel@tonic-gate #endif
11320Sstevel@tonic-gate BIO_printf(bio_err,"\n");
11330Sstevel@tonic-gate
11340Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
11350Sstevel@tonic-gate BIO_printf(bio_err,"rsa512 rsa1024 rsa2048 rsa4096\n");
11360Sstevel@tonic-gate #endif
11370Sstevel@tonic-gate
11380Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
11390Sstevel@tonic-gate BIO_printf(bio_err,"dsa512 dsa1024 dsa2048\n");
11400Sstevel@tonic-gate #endif
11412139Sjp161948 #ifndef OPENSSL_NO_ECDSA
11422139Sjp161948 BIO_printf(bio_err,"ecdsap160 ecdsap192 ecdsap224 ecdsap256 ecdsap384 ecdsap521\n");
11432139Sjp161948 BIO_printf(bio_err,"ecdsak163 ecdsak233 ecdsak283 ecdsak409 ecdsak571\n");
11442139Sjp161948 BIO_printf(bio_err,"ecdsab163 ecdsab233 ecdsab283 ecdsab409 ecdsab571\n");
11452139Sjp161948 BIO_printf(bio_err,"ecdsa\n");
11462139Sjp161948 #endif
11472139Sjp161948 #ifndef OPENSSL_NO_ECDH
11482139Sjp161948 BIO_printf(bio_err,"ecdhp160 ecdhp192 ecdhp224 ecdhp256 ecdhp384 ecdhp521\n");
11492139Sjp161948 BIO_printf(bio_err,"ecdhk163 ecdhk233 ecdhk283 ecdhk409 ecdhk571\n");
11502139Sjp161948 BIO_printf(bio_err,"ecdhb163 ecdhb233 ecdhb283 ecdhb409 ecdhb571\n");
11512139Sjp161948 BIO_printf(bio_err,"ecdh\n");
11522139Sjp161948 #endif
11530Sstevel@tonic-gate
11540Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
11550Sstevel@tonic-gate BIO_printf(bio_err,"idea ");
11560Sstevel@tonic-gate #endif
11570Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
11580Sstevel@tonic-gate BIO_printf(bio_err,"rc2 ");
11590Sstevel@tonic-gate #endif
11600Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
11610Sstevel@tonic-gate BIO_printf(bio_err,"des ");
11620Sstevel@tonic-gate #endif
11630Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
11640Sstevel@tonic-gate BIO_printf(bio_err,"aes ");
11650Sstevel@tonic-gate #endif
11660Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
11670Sstevel@tonic-gate BIO_printf(bio_err,"rsa ");
11680Sstevel@tonic-gate #endif
11690Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
11700Sstevel@tonic-gate BIO_printf(bio_err,"blowfish");
11710Sstevel@tonic-gate #endif
11720Sstevel@tonic-gate #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
11730Sstevel@tonic-gate !defined(OPENSSL_NO_DES) || !defined(OPENSSL_NO_RSA) || \
11740Sstevel@tonic-gate !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_AES)
11750Sstevel@tonic-gate BIO_printf(bio_err,"\n");
11760Sstevel@tonic-gate #endif
11770Sstevel@tonic-gate
11780Sstevel@tonic-gate BIO_printf(bio_err,"\n");
11790Sstevel@tonic-gate BIO_printf(bio_err,"Available options:\n");
11800Sstevel@tonic-gate #if defined(TIMES) || defined(USE_TOD)
11810Sstevel@tonic-gate BIO_printf(bio_err,"-elapsed measure time in real time instead of CPU user time.\n");
11820Sstevel@tonic-gate #endif
11830Sstevel@tonic-gate #ifndef OPENSSL_NO_ENGINE
11840Sstevel@tonic-gate BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n");
11850Sstevel@tonic-gate #endif
11860Sstevel@tonic-gate BIO_printf(bio_err,"-evp e use EVP e.\n");
11870Sstevel@tonic-gate BIO_printf(bio_err,"-decrypt time decryption instead of encryption (only EVP).\n");
11880Sstevel@tonic-gate BIO_printf(bio_err,"-mr produce machine readable output.\n");
11890Sstevel@tonic-gate #ifdef HAVE_FORK
11900Sstevel@tonic-gate BIO_printf(bio_err,"-multi n run n benchmarks in parallel.\n");
11910Sstevel@tonic-gate #endif
11920Sstevel@tonic-gate goto end;
11930Sstevel@tonic-gate }
11940Sstevel@tonic-gate argc--;
11950Sstevel@tonic-gate argv++;
11960Sstevel@tonic-gate j++;
11970Sstevel@tonic-gate }
11980Sstevel@tonic-gate
11990Sstevel@tonic-gate #ifdef HAVE_FORK
12000Sstevel@tonic-gate if(multi && do_multi(multi))
12010Sstevel@tonic-gate goto show_res;
12020Sstevel@tonic-gate #endif
12030Sstevel@tonic-gate
12040Sstevel@tonic-gate if (j == 0)
12050Sstevel@tonic-gate {
12060Sstevel@tonic-gate for (i=0; i<ALGOR_NUM; i++)
12070Sstevel@tonic-gate {
12080Sstevel@tonic-gate if (i != D_EVP)
12090Sstevel@tonic-gate doit[i]=1;
12100Sstevel@tonic-gate }
12110Sstevel@tonic-gate for (i=0; i<RSA_NUM; i++)
12120Sstevel@tonic-gate rsa_doit[i]=1;
12130Sstevel@tonic-gate for (i=0; i<DSA_NUM; i++)
12140Sstevel@tonic-gate dsa_doit[i]=1;
12150Sstevel@tonic-gate }
12160Sstevel@tonic-gate for (i=0; i<ALGOR_NUM; i++)
12170Sstevel@tonic-gate if (doit[i]) pr_header++;
12180Sstevel@tonic-gate
12190Sstevel@tonic-gate if (usertime == 0 && !mr)
12200Sstevel@tonic-gate BIO_printf(bio_err,"You have chosen to measure elapsed time instead of user CPU time.\n");
12210Sstevel@tonic-gate if (usertime <= 0 && !mr)
12220Sstevel@tonic-gate {
12230Sstevel@tonic-gate BIO_printf(bio_err,"To get the most accurate results, try to run this\n");
12240Sstevel@tonic-gate BIO_printf(bio_err,"program when this computer is idle.\n");
12250Sstevel@tonic-gate }
12260Sstevel@tonic-gate
12270Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
12280Sstevel@tonic-gate for (i=0; i<RSA_NUM; i++)
12290Sstevel@tonic-gate {
12300Sstevel@tonic-gate const unsigned char *p;
12310Sstevel@tonic-gate
12320Sstevel@tonic-gate p=rsa_data[i];
12330Sstevel@tonic-gate rsa_key[i]=d2i_RSAPrivateKey(NULL,&p,rsa_data_length[i]);
12340Sstevel@tonic-gate if (rsa_key[i] == NULL)
12350Sstevel@tonic-gate {
12360Sstevel@tonic-gate BIO_printf(bio_err,"internal error loading RSA key number %d\n",i);
12370Sstevel@tonic-gate goto end;
12380Sstevel@tonic-gate }
12390Sstevel@tonic-gate #if 0
12400Sstevel@tonic-gate else
12410Sstevel@tonic-gate {
12420Sstevel@tonic-gate BIO_printf(bio_err,mr ? "+RK:%d:"
12430Sstevel@tonic-gate : "Loaded RSA key, %d bit modulus and e= 0x",
12440Sstevel@tonic-gate BN_num_bits(rsa_key[i]->n));
12450Sstevel@tonic-gate BN_print(bio_err,rsa_key[i]->e);
12460Sstevel@tonic-gate BIO_printf(bio_err,"\n");
12470Sstevel@tonic-gate }
12480Sstevel@tonic-gate #endif
12490Sstevel@tonic-gate }
12500Sstevel@tonic-gate #endif
12510Sstevel@tonic-gate
12520Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
12530Sstevel@tonic-gate dsa_key[0]=get_dsa512();
12540Sstevel@tonic-gate dsa_key[1]=get_dsa1024();
12550Sstevel@tonic-gate dsa_key[2]=get_dsa2048();
12560Sstevel@tonic-gate #endif
12570Sstevel@tonic-gate
12580Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
12590Sstevel@tonic-gate DES_set_key_unchecked(&key,&sch);
12600Sstevel@tonic-gate DES_set_key_unchecked(&key2,&sch2);
12610Sstevel@tonic-gate DES_set_key_unchecked(&key3,&sch3);
12620Sstevel@tonic-gate #endif
12630Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
12640Sstevel@tonic-gate AES_set_encrypt_key(key16,128,&aes_ks1);
12650Sstevel@tonic-gate AES_set_encrypt_key(key24,192,&aes_ks2);
12660Sstevel@tonic-gate AES_set_encrypt_key(key32,256,&aes_ks3);
12670Sstevel@tonic-gate #endif
12680Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
12690Sstevel@tonic-gate idea_set_encrypt_key(key16,&idea_ks);
12700Sstevel@tonic-gate #endif
12710Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
12720Sstevel@tonic-gate RC4_set_key(&rc4_ks,16,key16);
12730Sstevel@tonic-gate #endif
12740Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
12750Sstevel@tonic-gate RC2_set_key(&rc2_ks,16,key16,128);
12760Sstevel@tonic-gate #endif
12770Sstevel@tonic-gate #ifndef OPENSSL_NO_RC5
12780Sstevel@tonic-gate RC5_32_set_key(&rc5_ks,16,key16,12);
12790Sstevel@tonic-gate #endif
12800Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
12810Sstevel@tonic-gate BF_set_key(&bf_ks,16,key16);
12820Sstevel@tonic-gate #endif
12830Sstevel@tonic-gate #ifndef OPENSSL_NO_CAST
12840Sstevel@tonic-gate CAST_set_key(&cast_ks,16,key16);
12850Sstevel@tonic-gate #endif
12860Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
12870Sstevel@tonic-gate memset(rsa_c,0,sizeof(rsa_c));
12880Sstevel@tonic-gate #endif
12890Sstevel@tonic-gate #ifndef SIGALRM
12900Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
12910Sstevel@tonic-gate BIO_printf(bio_err,"First we calculate the approximate speed ...\n");
12920Sstevel@tonic-gate count=10;
12930Sstevel@tonic-gate do {
12942139Sjp161948 long it;
12950Sstevel@tonic-gate count*=2;
12960Sstevel@tonic-gate Time_F(START);
12972139Sjp161948 for (it=count; it; it--)
12980Sstevel@tonic-gate DES_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock,
12990Sstevel@tonic-gate &sch,DES_ENCRYPT);
13000Sstevel@tonic-gate d=Time_F(STOP);
13010Sstevel@tonic-gate } while (d <3);
13020Sstevel@tonic-gate save_count=count;
13030Sstevel@tonic-gate c[D_MD2][0]=count/10;
13040Sstevel@tonic-gate c[D_MDC2][0]=count/10;
13050Sstevel@tonic-gate c[D_MD4][0]=count;
13060Sstevel@tonic-gate c[D_MD5][0]=count;
13070Sstevel@tonic-gate c[D_HMAC][0]=count;
13080Sstevel@tonic-gate c[D_SHA1][0]=count;
13090Sstevel@tonic-gate c[D_RMD160][0]=count;
13100Sstevel@tonic-gate c[D_RC4][0]=count*5;
13110Sstevel@tonic-gate c[D_CBC_DES][0]=count;
13120Sstevel@tonic-gate c[D_EDE3_DES][0]=count/3;
13130Sstevel@tonic-gate c[D_CBC_IDEA][0]=count;
13140Sstevel@tonic-gate c[D_CBC_RC2][0]=count;
13150Sstevel@tonic-gate c[D_CBC_RC5][0]=count;
13160Sstevel@tonic-gate c[D_CBC_BF][0]=count;
13170Sstevel@tonic-gate c[D_CBC_CAST][0]=count;
13180Sstevel@tonic-gate c[D_CBC_128_AES][0]=count;
13190Sstevel@tonic-gate c[D_CBC_192_AES][0]=count;
13200Sstevel@tonic-gate c[D_CBC_256_AES][0]=count;
13212139Sjp161948 c[D_SHA256][0]=count;
13222139Sjp161948 c[D_SHA512][0]=count;
13230Sstevel@tonic-gate
13240Sstevel@tonic-gate for (i=1; i<SIZE_NUM; i++)
13250Sstevel@tonic-gate {
13260Sstevel@tonic-gate c[D_MD2][i]=c[D_MD2][0]*4*lengths[0]/lengths[i];
13270Sstevel@tonic-gate c[D_MDC2][i]=c[D_MDC2][0]*4*lengths[0]/lengths[i];
13280Sstevel@tonic-gate c[D_MD4][i]=c[D_MD4][0]*4*lengths[0]/lengths[i];
13290Sstevel@tonic-gate c[D_MD5][i]=c[D_MD5][0]*4*lengths[0]/lengths[i];
13300Sstevel@tonic-gate c[D_HMAC][i]=c[D_HMAC][0]*4*lengths[0]/lengths[i];
13310Sstevel@tonic-gate c[D_SHA1][i]=c[D_SHA1][0]*4*lengths[0]/lengths[i];
13320Sstevel@tonic-gate c[D_RMD160][i]=c[D_RMD160][0]*4*lengths[0]/lengths[i];
13332139Sjp161948 c[D_SHA256][i]=c[D_SHA256][0]*4*lengths[0]/lengths[i];
13342139Sjp161948 c[D_SHA512][i]=c[D_SHA512][0]*4*lengths[0]/lengths[i];
13350Sstevel@tonic-gate }
13360Sstevel@tonic-gate for (i=1; i<SIZE_NUM; i++)
13370Sstevel@tonic-gate {
13380Sstevel@tonic-gate long l0,l1;
13390Sstevel@tonic-gate
13400Sstevel@tonic-gate l0=(long)lengths[i-1];
13410Sstevel@tonic-gate l1=(long)lengths[i];
13420Sstevel@tonic-gate c[D_RC4][i]=c[D_RC4][i-1]*l0/l1;
13430Sstevel@tonic-gate c[D_CBC_DES][i]=c[D_CBC_DES][i-1]*l0/l1;
13440Sstevel@tonic-gate c[D_EDE3_DES][i]=c[D_EDE3_DES][i-1]*l0/l1;
13450Sstevel@tonic-gate c[D_CBC_IDEA][i]=c[D_CBC_IDEA][i-1]*l0/l1;
13460Sstevel@tonic-gate c[D_CBC_RC2][i]=c[D_CBC_RC2][i-1]*l0/l1;
13470Sstevel@tonic-gate c[D_CBC_RC5][i]=c[D_CBC_RC5][i-1]*l0/l1;
13480Sstevel@tonic-gate c[D_CBC_BF][i]=c[D_CBC_BF][i-1]*l0/l1;
13490Sstevel@tonic-gate c[D_CBC_CAST][i]=c[D_CBC_CAST][i-1]*l0/l1;
13500Sstevel@tonic-gate c[D_CBC_128_AES][i]=c[D_CBC_128_AES][i-1]*l0/l1;
13510Sstevel@tonic-gate c[D_CBC_192_AES][i]=c[D_CBC_192_AES][i-1]*l0/l1;
13520Sstevel@tonic-gate c[D_CBC_256_AES][i]=c[D_CBC_256_AES][i-1]*l0/l1;
13530Sstevel@tonic-gate }
13540Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
13550Sstevel@tonic-gate rsa_c[R_RSA_512][0]=count/2000;
13560Sstevel@tonic-gate rsa_c[R_RSA_512][1]=count/400;
13570Sstevel@tonic-gate for (i=1; i<RSA_NUM; i++)
13580Sstevel@tonic-gate {
13590Sstevel@tonic-gate rsa_c[i][0]=rsa_c[i-1][0]/8;
13600Sstevel@tonic-gate rsa_c[i][1]=rsa_c[i-1][1]/4;
13610Sstevel@tonic-gate if ((rsa_doit[i] <= 1) && (rsa_c[i][0] == 0))
13620Sstevel@tonic-gate rsa_doit[i]=0;
13630Sstevel@tonic-gate else
13640Sstevel@tonic-gate {
13650Sstevel@tonic-gate if (rsa_c[i][0] == 0)
13660Sstevel@tonic-gate {
13670Sstevel@tonic-gate rsa_c[i][0]=1;
13680Sstevel@tonic-gate rsa_c[i][1]=20;
13690Sstevel@tonic-gate }
13700Sstevel@tonic-gate }
13710Sstevel@tonic-gate }
13720Sstevel@tonic-gate #endif
13730Sstevel@tonic-gate
13740Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
13750Sstevel@tonic-gate dsa_c[R_DSA_512][0]=count/1000;
13760Sstevel@tonic-gate dsa_c[R_DSA_512][1]=count/1000/2;
13770Sstevel@tonic-gate for (i=1; i<DSA_NUM; i++)
13780Sstevel@tonic-gate {
13790Sstevel@tonic-gate dsa_c[i][0]=dsa_c[i-1][0]/4;
13800Sstevel@tonic-gate dsa_c[i][1]=dsa_c[i-1][1]/4;
13810Sstevel@tonic-gate if ((dsa_doit[i] <= 1) && (dsa_c[i][0] == 0))
13820Sstevel@tonic-gate dsa_doit[i]=0;
13830Sstevel@tonic-gate else
13840Sstevel@tonic-gate {
13850Sstevel@tonic-gate if (dsa_c[i] == 0)
13860Sstevel@tonic-gate {
13870Sstevel@tonic-gate dsa_c[i][0]=1;
13880Sstevel@tonic-gate dsa_c[i][1]=1;
13890Sstevel@tonic-gate }
13900Sstevel@tonic-gate }
13910Sstevel@tonic-gate }
13920Sstevel@tonic-gate #endif
13930Sstevel@tonic-gate
13942139Sjp161948 #ifndef OPENSSL_NO_ECDSA
13952139Sjp161948 ecdsa_c[R_EC_P160][0]=count/1000;
13962139Sjp161948 ecdsa_c[R_EC_P160][1]=count/1000/2;
13972139Sjp161948 for (i=R_EC_P192; i<=R_EC_P521; i++)
13982139Sjp161948 {
13992139Sjp161948 ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
14002139Sjp161948 ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
14012139Sjp161948 if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
14022139Sjp161948 ecdsa_doit[i]=0;
14032139Sjp161948 else
14042139Sjp161948 {
14052139Sjp161948 if (ecdsa_c[i] == 0)
14062139Sjp161948 {
14072139Sjp161948 ecdsa_c[i][0]=1;
14082139Sjp161948 ecdsa_c[i][1]=1;
14092139Sjp161948 }
14102139Sjp161948 }
14112139Sjp161948 }
14122139Sjp161948 ecdsa_c[R_EC_K163][0]=count/1000;
14132139Sjp161948 ecdsa_c[R_EC_K163][1]=count/1000/2;
14142139Sjp161948 for (i=R_EC_K233; i<=R_EC_K571; i++)
14152139Sjp161948 {
14162139Sjp161948 ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
14172139Sjp161948 ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
14182139Sjp161948 if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
14192139Sjp161948 ecdsa_doit[i]=0;
14202139Sjp161948 else
14212139Sjp161948 {
14222139Sjp161948 if (ecdsa_c[i] == 0)
14232139Sjp161948 {
14242139Sjp161948 ecdsa_c[i][0]=1;
14252139Sjp161948 ecdsa_c[i][1]=1;
14262139Sjp161948 }
14272139Sjp161948 }
14282139Sjp161948 }
14292139Sjp161948 ecdsa_c[R_EC_B163][0]=count/1000;
14302139Sjp161948 ecdsa_c[R_EC_B163][1]=count/1000/2;
14312139Sjp161948 for (i=R_EC_B233; i<=R_EC_B571; i++)
14322139Sjp161948 {
14332139Sjp161948 ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
14342139Sjp161948 ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
14352139Sjp161948 if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
14362139Sjp161948 ecdsa_doit[i]=0;
14372139Sjp161948 else
14382139Sjp161948 {
14392139Sjp161948 if (ecdsa_c[i] == 0)
14402139Sjp161948 {
14412139Sjp161948 ecdsa_c[i][0]=1;
14422139Sjp161948 ecdsa_c[i][1]=1;
14432139Sjp161948 }
14442139Sjp161948 }
14452139Sjp161948 }
14462139Sjp161948 #endif
14472139Sjp161948
14482139Sjp161948 #ifndef OPENSSL_NO_ECDH
14492139Sjp161948 ecdh_c[R_EC_P160][0]=count/1000;
14502139Sjp161948 ecdh_c[R_EC_P160][1]=count/1000;
14512139Sjp161948 for (i=R_EC_P192; i<=R_EC_P521; i++)
14522139Sjp161948 {
14532139Sjp161948 ecdh_c[i][0]=ecdh_c[i-1][0]/2;
14542139Sjp161948 ecdh_c[i][1]=ecdh_c[i-1][1]/2;
14552139Sjp161948 if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
14562139Sjp161948 ecdh_doit[i]=0;
14572139Sjp161948 else
14582139Sjp161948 {
14592139Sjp161948 if (ecdh_c[i] == 0)
14602139Sjp161948 {
14612139Sjp161948 ecdh_c[i][0]=1;
14622139Sjp161948 ecdh_c[i][1]=1;
14632139Sjp161948 }
14642139Sjp161948 }
14652139Sjp161948 }
14662139Sjp161948 ecdh_c[R_EC_K163][0]=count/1000;
14672139Sjp161948 ecdh_c[R_EC_K163][1]=count/1000;
14682139Sjp161948 for (i=R_EC_K233; i<=R_EC_K571; i++)
14692139Sjp161948 {
14702139Sjp161948 ecdh_c[i][0]=ecdh_c[i-1][0]/2;
14712139Sjp161948 ecdh_c[i][1]=ecdh_c[i-1][1]/2;
14722139Sjp161948 if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
14732139Sjp161948 ecdh_doit[i]=0;
14742139Sjp161948 else
14752139Sjp161948 {
14762139Sjp161948 if (ecdh_c[i] == 0)
14772139Sjp161948 {
14782139Sjp161948 ecdh_c[i][0]=1;
14792139Sjp161948 ecdh_c[i][1]=1;
14802139Sjp161948 }
14812139Sjp161948 }
14822139Sjp161948 }
14832139Sjp161948 ecdh_c[R_EC_B163][0]=count/1000;
14842139Sjp161948 ecdh_c[R_EC_B163][1]=count/1000;
14852139Sjp161948 for (i=R_EC_B233; i<=R_EC_B571; i++)
14862139Sjp161948 {
14872139Sjp161948 ecdh_c[i][0]=ecdh_c[i-1][0]/2;
14882139Sjp161948 ecdh_c[i][1]=ecdh_c[i-1][1]/2;
14892139Sjp161948 if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
14902139Sjp161948 ecdh_doit[i]=0;
14912139Sjp161948 else
14922139Sjp161948 {
14932139Sjp161948 if (ecdh_c[i] == 0)
14942139Sjp161948 {
14952139Sjp161948 ecdh_c[i][0]=1;
14962139Sjp161948 ecdh_c[i][1]=1;
14972139Sjp161948 }
14982139Sjp161948 }
14992139Sjp161948 }
15002139Sjp161948 #endif
15012139Sjp161948
15020Sstevel@tonic-gate #define COND(d) (count < (d))
15030Sstevel@tonic-gate #define COUNT(d) (d)
15040Sstevel@tonic-gate #else
15050Sstevel@tonic-gate /* not worth fixing */
15060Sstevel@tonic-gate # error "You cannot disable DES on systems without SIGALRM."
15070Sstevel@tonic-gate #endif /* OPENSSL_NO_DES */
15080Sstevel@tonic-gate #else
15090Sstevel@tonic-gate #define COND(c) (run)
15100Sstevel@tonic-gate #define COUNT(d) (count)
15110Sstevel@tonic-gate signal(SIGALRM,sig_done);
15120Sstevel@tonic-gate #endif /* SIGALRM */
15130Sstevel@tonic-gate
15140Sstevel@tonic-gate #ifndef OPENSSL_NO_MD2
15150Sstevel@tonic-gate if (doit[D_MD2])
15160Sstevel@tonic-gate {
15170Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
15180Sstevel@tonic-gate {
15190Sstevel@tonic-gate print_message(names[D_MD2],c[D_MD2][j],lengths[j]);
15200Sstevel@tonic-gate Time_F(START);
15210Sstevel@tonic-gate for (count=0,run=1; COND(c[D_MD2][j]); count++)
15220Sstevel@tonic-gate EVP_Digest(buf,(unsigned long)lengths[j],&(md2[0]),NULL,EVP_md2(),NULL);
15230Sstevel@tonic-gate d=Time_F(STOP);
15240Sstevel@tonic-gate print_result(D_MD2,j,count,d);
15250Sstevel@tonic-gate }
15260Sstevel@tonic-gate }
15270Sstevel@tonic-gate #endif
15280Sstevel@tonic-gate #ifndef OPENSSL_NO_MDC2
15290Sstevel@tonic-gate if (doit[D_MDC2])
15300Sstevel@tonic-gate {
15310Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
15320Sstevel@tonic-gate {
15330Sstevel@tonic-gate print_message(names[D_MDC2],c[D_MDC2][j],lengths[j]);
15340Sstevel@tonic-gate Time_F(START);
15350Sstevel@tonic-gate for (count=0,run=1; COND(c[D_MDC2][j]); count++)
15360Sstevel@tonic-gate EVP_Digest(buf,(unsigned long)lengths[j],&(mdc2[0]),NULL,EVP_mdc2(),NULL);
15370Sstevel@tonic-gate d=Time_F(STOP);
15380Sstevel@tonic-gate print_result(D_MDC2,j,count,d);
15390Sstevel@tonic-gate }
15400Sstevel@tonic-gate }
15410Sstevel@tonic-gate #endif
15420Sstevel@tonic-gate
15430Sstevel@tonic-gate #ifndef OPENSSL_NO_MD4
15440Sstevel@tonic-gate if (doit[D_MD4])
15450Sstevel@tonic-gate {
15460Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
15470Sstevel@tonic-gate {
15480Sstevel@tonic-gate print_message(names[D_MD4],c[D_MD4][j],lengths[j]);
15490Sstevel@tonic-gate Time_F(START);
15500Sstevel@tonic-gate for (count=0,run=1; COND(c[D_MD4][j]); count++)
15510Sstevel@tonic-gate EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md4[0]),NULL,EVP_md4(),NULL);
15520Sstevel@tonic-gate d=Time_F(STOP);
15530Sstevel@tonic-gate print_result(D_MD4,j,count,d);
15540Sstevel@tonic-gate }
15550Sstevel@tonic-gate }
15560Sstevel@tonic-gate #endif
15570Sstevel@tonic-gate
15580Sstevel@tonic-gate #ifndef OPENSSL_NO_MD5
15590Sstevel@tonic-gate if (doit[D_MD5])
15600Sstevel@tonic-gate {
15610Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
15620Sstevel@tonic-gate {
15630Sstevel@tonic-gate print_message(names[D_MD5],c[D_MD5][j],lengths[j]);
15640Sstevel@tonic-gate Time_F(START);
15650Sstevel@tonic-gate for (count=0,run=1; COND(c[D_MD5][j]); count++)
15660Sstevel@tonic-gate EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md5[0]),NULL,EVP_get_digestbyname("md5"),NULL);
15670Sstevel@tonic-gate d=Time_F(STOP);
15680Sstevel@tonic-gate print_result(D_MD5,j,count,d);
15690Sstevel@tonic-gate }
15700Sstevel@tonic-gate }
15710Sstevel@tonic-gate #endif
15720Sstevel@tonic-gate
15730Sstevel@tonic-gate #if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC)
15740Sstevel@tonic-gate if (doit[D_HMAC])
15750Sstevel@tonic-gate {
15760Sstevel@tonic-gate HMAC_CTX hctx;
15770Sstevel@tonic-gate
15780Sstevel@tonic-gate HMAC_CTX_init(&hctx);
15790Sstevel@tonic-gate HMAC_Init_ex(&hctx,(unsigned char *)"This is a key...",
15800Sstevel@tonic-gate 16,EVP_md5(), NULL);
15810Sstevel@tonic-gate
15820Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
15830Sstevel@tonic-gate {
15840Sstevel@tonic-gate print_message(names[D_HMAC],c[D_HMAC][j],lengths[j]);
15850Sstevel@tonic-gate Time_F(START);
15860Sstevel@tonic-gate for (count=0,run=1; COND(c[D_HMAC][j]); count++)
15870Sstevel@tonic-gate {
15880Sstevel@tonic-gate HMAC_Init_ex(&hctx,NULL,0,NULL,NULL);
15890Sstevel@tonic-gate HMAC_Update(&hctx,buf,lengths[j]);
15900Sstevel@tonic-gate HMAC_Final(&hctx,&(hmac[0]),NULL);
15910Sstevel@tonic-gate }
15920Sstevel@tonic-gate d=Time_F(STOP);
15930Sstevel@tonic-gate print_result(D_HMAC,j,count,d);
15940Sstevel@tonic-gate }
15950Sstevel@tonic-gate HMAC_CTX_cleanup(&hctx);
15960Sstevel@tonic-gate }
15970Sstevel@tonic-gate #endif
15980Sstevel@tonic-gate #ifndef OPENSSL_NO_SHA
15990Sstevel@tonic-gate if (doit[D_SHA1])
16000Sstevel@tonic-gate {
16010Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
16020Sstevel@tonic-gate {
16030Sstevel@tonic-gate print_message(names[D_SHA1],c[D_SHA1][j],lengths[j]);
16040Sstevel@tonic-gate Time_F(START);
16050Sstevel@tonic-gate for (count=0,run=1; COND(c[D_SHA1][j]); count++)
16060Sstevel@tonic-gate EVP_Digest(buf,(unsigned long)lengths[j],&(sha[0]),NULL,EVP_sha1(),NULL);
16070Sstevel@tonic-gate d=Time_F(STOP);
16080Sstevel@tonic-gate print_result(D_SHA1,j,count,d);
16090Sstevel@tonic-gate }
16100Sstevel@tonic-gate }
16112139Sjp161948
16122139Sjp161948 #ifndef OPENSSL_NO_SHA256
16132139Sjp161948 if (doit[D_SHA256])
16142139Sjp161948 {
16152139Sjp161948 for (j=0; j<SIZE_NUM; j++)
16162139Sjp161948 {
16172139Sjp161948 print_message(names[D_SHA256],c[D_SHA256][j],lengths[j]);
16182139Sjp161948 Time_F(START);
16192139Sjp161948 for (count=0,run=1; COND(c[D_SHA256][j]); count++)
16202139Sjp161948 SHA256(buf,lengths[j],sha256);
16212139Sjp161948 d=Time_F(STOP);
16222139Sjp161948 print_result(D_SHA256,j,count,d);
16232139Sjp161948 }
16242139Sjp161948 }
16252139Sjp161948 #endif
16262139Sjp161948
16272139Sjp161948 #ifndef OPENSSL_NO_SHA512
16282139Sjp161948 if (doit[D_SHA512])
16292139Sjp161948 {
16302139Sjp161948 for (j=0; j<SIZE_NUM; j++)
16312139Sjp161948 {
16322139Sjp161948 print_message(names[D_SHA512],c[D_SHA512][j],lengths[j]);
16332139Sjp161948 Time_F(START);
16342139Sjp161948 for (count=0,run=1; COND(c[D_SHA512][j]); count++)
16352139Sjp161948 SHA512(buf,lengths[j],sha512);
16362139Sjp161948 d=Time_F(STOP);
16372139Sjp161948 print_result(D_SHA512,j,count,d);
16382139Sjp161948 }
16392139Sjp161948 }
16402139Sjp161948 #endif
16412139Sjp161948
16420Sstevel@tonic-gate #endif
16430Sstevel@tonic-gate #ifndef OPENSSL_NO_RIPEMD
16440Sstevel@tonic-gate if (doit[D_RMD160])
16450Sstevel@tonic-gate {
16460Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
16470Sstevel@tonic-gate {
16480Sstevel@tonic-gate print_message(names[D_RMD160],c[D_RMD160][j],lengths[j]);
16490Sstevel@tonic-gate Time_F(START);
16500Sstevel@tonic-gate for (count=0,run=1; COND(c[D_RMD160][j]); count++)
16510Sstevel@tonic-gate EVP_Digest(buf,(unsigned long)lengths[j],&(rmd160[0]),NULL,EVP_ripemd160(),NULL);
16520Sstevel@tonic-gate d=Time_F(STOP);
16530Sstevel@tonic-gate print_result(D_RMD160,j,count,d);
16540Sstevel@tonic-gate }
16550Sstevel@tonic-gate }
16560Sstevel@tonic-gate #endif
16570Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
16580Sstevel@tonic-gate if (doit[D_RC4])
16590Sstevel@tonic-gate {
16600Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
16610Sstevel@tonic-gate {
16620Sstevel@tonic-gate print_message(names[D_RC4],c[D_RC4][j],lengths[j]);
16630Sstevel@tonic-gate Time_F(START);
16640Sstevel@tonic-gate for (count=0,run=1; COND(c[D_RC4][j]); count++)
16650Sstevel@tonic-gate RC4(&rc4_ks,(unsigned int)lengths[j],
16660Sstevel@tonic-gate buf,buf);
16670Sstevel@tonic-gate d=Time_F(STOP);
16680Sstevel@tonic-gate print_result(D_RC4,j,count,d);
16690Sstevel@tonic-gate }
16700Sstevel@tonic-gate }
16710Sstevel@tonic-gate #endif
16720Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
16730Sstevel@tonic-gate if (doit[D_CBC_DES])
16740Sstevel@tonic-gate {
16750Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
16760Sstevel@tonic-gate {
16770Sstevel@tonic-gate print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
16780Sstevel@tonic-gate Time_F(START);
16790Sstevel@tonic-gate for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
16800Sstevel@tonic-gate DES_ncbc_encrypt(buf,buf,lengths[j],&sch,
16810Sstevel@tonic-gate &DES_iv,DES_ENCRYPT);
16820Sstevel@tonic-gate d=Time_F(STOP);
16830Sstevel@tonic-gate print_result(D_CBC_DES,j,count,d);
16840Sstevel@tonic-gate }
16850Sstevel@tonic-gate }
16860Sstevel@tonic-gate
16870Sstevel@tonic-gate if (doit[D_EDE3_DES])
16880Sstevel@tonic-gate {
16890Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
16900Sstevel@tonic-gate {
16910Sstevel@tonic-gate print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
16920Sstevel@tonic-gate Time_F(START);
16930Sstevel@tonic-gate for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
16940Sstevel@tonic-gate DES_ede3_cbc_encrypt(buf,buf,lengths[j],
16950Sstevel@tonic-gate &sch,&sch2,&sch3,
16960Sstevel@tonic-gate &DES_iv,DES_ENCRYPT);
16970Sstevel@tonic-gate d=Time_F(STOP);
16980Sstevel@tonic-gate print_result(D_EDE3_DES,j,count,d);
16990Sstevel@tonic-gate }
17000Sstevel@tonic-gate }
17010Sstevel@tonic-gate #endif
17020Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
17030Sstevel@tonic-gate if (doit[D_CBC_128_AES])
17040Sstevel@tonic-gate {
17050Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
17060Sstevel@tonic-gate {
17070Sstevel@tonic-gate print_message(names[D_CBC_128_AES],c[D_CBC_128_AES][j],lengths[j]);
17080Sstevel@tonic-gate Time_F(START);
17090Sstevel@tonic-gate for (count=0,run=1; COND(c[D_CBC_128_AES][j]); count++)
17100Sstevel@tonic-gate AES_cbc_encrypt(buf,buf,
17110Sstevel@tonic-gate (unsigned long)lengths[j],&aes_ks1,
17120Sstevel@tonic-gate iv,AES_ENCRYPT);
17130Sstevel@tonic-gate d=Time_F(STOP);
17140Sstevel@tonic-gate print_result(D_CBC_128_AES,j,count,d);
17150Sstevel@tonic-gate }
17160Sstevel@tonic-gate }
17170Sstevel@tonic-gate if (doit[D_CBC_192_AES])
17180Sstevel@tonic-gate {
17190Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
17200Sstevel@tonic-gate {
17210Sstevel@tonic-gate print_message(names[D_CBC_192_AES],c[D_CBC_192_AES][j],lengths[j]);
17220Sstevel@tonic-gate Time_F(START);
17230Sstevel@tonic-gate for (count=0,run=1; COND(c[D_CBC_192_AES][j]); count++)
17240Sstevel@tonic-gate AES_cbc_encrypt(buf,buf,
17250Sstevel@tonic-gate (unsigned long)lengths[j],&aes_ks2,
17260Sstevel@tonic-gate iv,AES_ENCRYPT);
17270Sstevel@tonic-gate d=Time_F(STOP);
17280Sstevel@tonic-gate print_result(D_CBC_192_AES,j,count,d);
17290Sstevel@tonic-gate }
17300Sstevel@tonic-gate }
17310Sstevel@tonic-gate if (doit[D_CBC_256_AES])
17320Sstevel@tonic-gate {
17330Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
17340Sstevel@tonic-gate {
17350Sstevel@tonic-gate print_message(names[D_CBC_256_AES],c[D_CBC_256_AES][j],lengths[j]);
17360Sstevel@tonic-gate Time_F(START);
17370Sstevel@tonic-gate for (count=0,run=1; COND(c[D_CBC_256_AES][j]); count++)
17380Sstevel@tonic-gate AES_cbc_encrypt(buf,buf,
17390Sstevel@tonic-gate (unsigned long)lengths[j],&aes_ks3,
17400Sstevel@tonic-gate iv,AES_ENCRYPT);
17410Sstevel@tonic-gate d=Time_F(STOP);
17420Sstevel@tonic-gate print_result(D_CBC_256_AES,j,count,d);
17430Sstevel@tonic-gate }
17440Sstevel@tonic-gate }
17450Sstevel@tonic-gate
17460Sstevel@tonic-gate #endif
17470Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
17480Sstevel@tonic-gate if (doit[D_CBC_IDEA])
17490Sstevel@tonic-gate {
17500Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
17510Sstevel@tonic-gate {
17520Sstevel@tonic-gate print_message(names[D_CBC_IDEA],c[D_CBC_IDEA][j],lengths[j]);
17530Sstevel@tonic-gate Time_F(START);
17540Sstevel@tonic-gate for (count=0,run=1; COND(c[D_CBC_IDEA][j]); count++)
17550Sstevel@tonic-gate idea_cbc_encrypt(buf,buf,
17560Sstevel@tonic-gate (unsigned long)lengths[j],&idea_ks,
17570Sstevel@tonic-gate iv,IDEA_ENCRYPT);
17580Sstevel@tonic-gate d=Time_F(STOP);
17590Sstevel@tonic-gate print_result(D_CBC_IDEA,j,count,d);
17600Sstevel@tonic-gate }
17610Sstevel@tonic-gate }
17620Sstevel@tonic-gate #endif
17630Sstevel@tonic-gate #ifndef OPENSSL_NO_RC2
17640Sstevel@tonic-gate if (doit[D_CBC_RC2])
17650Sstevel@tonic-gate {
17660Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
17670Sstevel@tonic-gate {
17680Sstevel@tonic-gate print_message(names[D_CBC_RC2],c[D_CBC_RC2][j],lengths[j]);
17690Sstevel@tonic-gate Time_F(START);
17700Sstevel@tonic-gate for (count=0,run=1; COND(c[D_CBC_RC2][j]); count++)
17710Sstevel@tonic-gate RC2_cbc_encrypt(buf,buf,
17720Sstevel@tonic-gate (unsigned long)lengths[j],&rc2_ks,
17730Sstevel@tonic-gate iv,RC2_ENCRYPT);
17740Sstevel@tonic-gate d=Time_F(STOP);
17750Sstevel@tonic-gate print_result(D_CBC_RC2,j,count,d);
17760Sstevel@tonic-gate }
17770Sstevel@tonic-gate }
17780Sstevel@tonic-gate #endif
17790Sstevel@tonic-gate #ifndef OPENSSL_NO_RC5
17800Sstevel@tonic-gate if (doit[D_CBC_RC5])
17810Sstevel@tonic-gate {
17820Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
17830Sstevel@tonic-gate {
17840Sstevel@tonic-gate print_message(names[D_CBC_RC5],c[D_CBC_RC5][j],lengths[j]);
17850Sstevel@tonic-gate Time_F(START);
17860Sstevel@tonic-gate for (count=0,run=1; COND(c[D_CBC_RC5][j]); count++)
17870Sstevel@tonic-gate RC5_32_cbc_encrypt(buf,buf,
17880Sstevel@tonic-gate (unsigned long)lengths[j],&rc5_ks,
17890Sstevel@tonic-gate iv,RC5_ENCRYPT);
17900Sstevel@tonic-gate d=Time_F(STOP);
17910Sstevel@tonic-gate print_result(D_CBC_RC5,j,count,d);
17920Sstevel@tonic-gate }
17930Sstevel@tonic-gate }
17940Sstevel@tonic-gate #endif
17950Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
17960Sstevel@tonic-gate if (doit[D_CBC_BF])
17970Sstevel@tonic-gate {
17980Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
17990Sstevel@tonic-gate {
18000Sstevel@tonic-gate print_message(names[D_CBC_BF],c[D_CBC_BF][j],lengths[j]);
18010Sstevel@tonic-gate Time_F(START);
18020Sstevel@tonic-gate for (count=0,run=1; COND(c[D_CBC_BF][j]); count++)
18030Sstevel@tonic-gate BF_cbc_encrypt(buf,buf,
18040Sstevel@tonic-gate (unsigned long)lengths[j],&bf_ks,
18050Sstevel@tonic-gate iv,BF_ENCRYPT);
18060Sstevel@tonic-gate d=Time_F(STOP);
18070Sstevel@tonic-gate print_result(D_CBC_BF,j,count,d);
18080Sstevel@tonic-gate }
18090Sstevel@tonic-gate }
18100Sstevel@tonic-gate #endif
18110Sstevel@tonic-gate #ifndef OPENSSL_NO_CAST
18120Sstevel@tonic-gate if (doit[D_CBC_CAST])
18130Sstevel@tonic-gate {
18140Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
18150Sstevel@tonic-gate {
18160Sstevel@tonic-gate print_message(names[D_CBC_CAST],c[D_CBC_CAST][j],lengths[j]);
18170Sstevel@tonic-gate Time_F(START);
18180Sstevel@tonic-gate for (count=0,run=1; COND(c[D_CBC_CAST][j]); count++)
18190Sstevel@tonic-gate CAST_cbc_encrypt(buf,buf,
18200Sstevel@tonic-gate (unsigned long)lengths[j],&cast_ks,
18210Sstevel@tonic-gate iv,CAST_ENCRYPT);
18220Sstevel@tonic-gate d=Time_F(STOP);
18230Sstevel@tonic-gate print_result(D_CBC_CAST,j,count,d);
18240Sstevel@tonic-gate }
18250Sstevel@tonic-gate }
18260Sstevel@tonic-gate #endif
18270Sstevel@tonic-gate
18280Sstevel@tonic-gate if (doit[D_EVP])
18290Sstevel@tonic-gate {
18300Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
18310Sstevel@tonic-gate {
18320Sstevel@tonic-gate if (evp_cipher)
18330Sstevel@tonic-gate {
18340Sstevel@tonic-gate EVP_CIPHER_CTX ctx;
18350Sstevel@tonic-gate int outl;
18360Sstevel@tonic-gate
18370Sstevel@tonic-gate names[D_EVP]=OBJ_nid2ln(evp_cipher->nid);
18380Sstevel@tonic-gate /* -O3 -fschedule-insns messes up an
18390Sstevel@tonic-gate * optimization here! names[D_EVP]
18400Sstevel@tonic-gate * somehow becomes NULL */
18410Sstevel@tonic-gate print_message(names[D_EVP],save_count,
18420Sstevel@tonic-gate lengths[j]);
18430Sstevel@tonic-gate
18440Sstevel@tonic-gate EVP_CIPHER_CTX_init(&ctx);
18450Sstevel@tonic-gate if(decrypt)
18460Sstevel@tonic-gate EVP_DecryptInit_ex(&ctx,evp_cipher,NULL,key16,iv);
18470Sstevel@tonic-gate else
18480Sstevel@tonic-gate EVP_EncryptInit_ex(&ctx,evp_cipher,NULL,key16,iv);
18492139Sjp161948 EVP_CIPHER_CTX_set_padding(&ctx, 0);
18500Sstevel@tonic-gate
18510Sstevel@tonic-gate Time_F(START);
18520Sstevel@tonic-gate if(decrypt)
18530Sstevel@tonic-gate for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
18540Sstevel@tonic-gate EVP_DecryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
18550Sstevel@tonic-gate else
18560Sstevel@tonic-gate for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
18570Sstevel@tonic-gate EVP_EncryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
18580Sstevel@tonic-gate if(decrypt)
18590Sstevel@tonic-gate EVP_DecryptFinal_ex(&ctx,buf,&outl);
18600Sstevel@tonic-gate else
18610Sstevel@tonic-gate EVP_EncryptFinal_ex(&ctx,buf,&outl);
18620Sstevel@tonic-gate d=Time_F(STOP);
18630Sstevel@tonic-gate EVP_CIPHER_CTX_cleanup(&ctx);
18640Sstevel@tonic-gate }
18650Sstevel@tonic-gate if (evp_md)
18660Sstevel@tonic-gate {
18670Sstevel@tonic-gate names[D_EVP]=OBJ_nid2ln(evp_md->type);
18680Sstevel@tonic-gate print_message(names[D_EVP],save_count,
18690Sstevel@tonic-gate lengths[j]);
18700Sstevel@tonic-gate
18710Sstevel@tonic-gate Time_F(START);
18720Sstevel@tonic-gate for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
18730Sstevel@tonic-gate EVP_Digest(buf,lengths[j],&(md[0]),NULL,evp_md,NULL);
18740Sstevel@tonic-gate
18750Sstevel@tonic-gate d=Time_F(STOP);
18760Sstevel@tonic-gate }
18770Sstevel@tonic-gate print_result(D_EVP,j,count,d);
18780Sstevel@tonic-gate }
18790Sstevel@tonic-gate }
18800Sstevel@tonic-gate
18810Sstevel@tonic-gate RAND_pseudo_bytes(buf,36);
18820Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
18830Sstevel@tonic-gate for (j=0; j<RSA_NUM; j++)
18840Sstevel@tonic-gate {
18850Sstevel@tonic-gate int ret;
18860Sstevel@tonic-gate if (!rsa_doit[j]) continue;
18870Sstevel@tonic-gate ret=RSA_sign(NID_md5_sha1, buf,36, buf2, &rsa_num, rsa_key[j]);
18880Sstevel@tonic-gate if (ret == 0)
18890Sstevel@tonic-gate {
18900Sstevel@tonic-gate BIO_printf(bio_err,"RSA sign failure. No RSA sign will be done.\n");
18910Sstevel@tonic-gate ERR_print_errors(bio_err);
18920Sstevel@tonic-gate rsa_count=1;
18930Sstevel@tonic-gate }
18940Sstevel@tonic-gate else
18950Sstevel@tonic-gate {
18960Sstevel@tonic-gate pkey_print_message("private","rsa",
18970Sstevel@tonic-gate rsa_c[j][0],rsa_bits[j],
18980Sstevel@tonic-gate RSA_SECONDS);
18990Sstevel@tonic-gate /* RSA_blinding_on(rsa_key[j],NULL); */
19000Sstevel@tonic-gate Time_F(START);
19010Sstevel@tonic-gate for (count=0,run=1; COND(rsa_c[j][0]); count++)
19020Sstevel@tonic-gate {
19030Sstevel@tonic-gate ret=RSA_sign(NID_md5_sha1, buf,36, buf2,
19040Sstevel@tonic-gate &rsa_num, rsa_key[j]);
19050Sstevel@tonic-gate if (ret == 0)
19060Sstevel@tonic-gate {
19070Sstevel@tonic-gate BIO_printf(bio_err,
19080Sstevel@tonic-gate "RSA sign failure\n");
19090Sstevel@tonic-gate ERR_print_errors(bio_err);
19100Sstevel@tonic-gate count=1;
19110Sstevel@tonic-gate break;
19120Sstevel@tonic-gate }
19130Sstevel@tonic-gate }
19140Sstevel@tonic-gate d=Time_F(STOP);
19150Sstevel@tonic-gate BIO_printf(bio_err,mr ? "+R1:%ld:%d:%.2f\n"
19160Sstevel@tonic-gate : "%ld %d bit private RSA's in %.2fs\n",
19170Sstevel@tonic-gate count,rsa_bits[j],d);
19180Sstevel@tonic-gate rsa_results[j][0]=d/(double)count;
19190Sstevel@tonic-gate rsa_count=count;
19200Sstevel@tonic-gate }
19210Sstevel@tonic-gate
19220Sstevel@tonic-gate #if 1
19230Sstevel@tonic-gate ret=RSA_verify(NID_md5_sha1, buf,36, buf2, rsa_num, rsa_key[j]);
19240Sstevel@tonic-gate if (ret <= 0)
19250Sstevel@tonic-gate {
19260Sstevel@tonic-gate BIO_printf(bio_err,"RSA verify failure. No RSA verify will be done.\n");
19270Sstevel@tonic-gate ERR_print_errors(bio_err);
19280Sstevel@tonic-gate rsa_doit[j] = 0;
19290Sstevel@tonic-gate }
19300Sstevel@tonic-gate else
19310Sstevel@tonic-gate {
19320Sstevel@tonic-gate pkey_print_message("public","rsa",
19330Sstevel@tonic-gate rsa_c[j][1],rsa_bits[j],
19340Sstevel@tonic-gate RSA_SECONDS);
19350Sstevel@tonic-gate Time_F(START);
19360Sstevel@tonic-gate for (count=0,run=1; COND(rsa_c[j][1]); count++)
19370Sstevel@tonic-gate {
19380Sstevel@tonic-gate ret=RSA_verify(NID_md5_sha1, buf,36, buf2,
19390Sstevel@tonic-gate rsa_num, rsa_key[j]);
1940*8545SJan.Pechanec@Sun.COM if (ret <= 0)
19410Sstevel@tonic-gate {
19420Sstevel@tonic-gate BIO_printf(bio_err,
19430Sstevel@tonic-gate "RSA verify failure\n");
19440Sstevel@tonic-gate ERR_print_errors(bio_err);
19450Sstevel@tonic-gate count=1;
19460Sstevel@tonic-gate break;
19470Sstevel@tonic-gate }
19480Sstevel@tonic-gate }
19490Sstevel@tonic-gate d=Time_F(STOP);
19500Sstevel@tonic-gate BIO_printf(bio_err,mr ? "+R2:%ld:%d:%.2f\n"
19510Sstevel@tonic-gate : "%ld %d bit public RSA's in %.2fs\n",
19520Sstevel@tonic-gate count,rsa_bits[j],d);
19530Sstevel@tonic-gate rsa_results[j][1]=d/(double)count;
19540Sstevel@tonic-gate }
19550Sstevel@tonic-gate #endif
19560Sstevel@tonic-gate
19570Sstevel@tonic-gate if (rsa_count <= 1)
19580Sstevel@tonic-gate {
19590Sstevel@tonic-gate /* if longer than 10s, don't do any more */
19600Sstevel@tonic-gate for (j++; j<RSA_NUM; j++)
19610Sstevel@tonic-gate rsa_doit[j]=0;
19620Sstevel@tonic-gate }
19630Sstevel@tonic-gate }
19640Sstevel@tonic-gate #endif
19650Sstevel@tonic-gate
19660Sstevel@tonic-gate RAND_pseudo_bytes(buf,20);
19670Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
19680Sstevel@tonic-gate if (RAND_status() != 1)
19690Sstevel@tonic-gate {
19700Sstevel@tonic-gate RAND_seed(rnd_seed, sizeof rnd_seed);
19710Sstevel@tonic-gate rnd_fake = 1;
19720Sstevel@tonic-gate }
19730Sstevel@tonic-gate for (j=0; j<DSA_NUM; j++)
19740Sstevel@tonic-gate {
19750Sstevel@tonic-gate unsigned int kk;
19760Sstevel@tonic-gate int ret;
19770Sstevel@tonic-gate
19780Sstevel@tonic-gate if (!dsa_doit[j]) continue;
19790Sstevel@tonic-gate /* DSA_generate_key(dsa_key[j]); */
19800Sstevel@tonic-gate /* DSA_sign_setup(dsa_key[j],NULL); */
19810Sstevel@tonic-gate ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
19820Sstevel@tonic-gate &kk,dsa_key[j]);
19830Sstevel@tonic-gate if (ret == 0)
19840Sstevel@tonic-gate {
19850Sstevel@tonic-gate BIO_printf(bio_err,"DSA sign failure. No DSA sign will be done.\n");
19860Sstevel@tonic-gate ERR_print_errors(bio_err);
19870Sstevel@tonic-gate rsa_count=1;
19880Sstevel@tonic-gate }
19890Sstevel@tonic-gate else
19900Sstevel@tonic-gate {
19910Sstevel@tonic-gate pkey_print_message("sign","dsa",
19920Sstevel@tonic-gate dsa_c[j][0],dsa_bits[j],
19930Sstevel@tonic-gate DSA_SECONDS);
19940Sstevel@tonic-gate Time_F(START);
19950Sstevel@tonic-gate for (count=0,run=1; COND(dsa_c[j][0]); count++)
19960Sstevel@tonic-gate {
19970Sstevel@tonic-gate ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
19980Sstevel@tonic-gate &kk,dsa_key[j]);
19990Sstevel@tonic-gate if (ret == 0)
20000Sstevel@tonic-gate {
20010Sstevel@tonic-gate BIO_printf(bio_err,
20020Sstevel@tonic-gate "DSA sign failure\n");
20030Sstevel@tonic-gate ERR_print_errors(bio_err);
20040Sstevel@tonic-gate count=1;
20050Sstevel@tonic-gate break;
20060Sstevel@tonic-gate }
20070Sstevel@tonic-gate }
20080Sstevel@tonic-gate d=Time_F(STOP);
20090Sstevel@tonic-gate BIO_printf(bio_err,mr ? "+R3:%ld:%d:%.2f\n"
20100Sstevel@tonic-gate : "%ld %d bit DSA signs in %.2fs\n",
20110Sstevel@tonic-gate count,dsa_bits[j],d);
20120Sstevel@tonic-gate dsa_results[j][0]=d/(double)count;
20130Sstevel@tonic-gate rsa_count=count;
20140Sstevel@tonic-gate }
20150Sstevel@tonic-gate
20160Sstevel@tonic-gate ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
20170Sstevel@tonic-gate kk,dsa_key[j]);
20180Sstevel@tonic-gate if (ret <= 0)
20190Sstevel@tonic-gate {
20200Sstevel@tonic-gate BIO_printf(bio_err,"DSA verify failure. No DSA verify will be done.\n");
20210Sstevel@tonic-gate ERR_print_errors(bio_err);
20220Sstevel@tonic-gate dsa_doit[j] = 0;
20230Sstevel@tonic-gate }
20240Sstevel@tonic-gate else
20250Sstevel@tonic-gate {
20260Sstevel@tonic-gate pkey_print_message("verify","dsa",
20270Sstevel@tonic-gate dsa_c[j][1],dsa_bits[j],
20280Sstevel@tonic-gate DSA_SECONDS);
20290Sstevel@tonic-gate Time_F(START);
20300Sstevel@tonic-gate for (count=0,run=1; COND(dsa_c[j][1]); count++)
20310Sstevel@tonic-gate {
20320Sstevel@tonic-gate ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
20330Sstevel@tonic-gate kk,dsa_key[j]);
20340Sstevel@tonic-gate if (ret <= 0)
20350Sstevel@tonic-gate {
20360Sstevel@tonic-gate BIO_printf(bio_err,
20370Sstevel@tonic-gate "DSA verify failure\n");
20380Sstevel@tonic-gate ERR_print_errors(bio_err);
20390Sstevel@tonic-gate count=1;
20400Sstevel@tonic-gate break;
20410Sstevel@tonic-gate }
20420Sstevel@tonic-gate }
20430Sstevel@tonic-gate d=Time_F(STOP);
20440Sstevel@tonic-gate BIO_printf(bio_err,mr ? "+R4:%ld:%d:%.2f\n"
20450Sstevel@tonic-gate : "%ld %d bit DSA verify in %.2fs\n",
20460Sstevel@tonic-gate count,dsa_bits[j],d);
20470Sstevel@tonic-gate dsa_results[j][1]=d/(double)count;
20480Sstevel@tonic-gate }
20490Sstevel@tonic-gate
20500Sstevel@tonic-gate if (rsa_count <= 1)
20510Sstevel@tonic-gate {
20520Sstevel@tonic-gate /* if longer than 10s, don't do any more */
20530Sstevel@tonic-gate for (j++; j<DSA_NUM; j++)
20540Sstevel@tonic-gate dsa_doit[j]=0;
20550Sstevel@tonic-gate }
20560Sstevel@tonic-gate }
20570Sstevel@tonic-gate if (rnd_fake) RAND_cleanup();
20580Sstevel@tonic-gate #endif
20592139Sjp161948
20602139Sjp161948 #ifndef OPENSSL_NO_ECDSA
20612139Sjp161948 if (RAND_status() != 1)
20622139Sjp161948 {
20632139Sjp161948 RAND_seed(rnd_seed, sizeof rnd_seed);
20642139Sjp161948 rnd_fake = 1;
20652139Sjp161948 }
20662139Sjp161948 for (j=0; j<EC_NUM; j++)
20672139Sjp161948 {
20682139Sjp161948 int ret;
20692139Sjp161948
20702139Sjp161948 if (!ecdsa_doit[j]) continue; /* Ignore Curve */
20712139Sjp161948 ecdsa[j] = EC_KEY_new_by_curve_name(test_curves[j]);
20722139Sjp161948 if (ecdsa[j] == NULL)
20732139Sjp161948 {
20742139Sjp161948 BIO_printf(bio_err,"ECDSA failure.\n");
20752139Sjp161948 ERR_print_errors(bio_err);
20762139Sjp161948 rsa_count=1;
20772139Sjp161948 }
20782139Sjp161948 else
20792139Sjp161948 {
20802139Sjp161948 #if 1
20812139Sjp161948 EC_KEY_precompute_mult(ecdsa[j], NULL);
20822139Sjp161948 #endif
20832139Sjp161948 /* Perform ECDSA signature test */
20842139Sjp161948 EC_KEY_generate_key(ecdsa[j]);
20852139Sjp161948 ret = ECDSA_sign(0, buf, 20, ecdsasig,
20862139Sjp161948 &ecdsasiglen, ecdsa[j]);
20872139Sjp161948 if (ret == 0)
20882139Sjp161948 {
20892139Sjp161948 BIO_printf(bio_err,"ECDSA sign failure. No ECDSA sign will be done.\n");
20902139Sjp161948 ERR_print_errors(bio_err);
20912139Sjp161948 rsa_count=1;
20922139Sjp161948 }
20932139Sjp161948 else
20942139Sjp161948 {
20952139Sjp161948 pkey_print_message("sign","ecdsa",
20962139Sjp161948 ecdsa_c[j][0],
20972139Sjp161948 test_curves_bits[j],
20982139Sjp161948 ECDSA_SECONDS);
20992139Sjp161948
21002139Sjp161948 Time_F(START);
21012139Sjp161948 for (count=0,run=1; COND(ecdsa_c[j][0]);
21022139Sjp161948 count++)
21032139Sjp161948 {
21042139Sjp161948 ret=ECDSA_sign(0, buf, 20,
21052139Sjp161948 ecdsasig, &ecdsasiglen,
21062139Sjp161948 ecdsa[j]);
21072139Sjp161948 if (ret == 0)
21082139Sjp161948 {
21092139Sjp161948 BIO_printf(bio_err, "ECDSA sign failure\n");
21102139Sjp161948 ERR_print_errors(bio_err);
21112139Sjp161948 count=1;
21122139Sjp161948 break;
21132139Sjp161948 }
21142139Sjp161948 }
21152139Sjp161948 d=Time_F(STOP);
21162139Sjp161948
21172139Sjp161948 BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" :
21182139Sjp161948 "%ld %d bit ECDSA signs in %.2fs \n",
21192139Sjp161948 count, test_curves_bits[j], d);
21202139Sjp161948 ecdsa_results[j][0]=d/(double)count;
21212139Sjp161948 rsa_count=count;
21222139Sjp161948 }
21232139Sjp161948
21242139Sjp161948 /* Perform ECDSA verification test */
21252139Sjp161948 ret=ECDSA_verify(0, buf, 20, ecdsasig,
21262139Sjp161948 ecdsasiglen, ecdsa[j]);
21272139Sjp161948 if (ret != 1)
21282139Sjp161948 {
21292139Sjp161948 BIO_printf(bio_err,"ECDSA verify failure. No ECDSA verify will be done.\n");
21302139Sjp161948 ERR_print_errors(bio_err);
21312139Sjp161948 ecdsa_doit[j] = 0;
21322139Sjp161948 }
21332139Sjp161948 else
21342139Sjp161948 {
21352139Sjp161948 pkey_print_message("verify","ecdsa",
21362139Sjp161948 ecdsa_c[j][1],
21372139Sjp161948 test_curves_bits[j],
21382139Sjp161948 ECDSA_SECONDS);
21392139Sjp161948 Time_F(START);
21402139Sjp161948 for (count=0,run=1; COND(ecdsa_c[j][1]); count++)
21412139Sjp161948 {
21422139Sjp161948 ret=ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]);
21432139Sjp161948 if (ret != 1)
21442139Sjp161948 {
21452139Sjp161948 BIO_printf(bio_err, "ECDSA verify failure\n");
21462139Sjp161948 ERR_print_errors(bio_err);
21472139Sjp161948 count=1;
21482139Sjp161948 break;
21492139Sjp161948 }
21502139Sjp161948 }
21512139Sjp161948 d=Time_F(STOP);
21522139Sjp161948 BIO_printf(bio_err, mr? "+R6:%ld:%d:%.2f\n"
21532139Sjp161948 : "%ld %d bit ECDSA verify in %.2fs\n",
21542139Sjp161948 count, test_curves_bits[j], d);
21552139Sjp161948 ecdsa_results[j][1]=d/(double)count;
21562139Sjp161948 }
21572139Sjp161948
21582139Sjp161948 if (rsa_count <= 1)
21592139Sjp161948 {
21602139Sjp161948 /* if longer than 10s, don't do any more */
21612139Sjp161948 for (j++; j<EC_NUM; j++)
21622139Sjp161948 ecdsa_doit[j]=0;
21632139Sjp161948 }
21642139Sjp161948 }
21652139Sjp161948 }
21662139Sjp161948 if (rnd_fake) RAND_cleanup();
21672139Sjp161948 #endif
21682139Sjp161948
21692139Sjp161948 #ifndef OPENSSL_NO_ECDH
21702139Sjp161948 if (RAND_status() != 1)
21712139Sjp161948 {
21722139Sjp161948 RAND_seed(rnd_seed, sizeof rnd_seed);
21732139Sjp161948 rnd_fake = 1;
21742139Sjp161948 }
21752139Sjp161948 for (j=0; j<EC_NUM; j++)
21762139Sjp161948 {
21772139Sjp161948 if (!ecdh_doit[j]) continue;
21782139Sjp161948 ecdh_a[j] = EC_KEY_new_by_curve_name(test_curves[j]);
21792139Sjp161948 ecdh_b[j] = EC_KEY_new_by_curve_name(test_curves[j]);
21802139Sjp161948 if ((ecdh_a[j] == NULL) || (ecdh_b[j] == NULL))
21812139Sjp161948 {
21822139Sjp161948 BIO_printf(bio_err,"ECDH failure.\n");
21832139Sjp161948 ERR_print_errors(bio_err);
21842139Sjp161948 rsa_count=1;
21852139Sjp161948 }
21862139Sjp161948 else
21872139Sjp161948 {
21882139Sjp161948 /* generate two ECDH key pairs */
21892139Sjp161948 if (!EC_KEY_generate_key(ecdh_a[j]) ||
21902139Sjp161948 !EC_KEY_generate_key(ecdh_b[j]))
21912139Sjp161948 {
21922139Sjp161948 BIO_printf(bio_err,"ECDH key generation failure.\n");
21932139Sjp161948 ERR_print_errors(bio_err);
21942139Sjp161948 rsa_count=1;
21952139Sjp161948 }
21962139Sjp161948 else
21972139Sjp161948 {
21982139Sjp161948 /* If field size is not more than 24 octets, then use SHA-1 hash of result;
21992139Sjp161948 * otherwise, use result (see section 4.8 of draft-ietf-tls-ecc-03.txt).
22002139Sjp161948 */
22012139Sjp161948 int field_size, outlen;
22022139Sjp161948 void *(*kdf)(const void *in, size_t inlen, void *out, size_t *xoutlen);
22032139Sjp161948 field_size = EC_GROUP_get_degree(EC_KEY_get0_group(ecdh_a[j]));
22042139Sjp161948 if (field_size <= 24 * 8)
22052139Sjp161948 {
22062139Sjp161948 outlen = KDF1_SHA1_len;
22072139Sjp161948 kdf = KDF1_SHA1;
22082139Sjp161948 }
22092139Sjp161948 else
22102139Sjp161948 {
22112139Sjp161948 outlen = (field_size+7)/8;
22122139Sjp161948 kdf = NULL;
22132139Sjp161948 }
22142139Sjp161948 secret_size_a = ECDH_compute_key(secret_a, outlen,
22152139Sjp161948 EC_KEY_get0_public_key(ecdh_b[j]),
22162139Sjp161948 ecdh_a[j], kdf);
22172139Sjp161948 secret_size_b = ECDH_compute_key(secret_b, outlen,
22182139Sjp161948 EC_KEY_get0_public_key(ecdh_a[j]),
22192139Sjp161948 ecdh_b[j], kdf);
22202139Sjp161948 if (secret_size_a != secret_size_b)
22212139Sjp161948 ecdh_checks = 0;
22222139Sjp161948 else
22232139Sjp161948 ecdh_checks = 1;
22242139Sjp161948
22252139Sjp161948 for (secret_idx = 0;
22262139Sjp161948 (secret_idx < secret_size_a)
22272139Sjp161948 && (ecdh_checks == 1);
22282139Sjp161948 secret_idx++)
22292139Sjp161948 {
22302139Sjp161948 if (secret_a[secret_idx] != secret_b[secret_idx])
22312139Sjp161948 ecdh_checks = 0;
22322139Sjp161948 }
22332139Sjp161948
22342139Sjp161948 if (ecdh_checks == 0)
22352139Sjp161948 {
22362139Sjp161948 BIO_printf(bio_err,"ECDH computations don't match.\n");
22372139Sjp161948 ERR_print_errors(bio_err);
22382139Sjp161948 rsa_count=1;
22392139Sjp161948 }
22402139Sjp161948
22412139Sjp161948 pkey_print_message("","ecdh",
22422139Sjp161948 ecdh_c[j][0],
22432139Sjp161948 test_curves_bits[j],
22442139Sjp161948 ECDH_SECONDS);
22452139Sjp161948 Time_F(START);
22462139Sjp161948 for (count=0,run=1; COND(ecdh_c[j][0]); count++)
22472139Sjp161948 {
22482139Sjp161948 ECDH_compute_key(secret_a, outlen,
22492139Sjp161948 EC_KEY_get0_public_key(ecdh_b[j]),
22502139Sjp161948 ecdh_a[j], kdf);
22512139Sjp161948 }
22522139Sjp161948 d=Time_F(STOP);
22532139Sjp161948 BIO_printf(bio_err, mr ? "+R7:%ld:%d:%.2f\n" :"%ld %d-bit ECDH ops in %.2fs\n",
22542139Sjp161948 count, test_curves_bits[j], d);
22552139Sjp161948 ecdh_results[j][0]=d/(double)count;
22562139Sjp161948 rsa_count=count;
22572139Sjp161948 }
22582139Sjp161948 }
22592139Sjp161948
22602139Sjp161948
22612139Sjp161948 if (rsa_count <= 1)
22622139Sjp161948 {
22632139Sjp161948 /* if longer than 10s, don't do any more */
22642139Sjp161948 for (j++; j<EC_NUM; j++)
22652139Sjp161948 ecdh_doit[j]=0;
22662139Sjp161948 }
22672139Sjp161948 }
22682139Sjp161948 if (rnd_fake) RAND_cleanup();
22692139Sjp161948 #endif
22700Sstevel@tonic-gate #ifdef HAVE_FORK
22710Sstevel@tonic-gate show_res:
22720Sstevel@tonic-gate #endif
22730Sstevel@tonic-gate if(!mr)
22740Sstevel@tonic-gate {
22750Sstevel@tonic-gate fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_VERSION));
22760Sstevel@tonic-gate fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_BUILT_ON));
22770Sstevel@tonic-gate printf("options:");
22780Sstevel@tonic-gate printf("%s ",BN_options());
22790Sstevel@tonic-gate #ifndef OPENSSL_NO_MD2
22800Sstevel@tonic-gate printf("%s ",MD2_options());
22810Sstevel@tonic-gate #endif
22820Sstevel@tonic-gate #ifndef OPENSSL_NO_RC4
22830Sstevel@tonic-gate printf("%s ",RC4_options());
22840Sstevel@tonic-gate #endif
22850Sstevel@tonic-gate #ifndef OPENSSL_NO_DES
22860Sstevel@tonic-gate printf("%s ",DES_options());
22870Sstevel@tonic-gate #endif
22880Sstevel@tonic-gate #ifndef OPENSSL_NO_AES
22890Sstevel@tonic-gate printf("%s ",AES_options());
22900Sstevel@tonic-gate #endif
22910Sstevel@tonic-gate #ifndef OPENSSL_NO_IDEA
22920Sstevel@tonic-gate printf("%s ",idea_options());
22930Sstevel@tonic-gate #endif
22940Sstevel@tonic-gate #ifndef OPENSSL_NO_BF
22950Sstevel@tonic-gate printf("%s ",BF_options());
22960Sstevel@tonic-gate #endif
22970Sstevel@tonic-gate fprintf(stdout,"\n%s\n",SSLeay_version(SSLEAY_CFLAGS));
22980Sstevel@tonic-gate printf("available timing options: ");
22990Sstevel@tonic-gate #ifdef TIMES
23000Sstevel@tonic-gate printf("TIMES ");
23010Sstevel@tonic-gate #endif
23020Sstevel@tonic-gate #ifdef TIMEB
23030Sstevel@tonic-gate printf("TIMEB ");
23040Sstevel@tonic-gate #endif
23050Sstevel@tonic-gate #ifdef USE_TOD
23060Sstevel@tonic-gate printf("USE_TOD ");
23070Sstevel@tonic-gate #endif
23080Sstevel@tonic-gate #ifdef HZ
23090Sstevel@tonic-gate #define as_string(s) (#s)
23102139Sjp161948 {
23112139Sjp161948 double dbl = HZ;
23122139Sjp161948 printf("HZ=%g", dbl);
23132139Sjp161948 }
23140Sstevel@tonic-gate # ifdef _SC_CLK_TCK
23150Sstevel@tonic-gate printf(" [sysconf value]");
23160Sstevel@tonic-gate # endif
23170Sstevel@tonic-gate #endif
23180Sstevel@tonic-gate printf("\n");
23190Sstevel@tonic-gate printf("timing function used: %s%s%s%s%s%s%s\n",
23200Sstevel@tonic-gate (ftime_used ? "ftime" : ""),
23210Sstevel@tonic-gate (ftime_used + times_used > 1 ? "," : ""),
23220Sstevel@tonic-gate (times_used ? "times" : ""),
23230Sstevel@tonic-gate (ftime_used + times_used + gettimeofday_used > 1 ? "," : ""),
23240Sstevel@tonic-gate (gettimeofday_used ? "gettimeofday" : ""),
23250Sstevel@tonic-gate (ftime_used + times_used + gettimeofday_used + getrusage_used > 1 ? "," : ""),
23260Sstevel@tonic-gate (getrusage_used ? "getrusage" : ""));
23270Sstevel@tonic-gate }
23280Sstevel@tonic-gate
23290Sstevel@tonic-gate if (pr_header)
23300Sstevel@tonic-gate {
23310Sstevel@tonic-gate if(mr)
23320Sstevel@tonic-gate fprintf(stdout,"+H");
23330Sstevel@tonic-gate else
23340Sstevel@tonic-gate {
23350Sstevel@tonic-gate fprintf(stdout,"The 'numbers' are in 1000s of bytes per second processed.\n");
23360Sstevel@tonic-gate fprintf(stdout,"type ");
23370Sstevel@tonic-gate }
23380Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
23390Sstevel@tonic-gate fprintf(stdout,mr ? ":%d" : "%7d bytes",lengths[j]);
23400Sstevel@tonic-gate fprintf(stdout,"\n");
23410Sstevel@tonic-gate }
23420Sstevel@tonic-gate
23430Sstevel@tonic-gate for (k=0; k<ALGOR_NUM; k++)
23440Sstevel@tonic-gate {
23450Sstevel@tonic-gate if (!doit[k]) continue;
23460Sstevel@tonic-gate if(mr)
23470Sstevel@tonic-gate fprintf(stdout,"+F:%d:%s",k,names[k]);
23480Sstevel@tonic-gate else
23490Sstevel@tonic-gate fprintf(stdout,"%-13s",names[k]);
23500Sstevel@tonic-gate for (j=0; j<SIZE_NUM; j++)
23510Sstevel@tonic-gate {
23520Sstevel@tonic-gate if (results[k][j] > 10000 && !mr)
23530Sstevel@tonic-gate fprintf(stdout," %11.2fk",results[k][j]/1e3);
23540Sstevel@tonic-gate else
23550Sstevel@tonic-gate fprintf(stdout,mr ? ":%.2f" : " %11.2f ",results[k][j]);
23560Sstevel@tonic-gate }
23570Sstevel@tonic-gate fprintf(stdout,"\n");
23580Sstevel@tonic-gate }
23590Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
23600Sstevel@tonic-gate j=1;
23610Sstevel@tonic-gate for (k=0; k<RSA_NUM; k++)
23620Sstevel@tonic-gate {
23630Sstevel@tonic-gate if (!rsa_doit[k]) continue;
23640Sstevel@tonic-gate if (j && !mr)
23650Sstevel@tonic-gate {
23660Sstevel@tonic-gate printf("%18ssign verify sign/s verify/s\n"," ");
23670Sstevel@tonic-gate j=0;
23680Sstevel@tonic-gate }
23690Sstevel@tonic-gate if(mr)
23700Sstevel@tonic-gate fprintf(stdout,"+F2:%u:%u:%f:%f\n",
23710Sstevel@tonic-gate k,rsa_bits[k],rsa_results[k][0],
23720Sstevel@tonic-gate rsa_results[k][1]);
23730Sstevel@tonic-gate else
23742139Sjp161948 fprintf(stdout,"rsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
23750Sstevel@tonic-gate rsa_bits[k],rsa_results[k][0],rsa_results[k][1],
23760Sstevel@tonic-gate 1.0/rsa_results[k][0],1.0/rsa_results[k][1]);
23770Sstevel@tonic-gate }
23780Sstevel@tonic-gate #endif
23790Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
23800Sstevel@tonic-gate j=1;
23810Sstevel@tonic-gate for (k=0; k<DSA_NUM; k++)
23820Sstevel@tonic-gate {
23830Sstevel@tonic-gate if (!dsa_doit[k]) continue;
23840Sstevel@tonic-gate if (j && !mr)
23850Sstevel@tonic-gate {
23860Sstevel@tonic-gate printf("%18ssign verify sign/s verify/s\n"," ");
23870Sstevel@tonic-gate j=0;
23880Sstevel@tonic-gate }
23890Sstevel@tonic-gate if(mr)
23900Sstevel@tonic-gate fprintf(stdout,"+F3:%u:%u:%f:%f\n",
23910Sstevel@tonic-gate k,dsa_bits[k],dsa_results[k][0],dsa_results[k][1]);
23920Sstevel@tonic-gate else
23932139Sjp161948 fprintf(stdout,"dsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
23940Sstevel@tonic-gate dsa_bits[k],dsa_results[k][0],dsa_results[k][1],
23950Sstevel@tonic-gate 1.0/dsa_results[k][0],1.0/dsa_results[k][1]);
23960Sstevel@tonic-gate }
23970Sstevel@tonic-gate #endif
23982139Sjp161948 #ifndef OPENSSL_NO_ECDSA
23992139Sjp161948 j=1;
24002139Sjp161948 for (k=0; k<EC_NUM; k++)
24012139Sjp161948 {
24022139Sjp161948 if (!ecdsa_doit[k]) continue;
24032139Sjp161948 if (j && !mr)
24042139Sjp161948 {
24052139Sjp161948 printf("%30ssign verify sign/s verify/s\n"," ");
24062139Sjp161948 j=0;
24072139Sjp161948 }
24082139Sjp161948
24092139Sjp161948 if (mr)
24102139Sjp161948 fprintf(stdout,"+F4:%u:%u:%f:%f\n",
24112139Sjp161948 k, test_curves_bits[k],
24122139Sjp161948 ecdsa_results[k][0],ecdsa_results[k][1]);
24132139Sjp161948 else
24142139Sjp161948 fprintf(stdout,
24152139Sjp161948 "%4u bit ecdsa (%s) %8.4fs %8.4fs %8.1f %8.1f\n",
24162139Sjp161948 test_curves_bits[k],
24172139Sjp161948 test_curves_names[k],
24182139Sjp161948 ecdsa_results[k][0],ecdsa_results[k][1],
24192139Sjp161948 1.0/ecdsa_results[k][0],1.0/ecdsa_results[k][1]);
24202139Sjp161948 }
24212139Sjp161948 #endif
24222139Sjp161948
24232139Sjp161948
24242139Sjp161948 #ifndef OPENSSL_NO_ECDH
24252139Sjp161948 j=1;
24262139Sjp161948 for (k=0; k<EC_NUM; k++)
24272139Sjp161948 {
24282139Sjp161948 if (!ecdh_doit[k]) continue;
24292139Sjp161948 if (j && !mr)
24302139Sjp161948 {
24312139Sjp161948 printf("%30sop op/s\n"," ");
24322139Sjp161948 j=0;
24332139Sjp161948 }
24342139Sjp161948 if (mr)
24352139Sjp161948 fprintf(stdout,"+F5:%u:%u:%f:%f\n",
24362139Sjp161948 k, test_curves_bits[k],
24372139Sjp161948 ecdh_results[k][0], 1.0/ecdh_results[k][0]);
24382139Sjp161948
24392139Sjp161948 else
24402139Sjp161948 fprintf(stdout,"%4u bit ecdh (%s) %8.4fs %8.1f\n",
24412139Sjp161948 test_curves_bits[k],
24422139Sjp161948 test_curves_names[k],
24432139Sjp161948 ecdh_results[k][0], 1.0/ecdh_results[k][0]);
24442139Sjp161948 }
24452139Sjp161948 #endif
24462139Sjp161948
24470Sstevel@tonic-gate mret=0;
24482139Sjp161948
24490Sstevel@tonic-gate end:
24500Sstevel@tonic-gate ERR_print_errors(bio_err);
24510Sstevel@tonic-gate if (buf != NULL) OPENSSL_free(buf);
24520Sstevel@tonic-gate if (buf2 != NULL) OPENSSL_free(buf2);
24530Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
24540Sstevel@tonic-gate for (i=0; i<RSA_NUM; i++)
24550Sstevel@tonic-gate if (rsa_key[i] != NULL)
24560Sstevel@tonic-gate RSA_free(rsa_key[i]);
24570Sstevel@tonic-gate #endif
24580Sstevel@tonic-gate #ifndef OPENSSL_NO_DSA
24590Sstevel@tonic-gate for (i=0; i<DSA_NUM; i++)
24600Sstevel@tonic-gate if (dsa_key[i] != NULL)
24610Sstevel@tonic-gate DSA_free(dsa_key[i]);
24620Sstevel@tonic-gate #endif
24632139Sjp161948
24642139Sjp161948 #ifndef OPENSSL_NO_ECDSA
24652139Sjp161948 for (i=0; i<EC_NUM; i++)
24662139Sjp161948 if (ecdsa[i] != NULL)
24672139Sjp161948 EC_KEY_free(ecdsa[i]);
24682139Sjp161948 #endif
24692139Sjp161948 #ifndef OPENSSL_NO_ECDH
24702139Sjp161948 for (i=0; i<EC_NUM; i++)
24712139Sjp161948 {
24722139Sjp161948 if (ecdh_a[i] != NULL)
24732139Sjp161948 EC_KEY_free(ecdh_a[i]);
24742139Sjp161948 if (ecdh_b[i] != NULL)
24752139Sjp161948 EC_KEY_free(ecdh_b[i]);
24762139Sjp161948 }
24772139Sjp161948 #endif
24782139Sjp161948
24790Sstevel@tonic-gate apps_shutdown();
24800Sstevel@tonic-gate OPENSSL_EXIT(mret);
24810Sstevel@tonic-gate }
24820Sstevel@tonic-gate
print_message(const char * s,long num,int length)24830Sstevel@tonic-gate static void print_message(const char *s, long num, int length)
24840Sstevel@tonic-gate {
24850Sstevel@tonic-gate #ifdef SIGALRM
24860Sstevel@tonic-gate BIO_printf(bio_err,mr ? "+DT:%s:%d:%d\n"
24870Sstevel@tonic-gate : "Doing %s for %ds on %d size blocks: ",s,SECONDS,length);
24880Sstevel@tonic-gate (void)BIO_flush(bio_err);
24890Sstevel@tonic-gate alarm(SECONDS);
24900Sstevel@tonic-gate #else
24910Sstevel@tonic-gate BIO_printf(bio_err,mr ? "+DN:%s:%ld:%d\n"
24920Sstevel@tonic-gate : "Doing %s %ld times on %d size blocks: ",s,num,length);
24930Sstevel@tonic-gate (void)BIO_flush(bio_err);
24940Sstevel@tonic-gate #endif
24950Sstevel@tonic-gate #ifdef LINT
24960Sstevel@tonic-gate num=num;
24970Sstevel@tonic-gate #endif
24980Sstevel@tonic-gate }
24990Sstevel@tonic-gate
pkey_print_message(const char * str,const char * str2,long num,int bits,int tm)25002139Sjp161948 static void pkey_print_message(const char *str, const char *str2, long num,
25012139Sjp161948 int bits, int tm)
25020Sstevel@tonic-gate {
25030Sstevel@tonic-gate #ifdef SIGALRM
25040Sstevel@tonic-gate BIO_printf(bio_err,mr ? "+DTP:%d:%s:%s:%d\n"
25050Sstevel@tonic-gate : "Doing %d bit %s %s's for %ds: ",bits,str,str2,tm);
25060Sstevel@tonic-gate (void)BIO_flush(bio_err);
25070Sstevel@tonic-gate alarm(RSA_SECONDS);
25080Sstevel@tonic-gate #else
25090Sstevel@tonic-gate BIO_printf(bio_err,mr ? "+DNP:%ld:%d:%s:%s\n"
25100Sstevel@tonic-gate : "Doing %ld %d bit %s %s's: ",num,bits,str,str2);
25110Sstevel@tonic-gate (void)BIO_flush(bio_err);
25120Sstevel@tonic-gate #endif
25130Sstevel@tonic-gate #ifdef LINT
25140Sstevel@tonic-gate num=num;
25150Sstevel@tonic-gate #endif
25160Sstevel@tonic-gate }
25170Sstevel@tonic-gate
print_result(int alg,int run_no,int count,double time_used)25180Sstevel@tonic-gate static void print_result(int alg,int run_no,int count,double time_used)
25190Sstevel@tonic-gate {
25202139Sjp161948 BIO_printf(bio_err,mr ? "+R:%d:%s:%f\n"
25212139Sjp161948 : "%d %s's in %.2fs\n",count,names[alg],time_used);
25220Sstevel@tonic-gate results[alg][run_no]=((double)count)/time_used*lengths[run_no];
25230Sstevel@tonic-gate }
25240Sstevel@tonic-gate
sstrsep(char ** string,const char * delim)25250Sstevel@tonic-gate static char *sstrsep(char **string, const char *delim)
25260Sstevel@tonic-gate {
25270Sstevel@tonic-gate char isdelim[256];
25280Sstevel@tonic-gate char *token = *string;
25290Sstevel@tonic-gate
25300Sstevel@tonic-gate if (**string == 0)
25310Sstevel@tonic-gate return NULL;
25320Sstevel@tonic-gate
25330Sstevel@tonic-gate memset(isdelim, 0, sizeof isdelim);
25340Sstevel@tonic-gate isdelim[0] = 1;
25350Sstevel@tonic-gate
25360Sstevel@tonic-gate while (*delim)
25370Sstevel@tonic-gate {
25380Sstevel@tonic-gate isdelim[(unsigned char)(*delim)] = 1;
25390Sstevel@tonic-gate delim++;
25400Sstevel@tonic-gate }
25410Sstevel@tonic-gate
25420Sstevel@tonic-gate while (!isdelim[(unsigned char)(**string)])
25430Sstevel@tonic-gate {
25440Sstevel@tonic-gate (*string)++;
25450Sstevel@tonic-gate }
25460Sstevel@tonic-gate
25470Sstevel@tonic-gate if (**string)
25480Sstevel@tonic-gate {
25490Sstevel@tonic-gate **string = 0;
25500Sstevel@tonic-gate (*string)++;
25510Sstevel@tonic-gate }
25520Sstevel@tonic-gate
25530Sstevel@tonic-gate return token;
25540Sstevel@tonic-gate }
25550Sstevel@tonic-gate
25560Sstevel@tonic-gate #ifdef HAVE_FORK
do_multi(int multi)25570Sstevel@tonic-gate static int do_multi(int multi)
25580Sstevel@tonic-gate {
25590Sstevel@tonic-gate int n;
25600Sstevel@tonic-gate int fd[2];
25610Sstevel@tonic-gate int *fds;
25620Sstevel@tonic-gate static char sep[]=":";
25630Sstevel@tonic-gate
25640Sstevel@tonic-gate fds=malloc(multi*sizeof *fds);
25650Sstevel@tonic-gate for(n=0 ; n < multi ; ++n)
25660Sstevel@tonic-gate {
25670Sstevel@tonic-gate pipe(fd);
25680Sstevel@tonic-gate if(fork())
25690Sstevel@tonic-gate {
25700Sstevel@tonic-gate close(fd[1]);
25710Sstevel@tonic-gate fds[n]=fd[0];
25720Sstevel@tonic-gate }
25730Sstevel@tonic-gate else
25740Sstevel@tonic-gate {
25750Sstevel@tonic-gate close(fd[0]);
25760Sstevel@tonic-gate close(1);
25770Sstevel@tonic-gate dup(fd[1]);
25780Sstevel@tonic-gate close(fd[1]);
25790Sstevel@tonic-gate mr=1;
25800Sstevel@tonic-gate usertime=0;
25810Sstevel@tonic-gate return 0;
25820Sstevel@tonic-gate }
25830Sstevel@tonic-gate printf("Forked child %d\n",n);
25840Sstevel@tonic-gate }
25850Sstevel@tonic-gate
25860Sstevel@tonic-gate /* for now, assume the pipe is long enough to take all the output */
25870Sstevel@tonic-gate for(n=0 ; n < multi ; ++n)
25880Sstevel@tonic-gate {
25890Sstevel@tonic-gate FILE *f;
25900Sstevel@tonic-gate char buf[1024];
25910Sstevel@tonic-gate char *p;
25920Sstevel@tonic-gate
25930Sstevel@tonic-gate f=fdopen(fds[n],"r");
25940Sstevel@tonic-gate while(fgets(buf,sizeof buf,f))
25950Sstevel@tonic-gate {
25960Sstevel@tonic-gate p=strchr(buf,'\n');
25970Sstevel@tonic-gate if(p)
25980Sstevel@tonic-gate *p='\0';
25990Sstevel@tonic-gate if(buf[0] != '+')
26000Sstevel@tonic-gate {
26010Sstevel@tonic-gate fprintf(stderr,"Don't understand line '%s' from child %d\n",
26020Sstevel@tonic-gate buf,n);
26030Sstevel@tonic-gate continue;
26040Sstevel@tonic-gate }
26050Sstevel@tonic-gate printf("Got: %s from %d\n",buf,n);
26060Sstevel@tonic-gate if(!strncmp(buf,"+F:",3))
26070Sstevel@tonic-gate {
26080Sstevel@tonic-gate int alg;
26090Sstevel@tonic-gate int j;
26100Sstevel@tonic-gate
26110Sstevel@tonic-gate p=buf+3;
26120Sstevel@tonic-gate alg=atoi(sstrsep(&p,sep));
26130Sstevel@tonic-gate sstrsep(&p,sep);
26140Sstevel@tonic-gate for(j=0 ; j < SIZE_NUM ; ++j)
26150Sstevel@tonic-gate results[alg][j]+=atof(sstrsep(&p,sep));
26160Sstevel@tonic-gate }
26170Sstevel@tonic-gate else if(!strncmp(buf,"+F2:",4))
26180Sstevel@tonic-gate {
26190Sstevel@tonic-gate int k;
26200Sstevel@tonic-gate double d;
26210Sstevel@tonic-gate
26220Sstevel@tonic-gate p=buf+4;
26230Sstevel@tonic-gate k=atoi(sstrsep(&p,sep));
26240Sstevel@tonic-gate sstrsep(&p,sep);
26250Sstevel@tonic-gate
26260Sstevel@tonic-gate d=atof(sstrsep(&p,sep));
26270Sstevel@tonic-gate if(n)
26280Sstevel@tonic-gate rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
26290Sstevel@tonic-gate else
26300Sstevel@tonic-gate rsa_results[k][0]=d;
26310Sstevel@tonic-gate
26320Sstevel@tonic-gate d=atof(sstrsep(&p,sep));
26330Sstevel@tonic-gate if(n)
26340Sstevel@tonic-gate rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
26350Sstevel@tonic-gate else
26360Sstevel@tonic-gate rsa_results[k][1]=d;
26370Sstevel@tonic-gate }
26380Sstevel@tonic-gate else if(!strncmp(buf,"+F2:",4))
26390Sstevel@tonic-gate {
26400Sstevel@tonic-gate int k;
26410Sstevel@tonic-gate double d;
26420Sstevel@tonic-gate
26430Sstevel@tonic-gate p=buf+4;
26440Sstevel@tonic-gate k=atoi(sstrsep(&p,sep));
26450Sstevel@tonic-gate sstrsep(&p,sep);
26460Sstevel@tonic-gate
26470Sstevel@tonic-gate d=atof(sstrsep(&p,sep));
26480Sstevel@tonic-gate if(n)
26490Sstevel@tonic-gate rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
26500Sstevel@tonic-gate else
26510Sstevel@tonic-gate rsa_results[k][0]=d;
26520Sstevel@tonic-gate
26530Sstevel@tonic-gate d=atof(sstrsep(&p,sep));
26540Sstevel@tonic-gate if(n)
26550Sstevel@tonic-gate rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
26560Sstevel@tonic-gate else
26570Sstevel@tonic-gate rsa_results[k][1]=d;
26580Sstevel@tonic-gate }
26590Sstevel@tonic-gate else if(!strncmp(buf,"+F3:",4))
26600Sstevel@tonic-gate {
26610Sstevel@tonic-gate int k;
26620Sstevel@tonic-gate double d;
26630Sstevel@tonic-gate
26640Sstevel@tonic-gate p=buf+4;
26650Sstevel@tonic-gate k=atoi(sstrsep(&p,sep));
26660Sstevel@tonic-gate sstrsep(&p,sep);
26670Sstevel@tonic-gate
26680Sstevel@tonic-gate d=atof(sstrsep(&p,sep));
26690Sstevel@tonic-gate if(n)
26700Sstevel@tonic-gate dsa_results[k][0]=1/(1/dsa_results[k][0]+1/d);
26710Sstevel@tonic-gate else
26720Sstevel@tonic-gate dsa_results[k][0]=d;
26730Sstevel@tonic-gate
26740Sstevel@tonic-gate d=atof(sstrsep(&p,sep));
26750Sstevel@tonic-gate if(n)
26760Sstevel@tonic-gate dsa_results[k][1]=1/(1/dsa_results[k][1]+1/d);
26770Sstevel@tonic-gate else
26780Sstevel@tonic-gate dsa_results[k][1]=d;
26790Sstevel@tonic-gate }
26802139Sjp161948 #ifndef OPENSSL_NO_ECDSA
26812139Sjp161948 else if(!strncmp(buf,"+F4:",4))
26822139Sjp161948 {
26832139Sjp161948 int k;
26842139Sjp161948 double d;
26852139Sjp161948
26862139Sjp161948 p=buf+4;
26872139Sjp161948 k=atoi(sstrsep(&p,sep));
26882139Sjp161948 sstrsep(&p,sep);
26892139Sjp161948
26902139Sjp161948 d=atof(sstrsep(&p,sep));
26912139Sjp161948 if(n)
26922139Sjp161948 ecdsa_results[k][0]=1/(1/ecdsa_results[k][0]+1/d);
26932139Sjp161948 else
26942139Sjp161948 ecdsa_results[k][0]=d;
26952139Sjp161948
26962139Sjp161948 d=atof(sstrsep(&p,sep));
26972139Sjp161948 if(n)
26982139Sjp161948 ecdsa_results[k][1]=1/(1/ecdsa_results[k][1]+1/d);
26992139Sjp161948 else
27002139Sjp161948 ecdsa_results[k][1]=d;
27012139Sjp161948 }
27022139Sjp161948 #endif
27032139Sjp161948
27042139Sjp161948 #ifndef OPENSSL_NO_ECDH
27052139Sjp161948 else if(!strncmp(buf,"+F5:",4))
27062139Sjp161948 {
27072139Sjp161948 int k;
27082139Sjp161948 double d;
27092139Sjp161948
27102139Sjp161948 p=buf+4;
27112139Sjp161948 k=atoi(sstrsep(&p,sep));
27122139Sjp161948 sstrsep(&p,sep);
27132139Sjp161948
27142139Sjp161948 d=atof(sstrsep(&p,sep));
27152139Sjp161948 if(n)
27162139Sjp161948 ecdh_results[k][0]=1/(1/ecdh_results[k][0]+1/d);
27172139Sjp161948 else
27182139Sjp161948 ecdh_results[k][0]=d;
27192139Sjp161948
27202139Sjp161948 }
27212139Sjp161948 #endif
27222139Sjp161948
27230Sstevel@tonic-gate else if(!strncmp(buf,"+H:",3))
27240Sstevel@tonic-gate {
27250Sstevel@tonic-gate }
27260Sstevel@tonic-gate else
27270Sstevel@tonic-gate fprintf(stderr,"Unknown type '%s' from child %d\n",buf,n);
27280Sstevel@tonic-gate }
27290Sstevel@tonic-gate }
27300Sstevel@tonic-gate return 1;
27310Sstevel@tonic-gate }
27320Sstevel@tonic-gate #endif
27330Sstevel@tonic-gate #endif
2734