1ebfedea0SLionel Sambuc /* apps/speed.c -*- mode:C; c-file-style: "eay" -*- */
2ebfedea0SLionel Sambuc /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3ebfedea0SLionel Sambuc * All rights reserved.
4ebfedea0SLionel Sambuc *
5ebfedea0SLionel Sambuc * This package is an SSL implementation written
6ebfedea0SLionel Sambuc * by Eric Young (eay@cryptsoft.com).
7ebfedea0SLionel Sambuc * The implementation was written so as to conform with Netscapes SSL.
8ebfedea0SLionel Sambuc *
9ebfedea0SLionel Sambuc * This library is free for commercial and non-commercial use as long as
10ebfedea0SLionel Sambuc * the following conditions are aheared to. The following conditions
11ebfedea0SLionel Sambuc * apply to all code found in this distribution, be it the RC4, RSA,
12ebfedea0SLionel Sambuc * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13ebfedea0SLionel Sambuc * included with this distribution is covered by the same copyright terms
14ebfedea0SLionel Sambuc * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15ebfedea0SLionel Sambuc *
16ebfedea0SLionel Sambuc * Copyright remains Eric Young's, and as such any Copyright notices in
17ebfedea0SLionel Sambuc * the code are not to be removed.
18ebfedea0SLionel Sambuc * If this package is used in a product, Eric Young should be given attribution
19ebfedea0SLionel Sambuc * as the author of the parts of the library used.
20ebfedea0SLionel Sambuc * This can be in the form of a textual message at program startup or
21ebfedea0SLionel Sambuc * in documentation (online or textual) provided with the package.
22ebfedea0SLionel Sambuc *
23ebfedea0SLionel Sambuc * Redistribution and use in source and binary forms, with or without
24ebfedea0SLionel Sambuc * modification, are permitted provided that the following conditions
25ebfedea0SLionel Sambuc * are met:
26ebfedea0SLionel Sambuc * 1. Redistributions of source code must retain the copyright
27ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer.
28ebfedea0SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
29ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer in the
30ebfedea0SLionel Sambuc * documentation and/or other materials provided with the distribution.
31ebfedea0SLionel Sambuc * 3. All advertising materials mentioning features or use of this software
32ebfedea0SLionel Sambuc * must display the following acknowledgement:
33ebfedea0SLionel Sambuc * "This product includes cryptographic software written by
34ebfedea0SLionel Sambuc * Eric Young (eay@cryptsoft.com)"
35ebfedea0SLionel Sambuc * The word 'cryptographic' can be left out if the rouines from the library
36ebfedea0SLionel Sambuc * being used are not cryptographic related :-).
37ebfedea0SLionel Sambuc * 4. If you include any Windows specific code (or a derivative thereof) from
38ebfedea0SLionel Sambuc * the apps directory (application code) you must include an acknowledgement:
39ebfedea0SLionel Sambuc * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40ebfedea0SLionel Sambuc *
41ebfedea0SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42ebfedea0SLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43ebfedea0SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44ebfedea0SLionel Sambuc * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45ebfedea0SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46ebfedea0SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47ebfedea0SLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48ebfedea0SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49ebfedea0SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50ebfedea0SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51ebfedea0SLionel Sambuc * SUCH DAMAGE.
52ebfedea0SLionel Sambuc *
53ebfedea0SLionel Sambuc * The licence and distribution terms for any publically available version or
54ebfedea0SLionel Sambuc * derivative of this code cannot be changed. i.e. this code cannot simply be
55ebfedea0SLionel Sambuc * copied and put under another distribution licence
56ebfedea0SLionel Sambuc * [including the GNU Public Licence.]
57ebfedea0SLionel Sambuc */
58ebfedea0SLionel Sambuc /* ====================================================================
59ebfedea0SLionel Sambuc * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
60ebfedea0SLionel Sambuc *
61ebfedea0SLionel Sambuc * Portions of the attached software ("Contribution") are developed by
62ebfedea0SLionel Sambuc * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
63ebfedea0SLionel Sambuc *
64ebfedea0SLionel Sambuc * The Contribution is licensed pursuant to the OpenSSL open source
65ebfedea0SLionel Sambuc * license provided above.
66ebfedea0SLionel Sambuc *
67ebfedea0SLionel Sambuc * The ECDH and ECDSA speed test software is originally written by
68ebfedea0SLionel Sambuc * Sumit Gupta of Sun Microsystems Laboratories.
69ebfedea0SLionel Sambuc *
70ebfedea0SLionel Sambuc */
71ebfedea0SLionel Sambuc
72ebfedea0SLionel Sambuc /* most of this code has been pilfered from my libdes speed.c program */
73ebfedea0SLionel Sambuc
74ebfedea0SLionel Sambuc #ifndef OPENSSL_NO_SPEED
75ebfedea0SLionel Sambuc
76ebfedea0SLionel Sambuc # undef SECONDS
77ebfedea0SLionel Sambuc # define SECONDS 3
78ebfedea0SLionel Sambuc # define RSA_SECONDS 10
79ebfedea0SLionel Sambuc # define DSA_SECONDS 10
80ebfedea0SLionel Sambuc # define ECDSA_SECONDS 10
81ebfedea0SLionel Sambuc # define ECDH_SECONDS 10
82ebfedea0SLionel Sambuc
83ebfedea0SLionel Sambuc /* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
84ebfedea0SLionel Sambuc /* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
85ebfedea0SLionel Sambuc
86ebfedea0SLionel Sambuc # undef PROG
87ebfedea0SLionel Sambuc # define PROG speed_main
88ebfedea0SLionel Sambuc
89ebfedea0SLionel Sambuc # include <stdio.h>
90ebfedea0SLionel Sambuc # include <stdlib.h>
91ebfedea0SLionel Sambuc
92ebfedea0SLionel Sambuc # include <string.h>
93ebfedea0SLionel Sambuc # include <math.h>
94ebfedea0SLionel Sambuc # include "apps.h"
95ebfedea0SLionel Sambuc # ifdef OPENSSL_NO_STDIO
96ebfedea0SLionel Sambuc # define APPS_WIN16
97ebfedea0SLionel Sambuc # endif
98ebfedea0SLionel Sambuc # include <openssl/crypto.h>
99ebfedea0SLionel Sambuc # include <openssl/rand.h>
100ebfedea0SLionel Sambuc # include <openssl/err.h>
101ebfedea0SLionel Sambuc # include <openssl/evp.h>
102ebfedea0SLionel Sambuc # include <openssl/objects.h>
103ebfedea0SLionel Sambuc # if !defined(OPENSSL_SYS_MSDOS)
104ebfedea0SLionel Sambuc # include <unistd.h>
105ebfedea0SLionel Sambuc # endif
106ebfedea0SLionel Sambuc
107ebfedea0SLionel Sambuc # ifndef OPENSSL_SYS_NETWARE
108ebfedea0SLionel Sambuc # include <signal.h>
109ebfedea0SLionel Sambuc # endif
110ebfedea0SLionel Sambuc
111ebfedea0SLionel Sambuc # if defined(_WIN32) || defined(__CYGWIN__)
112ebfedea0SLionel Sambuc # include <windows.h>
113ebfedea0SLionel Sambuc # if defined(__CYGWIN__) && !defined(_WIN32)
114*0a6a1f1dSLionel Sambuc /*
115*0a6a1f1dSLionel Sambuc * <windows.h> should define _WIN32, which normally is mutually exclusive
116*0a6a1f1dSLionel Sambuc * with __CYGWIN__, but if it didn't...
117*0a6a1f1dSLionel Sambuc */
118ebfedea0SLionel Sambuc # define _WIN32
119ebfedea0SLionel Sambuc /* this is done because Cygwin alarm() fails sometimes. */
120ebfedea0SLionel Sambuc # endif
121ebfedea0SLionel Sambuc # endif
122ebfedea0SLionel Sambuc
123ebfedea0SLionel Sambuc # include <openssl/bn.h>
124ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DES
125ebfedea0SLionel Sambuc # include <openssl/des.h>
126ebfedea0SLionel Sambuc # endif
127ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_AES
128ebfedea0SLionel Sambuc # include <openssl/aes.h>
129ebfedea0SLionel Sambuc # endif
130ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAMELLIA
131ebfedea0SLionel Sambuc # include <openssl/camellia.h>
132ebfedea0SLionel Sambuc # endif
133ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD2
134ebfedea0SLionel Sambuc # include <openssl/md2.h>
135ebfedea0SLionel Sambuc # endif
136ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MDC2
137ebfedea0SLionel Sambuc # include <openssl/mdc2.h>
138ebfedea0SLionel Sambuc # endif
139ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD4
140ebfedea0SLionel Sambuc # include <openssl/md4.h>
141ebfedea0SLionel Sambuc # endif
142ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD5
143ebfedea0SLionel Sambuc # include <openssl/md5.h>
144ebfedea0SLionel Sambuc # endif
145ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_HMAC
146ebfedea0SLionel Sambuc # include <openssl/hmac.h>
147ebfedea0SLionel Sambuc # endif
148ebfedea0SLionel Sambuc # include <openssl/evp.h>
149ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA
150ebfedea0SLionel Sambuc # include <openssl/sha.h>
151ebfedea0SLionel Sambuc # endif
152ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RIPEMD
153ebfedea0SLionel Sambuc # include <openssl/ripemd.h>
154ebfedea0SLionel Sambuc # endif
155ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_WHIRLPOOL
156ebfedea0SLionel Sambuc # include <openssl/whrlpool.h>
157ebfedea0SLionel Sambuc # endif
158ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC4
159ebfedea0SLionel Sambuc # include <openssl/rc4.h>
160ebfedea0SLionel Sambuc # endif
161ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC5
162ebfedea0SLionel Sambuc # include <openssl/rc5.h>
163ebfedea0SLionel Sambuc # endif
164ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC2
165ebfedea0SLionel Sambuc # include <openssl/rc2.h>
166ebfedea0SLionel Sambuc # endif
167ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_IDEA
168ebfedea0SLionel Sambuc # include <openssl/idea.h>
169ebfedea0SLionel Sambuc # endif
170ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SEED
171ebfedea0SLionel Sambuc # include <openssl/seed.h>
172ebfedea0SLionel Sambuc # endif
173ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_BF
174ebfedea0SLionel Sambuc # include <openssl/blowfish.h>
175ebfedea0SLionel Sambuc # endif
176ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAST
177ebfedea0SLionel Sambuc # include <openssl/cast.h>
178ebfedea0SLionel Sambuc # endif
179ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
180ebfedea0SLionel Sambuc # include <openssl/rsa.h>
181ebfedea0SLionel Sambuc # include "./testrsa.h"
182ebfedea0SLionel Sambuc # endif
183ebfedea0SLionel Sambuc # include <openssl/x509.h>
184ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
185ebfedea0SLionel Sambuc # include <openssl/dsa.h>
186ebfedea0SLionel Sambuc # include "./testdsa.h"
187ebfedea0SLionel Sambuc # endif
188ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
189ebfedea0SLionel Sambuc # include <openssl/ecdsa.h>
190ebfedea0SLionel Sambuc # endif
191ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
192ebfedea0SLionel Sambuc # include <openssl/ecdh.h>
193ebfedea0SLionel Sambuc # endif
194ebfedea0SLionel Sambuc # include <openssl/modes.h>
195ebfedea0SLionel Sambuc
196ebfedea0SLionel Sambuc # ifdef OPENSSL_FIPS
197ebfedea0SLionel Sambuc # ifdef OPENSSL_DOING_MAKEDEPEND
198ebfedea0SLionel Sambuc # undef AES_set_encrypt_key
199ebfedea0SLionel Sambuc # undef AES_set_decrypt_key
200ebfedea0SLionel Sambuc # undef DES_set_key_unchecked
201ebfedea0SLionel Sambuc # endif
202ebfedea0SLionel Sambuc # define BF_set_key private_BF_set_key
203ebfedea0SLionel Sambuc # define CAST_set_key private_CAST_set_key
204ebfedea0SLionel Sambuc # define idea_set_encrypt_key private_idea_set_encrypt_key
205ebfedea0SLionel Sambuc # define SEED_set_key private_SEED_set_key
206ebfedea0SLionel Sambuc # define RC2_set_key private_RC2_set_key
207ebfedea0SLionel Sambuc # define RC4_set_key private_RC4_set_key
208ebfedea0SLionel Sambuc # define DES_set_key_unchecked private_DES_set_key_unchecked
209ebfedea0SLionel Sambuc # define AES_set_encrypt_key private_AES_set_encrypt_key
210ebfedea0SLionel Sambuc # define AES_set_decrypt_key private_AES_set_decrypt_key
211ebfedea0SLionel Sambuc # define Camellia_set_key private_Camellia_set_key
212ebfedea0SLionel Sambuc # endif
213ebfedea0SLionel Sambuc
214ebfedea0SLionel Sambuc # ifndef HAVE_FORK
215ebfedea0SLionel Sambuc # if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_NETWARE)
216ebfedea0SLionel Sambuc # define HAVE_FORK 0
217ebfedea0SLionel Sambuc # else
218ebfedea0SLionel Sambuc # define HAVE_FORK 1
219ebfedea0SLionel Sambuc # endif
220ebfedea0SLionel Sambuc # endif
221ebfedea0SLionel Sambuc
222ebfedea0SLionel Sambuc # if HAVE_FORK
223ebfedea0SLionel Sambuc # undef NO_FORK
224ebfedea0SLionel Sambuc # else
225ebfedea0SLionel Sambuc # define NO_FORK
226ebfedea0SLionel Sambuc # endif
227ebfedea0SLionel Sambuc
228ebfedea0SLionel Sambuc # undef BUFSIZE
229ebfedea0SLionel Sambuc # define BUFSIZE ((long)1024*8+1)
230*0a6a1f1dSLionel Sambuc static volatile int run = 0;
231ebfedea0SLionel Sambuc
232ebfedea0SLionel Sambuc static int mr = 0;
233ebfedea0SLionel Sambuc static int usertime = 1;
234ebfedea0SLionel Sambuc
235ebfedea0SLionel Sambuc static double Time_F(int s);
236ebfedea0SLionel Sambuc static void print_message(const char *s, long num, int length);
237ebfedea0SLionel Sambuc static void pkey_print_message(const char *str, const char *str2,
238ebfedea0SLionel Sambuc long num, int bits, int sec);
239ebfedea0SLionel Sambuc static void print_result(int alg, int run_no, int count, double time_used);
240ebfedea0SLionel Sambuc # ifndef NO_FORK
241ebfedea0SLionel Sambuc static int do_multi(int multi);
242ebfedea0SLionel Sambuc # endif
243ebfedea0SLionel Sambuc
244ebfedea0SLionel Sambuc # define ALGOR_NUM 30
245ebfedea0SLionel Sambuc # define SIZE_NUM 5
246ebfedea0SLionel Sambuc # define RSA_NUM 4
247ebfedea0SLionel Sambuc # define DSA_NUM 3
248ebfedea0SLionel Sambuc
249ebfedea0SLionel Sambuc # define EC_NUM 16
250ebfedea0SLionel Sambuc # define MAX_ECDH_SIZE 256
251ebfedea0SLionel Sambuc
252ebfedea0SLionel Sambuc static const char *names[ALGOR_NUM] = {
253ebfedea0SLionel Sambuc "md2", "mdc2", "md4", "md5", "hmac(md5)", "sha1", "rmd160", "rc4",
254ebfedea0SLionel Sambuc "des cbc", "des ede3", "idea cbc", "seed cbc",
255ebfedea0SLionel Sambuc "rc2 cbc", "rc5-32/12 cbc", "blowfish cbc", "cast cbc",
256ebfedea0SLionel Sambuc "aes-128 cbc", "aes-192 cbc", "aes-256 cbc",
257ebfedea0SLionel Sambuc "camellia-128 cbc", "camellia-192 cbc", "camellia-256 cbc",
258ebfedea0SLionel Sambuc "evp", "sha256", "sha512", "whirlpool",
259*0a6a1f1dSLionel Sambuc "aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash"
260*0a6a1f1dSLionel Sambuc };
261*0a6a1f1dSLionel Sambuc
262ebfedea0SLionel Sambuc static double results[ALGOR_NUM][SIZE_NUM];
263ebfedea0SLionel Sambuc static int lengths[SIZE_NUM] = { 16, 64, 256, 1024, 8 * 1024 };
264*0a6a1f1dSLionel Sambuc
265ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
266ebfedea0SLionel Sambuc static double rsa_results[RSA_NUM][2];
267ebfedea0SLionel Sambuc # endif
268ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
269ebfedea0SLionel Sambuc static double dsa_results[DSA_NUM][2];
270ebfedea0SLionel Sambuc # endif
271ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
272ebfedea0SLionel Sambuc static double ecdsa_results[EC_NUM][2];
273ebfedea0SLionel Sambuc # endif
274ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
275ebfedea0SLionel Sambuc static double ecdh_results[EC_NUM][1];
276ebfedea0SLionel Sambuc # endif
277ebfedea0SLionel Sambuc
278ebfedea0SLionel Sambuc # if defined(OPENSSL_NO_DSA) && !(defined(OPENSSL_NO_ECDSA) && defined(OPENSSL_NO_ECDH))
279*0a6a1f1dSLionel Sambuc static const char rnd_seed[] =
280*0a6a1f1dSLionel Sambuc "string to make the random number generator think it has entropy";
281ebfedea0SLionel Sambuc static int rnd_fake = 0;
282ebfedea0SLionel Sambuc # endif
283ebfedea0SLionel Sambuc
284ebfedea0SLionel Sambuc # ifdef SIGALRM
285ebfedea0SLionel Sambuc # if defined(__STDC__) || defined(sgi) || defined(_AIX)
286ebfedea0SLionel Sambuc # define SIGRETTYPE void
287ebfedea0SLionel Sambuc # else
288ebfedea0SLionel Sambuc # define SIGRETTYPE int
289ebfedea0SLionel Sambuc # endif
290ebfedea0SLionel Sambuc
291ebfedea0SLionel Sambuc static SIGRETTYPE sig_done(int sig);
sig_done(int sig)292ebfedea0SLionel Sambuc static SIGRETTYPE sig_done(int sig)
293ebfedea0SLionel Sambuc {
294ebfedea0SLionel Sambuc signal(SIGALRM, sig_done);
295ebfedea0SLionel Sambuc run = 0;
296ebfedea0SLionel Sambuc # ifdef LINT
297ebfedea0SLionel Sambuc sig = sig;
298ebfedea0SLionel Sambuc # endif
299ebfedea0SLionel Sambuc }
300ebfedea0SLionel Sambuc # endif
301ebfedea0SLionel Sambuc
302ebfedea0SLionel Sambuc # define START 0
303ebfedea0SLionel Sambuc # define STOP 1
304ebfedea0SLionel Sambuc
305ebfedea0SLionel Sambuc # if defined(_WIN32)
306ebfedea0SLionel Sambuc
307ebfedea0SLionel Sambuc # if !defined(SIGALRM)
308ebfedea0SLionel Sambuc # define SIGALRM
309ebfedea0SLionel Sambuc # endif
310ebfedea0SLionel Sambuc static unsigned int lapse, schlock;
alarm_win32(unsigned int secs)311*0a6a1f1dSLionel Sambuc static void alarm_win32(unsigned int secs)
312*0a6a1f1dSLionel Sambuc {
313*0a6a1f1dSLionel Sambuc lapse = secs * 1000;
314*0a6a1f1dSLionel Sambuc }
315*0a6a1f1dSLionel Sambuc
316ebfedea0SLionel Sambuc # define alarm alarm_win32
317ebfedea0SLionel Sambuc
sleepy(VOID * arg)318ebfedea0SLionel Sambuc static DWORD WINAPI sleepy(VOID * arg)
319ebfedea0SLionel Sambuc {
320ebfedea0SLionel Sambuc schlock = 1;
321ebfedea0SLionel Sambuc Sleep(lapse);
322ebfedea0SLionel Sambuc run = 0;
323ebfedea0SLionel Sambuc return 0;
324ebfedea0SLionel Sambuc }
325ebfedea0SLionel Sambuc
Time_F(int s)326ebfedea0SLionel Sambuc static double Time_F(int s)
327ebfedea0SLionel Sambuc {
328*0a6a1f1dSLionel Sambuc if (s == START) {
329ebfedea0SLionel Sambuc HANDLE thr;
330ebfedea0SLionel Sambuc schlock = 0;
331ebfedea0SLionel Sambuc thr = CreateThread(NULL, 4096, sleepy, NULL, 0, NULL);
332*0a6a1f1dSLionel Sambuc if (thr == NULL) {
333ebfedea0SLionel Sambuc DWORD ret = GetLastError();
334ebfedea0SLionel Sambuc BIO_printf(bio_err, "unable to CreateThread (%d)", ret);
335ebfedea0SLionel Sambuc ExitProcess(ret);
336ebfedea0SLionel Sambuc }
337ebfedea0SLionel Sambuc CloseHandle(thr); /* detach the thread */
338*0a6a1f1dSLionel Sambuc while (!schlock)
339*0a6a1f1dSLionel Sambuc Sleep(0); /* scheduler spinlock */
340ebfedea0SLionel Sambuc }
341ebfedea0SLionel Sambuc
342ebfedea0SLionel Sambuc return app_tminterval(s, usertime);
343ebfedea0SLionel Sambuc }
344ebfedea0SLionel Sambuc # else
345ebfedea0SLionel Sambuc
Time_F(int s)346ebfedea0SLionel Sambuc static double Time_F(int s)
347ebfedea0SLionel Sambuc {
348ebfedea0SLionel Sambuc return app_tminterval(s, usertime);
349ebfedea0SLionel Sambuc }
350ebfedea0SLionel Sambuc # endif
351ebfedea0SLionel Sambuc
352ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
353ebfedea0SLionel Sambuc static const int KDF1_SHA1_len = 20;
KDF1_SHA1(const void * in,size_t inlen,void * out,size_t * outlen)354*0a6a1f1dSLionel Sambuc static void *KDF1_SHA1(const void *in, size_t inlen, void *out,
355*0a6a1f1dSLionel Sambuc size_t *outlen)
356ebfedea0SLionel Sambuc {
357ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA
358ebfedea0SLionel Sambuc if (*outlen < SHA_DIGEST_LENGTH)
359ebfedea0SLionel Sambuc return NULL;
360ebfedea0SLionel Sambuc else
361ebfedea0SLionel Sambuc *outlen = SHA_DIGEST_LENGTH;
362ebfedea0SLionel Sambuc return SHA1(in, inlen, out);
363ebfedea0SLionel Sambuc # else
364ebfedea0SLionel Sambuc return NULL;
365ebfedea0SLionel Sambuc # endif /* OPENSSL_NO_SHA */
366ebfedea0SLionel Sambuc }
367ebfedea0SLionel Sambuc # endif /* OPENSSL_NO_ECDH */
368ebfedea0SLionel Sambuc
369ebfedea0SLionel Sambuc int MAIN(int, char **);
370ebfedea0SLionel Sambuc
MAIN(int argc,char ** argv)371ebfedea0SLionel Sambuc int MAIN(int argc, char **argv)
372ebfedea0SLionel Sambuc {
373ebfedea0SLionel Sambuc unsigned char *buf = NULL, *buf2 = NULL;
374ebfedea0SLionel Sambuc int mret = 1;
375ebfedea0SLionel Sambuc long count = 0, save_count = 0;
376ebfedea0SLionel Sambuc int i, j, k;
377ebfedea0SLionel Sambuc # if !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_DSA)
378ebfedea0SLionel Sambuc long rsa_count;
379ebfedea0SLionel Sambuc # endif
380ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
381ebfedea0SLionel Sambuc unsigned rsa_num;
382ebfedea0SLionel Sambuc # endif
383ebfedea0SLionel Sambuc unsigned char md[EVP_MAX_MD_SIZE];
384ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD2
385ebfedea0SLionel Sambuc unsigned char md2[MD2_DIGEST_LENGTH];
386ebfedea0SLionel Sambuc # endif
387ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MDC2
388ebfedea0SLionel Sambuc unsigned char mdc2[MDC2_DIGEST_LENGTH];
389ebfedea0SLionel Sambuc # endif
390ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD4
391ebfedea0SLionel Sambuc unsigned char md4[MD4_DIGEST_LENGTH];
392ebfedea0SLionel Sambuc # endif
393ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD5
394ebfedea0SLionel Sambuc unsigned char md5[MD5_DIGEST_LENGTH];
395ebfedea0SLionel Sambuc unsigned char hmac[MD5_DIGEST_LENGTH];
396ebfedea0SLionel Sambuc # endif
397ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA
398ebfedea0SLionel Sambuc unsigned char sha[SHA_DIGEST_LENGTH];
399ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA256
400ebfedea0SLionel Sambuc unsigned char sha256[SHA256_DIGEST_LENGTH];
401ebfedea0SLionel Sambuc # endif
402ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA512
403ebfedea0SLionel Sambuc unsigned char sha512[SHA512_DIGEST_LENGTH];
404ebfedea0SLionel Sambuc # endif
405ebfedea0SLionel Sambuc # endif
406ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_WHIRLPOOL
407ebfedea0SLionel Sambuc unsigned char whirlpool[WHIRLPOOL_DIGEST_LENGTH];
408ebfedea0SLionel Sambuc # endif
409ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RIPEMD
410ebfedea0SLionel Sambuc unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];
411ebfedea0SLionel Sambuc # endif
412ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC4
413ebfedea0SLionel Sambuc RC4_KEY rc4_ks;
414ebfedea0SLionel Sambuc # endif
415ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC5
416ebfedea0SLionel Sambuc RC5_32_KEY rc5_ks;
417ebfedea0SLionel Sambuc # endif
418ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC2
419ebfedea0SLionel Sambuc RC2_KEY rc2_ks;
420ebfedea0SLionel Sambuc # endif
421ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_IDEA
422ebfedea0SLionel Sambuc IDEA_KEY_SCHEDULE idea_ks;
423ebfedea0SLionel Sambuc # endif
424ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SEED
425ebfedea0SLionel Sambuc SEED_KEY_SCHEDULE seed_ks;
426ebfedea0SLionel Sambuc # endif
427ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_BF
428ebfedea0SLionel Sambuc BF_KEY bf_ks;
429ebfedea0SLionel Sambuc # endif
430ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAST
431ebfedea0SLionel Sambuc CAST_KEY cast_ks;
432ebfedea0SLionel Sambuc # endif
433*0a6a1f1dSLionel Sambuc static const unsigned char key16[16] = {
434*0a6a1f1dSLionel Sambuc 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
435*0a6a1f1dSLionel Sambuc 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12
436*0a6a1f1dSLionel Sambuc };
437ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_AES
438*0a6a1f1dSLionel Sambuc static const unsigned char key24[24] = {
439*0a6a1f1dSLionel Sambuc 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
440ebfedea0SLionel Sambuc 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
441*0a6a1f1dSLionel Sambuc 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34
442*0a6a1f1dSLionel Sambuc };
443*0a6a1f1dSLionel Sambuc static const unsigned char key32[32] = {
444*0a6a1f1dSLionel Sambuc 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
445ebfedea0SLionel Sambuc 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
446ebfedea0SLionel Sambuc 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,
447*0a6a1f1dSLionel Sambuc 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56
448*0a6a1f1dSLionel Sambuc };
449ebfedea0SLionel Sambuc # endif
450ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAMELLIA
451*0a6a1f1dSLionel Sambuc static const unsigned char ckey24[24] = {
452*0a6a1f1dSLionel Sambuc 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
453ebfedea0SLionel Sambuc 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
454*0a6a1f1dSLionel Sambuc 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34
455*0a6a1f1dSLionel Sambuc };
456*0a6a1f1dSLionel Sambuc static const unsigned char ckey32[32] = {
457*0a6a1f1dSLionel Sambuc 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
458ebfedea0SLionel Sambuc 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
459ebfedea0SLionel Sambuc 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,
460*0a6a1f1dSLionel Sambuc 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56
461*0a6a1f1dSLionel Sambuc };
462ebfedea0SLionel Sambuc # endif
463ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_AES
464ebfedea0SLionel Sambuc # define MAX_BLOCK_SIZE 128
465ebfedea0SLionel Sambuc # else
466ebfedea0SLionel Sambuc # define MAX_BLOCK_SIZE 64
467ebfedea0SLionel Sambuc # endif
468ebfedea0SLionel Sambuc unsigned char DES_iv[8];
469ebfedea0SLionel Sambuc unsigned char iv[2 * MAX_BLOCK_SIZE / 8];
470ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DES
471*0a6a1f1dSLionel Sambuc static DES_cblock key =
472*0a6a1f1dSLionel Sambuc { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 };
473*0a6a1f1dSLionel Sambuc static DES_cblock key2 =
474*0a6a1f1dSLionel Sambuc { 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12 };
475*0a6a1f1dSLionel Sambuc static DES_cblock key3 =
476*0a6a1f1dSLionel Sambuc { 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34 };
477ebfedea0SLionel Sambuc DES_key_schedule sch;
478ebfedea0SLionel Sambuc DES_key_schedule sch2;
479ebfedea0SLionel Sambuc DES_key_schedule sch3;
480ebfedea0SLionel Sambuc # endif
481ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_AES
482ebfedea0SLionel Sambuc AES_KEY aes_ks1, aes_ks2, aes_ks3;
483ebfedea0SLionel Sambuc # endif
484ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAMELLIA
485ebfedea0SLionel Sambuc CAMELLIA_KEY camellia_ks1, camellia_ks2, camellia_ks3;
486ebfedea0SLionel Sambuc # endif
487ebfedea0SLionel Sambuc # define D_MD2 0
488ebfedea0SLionel Sambuc # define D_MDC2 1
489ebfedea0SLionel Sambuc # define D_MD4 2
490ebfedea0SLionel Sambuc # define D_MD5 3
491ebfedea0SLionel Sambuc # define D_HMAC 4
492ebfedea0SLionel Sambuc # define D_SHA1 5
493ebfedea0SLionel Sambuc # define D_RMD160 6
494ebfedea0SLionel Sambuc # define D_RC4 7
495ebfedea0SLionel Sambuc # define D_CBC_DES 8
496ebfedea0SLionel Sambuc # define D_EDE3_DES 9
497ebfedea0SLionel Sambuc # define D_CBC_IDEA 10
498ebfedea0SLionel Sambuc # define D_CBC_SEED 11
499ebfedea0SLionel Sambuc # define D_CBC_RC2 12
500ebfedea0SLionel Sambuc # define D_CBC_RC5 13
501ebfedea0SLionel Sambuc # define D_CBC_BF 14
502ebfedea0SLionel Sambuc # define D_CBC_CAST 15
503ebfedea0SLionel Sambuc # define D_CBC_128_AES 16
504ebfedea0SLionel Sambuc # define D_CBC_192_AES 17
505ebfedea0SLionel Sambuc # define D_CBC_256_AES 18
506ebfedea0SLionel Sambuc # define D_CBC_128_CML 19
507ebfedea0SLionel Sambuc # define D_CBC_192_CML 20
508ebfedea0SLionel Sambuc # define D_CBC_256_CML 21
509ebfedea0SLionel Sambuc # define D_EVP 22
510ebfedea0SLionel Sambuc # define D_SHA256 23
511ebfedea0SLionel Sambuc # define D_SHA512 24
512ebfedea0SLionel Sambuc # define D_WHIRLPOOL 25
513ebfedea0SLionel Sambuc # define D_IGE_128_AES 26
514ebfedea0SLionel Sambuc # define D_IGE_192_AES 27
515ebfedea0SLionel Sambuc # define D_IGE_256_AES 28
516ebfedea0SLionel Sambuc # define D_GHASH 29
517ebfedea0SLionel Sambuc double d = 0.0;
518ebfedea0SLionel Sambuc long c[ALGOR_NUM][SIZE_NUM];
519ebfedea0SLionel Sambuc # define R_DSA_512 0
520ebfedea0SLionel Sambuc # define R_DSA_1024 1
521ebfedea0SLionel Sambuc # define R_DSA_2048 2
522ebfedea0SLionel Sambuc # define R_RSA_512 0
523ebfedea0SLionel Sambuc # define R_RSA_1024 1
524ebfedea0SLionel Sambuc # define R_RSA_2048 2
525ebfedea0SLionel Sambuc # define R_RSA_4096 3
526ebfedea0SLionel Sambuc
527ebfedea0SLionel Sambuc # define R_EC_P160 0
528ebfedea0SLionel Sambuc # define R_EC_P192 1
529ebfedea0SLionel Sambuc # define R_EC_P224 2
530ebfedea0SLionel Sambuc # define R_EC_P256 3
531ebfedea0SLionel Sambuc # define R_EC_P384 4
532ebfedea0SLionel Sambuc # define R_EC_P521 5
533ebfedea0SLionel Sambuc # define R_EC_K163 6
534ebfedea0SLionel Sambuc # define R_EC_K233 7
535ebfedea0SLionel Sambuc # define R_EC_K283 8
536ebfedea0SLionel Sambuc # define R_EC_K409 9
537ebfedea0SLionel Sambuc # define R_EC_K571 10
538ebfedea0SLionel Sambuc # define R_EC_B163 11
539ebfedea0SLionel Sambuc # define R_EC_B233 12
540ebfedea0SLionel Sambuc # define R_EC_B283 13
541ebfedea0SLionel Sambuc # define R_EC_B409 14
542ebfedea0SLionel Sambuc # define R_EC_B571 15
543ebfedea0SLionel Sambuc
544ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
545ebfedea0SLionel Sambuc RSA *rsa_key[RSA_NUM];
546ebfedea0SLionel Sambuc long rsa_c[RSA_NUM][2];
547*0a6a1f1dSLionel Sambuc static unsigned int rsa_bits[RSA_NUM] = {
548*0a6a1f1dSLionel Sambuc 512, 1024, 2048, 4096
549*0a6a1f1dSLionel Sambuc };
550*0a6a1f1dSLionel Sambuc static unsigned char *rsa_data[RSA_NUM] = {
551*0a6a1f1dSLionel Sambuc test512, test1024, test2048, test4096
552*0a6a1f1dSLionel Sambuc };
553ebfedea0SLionel Sambuc static int rsa_data_length[RSA_NUM] = {
554ebfedea0SLionel Sambuc sizeof(test512), sizeof(test1024),
555*0a6a1f1dSLionel Sambuc sizeof(test2048), sizeof(test4096)
556*0a6a1f1dSLionel Sambuc };
557ebfedea0SLionel Sambuc # endif
558ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
559ebfedea0SLionel Sambuc DSA *dsa_key[DSA_NUM];
560ebfedea0SLionel Sambuc long dsa_c[DSA_NUM][2];
561ebfedea0SLionel Sambuc static unsigned int dsa_bits[DSA_NUM] = { 512, 1024, 2048 };
562ebfedea0SLionel Sambuc # endif
563ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_EC
564*0a6a1f1dSLionel Sambuc /*
565*0a6a1f1dSLionel Sambuc * We only test over the following curves as they are representative, To
566*0a6a1f1dSLionel Sambuc * add tests over more curves, simply add the curve NID and curve name to
567*0a6a1f1dSLionel Sambuc * the following arrays and increase the EC_NUM value accordingly.
568ebfedea0SLionel Sambuc */
569*0a6a1f1dSLionel Sambuc static unsigned int test_curves[EC_NUM] = {
570ebfedea0SLionel Sambuc /* Prime Curves */
571ebfedea0SLionel Sambuc NID_secp160r1,
572ebfedea0SLionel Sambuc NID_X9_62_prime192v1,
573ebfedea0SLionel Sambuc NID_secp224r1,
574ebfedea0SLionel Sambuc NID_X9_62_prime256v1,
575ebfedea0SLionel Sambuc NID_secp384r1,
576ebfedea0SLionel Sambuc NID_secp521r1,
577ebfedea0SLionel Sambuc /* Binary Curves */
578ebfedea0SLionel Sambuc NID_sect163k1,
579ebfedea0SLionel Sambuc NID_sect233k1,
580ebfedea0SLionel Sambuc NID_sect283k1,
581ebfedea0SLionel Sambuc NID_sect409k1,
582ebfedea0SLionel Sambuc NID_sect571k1,
583ebfedea0SLionel Sambuc NID_sect163r2,
584ebfedea0SLionel Sambuc NID_sect233r1,
585ebfedea0SLionel Sambuc NID_sect283r1,
586ebfedea0SLionel Sambuc NID_sect409r1,
587ebfedea0SLionel Sambuc NID_sect571r1
588ebfedea0SLionel Sambuc };
589*0a6a1f1dSLionel Sambuc static const char *test_curves_names[EC_NUM] = {
590ebfedea0SLionel Sambuc /* Prime Curves */
591ebfedea0SLionel Sambuc "secp160r1",
592ebfedea0SLionel Sambuc "nistp192",
593ebfedea0SLionel Sambuc "nistp224",
594ebfedea0SLionel Sambuc "nistp256",
595ebfedea0SLionel Sambuc "nistp384",
596ebfedea0SLionel Sambuc "nistp521",
597ebfedea0SLionel Sambuc /* Binary Curves */
598ebfedea0SLionel Sambuc "nistk163",
599ebfedea0SLionel Sambuc "nistk233",
600ebfedea0SLionel Sambuc "nistk283",
601ebfedea0SLionel Sambuc "nistk409",
602ebfedea0SLionel Sambuc "nistk571",
603ebfedea0SLionel Sambuc "nistb163",
604ebfedea0SLionel Sambuc "nistb233",
605ebfedea0SLionel Sambuc "nistb283",
606ebfedea0SLionel Sambuc "nistb409",
607ebfedea0SLionel Sambuc "nistb571"
608ebfedea0SLionel Sambuc };
609*0a6a1f1dSLionel Sambuc static int test_curves_bits[EC_NUM] = {
610ebfedea0SLionel Sambuc 160, 192, 224, 256, 384, 521,
611ebfedea0SLionel Sambuc 163, 233, 283, 409, 571,
612ebfedea0SLionel Sambuc 163, 233, 283, 409, 571
613ebfedea0SLionel Sambuc };
614ebfedea0SLionel Sambuc
615ebfedea0SLionel Sambuc # endif
616ebfedea0SLionel Sambuc
617ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
618ebfedea0SLionel Sambuc unsigned char ecdsasig[256];
619ebfedea0SLionel Sambuc unsigned int ecdsasiglen;
620ebfedea0SLionel Sambuc EC_KEY *ecdsa[EC_NUM];
621ebfedea0SLionel Sambuc long ecdsa_c[EC_NUM][2];
622ebfedea0SLionel Sambuc # endif
623ebfedea0SLionel Sambuc
624ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
625ebfedea0SLionel Sambuc EC_KEY *ecdh_a[EC_NUM], *ecdh_b[EC_NUM];
626ebfedea0SLionel Sambuc unsigned char secret_a[MAX_ECDH_SIZE], secret_b[MAX_ECDH_SIZE];
627ebfedea0SLionel Sambuc int secret_size_a, secret_size_b;
628ebfedea0SLionel Sambuc int ecdh_checks = 0;
629ebfedea0SLionel Sambuc int secret_idx = 0;
630ebfedea0SLionel Sambuc long ecdh_c[EC_NUM][2];
631ebfedea0SLionel Sambuc # endif
632ebfedea0SLionel Sambuc
633ebfedea0SLionel Sambuc int rsa_doit[RSA_NUM];
634ebfedea0SLionel Sambuc int dsa_doit[DSA_NUM];
635ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
636ebfedea0SLionel Sambuc int ecdsa_doit[EC_NUM];
637ebfedea0SLionel Sambuc # endif
638ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
639ebfedea0SLionel Sambuc int ecdh_doit[EC_NUM];
640ebfedea0SLionel Sambuc # endif
641ebfedea0SLionel Sambuc int doit[ALGOR_NUM];
642ebfedea0SLionel Sambuc int pr_header = 0;
643ebfedea0SLionel Sambuc const EVP_CIPHER *evp_cipher = NULL;
644ebfedea0SLionel Sambuc const EVP_MD *evp_md = NULL;
645ebfedea0SLionel Sambuc int decrypt = 0;
646ebfedea0SLionel Sambuc # ifndef NO_FORK
647ebfedea0SLionel Sambuc int multi = 0;
648ebfedea0SLionel Sambuc # endif
649ebfedea0SLionel Sambuc
650ebfedea0SLionel Sambuc # ifndef TIMES
651ebfedea0SLionel Sambuc usertime = -1;
652ebfedea0SLionel Sambuc # endif
653ebfedea0SLionel Sambuc
654ebfedea0SLionel Sambuc apps_startup();
655ebfedea0SLionel Sambuc memset(results, 0, sizeof(results));
656ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
657ebfedea0SLionel Sambuc memset(dsa_key, 0, sizeof(dsa_key));
658ebfedea0SLionel Sambuc # endif
659ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
660*0a6a1f1dSLionel Sambuc for (i = 0; i < EC_NUM; i++)
661*0a6a1f1dSLionel Sambuc ecdsa[i] = NULL;
662ebfedea0SLionel Sambuc # endif
663ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
664*0a6a1f1dSLionel Sambuc for (i = 0; i < EC_NUM; i++) {
665ebfedea0SLionel Sambuc ecdh_a[i] = NULL;
666ebfedea0SLionel Sambuc ecdh_b[i] = NULL;
667ebfedea0SLionel Sambuc }
668ebfedea0SLionel Sambuc # endif
669ebfedea0SLionel Sambuc
670ebfedea0SLionel Sambuc if (bio_err == NULL)
671ebfedea0SLionel Sambuc if ((bio_err = BIO_new(BIO_s_file())) != NULL)
672ebfedea0SLionel Sambuc BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
673ebfedea0SLionel Sambuc
674ebfedea0SLionel Sambuc if (!load_config(bio_err, NULL))
675ebfedea0SLionel Sambuc goto end;
676ebfedea0SLionel Sambuc
677ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
678ebfedea0SLionel Sambuc memset(rsa_key, 0, sizeof(rsa_key));
679ebfedea0SLionel Sambuc for (i = 0; i < RSA_NUM; i++)
680ebfedea0SLionel Sambuc rsa_key[i] = NULL;
681ebfedea0SLionel Sambuc # endif
682ebfedea0SLionel Sambuc
683*0a6a1f1dSLionel Sambuc if ((buf = (unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL) {
684ebfedea0SLionel Sambuc BIO_printf(bio_err, "out of memory\n");
685ebfedea0SLionel Sambuc goto end;
686ebfedea0SLionel Sambuc }
687*0a6a1f1dSLionel Sambuc if ((buf2 = (unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL) {
688ebfedea0SLionel Sambuc BIO_printf(bio_err, "out of memory\n");
689ebfedea0SLionel Sambuc goto end;
690ebfedea0SLionel Sambuc }
691ebfedea0SLionel Sambuc
692ebfedea0SLionel Sambuc memset(c, 0, sizeof(c));
693ebfedea0SLionel Sambuc memset(DES_iv, 0, sizeof(DES_iv));
694ebfedea0SLionel Sambuc memset(iv, 0, sizeof(iv));
695ebfedea0SLionel Sambuc
696ebfedea0SLionel Sambuc for (i = 0; i < ALGOR_NUM; i++)
697ebfedea0SLionel Sambuc doit[i] = 0;
698ebfedea0SLionel Sambuc for (i = 0; i < RSA_NUM; i++)
699ebfedea0SLionel Sambuc rsa_doit[i] = 0;
700ebfedea0SLionel Sambuc for (i = 0; i < DSA_NUM; i++)
701ebfedea0SLionel Sambuc dsa_doit[i] = 0;
702ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
703ebfedea0SLionel Sambuc for (i = 0; i < EC_NUM; i++)
704ebfedea0SLionel Sambuc ecdsa_doit[i] = 0;
705ebfedea0SLionel Sambuc # endif
706ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
707ebfedea0SLionel Sambuc for (i = 0; i < EC_NUM; i++)
708ebfedea0SLionel Sambuc ecdh_doit[i] = 0;
709ebfedea0SLionel Sambuc # endif
710ebfedea0SLionel Sambuc
711ebfedea0SLionel Sambuc j = 0;
712ebfedea0SLionel Sambuc argc--;
713ebfedea0SLionel Sambuc argv++;
714*0a6a1f1dSLionel Sambuc while (argc) {
715*0a6a1f1dSLionel Sambuc if ((argc > 0) && (strcmp(*argv, "-elapsed") == 0)) {
716ebfedea0SLionel Sambuc usertime = 0;
717*0a6a1f1dSLionel Sambuc j--; /* Otherwise, -elapsed gets confused with an
718*0a6a1f1dSLionel Sambuc * algorithm. */
719*0a6a1f1dSLionel Sambuc } else if ((argc > 0) && (strcmp(*argv, "-evp") == 0)) {
720ebfedea0SLionel Sambuc argc--;
721ebfedea0SLionel Sambuc argv++;
722*0a6a1f1dSLionel Sambuc if (argc == 0) {
723ebfedea0SLionel Sambuc BIO_printf(bio_err, "no EVP given\n");
724ebfedea0SLionel Sambuc goto end;
725ebfedea0SLionel Sambuc }
726ebfedea0SLionel Sambuc evp_cipher = EVP_get_cipherbyname(*argv);
727*0a6a1f1dSLionel Sambuc if (!evp_cipher) {
728ebfedea0SLionel Sambuc evp_md = EVP_get_digestbyname(*argv);
729ebfedea0SLionel Sambuc }
730*0a6a1f1dSLionel Sambuc if (!evp_cipher && !evp_md) {
731*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, "%s is an unknown cipher or digest\n",
732*0a6a1f1dSLionel Sambuc *argv);
733ebfedea0SLionel Sambuc goto end;
734ebfedea0SLionel Sambuc }
735ebfedea0SLionel Sambuc doit[D_EVP] = 1;
736*0a6a1f1dSLionel Sambuc } else if (argc > 0 && !strcmp(*argv, "-decrypt")) {
737ebfedea0SLionel Sambuc decrypt = 1;
738*0a6a1f1dSLionel Sambuc j--; /* Otherwise, -elapsed gets confused with an
739*0a6a1f1dSLionel Sambuc * algorithm. */
740ebfedea0SLionel Sambuc }
741ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ENGINE
742*0a6a1f1dSLionel Sambuc else if ((argc > 0) && (strcmp(*argv, "-engine") == 0)) {
743ebfedea0SLionel Sambuc argc--;
744ebfedea0SLionel Sambuc argv++;
745*0a6a1f1dSLionel Sambuc if (argc == 0) {
746ebfedea0SLionel Sambuc BIO_printf(bio_err, "no engine given\n");
747ebfedea0SLionel Sambuc goto end;
748ebfedea0SLionel Sambuc }
749ebfedea0SLionel Sambuc setup_engine(bio_err, *argv, 0);
750*0a6a1f1dSLionel Sambuc /*
751*0a6a1f1dSLionel Sambuc * j will be increased again further down. We just don't want
752*0a6a1f1dSLionel Sambuc * speed to confuse an engine with an algorithm, especially when
753*0a6a1f1dSLionel Sambuc * none is given (which means all of them should be run)
754*0a6a1f1dSLionel Sambuc */
755ebfedea0SLionel Sambuc j--;
756ebfedea0SLionel Sambuc }
757ebfedea0SLionel Sambuc # endif
758ebfedea0SLionel Sambuc # ifndef NO_FORK
759*0a6a1f1dSLionel Sambuc else if ((argc > 0) && (strcmp(*argv, "-multi") == 0)) {
760ebfedea0SLionel Sambuc argc--;
761ebfedea0SLionel Sambuc argv++;
762*0a6a1f1dSLionel Sambuc if (argc == 0) {
763ebfedea0SLionel Sambuc BIO_printf(bio_err, "no multi count given\n");
764ebfedea0SLionel Sambuc goto end;
765ebfedea0SLionel Sambuc }
766ebfedea0SLionel Sambuc multi = atoi(argv[0]);
767*0a6a1f1dSLionel Sambuc if (multi <= 0) {
768ebfedea0SLionel Sambuc BIO_printf(bio_err, "bad multi count\n");
769ebfedea0SLionel Sambuc goto end;
770ebfedea0SLionel Sambuc }
771*0a6a1f1dSLionel Sambuc j--; /* Otherwise, -mr gets confused with an
772*0a6a1f1dSLionel Sambuc * algorithm. */
773ebfedea0SLionel Sambuc }
774ebfedea0SLionel Sambuc # endif
775*0a6a1f1dSLionel Sambuc else if (argc > 0 && !strcmp(*argv, "-mr")) {
776ebfedea0SLionel Sambuc mr = 1;
777*0a6a1f1dSLionel Sambuc j--; /* Otherwise, -mr gets confused with an
778*0a6a1f1dSLionel Sambuc * algorithm. */
779*0a6a1f1dSLionel Sambuc } else
780ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD2
781*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "md2") == 0)
782*0a6a1f1dSLionel Sambuc doit[D_MD2] = 1;
783ebfedea0SLionel Sambuc else
784ebfedea0SLionel Sambuc # endif
785ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MDC2
786*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "mdc2") == 0)
787*0a6a1f1dSLionel Sambuc doit[D_MDC2] = 1;
788ebfedea0SLionel Sambuc else
789ebfedea0SLionel Sambuc # endif
790ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD4
791*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "md4") == 0)
792*0a6a1f1dSLionel Sambuc doit[D_MD4] = 1;
793ebfedea0SLionel Sambuc else
794ebfedea0SLionel Sambuc # endif
795ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD5
796*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "md5") == 0)
797*0a6a1f1dSLionel Sambuc doit[D_MD5] = 1;
798ebfedea0SLionel Sambuc else
799ebfedea0SLionel Sambuc # endif
800ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD5
801*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "hmac") == 0)
802*0a6a1f1dSLionel Sambuc doit[D_HMAC] = 1;
803ebfedea0SLionel Sambuc else
804ebfedea0SLionel Sambuc # endif
805ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA
806*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "sha1") == 0)
807*0a6a1f1dSLionel Sambuc doit[D_SHA1] = 1;
808*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "sha") == 0)
809*0a6a1f1dSLionel Sambuc doit[D_SHA1] = 1, doit[D_SHA256] = 1, doit[D_SHA512] = 1;
810ebfedea0SLionel Sambuc else
811ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA256
812*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "sha256") == 0)
813*0a6a1f1dSLionel Sambuc doit[D_SHA256] = 1;
814ebfedea0SLionel Sambuc else
815ebfedea0SLionel Sambuc # endif
816ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA512
817*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "sha512") == 0)
818*0a6a1f1dSLionel Sambuc doit[D_SHA512] = 1;
819ebfedea0SLionel Sambuc else
820ebfedea0SLionel Sambuc # endif
821ebfedea0SLionel Sambuc # endif
822ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_WHIRLPOOL
823*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "whirlpool") == 0)
824*0a6a1f1dSLionel Sambuc doit[D_WHIRLPOOL] = 1;
825ebfedea0SLionel Sambuc else
826ebfedea0SLionel Sambuc # endif
827ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RIPEMD
828*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "ripemd") == 0)
829*0a6a1f1dSLionel Sambuc doit[D_RMD160] = 1;
830*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "rmd160") == 0)
831*0a6a1f1dSLionel Sambuc doit[D_RMD160] = 1;
832*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ripemd160") == 0)
833*0a6a1f1dSLionel Sambuc doit[D_RMD160] = 1;
834ebfedea0SLionel Sambuc else
835ebfedea0SLionel Sambuc # endif
836ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC4
837*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "rc4") == 0)
838*0a6a1f1dSLionel Sambuc doit[D_RC4] = 1;
839ebfedea0SLionel Sambuc else
840ebfedea0SLionel Sambuc # endif
841ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DES
842*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "des-cbc") == 0)
843*0a6a1f1dSLionel Sambuc doit[D_CBC_DES] = 1;
844*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "des-ede3") == 0)
845*0a6a1f1dSLionel Sambuc doit[D_EDE3_DES] = 1;
846ebfedea0SLionel Sambuc else
847ebfedea0SLionel Sambuc # endif
848ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_AES
849*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "aes-128-cbc") == 0)
850*0a6a1f1dSLionel Sambuc doit[D_CBC_128_AES] = 1;
851*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "aes-192-cbc") == 0)
852*0a6a1f1dSLionel Sambuc doit[D_CBC_192_AES] = 1;
853*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "aes-256-cbc") == 0)
854*0a6a1f1dSLionel Sambuc doit[D_CBC_256_AES] = 1;
855*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "aes-128-ige") == 0)
856*0a6a1f1dSLionel Sambuc doit[D_IGE_128_AES] = 1;
857*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "aes-192-ige") == 0)
858*0a6a1f1dSLionel Sambuc doit[D_IGE_192_AES] = 1;
859*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "aes-256-ige") == 0)
860*0a6a1f1dSLionel Sambuc doit[D_IGE_256_AES] = 1;
861ebfedea0SLionel Sambuc else
862ebfedea0SLionel Sambuc # endif
863ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAMELLIA
864*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "camellia-128-cbc") == 0)
865*0a6a1f1dSLionel Sambuc doit[D_CBC_128_CML] = 1;
866*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "camellia-192-cbc") == 0)
867*0a6a1f1dSLionel Sambuc doit[D_CBC_192_CML] = 1;
868*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "camellia-256-cbc") == 0)
869*0a6a1f1dSLionel Sambuc doit[D_CBC_256_CML] = 1;
870ebfedea0SLionel Sambuc else
871ebfedea0SLionel Sambuc # endif
872ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
873ebfedea0SLionel Sambuc # if 0 /* was: #ifdef RSAref */
874*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "rsaref") == 0) {
875ebfedea0SLionel Sambuc RSA_set_default_openssl_method(RSA_PKCS1_RSAref());
876ebfedea0SLionel Sambuc j--;
877*0a6a1f1dSLionel Sambuc } else
878ebfedea0SLionel Sambuc # endif
879ebfedea0SLionel Sambuc # ifndef RSA_NULL
880*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "openssl") == 0) {
881ebfedea0SLionel Sambuc RSA_set_default_method(RSA_PKCS1_SSLeay());
882ebfedea0SLionel Sambuc j--;
883*0a6a1f1dSLionel Sambuc } else
884ebfedea0SLionel Sambuc # endif
885ebfedea0SLionel Sambuc # endif /* !OPENSSL_NO_RSA */
886*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "dsa512") == 0)
887*0a6a1f1dSLionel Sambuc dsa_doit[R_DSA_512] = 2;
888*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "dsa1024") == 0)
889*0a6a1f1dSLionel Sambuc dsa_doit[R_DSA_1024] = 2;
890*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "dsa2048") == 0)
891*0a6a1f1dSLionel Sambuc dsa_doit[R_DSA_2048] = 2;
892*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "rsa512") == 0)
893*0a6a1f1dSLionel Sambuc rsa_doit[R_RSA_512] = 2;
894*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "rsa1024") == 0)
895*0a6a1f1dSLionel Sambuc rsa_doit[R_RSA_1024] = 2;
896*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "rsa2048") == 0)
897*0a6a1f1dSLionel Sambuc rsa_doit[R_RSA_2048] = 2;
898*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "rsa4096") == 0)
899*0a6a1f1dSLionel Sambuc rsa_doit[R_RSA_4096] = 2;
900ebfedea0SLionel Sambuc else
901ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC2
902*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "rc2-cbc") == 0)
903*0a6a1f1dSLionel Sambuc doit[D_CBC_RC2] = 1;
904*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "rc2") == 0)
905*0a6a1f1dSLionel Sambuc doit[D_CBC_RC2] = 1;
906ebfedea0SLionel Sambuc else
907ebfedea0SLionel Sambuc # endif
908ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC5
909*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "rc5-cbc") == 0)
910*0a6a1f1dSLionel Sambuc doit[D_CBC_RC5] = 1;
911*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "rc5") == 0)
912*0a6a1f1dSLionel Sambuc doit[D_CBC_RC5] = 1;
913ebfedea0SLionel Sambuc else
914ebfedea0SLionel Sambuc # endif
915ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_IDEA
916*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "idea-cbc") == 0)
917*0a6a1f1dSLionel Sambuc doit[D_CBC_IDEA] = 1;
918*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "idea") == 0)
919*0a6a1f1dSLionel Sambuc doit[D_CBC_IDEA] = 1;
920ebfedea0SLionel Sambuc else
921ebfedea0SLionel Sambuc # endif
922ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SEED
923*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "seed-cbc") == 0)
924*0a6a1f1dSLionel Sambuc doit[D_CBC_SEED] = 1;
925*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "seed") == 0)
926*0a6a1f1dSLionel Sambuc doit[D_CBC_SEED] = 1;
927ebfedea0SLionel Sambuc else
928ebfedea0SLionel Sambuc # endif
929ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_BF
930*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "bf-cbc") == 0)
931*0a6a1f1dSLionel Sambuc doit[D_CBC_BF] = 1;
932*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "blowfish") == 0)
933*0a6a1f1dSLionel Sambuc doit[D_CBC_BF] = 1;
934*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "bf") == 0)
935*0a6a1f1dSLionel Sambuc doit[D_CBC_BF] = 1;
936ebfedea0SLionel Sambuc else
937ebfedea0SLionel Sambuc # endif
938ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAST
939*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "cast-cbc") == 0)
940*0a6a1f1dSLionel Sambuc doit[D_CBC_CAST] = 1;
941*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "cast") == 0)
942*0a6a1f1dSLionel Sambuc doit[D_CBC_CAST] = 1;
943*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "cast5") == 0)
944*0a6a1f1dSLionel Sambuc doit[D_CBC_CAST] = 1;
945ebfedea0SLionel Sambuc else
946ebfedea0SLionel Sambuc # endif
947ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DES
948*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "des") == 0) {
949ebfedea0SLionel Sambuc doit[D_CBC_DES] = 1;
950ebfedea0SLionel Sambuc doit[D_EDE3_DES] = 1;
951*0a6a1f1dSLionel Sambuc } else
952ebfedea0SLionel Sambuc # endif
953ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_AES
954*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "aes") == 0) {
955ebfedea0SLionel Sambuc doit[D_CBC_128_AES] = 1;
956ebfedea0SLionel Sambuc doit[D_CBC_192_AES] = 1;
957ebfedea0SLionel Sambuc doit[D_CBC_256_AES] = 1;
958*0a6a1f1dSLionel Sambuc } else if (strcmp(*argv, "ghash") == 0) {
959ebfedea0SLionel Sambuc doit[D_GHASH] = 1;
960*0a6a1f1dSLionel Sambuc } else
961ebfedea0SLionel Sambuc # endif
962ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAMELLIA
963*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "camellia") == 0) {
964ebfedea0SLionel Sambuc doit[D_CBC_128_CML] = 1;
965ebfedea0SLionel Sambuc doit[D_CBC_192_CML] = 1;
966ebfedea0SLionel Sambuc doit[D_CBC_256_CML] = 1;
967*0a6a1f1dSLionel Sambuc } else
968ebfedea0SLionel Sambuc # endif
969ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
970*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "rsa") == 0) {
971ebfedea0SLionel Sambuc rsa_doit[R_RSA_512] = 1;
972ebfedea0SLionel Sambuc rsa_doit[R_RSA_1024] = 1;
973ebfedea0SLionel Sambuc rsa_doit[R_RSA_2048] = 1;
974ebfedea0SLionel Sambuc rsa_doit[R_RSA_4096] = 1;
975*0a6a1f1dSLionel Sambuc } else
976ebfedea0SLionel Sambuc # endif
977ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
978*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "dsa") == 0) {
979ebfedea0SLionel Sambuc dsa_doit[R_DSA_512] = 1;
980ebfedea0SLionel Sambuc dsa_doit[R_DSA_1024] = 1;
981ebfedea0SLionel Sambuc dsa_doit[R_DSA_2048] = 1;
982*0a6a1f1dSLionel Sambuc } else
983ebfedea0SLionel Sambuc # endif
984ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
985*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "ecdsap160") == 0)
986*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_P160] = 2;
987*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsap192") == 0)
988*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_P192] = 2;
989*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsap224") == 0)
990*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_P224] = 2;
991*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsap256") == 0)
992*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_P256] = 2;
993*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsap384") == 0)
994*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_P384] = 2;
995*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsap521") == 0)
996*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_P521] = 2;
997*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsak163") == 0)
998*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_K163] = 2;
999*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsak233") == 0)
1000*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_K233] = 2;
1001*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsak283") == 0)
1002*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_K283] = 2;
1003*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsak409") == 0)
1004*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_K409] = 2;
1005*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsak571") == 0)
1006*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_K571] = 2;
1007*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsab163") == 0)
1008*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_B163] = 2;
1009*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsab233") == 0)
1010*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_B233] = 2;
1011*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsab283") == 0)
1012*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_B283] = 2;
1013*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsab409") == 0)
1014*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_B409] = 2;
1015*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsab571") == 0)
1016*0a6a1f1dSLionel Sambuc ecdsa_doit[R_EC_B571] = 2;
1017*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdsa") == 0) {
1018ebfedea0SLionel Sambuc for (i = 0; i < EC_NUM; i++)
1019ebfedea0SLionel Sambuc ecdsa_doit[i] = 1;
1020*0a6a1f1dSLionel Sambuc } else
1021ebfedea0SLionel Sambuc # endif
1022ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
1023*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "ecdhp160") == 0)
1024*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_P160] = 2;
1025*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhp192") == 0)
1026*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_P192] = 2;
1027*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhp224") == 0)
1028*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_P224] = 2;
1029*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhp256") == 0)
1030*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_P256] = 2;
1031*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhp384") == 0)
1032*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_P384] = 2;
1033*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhp521") == 0)
1034*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_P521] = 2;
1035*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhk163") == 0)
1036*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_K163] = 2;
1037*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhk233") == 0)
1038*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_K233] = 2;
1039*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhk283") == 0)
1040*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_K283] = 2;
1041*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhk409") == 0)
1042*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_K409] = 2;
1043*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhk571") == 0)
1044*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_K571] = 2;
1045*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhb163") == 0)
1046*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_B163] = 2;
1047*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhb233") == 0)
1048*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_B233] = 2;
1049*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhb283") == 0)
1050*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_B283] = 2;
1051*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhb409") == 0)
1052*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_B409] = 2;
1053*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdhb571") == 0)
1054*0a6a1f1dSLionel Sambuc ecdh_doit[R_EC_B571] = 2;
1055*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "ecdh") == 0) {
1056ebfedea0SLionel Sambuc for (i = 0; i < EC_NUM; i++)
1057ebfedea0SLionel Sambuc ecdh_doit[i] = 1;
1058*0a6a1f1dSLionel Sambuc } else
1059ebfedea0SLionel Sambuc # endif
1060ebfedea0SLionel Sambuc {
1061ebfedea0SLionel Sambuc BIO_printf(bio_err, "Error: bad option or value\n");
1062ebfedea0SLionel Sambuc BIO_printf(bio_err, "\n");
1063ebfedea0SLionel Sambuc BIO_printf(bio_err, "Available values:\n");
1064ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD2
1065ebfedea0SLionel Sambuc BIO_printf(bio_err, "md2 ");
1066ebfedea0SLionel Sambuc # endif
1067ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MDC2
1068ebfedea0SLionel Sambuc BIO_printf(bio_err, "mdc2 ");
1069ebfedea0SLionel Sambuc # endif
1070ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD4
1071ebfedea0SLionel Sambuc BIO_printf(bio_err, "md4 ");
1072ebfedea0SLionel Sambuc # endif
1073ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD5
1074ebfedea0SLionel Sambuc BIO_printf(bio_err, "md5 ");
1075ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_HMAC
1076ebfedea0SLionel Sambuc BIO_printf(bio_err, "hmac ");
1077ebfedea0SLionel Sambuc # endif
1078ebfedea0SLionel Sambuc # endif
1079ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA1
1080ebfedea0SLionel Sambuc BIO_printf(bio_err, "sha1 ");
1081ebfedea0SLionel Sambuc # endif
1082ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA256
1083ebfedea0SLionel Sambuc BIO_printf(bio_err, "sha256 ");
1084ebfedea0SLionel Sambuc # endif
1085ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA512
1086ebfedea0SLionel Sambuc BIO_printf(bio_err, "sha512 ");
1087ebfedea0SLionel Sambuc # endif
1088ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_WHIRLPOOL
1089ebfedea0SLionel Sambuc BIO_printf(bio_err, "whirlpool");
1090ebfedea0SLionel Sambuc # endif
1091ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RIPEMD160
1092ebfedea0SLionel Sambuc BIO_printf(bio_err, "rmd160");
1093ebfedea0SLionel Sambuc # endif
1094ebfedea0SLionel Sambuc # if !defined(OPENSSL_NO_MD2) || !defined(OPENSSL_NO_MDC2) || \
1095ebfedea0SLionel Sambuc !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \
1096ebfedea0SLionel Sambuc !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160) || \
1097ebfedea0SLionel Sambuc !defined(OPENSSL_NO_WHIRLPOOL)
1098ebfedea0SLionel Sambuc BIO_printf(bio_err, "\n");
1099ebfedea0SLionel Sambuc # endif
1100ebfedea0SLionel Sambuc
1101ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_IDEA
1102ebfedea0SLionel Sambuc BIO_printf(bio_err, "idea-cbc ");
1103ebfedea0SLionel Sambuc # endif
1104ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SEED
1105ebfedea0SLionel Sambuc BIO_printf(bio_err, "seed-cbc ");
1106ebfedea0SLionel Sambuc # endif
1107ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC2
1108ebfedea0SLionel Sambuc BIO_printf(bio_err, "rc2-cbc ");
1109ebfedea0SLionel Sambuc # endif
1110ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC5
1111ebfedea0SLionel Sambuc BIO_printf(bio_err, "rc5-cbc ");
1112ebfedea0SLionel Sambuc # endif
1113ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_BF
1114ebfedea0SLionel Sambuc BIO_printf(bio_err, "bf-cbc");
1115ebfedea0SLionel Sambuc # endif
1116ebfedea0SLionel Sambuc # if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_SEED) || !defined(OPENSSL_NO_RC2) || \
1117ebfedea0SLionel Sambuc !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_RC5)
1118ebfedea0SLionel Sambuc BIO_printf(bio_err, "\n");
1119ebfedea0SLionel Sambuc # endif
1120ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DES
1121ebfedea0SLionel Sambuc BIO_printf(bio_err, "des-cbc des-ede3 ");
1122ebfedea0SLionel Sambuc # endif
1123ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_AES
1124ebfedea0SLionel Sambuc BIO_printf(bio_err, "aes-128-cbc aes-192-cbc aes-256-cbc ");
1125ebfedea0SLionel Sambuc BIO_printf(bio_err, "aes-128-ige aes-192-ige aes-256-ige ");
1126ebfedea0SLionel Sambuc # endif
1127ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAMELLIA
1128ebfedea0SLionel Sambuc BIO_printf(bio_err, "\n");
1129*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
1130*0a6a1f1dSLionel Sambuc "camellia-128-cbc camellia-192-cbc camellia-256-cbc ");
1131ebfedea0SLionel Sambuc # endif
1132ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC4
1133ebfedea0SLionel Sambuc BIO_printf(bio_err, "rc4");
1134ebfedea0SLionel Sambuc # endif
1135ebfedea0SLionel Sambuc BIO_printf(bio_err, "\n");
1136ebfedea0SLionel Sambuc
1137ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
1138ebfedea0SLionel Sambuc BIO_printf(bio_err, "rsa512 rsa1024 rsa2048 rsa4096\n");
1139ebfedea0SLionel Sambuc # endif
1140ebfedea0SLionel Sambuc
1141ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
1142ebfedea0SLionel Sambuc BIO_printf(bio_err, "dsa512 dsa1024 dsa2048\n");
1143ebfedea0SLionel Sambuc # endif
1144ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
1145*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, "ecdsap160 ecdsap192 ecdsap224 "
1146*0a6a1f1dSLionel Sambuc "ecdsap256 ecdsap384 ecdsap521\n");
1147*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
1148*0a6a1f1dSLionel Sambuc "ecdsak163 ecdsak233 ecdsak283 ecdsak409 ecdsak571\n");
1149*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
1150*0a6a1f1dSLionel Sambuc "ecdsab163 ecdsab233 ecdsab283 ecdsab409 ecdsab571\n");
1151ebfedea0SLionel Sambuc BIO_printf(bio_err, "ecdsa\n");
1152ebfedea0SLionel Sambuc # endif
1153ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
1154*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, "ecdhp160 ecdhp192 ecdhp224 "
1155*0a6a1f1dSLionel Sambuc "ecdhp256 ecdhp384 ecdhp521\n");
1156*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
1157*0a6a1f1dSLionel Sambuc "ecdhk163 ecdhk233 ecdhk283 ecdhk409 ecdhk571\n");
1158*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
1159*0a6a1f1dSLionel Sambuc "ecdhb163 ecdhb233 ecdhb283 ecdhb409 ecdhb571\n");
1160ebfedea0SLionel Sambuc BIO_printf(bio_err, "ecdh\n");
1161ebfedea0SLionel Sambuc # endif
1162ebfedea0SLionel Sambuc
1163ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_IDEA
1164ebfedea0SLionel Sambuc BIO_printf(bio_err, "idea ");
1165ebfedea0SLionel Sambuc # endif
1166ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SEED
1167ebfedea0SLionel Sambuc BIO_printf(bio_err, "seed ");
1168ebfedea0SLionel Sambuc # endif
1169ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC2
1170ebfedea0SLionel Sambuc BIO_printf(bio_err, "rc2 ");
1171ebfedea0SLionel Sambuc # endif
1172ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DES
1173ebfedea0SLionel Sambuc BIO_printf(bio_err, "des ");
1174ebfedea0SLionel Sambuc # endif
1175ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_AES
1176ebfedea0SLionel Sambuc BIO_printf(bio_err, "aes ");
1177ebfedea0SLionel Sambuc # endif
1178ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAMELLIA
1179ebfedea0SLionel Sambuc BIO_printf(bio_err, "camellia ");
1180ebfedea0SLionel Sambuc # endif
1181ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
1182ebfedea0SLionel Sambuc BIO_printf(bio_err, "rsa ");
1183ebfedea0SLionel Sambuc # endif
1184ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_BF
1185ebfedea0SLionel Sambuc BIO_printf(bio_err, "blowfish");
1186ebfedea0SLionel Sambuc # endif
1187ebfedea0SLionel Sambuc # if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_SEED) || \
1188ebfedea0SLionel Sambuc !defined(OPENSSL_NO_RC2) || !defined(OPENSSL_NO_DES) || \
1189ebfedea0SLionel Sambuc !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_BF) || \
1190ebfedea0SLionel Sambuc !defined(OPENSSL_NO_AES) || !defined(OPENSSL_NO_CAMELLIA)
1191ebfedea0SLionel Sambuc BIO_printf(bio_err, "\n");
1192ebfedea0SLionel Sambuc # endif
1193ebfedea0SLionel Sambuc
1194ebfedea0SLionel Sambuc BIO_printf(bio_err, "\n");
1195ebfedea0SLionel Sambuc BIO_printf(bio_err, "Available options:\n");
1196ebfedea0SLionel Sambuc # if defined(TIMES) || defined(USE_TOD)
1197*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, "-elapsed "
1198*0a6a1f1dSLionel Sambuc "measure time in real time instead of CPU user time.\n");
1199ebfedea0SLionel Sambuc # endif
1200ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ENGINE
1201*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
1202*0a6a1f1dSLionel Sambuc "-engine e "
1203*0a6a1f1dSLionel Sambuc "use engine e, possibly a hardware device.\n");
1204ebfedea0SLionel Sambuc # endif
1205*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, "-evp e " "use EVP e.\n");
1206*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
1207*0a6a1f1dSLionel Sambuc "-decrypt "
1208*0a6a1f1dSLionel Sambuc "time decryption instead of encryption (only EVP).\n");
1209*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
1210*0a6a1f1dSLionel Sambuc "-mr "
1211*0a6a1f1dSLionel Sambuc "produce machine readable output.\n");
1212ebfedea0SLionel Sambuc # ifndef NO_FORK
1213*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
1214*0a6a1f1dSLionel Sambuc "-multi n " "run n benchmarks in parallel.\n");
1215ebfedea0SLionel Sambuc # endif
1216ebfedea0SLionel Sambuc goto end;
1217ebfedea0SLionel Sambuc }
1218ebfedea0SLionel Sambuc argc--;
1219ebfedea0SLionel Sambuc argv++;
1220ebfedea0SLionel Sambuc j++;
1221ebfedea0SLionel Sambuc }
1222ebfedea0SLionel Sambuc
1223ebfedea0SLionel Sambuc # ifndef NO_FORK
1224ebfedea0SLionel Sambuc if (multi && do_multi(multi))
1225ebfedea0SLionel Sambuc goto show_res;
1226ebfedea0SLionel Sambuc # endif
1227ebfedea0SLionel Sambuc
1228*0a6a1f1dSLionel Sambuc if (j == 0) {
1229*0a6a1f1dSLionel Sambuc for (i = 0; i < ALGOR_NUM; i++) {
1230ebfedea0SLionel Sambuc if (i != D_EVP)
1231ebfedea0SLionel Sambuc doit[i] = 1;
1232ebfedea0SLionel Sambuc }
1233ebfedea0SLionel Sambuc for (i = 0; i < RSA_NUM; i++)
1234ebfedea0SLionel Sambuc rsa_doit[i] = 1;
1235ebfedea0SLionel Sambuc for (i = 0; i < DSA_NUM; i++)
1236ebfedea0SLionel Sambuc dsa_doit[i] = 1;
1237ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
1238ebfedea0SLionel Sambuc for (i = 0; i < EC_NUM; i++)
1239ebfedea0SLionel Sambuc ecdsa_doit[i] = 1;
1240ebfedea0SLionel Sambuc # endif
1241ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
1242ebfedea0SLionel Sambuc for (i = 0; i < EC_NUM; i++)
1243ebfedea0SLionel Sambuc ecdh_doit[i] = 1;
1244ebfedea0SLionel Sambuc # endif
1245ebfedea0SLionel Sambuc }
1246ebfedea0SLionel Sambuc for (i = 0; i < ALGOR_NUM; i++)
1247*0a6a1f1dSLionel Sambuc if (doit[i])
1248*0a6a1f1dSLionel Sambuc pr_header++;
1249ebfedea0SLionel Sambuc
1250ebfedea0SLionel Sambuc if (usertime == 0 && !mr)
1251*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
1252*0a6a1f1dSLionel Sambuc "You have chosen to measure elapsed time "
1253*0a6a1f1dSLionel Sambuc "instead of user CPU time.\n");
1254ebfedea0SLionel Sambuc
1255ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
1256*0a6a1f1dSLionel Sambuc for (i = 0; i < RSA_NUM; i++) {
1257ebfedea0SLionel Sambuc const unsigned char *p;
1258ebfedea0SLionel Sambuc
1259ebfedea0SLionel Sambuc p = rsa_data[i];
1260ebfedea0SLionel Sambuc rsa_key[i] = d2i_RSAPrivateKey(NULL, &p, rsa_data_length[i]);
1261*0a6a1f1dSLionel Sambuc if (rsa_key[i] == NULL) {
1262*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, "internal error loading RSA key number %d\n",
1263*0a6a1f1dSLionel Sambuc i);
1264ebfedea0SLionel Sambuc goto end;
1265ebfedea0SLionel Sambuc }
1266ebfedea0SLionel Sambuc # if 0
1267*0a6a1f1dSLionel Sambuc else {
1268*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
1269*0a6a1f1dSLionel Sambuc mr ? "+RK:%d:"
1270ebfedea0SLionel Sambuc : "Loaded RSA key, %d bit modulus and e= 0x",
1271ebfedea0SLionel Sambuc BN_num_bits(rsa_key[i]->n));
1272ebfedea0SLionel Sambuc BN_print(bio_err, rsa_key[i]->e);
1273ebfedea0SLionel Sambuc BIO_printf(bio_err, "\n");
1274ebfedea0SLionel Sambuc }
1275ebfedea0SLionel Sambuc # endif
1276ebfedea0SLionel Sambuc }
1277ebfedea0SLionel Sambuc # endif
1278ebfedea0SLionel Sambuc
1279ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
1280ebfedea0SLionel Sambuc dsa_key[0] = get_dsa512();
1281ebfedea0SLionel Sambuc dsa_key[1] = get_dsa1024();
1282ebfedea0SLionel Sambuc dsa_key[2] = get_dsa2048();
1283ebfedea0SLionel Sambuc # endif
1284ebfedea0SLionel Sambuc
1285ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DES
1286ebfedea0SLionel Sambuc DES_set_key_unchecked(&key, &sch);
1287ebfedea0SLionel Sambuc DES_set_key_unchecked(&key2, &sch2);
1288ebfedea0SLionel Sambuc DES_set_key_unchecked(&key3, &sch3);
1289ebfedea0SLionel Sambuc # endif
1290ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_AES
1291ebfedea0SLionel Sambuc AES_set_encrypt_key(key16, 128, &aes_ks1);
1292ebfedea0SLionel Sambuc AES_set_encrypt_key(key24, 192, &aes_ks2);
1293ebfedea0SLionel Sambuc AES_set_encrypt_key(key32, 256, &aes_ks3);
1294ebfedea0SLionel Sambuc # endif
1295ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAMELLIA
1296ebfedea0SLionel Sambuc Camellia_set_key(key16, 128, &camellia_ks1);
1297ebfedea0SLionel Sambuc Camellia_set_key(ckey24, 192, &camellia_ks2);
1298ebfedea0SLionel Sambuc Camellia_set_key(ckey32, 256, &camellia_ks3);
1299ebfedea0SLionel Sambuc # endif
1300ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_IDEA
1301ebfedea0SLionel Sambuc idea_set_encrypt_key(key16, &idea_ks);
1302ebfedea0SLionel Sambuc # endif
1303ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SEED
1304ebfedea0SLionel Sambuc SEED_set_key(key16, &seed_ks);
1305ebfedea0SLionel Sambuc # endif
1306ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC4
1307ebfedea0SLionel Sambuc RC4_set_key(&rc4_ks, 16, key16);
1308ebfedea0SLionel Sambuc # endif
1309ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC2
1310ebfedea0SLionel Sambuc RC2_set_key(&rc2_ks, 16, key16, 128);
1311ebfedea0SLionel Sambuc # endif
1312ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC5
1313ebfedea0SLionel Sambuc RC5_32_set_key(&rc5_ks, 16, key16, 12);
1314ebfedea0SLionel Sambuc # endif
1315ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_BF
1316ebfedea0SLionel Sambuc BF_set_key(&bf_ks, 16, key16);
1317ebfedea0SLionel Sambuc # endif
1318ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAST
1319ebfedea0SLionel Sambuc CAST_set_key(&cast_ks, 16, key16);
1320ebfedea0SLionel Sambuc # endif
1321ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
1322ebfedea0SLionel Sambuc memset(rsa_c, 0, sizeof(rsa_c));
1323ebfedea0SLionel Sambuc # endif
1324ebfedea0SLionel Sambuc # ifndef SIGALRM
1325ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DES
1326ebfedea0SLionel Sambuc BIO_printf(bio_err, "First we calculate the approximate speed ...\n");
1327ebfedea0SLionel Sambuc count = 10;
1328ebfedea0SLionel Sambuc do {
1329ebfedea0SLionel Sambuc long it;
1330ebfedea0SLionel Sambuc count *= 2;
1331ebfedea0SLionel Sambuc Time_F(START);
1332ebfedea0SLionel Sambuc for (it = count; it; it--)
1333ebfedea0SLionel Sambuc DES_ecb_encrypt((DES_cblock *)buf,
1334*0a6a1f1dSLionel Sambuc (DES_cblock *)buf, &sch, DES_ENCRYPT);
1335ebfedea0SLionel Sambuc d = Time_F(STOP);
1336ebfedea0SLionel Sambuc } while (d < 3);
1337ebfedea0SLionel Sambuc save_count = count;
1338ebfedea0SLionel Sambuc c[D_MD2][0] = count / 10;
1339ebfedea0SLionel Sambuc c[D_MDC2][0] = count / 10;
1340ebfedea0SLionel Sambuc c[D_MD4][0] = count;
1341ebfedea0SLionel Sambuc c[D_MD5][0] = count;
1342ebfedea0SLionel Sambuc c[D_HMAC][0] = count;
1343ebfedea0SLionel Sambuc c[D_SHA1][0] = count;
1344ebfedea0SLionel Sambuc c[D_RMD160][0] = count;
1345ebfedea0SLionel Sambuc c[D_RC4][0] = count * 5;
1346ebfedea0SLionel Sambuc c[D_CBC_DES][0] = count;
1347ebfedea0SLionel Sambuc c[D_EDE3_DES][0] = count / 3;
1348ebfedea0SLionel Sambuc c[D_CBC_IDEA][0] = count;
1349ebfedea0SLionel Sambuc c[D_CBC_SEED][0] = count;
1350ebfedea0SLionel Sambuc c[D_CBC_RC2][0] = count;
1351ebfedea0SLionel Sambuc c[D_CBC_RC5][0] = count;
1352ebfedea0SLionel Sambuc c[D_CBC_BF][0] = count;
1353ebfedea0SLionel Sambuc c[D_CBC_CAST][0] = count;
1354ebfedea0SLionel Sambuc c[D_CBC_128_AES][0] = count;
1355ebfedea0SLionel Sambuc c[D_CBC_192_AES][0] = count;
1356ebfedea0SLionel Sambuc c[D_CBC_256_AES][0] = count;
1357ebfedea0SLionel Sambuc c[D_CBC_128_CML][0] = count;
1358ebfedea0SLionel Sambuc c[D_CBC_192_CML][0] = count;
1359ebfedea0SLionel Sambuc c[D_CBC_256_CML][0] = count;
1360ebfedea0SLionel Sambuc c[D_SHA256][0] = count;
1361ebfedea0SLionel Sambuc c[D_SHA512][0] = count;
1362ebfedea0SLionel Sambuc c[D_WHIRLPOOL][0] = count;
1363ebfedea0SLionel Sambuc c[D_IGE_128_AES][0] = count;
1364ebfedea0SLionel Sambuc c[D_IGE_192_AES][0] = count;
1365ebfedea0SLionel Sambuc c[D_IGE_256_AES][0] = count;
1366ebfedea0SLionel Sambuc c[D_GHASH][0] = count;
1367ebfedea0SLionel Sambuc
1368*0a6a1f1dSLionel Sambuc for (i = 1; i < SIZE_NUM; i++) {
1369ebfedea0SLionel Sambuc c[D_MD2][i] = c[D_MD2][0] * 4 * lengths[0] / lengths[i];
1370ebfedea0SLionel Sambuc c[D_MDC2][i] = c[D_MDC2][0] * 4 * lengths[0] / lengths[i];
1371ebfedea0SLionel Sambuc c[D_MD4][i] = c[D_MD4][0] * 4 * lengths[0] / lengths[i];
1372ebfedea0SLionel Sambuc c[D_MD5][i] = c[D_MD5][0] * 4 * lengths[0] / lengths[i];
1373ebfedea0SLionel Sambuc c[D_HMAC][i] = c[D_HMAC][0] * 4 * lengths[0] / lengths[i];
1374ebfedea0SLionel Sambuc c[D_SHA1][i] = c[D_SHA1][0] * 4 * lengths[0] / lengths[i];
1375ebfedea0SLionel Sambuc c[D_RMD160][i] = c[D_RMD160][0] * 4 * lengths[0] / lengths[i];
1376ebfedea0SLionel Sambuc c[D_SHA256][i] = c[D_SHA256][0] * 4 * lengths[0] / lengths[i];
1377ebfedea0SLionel Sambuc c[D_SHA512][i] = c[D_SHA512][0] * 4 * lengths[0] / lengths[i];
1378ebfedea0SLionel Sambuc c[D_WHIRLPOOL][i] = c[D_WHIRLPOOL][0] * 4 * lengths[0] / lengths[i];
1379ebfedea0SLionel Sambuc }
1380*0a6a1f1dSLionel Sambuc for (i = 1; i < SIZE_NUM; i++) {
1381ebfedea0SLionel Sambuc long l0, l1;
1382ebfedea0SLionel Sambuc
1383ebfedea0SLionel Sambuc l0 = (long)lengths[i - 1];
1384ebfedea0SLionel Sambuc l1 = (long)lengths[i];
1385ebfedea0SLionel Sambuc c[D_RC4][i] = c[D_RC4][i - 1] * l0 / l1;
1386ebfedea0SLionel Sambuc c[D_CBC_DES][i] = c[D_CBC_DES][i - 1] * l0 / l1;
1387ebfedea0SLionel Sambuc c[D_EDE3_DES][i] = c[D_EDE3_DES][i - 1] * l0 / l1;
1388ebfedea0SLionel Sambuc c[D_CBC_IDEA][i] = c[D_CBC_IDEA][i - 1] * l0 / l1;
1389ebfedea0SLionel Sambuc c[D_CBC_SEED][i] = c[D_CBC_SEED][i - 1] * l0 / l1;
1390ebfedea0SLionel Sambuc c[D_CBC_RC2][i] = c[D_CBC_RC2][i - 1] * l0 / l1;
1391ebfedea0SLionel Sambuc c[D_CBC_RC5][i] = c[D_CBC_RC5][i - 1] * l0 / l1;
1392ebfedea0SLionel Sambuc c[D_CBC_BF][i] = c[D_CBC_BF][i - 1] * l0 / l1;
1393ebfedea0SLionel Sambuc c[D_CBC_CAST][i] = c[D_CBC_CAST][i - 1] * l0 / l1;
1394ebfedea0SLionel Sambuc c[D_CBC_128_AES][i] = c[D_CBC_128_AES][i - 1] * l0 / l1;
1395ebfedea0SLionel Sambuc c[D_CBC_192_AES][i] = c[D_CBC_192_AES][i - 1] * l0 / l1;
1396ebfedea0SLionel Sambuc c[D_CBC_256_AES][i] = c[D_CBC_256_AES][i - 1] * l0 / l1;
1397ebfedea0SLionel Sambuc c[D_CBC_128_CML][i] = c[D_CBC_128_CML][i - 1] * l0 / l1;
1398ebfedea0SLionel Sambuc c[D_CBC_192_CML][i] = c[D_CBC_192_CML][i - 1] * l0 / l1;
1399ebfedea0SLionel Sambuc c[D_CBC_256_CML][i] = c[D_CBC_256_CML][i - 1] * l0 / l1;
1400ebfedea0SLionel Sambuc c[D_IGE_128_AES][i] = c[D_IGE_128_AES][i - 1] * l0 / l1;
1401ebfedea0SLionel Sambuc c[D_IGE_192_AES][i] = c[D_IGE_192_AES][i - 1] * l0 / l1;
1402ebfedea0SLionel Sambuc c[D_IGE_256_AES][i] = c[D_IGE_256_AES][i - 1] * l0 / l1;
1403ebfedea0SLionel Sambuc }
1404ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
1405ebfedea0SLionel Sambuc rsa_c[R_RSA_512][0] = count / 2000;
1406ebfedea0SLionel Sambuc rsa_c[R_RSA_512][1] = count / 400;
1407*0a6a1f1dSLionel Sambuc for (i = 1; i < RSA_NUM; i++) {
1408ebfedea0SLionel Sambuc rsa_c[i][0] = rsa_c[i - 1][0] / 8;
1409ebfedea0SLionel Sambuc rsa_c[i][1] = rsa_c[i - 1][1] / 4;
1410ebfedea0SLionel Sambuc if ((rsa_doit[i] <= 1) && (rsa_c[i][0] == 0))
1411ebfedea0SLionel Sambuc rsa_doit[i] = 0;
1412*0a6a1f1dSLionel Sambuc else {
1413*0a6a1f1dSLionel Sambuc if (rsa_c[i][0] == 0) {
1414ebfedea0SLionel Sambuc rsa_c[i][0] = 1;
1415ebfedea0SLionel Sambuc rsa_c[i][1] = 20;
1416ebfedea0SLionel Sambuc }
1417ebfedea0SLionel Sambuc }
1418ebfedea0SLionel Sambuc }
1419ebfedea0SLionel Sambuc # endif
1420ebfedea0SLionel Sambuc
1421ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
1422ebfedea0SLionel Sambuc dsa_c[R_DSA_512][0] = count / 1000;
1423ebfedea0SLionel Sambuc dsa_c[R_DSA_512][1] = count / 1000 / 2;
1424*0a6a1f1dSLionel Sambuc for (i = 1; i < DSA_NUM; i++) {
1425ebfedea0SLionel Sambuc dsa_c[i][0] = dsa_c[i - 1][0] / 4;
1426ebfedea0SLionel Sambuc dsa_c[i][1] = dsa_c[i - 1][1] / 4;
1427ebfedea0SLionel Sambuc if ((dsa_doit[i] <= 1) && (dsa_c[i][0] == 0))
1428ebfedea0SLionel Sambuc dsa_doit[i] = 0;
1429*0a6a1f1dSLionel Sambuc else {
1430*0a6a1f1dSLionel Sambuc if (dsa_c[i] == 0) {
1431ebfedea0SLionel Sambuc dsa_c[i][0] = 1;
1432ebfedea0SLionel Sambuc dsa_c[i][1] = 1;
1433ebfedea0SLionel Sambuc }
1434ebfedea0SLionel Sambuc }
1435ebfedea0SLionel Sambuc }
1436ebfedea0SLionel Sambuc # endif
1437ebfedea0SLionel Sambuc
1438ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
1439ebfedea0SLionel Sambuc ecdsa_c[R_EC_P160][0] = count / 1000;
1440ebfedea0SLionel Sambuc ecdsa_c[R_EC_P160][1] = count / 1000 / 2;
1441*0a6a1f1dSLionel Sambuc for (i = R_EC_P192; i <= R_EC_P521; i++) {
1442ebfedea0SLionel Sambuc ecdsa_c[i][0] = ecdsa_c[i - 1][0] / 2;
1443ebfedea0SLionel Sambuc ecdsa_c[i][1] = ecdsa_c[i - 1][1] / 2;
1444ebfedea0SLionel Sambuc if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
1445ebfedea0SLionel Sambuc ecdsa_doit[i] = 0;
1446*0a6a1f1dSLionel Sambuc else {
1447*0a6a1f1dSLionel Sambuc if (ecdsa_c[i] == 0) {
1448ebfedea0SLionel Sambuc ecdsa_c[i][0] = 1;
1449ebfedea0SLionel Sambuc ecdsa_c[i][1] = 1;
1450ebfedea0SLionel Sambuc }
1451ebfedea0SLionel Sambuc }
1452ebfedea0SLionel Sambuc }
1453ebfedea0SLionel Sambuc ecdsa_c[R_EC_K163][0] = count / 1000;
1454ebfedea0SLionel Sambuc ecdsa_c[R_EC_K163][1] = count / 1000 / 2;
1455*0a6a1f1dSLionel Sambuc for (i = R_EC_K233; i <= R_EC_K571; i++) {
1456ebfedea0SLionel Sambuc ecdsa_c[i][0] = ecdsa_c[i - 1][0] / 2;
1457ebfedea0SLionel Sambuc ecdsa_c[i][1] = ecdsa_c[i - 1][1] / 2;
1458ebfedea0SLionel Sambuc if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
1459ebfedea0SLionel Sambuc ecdsa_doit[i] = 0;
1460*0a6a1f1dSLionel Sambuc else {
1461*0a6a1f1dSLionel Sambuc if (ecdsa_c[i] == 0) {
1462ebfedea0SLionel Sambuc ecdsa_c[i][0] = 1;
1463ebfedea0SLionel Sambuc ecdsa_c[i][1] = 1;
1464ebfedea0SLionel Sambuc }
1465ebfedea0SLionel Sambuc }
1466ebfedea0SLionel Sambuc }
1467ebfedea0SLionel Sambuc ecdsa_c[R_EC_B163][0] = count / 1000;
1468ebfedea0SLionel Sambuc ecdsa_c[R_EC_B163][1] = count / 1000 / 2;
1469*0a6a1f1dSLionel Sambuc for (i = R_EC_B233; i <= R_EC_B571; i++) {
1470ebfedea0SLionel Sambuc ecdsa_c[i][0] = ecdsa_c[i - 1][0] / 2;
1471ebfedea0SLionel Sambuc ecdsa_c[i][1] = ecdsa_c[i - 1][1] / 2;
1472ebfedea0SLionel Sambuc if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
1473ebfedea0SLionel Sambuc ecdsa_doit[i] = 0;
1474*0a6a1f1dSLionel Sambuc else {
1475*0a6a1f1dSLionel Sambuc if (ecdsa_c[i] == 0) {
1476ebfedea0SLionel Sambuc ecdsa_c[i][0] = 1;
1477ebfedea0SLionel Sambuc ecdsa_c[i][1] = 1;
1478ebfedea0SLionel Sambuc }
1479ebfedea0SLionel Sambuc }
1480ebfedea0SLionel Sambuc }
1481ebfedea0SLionel Sambuc # endif
1482ebfedea0SLionel Sambuc
1483ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
1484ebfedea0SLionel Sambuc ecdh_c[R_EC_P160][0] = count / 1000;
1485ebfedea0SLionel Sambuc ecdh_c[R_EC_P160][1] = count / 1000;
1486*0a6a1f1dSLionel Sambuc for (i = R_EC_P192; i <= R_EC_P521; i++) {
1487ebfedea0SLionel Sambuc ecdh_c[i][0] = ecdh_c[i - 1][0] / 2;
1488ebfedea0SLionel Sambuc ecdh_c[i][1] = ecdh_c[i - 1][1] / 2;
1489ebfedea0SLionel Sambuc if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
1490ebfedea0SLionel Sambuc ecdh_doit[i] = 0;
1491*0a6a1f1dSLionel Sambuc else {
1492*0a6a1f1dSLionel Sambuc if (ecdh_c[i] == 0) {
1493ebfedea0SLionel Sambuc ecdh_c[i][0] = 1;
1494ebfedea0SLionel Sambuc ecdh_c[i][1] = 1;
1495ebfedea0SLionel Sambuc }
1496ebfedea0SLionel Sambuc }
1497ebfedea0SLionel Sambuc }
1498ebfedea0SLionel Sambuc ecdh_c[R_EC_K163][0] = count / 1000;
1499ebfedea0SLionel Sambuc ecdh_c[R_EC_K163][1] = count / 1000;
1500*0a6a1f1dSLionel Sambuc for (i = R_EC_K233; i <= R_EC_K571; i++) {
1501ebfedea0SLionel Sambuc ecdh_c[i][0] = ecdh_c[i - 1][0] / 2;
1502ebfedea0SLionel Sambuc ecdh_c[i][1] = ecdh_c[i - 1][1] / 2;
1503ebfedea0SLionel Sambuc if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
1504ebfedea0SLionel Sambuc ecdh_doit[i] = 0;
1505*0a6a1f1dSLionel Sambuc else {
1506*0a6a1f1dSLionel Sambuc if (ecdh_c[i] == 0) {
1507ebfedea0SLionel Sambuc ecdh_c[i][0] = 1;
1508ebfedea0SLionel Sambuc ecdh_c[i][1] = 1;
1509ebfedea0SLionel Sambuc }
1510ebfedea0SLionel Sambuc }
1511ebfedea0SLionel Sambuc }
1512ebfedea0SLionel Sambuc ecdh_c[R_EC_B163][0] = count / 1000;
1513ebfedea0SLionel Sambuc ecdh_c[R_EC_B163][1] = count / 1000;
1514*0a6a1f1dSLionel Sambuc for (i = R_EC_B233; i <= R_EC_B571; i++) {
1515ebfedea0SLionel Sambuc ecdh_c[i][0] = ecdh_c[i - 1][0] / 2;
1516ebfedea0SLionel Sambuc ecdh_c[i][1] = ecdh_c[i - 1][1] / 2;
1517ebfedea0SLionel Sambuc if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
1518ebfedea0SLionel Sambuc ecdh_doit[i] = 0;
1519*0a6a1f1dSLionel Sambuc else {
1520*0a6a1f1dSLionel Sambuc if (ecdh_c[i] == 0) {
1521ebfedea0SLionel Sambuc ecdh_c[i][0] = 1;
1522ebfedea0SLionel Sambuc ecdh_c[i][1] = 1;
1523ebfedea0SLionel Sambuc }
1524ebfedea0SLionel Sambuc }
1525ebfedea0SLionel Sambuc }
1526ebfedea0SLionel Sambuc # endif
1527ebfedea0SLionel Sambuc
1528ebfedea0SLionel Sambuc # define COND(d) (count < (d))
1529ebfedea0SLionel Sambuc # define COUNT(d) (d)
1530ebfedea0SLionel Sambuc # else
1531ebfedea0SLionel Sambuc /* not worth fixing */
1532ebfedea0SLionel Sambuc # error "You cannot disable DES on systems without SIGALRM."
1533ebfedea0SLionel Sambuc # endif /* OPENSSL_NO_DES */
1534ebfedea0SLionel Sambuc # else
1535ebfedea0SLionel Sambuc # define COND(c) (run && count<0x7fffffff)
1536ebfedea0SLionel Sambuc # define COUNT(d) (count)
1537ebfedea0SLionel Sambuc # ifndef _WIN32
1538ebfedea0SLionel Sambuc signal(SIGALRM, sig_done);
1539ebfedea0SLionel Sambuc # endif
1540ebfedea0SLionel Sambuc # endif /* SIGALRM */
1541ebfedea0SLionel Sambuc
1542ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD2
1543*0a6a1f1dSLionel Sambuc if (doit[D_MD2]) {
1544*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1545ebfedea0SLionel Sambuc print_message(names[D_MD2], c[D_MD2][j], lengths[j]);
1546ebfedea0SLionel Sambuc Time_F(START);
1547ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_MD2][j]); count++)
1548*0a6a1f1dSLionel Sambuc EVP_Digest(buf, (unsigned long)lengths[j], &(md2[0]), NULL,
1549*0a6a1f1dSLionel Sambuc EVP_md2(), NULL);
1550ebfedea0SLionel Sambuc d = Time_F(STOP);
1551ebfedea0SLionel Sambuc print_result(D_MD2, j, count, d);
1552ebfedea0SLionel Sambuc }
1553ebfedea0SLionel Sambuc }
1554ebfedea0SLionel Sambuc # endif
1555ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MDC2
1556*0a6a1f1dSLionel Sambuc if (doit[D_MDC2]) {
1557*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1558ebfedea0SLionel Sambuc print_message(names[D_MDC2], c[D_MDC2][j], lengths[j]);
1559ebfedea0SLionel Sambuc Time_F(START);
1560ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_MDC2][j]); count++)
1561*0a6a1f1dSLionel Sambuc EVP_Digest(buf, (unsigned long)lengths[j], &(mdc2[0]), NULL,
1562*0a6a1f1dSLionel Sambuc EVP_mdc2(), NULL);
1563ebfedea0SLionel Sambuc d = Time_F(STOP);
1564ebfedea0SLionel Sambuc print_result(D_MDC2, j, count, d);
1565ebfedea0SLionel Sambuc }
1566ebfedea0SLionel Sambuc }
1567ebfedea0SLionel Sambuc # endif
1568ebfedea0SLionel Sambuc
1569ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD4
1570*0a6a1f1dSLionel Sambuc if (doit[D_MD4]) {
1571*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1572ebfedea0SLionel Sambuc print_message(names[D_MD4], c[D_MD4][j], lengths[j]);
1573ebfedea0SLionel Sambuc Time_F(START);
1574ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_MD4][j]); count++)
1575*0a6a1f1dSLionel Sambuc EVP_Digest(&(buf[0]), (unsigned long)lengths[j], &(md4[0]),
1576*0a6a1f1dSLionel Sambuc NULL, EVP_md4(), NULL);
1577ebfedea0SLionel Sambuc d = Time_F(STOP);
1578ebfedea0SLionel Sambuc print_result(D_MD4, j, count, d);
1579ebfedea0SLionel Sambuc }
1580ebfedea0SLionel Sambuc }
1581ebfedea0SLionel Sambuc # endif
1582ebfedea0SLionel Sambuc
1583ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD5
1584*0a6a1f1dSLionel Sambuc if (doit[D_MD5]) {
1585*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1586ebfedea0SLionel Sambuc print_message(names[D_MD5], c[D_MD5][j], lengths[j]);
1587ebfedea0SLionel Sambuc Time_F(START);
1588ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_MD5][j]); count++)
1589*0a6a1f1dSLionel Sambuc EVP_Digest(&(buf[0]), (unsigned long)lengths[j], &(md5[0]),
1590*0a6a1f1dSLionel Sambuc NULL, EVP_get_digestbyname("md5"), NULL);
1591ebfedea0SLionel Sambuc d = Time_F(STOP);
1592ebfedea0SLionel Sambuc print_result(D_MD5, j, count, d);
1593ebfedea0SLionel Sambuc }
1594ebfedea0SLionel Sambuc }
1595ebfedea0SLionel Sambuc # endif
1596ebfedea0SLionel Sambuc
1597ebfedea0SLionel Sambuc # if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC)
1598*0a6a1f1dSLionel Sambuc if (doit[D_HMAC]) {
1599ebfedea0SLionel Sambuc HMAC_CTX hctx;
1600ebfedea0SLionel Sambuc
1601ebfedea0SLionel Sambuc HMAC_CTX_init(&hctx);
1602ebfedea0SLionel Sambuc HMAC_Init_ex(&hctx, (unsigned char *)"This is a key...",
1603ebfedea0SLionel Sambuc 16, EVP_md5(), NULL);
1604ebfedea0SLionel Sambuc
1605*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1606ebfedea0SLionel Sambuc print_message(names[D_HMAC], c[D_HMAC][j], lengths[j]);
1607ebfedea0SLionel Sambuc Time_F(START);
1608*0a6a1f1dSLionel Sambuc for (count = 0, run = 1; COND(c[D_HMAC][j]); count++) {
1609ebfedea0SLionel Sambuc HMAC_Init_ex(&hctx, NULL, 0, NULL, NULL);
1610ebfedea0SLionel Sambuc HMAC_Update(&hctx, buf, lengths[j]);
1611ebfedea0SLionel Sambuc HMAC_Final(&hctx, &(hmac[0]), NULL);
1612ebfedea0SLionel Sambuc }
1613ebfedea0SLionel Sambuc d = Time_F(STOP);
1614ebfedea0SLionel Sambuc print_result(D_HMAC, j, count, d);
1615ebfedea0SLionel Sambuc }
1616ebfedea0SLionel Sambuc HMAC_CTX_cleanup(&hctx);
1617ebfedea0SLionel Sambuc }
1618ebfedea0SLionel Sambuc # endif
1619ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA
1620*0a6a1f1dSLionel Sambuc if (doit[D_SHA1]) {
1621*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1622ebfedea0SLionel Sambuc print_message(names[D_SHA1], c[D_SHA1][j], lengths[j]);
1623ebfedea0SLionel Sambuc Time_F(START);
1624ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_SHA1][j]); count++)
1625*0a6a1f1dSLionel Sambuc EVP_Digest(buf, (unsigned long)lengths[j], &(sha[0]), NULL,
1626*0a6a1f1dSLionel Sambuc EVP_sha1(), NULL);
1627ebfedea0SLionel Sambuc d = Time_F(STOP);
1628ebfedea0SLionel Sambuc print_result(D_SHA1, j, count, d);
1629ebfedea0SLionel Sambuc }
1630ebfedea0SLionel Sambuc }
1631ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA256
1632*0a6a1f1dSLionel Sambuc if (doit[D_SHA256]) {
1633*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1634ebfedea0SLionel Sambuc print_message(names[D_SHA256], c[D_SHA256][j], lengths[j]);
1635ebfedea0SLionel Sambuc Time_F(START);
1636ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_SHA256][j]); count++)
1637ebfedea0SLionel Sambuc SHA256(buf, lengths[j], sha256);
1638ebfedea0SLionel Sambuc d = Time_F(STOP);
1639ebfedea0SLionel Sambuc print_result(D_SHA256, j, count, d);
1640ebfedea0SLionel Sambuc }
1641ebfedea0SLionel Sambuc }
1642ebfedea0SLionel Sambuc # endif
1643ebfedea0SLionel Sambuc
1644ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SHA512
1645*0a6a1f1dSLionel Sambuc if (doit[D_SHA512]) {
1646*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1647ebfedea0SLionel Sambuc print_message(names[D_SHA512], c[D_SHA512][j], lengths[j]);
1648ebfedea0SLionel Sambuc Time_F(START);
1649ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_SHA512][j]); count++)
1650ebfedea0SLionel Sambuc SHA512(buf, lengths[j], sha512);
1651ebfedea0SLionel Sambuc d = Time_F(STOP);
1652ebfedea0SLionel Sambuc print_result(D_SHA512, j, count, d);
1653ebfedea0SLionel Sambuc }
1654ebfedea0SLionel Sambuc }
1655ebfedea0SLionel Sambuc # endif
1656ebfedea0SLionel Sambuc # endif
1657ebfedea0SLionel Sambuc
1658ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_WHIRLPOOL
1659*0a6a1f1dSLionel Sambuc if (doit[D_WHIRLPOOL]) {
1660*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1661ebfedea0SLionel Sambuc print_message(names[D_WHIRLPOOL], c[D_WHIRLPOOL][j], lengths[j]);
1662ebfedea0SLionel Sambuc Time_F(START);
1663ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_WHIRLPOOL][j]); count++)
1664ebfedea0SLionel Sambuc WHIRLPOOL(buf, lengths[j], whirlpool);
1665ebfedea0SLionel Sambuc d = Time_F(STOP);
1666ebfedea0SLionel Sambuc print_result(D_WHIRLPOOL, j, count, d);
1667ebfedea0SLionel Sambuc }
1668ebfedea0SLionel Sambuc }
1669ebfedea0SLionel Sambuc # endif
1670ebfedea0SLionel Sambuc
1671ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RIPEMD
1672*0a6a1f1dSLionel Sambuc if (doit[D_RMD160]) {
1673*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1674ebfedea0SLionel Sambuc print_message(names[D_RMD160], c[D_RMD160][j], lengths[j]);
1675ebfedea0SLionel Sambuc Time_F(START);
1676ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_RMD160][j]); count++)
1677*0a6a1f1dSLionel Sambuc EVP_Digest(buf, (unsigned long)lengths[j], &(rmd160[0]), NULL,
1678*0a6a1f1dSLionel Sambuc EVP_ripemd160(), NULL);
1679ebfedea0SLionel Sambuc d = Time_F(STOP);
1680ebfedea0SLionel Sambuc print_result(D_RMD160, j, count, d);
1681ebfedea0SLionel Sambuc }
1682ebfedea0SLionel Sambuc }
1683ebfedea0SLionel Sambuc # endif
1684ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC4
1685*0a6a1f1dSLionel Sambuc if (doit[D_RC4]) {
1686*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1687ebfedea0SLionel Sambuc print_message(names[D_RC4], c[D_RC4][j], lengths[j]);
1688ebfedea0SLionel Sambuc Time_F(START);
1689ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_RC4][j]); count++)
1690*0a6a1f1dSLionel Sambuc RC4(&rc4_ks, (unsigned int)lengths[j], buf, buf);
1691ebfedea0SLionel Sambuc d = Time_F(STOP);
1692ebfedea0SLionel Sambuc print_result(D_RC4, j, count, d);
1693ebfedea0SLionel Sambuc }
1694ebfedea0SLionel Sambuc }
1695ebfedea0SLionel Sambuc # endif
1696ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DES
1697*0a6a1f1dSLionel Sambuc if (doit[D_CBC_DES]) {
1698*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1699ebfedea0SLionel Sambuc print_message(names[D_CBC_DES], c[D_CBC_DES][j], lengths[j]);
1700ebfedea0SLionel Sambuc Time_F(START);
1701ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_CBC_DES][j]); count++)
1702ebfedea0SLionel Sambuc DES_ncbc_encrypt(buf, buf, lengths[j], &sch,
1703ebfedea0SLionel Sambuc &DES_iv, DES_ENCRYPT);
1704ebfedea0SLionel Sambuc d = Time_F(STOP);
1705ebfedea0SLionel Sambuc print_result(D_CBC_DES, j, count, d);
1706ebfedea0SLionel Sambuc }
1707ebfedea0SLionel Sambuc }
1708ebfedea0SLionel Sambuc
1709*0a6a1f1dSLionel Sambuc if (doit[D_EDE3_DES]) {
1710*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1711ebfedea0SLionel Sambuc print_message(names[D_EDE3_DES], c[D_EDE3_DES][j], lengths[j]);
1712ebfedea0SLionel Sambuc Time_F(START);
1713ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_EDE3_DES][j]); count++)
1714ebfedea0SLionel Sambuc DES_ede3_cbc_encrypt(buf, buf, lengths[j],
1715ebfedea0SLionel Sambuc &sch, &sch2, &sch3,
1716ebfedea0SLionel Sambuc &DES_iv, DES_ENCRYPT);
1717ebfedea0SLionel Sambuc d = Time_F(STOP);
1718ebfedea0SLionel Sambuc print_result(D_EDE3_DES, j, count, d);
1719ebfedea0SLionel Sambuc }
1720ebfedea0SLionel Sambuc }
1721ebfedea0SLionel Sambuc # endif
1722ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_AES
1723*0a6a1f1dSLionel Sambuc if (doit[D_CBC_128_AES]) {
1724*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1725*0a6a1f1dSLionel Sambuc print_message(names[D_CBC_128_AES], c[D_CBC_128_AES][j],
1726*0a6a1f1dSLionel Sambuc lengths[j]);
1727ebfedea0SLionel Sambuc Time_F(START);
1728ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_CBC_128_AES][j]); count++)
1729ebfedea0SLionel Sambuc AES_cbc_encrypt(buf, buf,
1730ebfedea0SLionel Sambuc (unsigned long)lengths[j], &aes_ks1,
1731ebfedea0SLionel Sambuc iv, AES_ENCRYPT);
1732ebfedea0SLionel Sambuc d = Time_F(STOP);
1733ebfedea0SLionel Sambuc print_result(D_CBC_128_AES, j, count, d);
1734ebfedea0SLionel Sambuc }
1735ebfedea0SLionel Sambuc }
1736*0a6a1f1dSLionel Sambuc if (doit[D_CBC_192_AES]) {
1737*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1738*0a6a1f1dSLionel Sambuc print_message(names[D_CBC_192_AES], c[D_CBC_192_AES][j],
1739*0a6a1f1dSLionel Sambuc lengths[j]);
1740ebfedea0SLionel Sambuc Time_F(START);
1741ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_CBC_192_AES][j]); count++)
1742ebfedea0SLionel Sambuc AES_cbc_encrypt(buf, buf,
1743ebfedea0SLionel Sambuc (unsigned long)lengths[j], &aes_ks2,
1744ebfedea0SLionel Sambuc iv, AES_ENCRYPT);
1745ebfedea0SLionel Sambuc d = Time_F(STOP);
1746ebfedea0SLionel Sambuc print_result(D_CBC_192_AES, j, count, d);
1747ebfedea0SLionel Sambuc }
1748ebfedea0SLionel Sambuc }
1749*0a6a1f1dSLionel Sambuc if (doit[D_CBC_256_AES]) {
1750*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1751*0a6a1f1dSLionel Sambuc print_message(names[D_CBC_256_AES], c[D_CBC_256_AES][j],
1752*0a6a1f1dSLionel Sambuc lengths[j]);
1753ebfedea0SLionel Sambuc Time_F(START);
1754ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_CBC_256_AES][j]); count++)
1755ebfedea0SLionel Sambuc AES_cbc_encrypt(buf, buf,
1756ebfedea0SLionel Sambuc (unsigned long)lengths[j], &aes_ks3,
1757ebfedea0SLionel Sambuc iv, AES_ENCRYPT);
1758ebfedea0SLionel Sambuc d = Time_F(STOP);
1759ebfedea0SLionel Sambuc print_result(D_CBC_256_AES, j, count, d);
1760ebfedea0SLionel Sambuc }
1761ebfedea0SLionel Sambuc }
1762ebfedea0SLionel Sambuc
1763*0a6a1f1dSLionel Sambuc if (doit[D_IGE_128_AES]) {
1764*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1765*0a6a1f1dSLionel Sambuc print_message(names[D_IGE_128_AES], c[D_IGE_128_AES][j],
1766*0a6a1f1dSLionel Sambuc lengths[j]);
1767ebfedea0SLionel Sambuc Time_F(START);
1768ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_IGE_128_AES][j]); count++)
1769ebfedea0SLionel Sambuc AES_ige_encrypt(buf, buf2,
1770ebfedea0SLionel Sambuc (unsigned long)lengths[j], &aes_ks1,
1771ebfedea0SLionel Sambuc iv, AES_ENCRYPT);
1772ebfedea0SLionel Sambuc d = Time_F(STOP);
1773ebfedea0SLionel Sambuc print_result(D_IGE_128_AES, j, count, d);
1774ebfedea0SLionel Sambuc }
1775ebfedea0SLionel Sambuc }
1776*0a6a1f1dSLionel Sambuc if (doit[D_IGE_192_AES]) {
1777*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1778*0a6a1f1dSLionel Sambuc print_message(names[D_IGE_192_AES], c[D_IGE_192_AES][j],
1779*0a6a1f1dSLionel Sambuc lengths[j]);
1780ebfedea0SLionel Sambuc Time_F(START);
1781ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_IGE_192_AES][j]); count++)
1782ebfedea0SLionel Sambuc AES_ige_encrypt(buf, buf2,
1783ebfedea0SLionel Sambuc (unsigned long)lengths[j], &aes_ks2,
1784ebfedea0SLionel Sambuc iv, AES_ENCRYPT);
1785ebfedea0SLionel Sambuc d = Time_F(STOP);
1786ebfedea0SLionel Sambuc print_result(D_IGE_192_AES, j, count, d);
1787ebfedea0SLionel Sambuc }
1788ebfedea0SLionel Sambuc }
1789*0a6a1f1dSLionel Sambuc if (doit[D_IGE_256_AES]) {
1790*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1791*0a6a1f1dSLionel Sambuc print_message(names[D_IGE_256_AES], c[D_IGE_256_AES][j],
1792*0a6a1f1dSLionel Sambuc lengths[j]);
1793ebfedea0SLionel Sambuc Time_F(START);
1794ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_IGE_256_AES][j]); count++)
1795ebfedea0SLionel Sambuc AES_ige_encrypt(buf, buf2,
1796ebfedea0SLionel Sambuc (unsigned long)lengths[j], &aes_ks3,
1797ebfedea0SLionel Sambuc iv, AES_ENCRYPT);
1798ebfedea0SLionel Sambuc d = Time_F(STOP);
1799ebfedea0SLionel Sambuc print_result(D_IGE_256_AES, j, count, d);
1800ebfedea0SLionel Sambuc }
1801ebfedea0SLionel Sambuc }
1802*0a6a1f1dSLionel Sambuc if (doit[D_GHASH]) {
1803*0a6a1f1dSLionel Sambuc GCM128_CONTEXT *ctx =
1804*0a6a1f1dSLionel Sambuc CRYPTO_gcm128_new(&aes_ks1, (block128_f) AES_encrypt);
1805ebfedea0SLionel Sambuc CRYPTO_gcm128_setiv(ctx, (unsigned char *)"0123456789ab", 12);
1806ebfedea0SLionel Sambuc
1807*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1808ebfedea0SLionel Sambuc print_message(names[D_GHASH], c[D_GHASH][j], lengths[j]);
1809ebfedea0SLionel Sambuc Time_F(START);
1810ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_GHASH][j]); count++)
1811ebfedea0SLionel Sambuc CRYPTO_gcm128_aad(ctx, buf, lengths[j]);
1812ebfedea0SLionel Sambuc d = Time_F(STOP);
1813ebfedea0SLionel Sambuc print_result(D_GHASH, j, count, d);
1814ebfedea0SLionel Sambuc }
1815ebfedea0SLionel Sambuc CRYPTO_gcm128_release(ctx);
1816ebfedea0SLionel Sambuc }
1817ebfedea0SLionel Sambuc # endif
1818ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAMELLIA
1819*0a6a1f1dSLionel Sambuc if (doit[D_CBC_128_CML]) {
1820*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1821*0a6a1f1dSLionel Sambuc print_message(names[D_CBC_128_CML], c[D_CBC_128_CML][j],
1822*0a6a1f1dSLionel Sambuc lengths[j]);
1823ebfedea0SLionel Sambuc Time_F(START);
1824ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_CBC_128_CML][j]); count++)
1825ebfedea0SLionel Sambuc Camellia_cbc_encrypt(buf, buf,
1826ebfedea0SLionel Sambuc (unsigned long)lengths[j], &camellia_ks1,
1827ebfedea0SLionel Sambuc iv, CAMELLIA_ENCRYPT);
1828ebfedea0SLionel Sambuc d = Time_F(STOP);
1829ebfedea0SLionel Sambuc print_result(D_CBC_128_CML, j, count, d);
1830ebfedea0SLionel Sambuc }
1831ebfedea0SLionel Sambuc }
1832*0a6a1f1dSLionel Sambuc if (doit[D_CBC_192_CML]) {
1833*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1834*0a6a1f1dSLionel Sambuc print_message(names[D_CBC_192_CML], c[D_CBC_192_CML][j],
1835*0a6a1f1dSLionel Sambuc lengths[j]);
1836ebfedea0SLionel Sambuc Time_F(START);
1837ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_CBC_192_CML][j]); count++)
1838ebfedea0SLionel Sambuc Camellia_cbc_encrypt(buf, buf,
1839ebfedea0SLionel Sambuc (unsigned long)lengths[j], &camellia_ks2,
1840ebfedea0SLionel Sambuc iv, CAMELLIA_ENCRYPT);
1841ebfedea0SLionel Sambuc d = Time_F(STOP);
1842ebfedea0SLionel Sambuc print_result(D_CBC_192_CML, j, count, d);
1843ebfedea0SLionel Sambuc }
1844ebfedea0SLionel Sambuc }
1845*0a6a1f1dSLionel Sambuc if (doit[D_CBC_256_CML]) {
1846*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1847*0a6a1f1dSLionel Sambuc print_message(names[D_CBC_256_CML], c[D_CBC_256_CML][j],
1848*0a6a1f1dSLionel Sambuc lengths[j]);
1849ebfedea0SLionel Sambuc Time_F(START);
1850ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_CBC_256_CML][j]); count++)
1851ebfedea0SLionel Sambuc Camellia_cbc_encrypt(buf, buf,
1852ebfedea0SLionel Sambuc (unsigned long)lengths[j], &camellia_ks3,
1853ebfedea0SLionel Sambuc iv, CAMELLIA_ENCRYPT);
1854ebfedea0SLionel Sambuc d = Time_F(STOP);
1855ebfedea0SLionel Sambuc print_result(D_CBC_256_CML, j, count, d);
1856ebfedea0SLionel Sambuc }
1857ebfedea0SLionel Sambuc }
1858ebfedea0SLionel Sambuc # endif
1859ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_IDEA
1860*0a6a1f1dSLionel Sambuc if (doit[D_CBC_IDEA]) {
1861*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1862ebfedea0SLionel Sambuc print_message(names[D_CBC_IDEA], c[D_CBC_IDEA][j], lengths[j]);
1863ebfedea0SLionel Sambuc Time_F(START);
1864ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_CBC_IDEA][j]); count++)
1865ebfedea0SLionel Sambuc idea_cbc_encrypt(buf, buf,
1866ebfedea0SLionel Sambuc (unsigned long)lengths[j], &idea_ks,
1867ebfedea0SLionel Sambuc iv, IDEA_ENCRYPT);
1868ebfedea0SLionel Sambuc d = Time_F(STOP);
1869ebfedea0SLionel Sambuc print_result(D_CBC_IDEA, j, count, d);
1870ebfedea0SLionel Sambuc }
1871ebfedea0SLionel Sambuc }
1872ebfedea0SLionel Sambuc # endif
1873ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SEED
1874*0a6a1f1dSLionel Sambuc if (doit[D_CBC_SEED]) {
1875*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1876ebfedea0SLionel Sambuc print_message(names[D_CBC_SEED], c[D_CBC_SEED][j], lengths[j]);
1877ebfedea0SLionel Sambuc Time_F(START);
1878ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_CBC_SEED][j]); count++)
1879ebfedea0SLionel Sambuc SEED_cbc_encrypt(buf, buf,
1880ebfedea0SLionel Sambuc (unsigned long)lengths[j], &seed_ks, iv, 1);
1881ebfedea0SLionel Sambuc d = Time_F(STOP);
1882ebfedea0SLionel Sambuc print_result(D_CBC_SEED, j, count, d);
1883ebfedea0SLionel Sambuc }
1884ebfedea0SLionel Sambuc }
1885ebfedea0SLionel Sambuc # endif
1886ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC2
1887*0a6a1f1dSLionel Sambuc if (doit[D_CBC_RC2]) {
1888*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1889ebfedea0SLionel Sambuc print_message(names[D_CBC_RC2], c[D_CBC_RC2][j], lengths[j]);
1890ebfedea0SLionel Sambuc Time_F(START);
1891ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_CBC_RC2][j]); count++)
1892ebfedea0SLionel Sambuc RC2_cbc_encrypt(buf, buf,
1893ebfedea0SLionel Sambuc (unsigned long)lengths[j], &rc2_ks,
1894ebfedea0SLionel Sambuc iv, RC2_ENCRYPT);
1895ebfedea0SLionel Sambuc d = Time_F(STOP);
1896ebfedea0SLionel Sambuc print_result(D_CBC_RC2, j, count, d);
1897ebfedea0SLionel Sambuc }
1898ebfedea0SLionel Sambuc }
1899ebfedea0SLionel Sambuc # endif
1900ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC5
1901*0a6a1f1dSLionel Sambuc if (doit[D_CBC_RC5]) {
1902*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1903ebfedea0SLionel Sambuc print_message(names[D_CBC_RC5], c[D_CBC_RC5][j], lengths[j]);
1904ebfedea0SLionel Sambuc Time_F(START);
1905ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_CBC_RC5][j]); count++)
1906ebfedea0SLionel Sambuc RC5_32_cbc_encrypt(buf, buf,
1907ebfedea0SLionel Sambuc (unsigned long)lengths[j], &rc5_ks,
1908ebfedea0SLionel Sambuc iv, RC5_ENCRYPT);
1909ebfedea0SLionel Sambuc d = Time_F(STOP);
1910ebfedea0SLionel Sambuc print_result(D_CBC_RC5, j, count, d);
1911ebfedea0SLionel Sambuc }
1912ebfedea0SLionel Sambuc }
1913ebfedea0SLionel Sambuc # endif
1914ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_BF
1915*0a6a1f1dSLionel Sambuc if (doit[D_CBC_BF]) {
1916*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1917ebfedea0SLionel Sambuc print_message(names[D_CBC_BF], c[D_CBC_BF][j], lengths[j]);
1918ebfedea0SLionel Sambuc Time_F(START);
1919ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_CBC_BF][j]); count++)
1920ebfedea0SLionel Sambuc BF_cbc_encrypt(buf, buf,
1921ebfedea0SLionel Sambuc (unsigned long)lengths[j], &bf_ks,
1922ebfedea0SLionel Sambuc iv, BF_ENCRYPT);
1923ebfedea0SLionel Sambuc d = Time_F(STOP);
1924ebfedea0SLionel Sambuc print_result(D_CBC_BF, j, count, d);
1925ebfedea0SLionel Sambuc }
1926ebfedea0SLionel Sambuc }
1927ebfedea0SLionel Sambuc # endif
1928ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAST
1929*0a6a1f1dSLionel Sambuc if (doit[D_CBC_CAST]) {
1930*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1931ebfedea0SLionel Sambuc print_message(names[D_CBC_CAST], c[D_CBC_CAST][j], lengths[j]);
1932ebfedea0SLionel Sambuc Time_F(START);
1933ebfedea0SLionel Sambuc for (count = 0, run = 1; COND(c[D_CBC_CAST][j]); count++)
1934ebfedea0SLionel Sambuc CAST_cbc_encrypt(buf, buf,
1935ebfedea0SLionel Sambuc (unsigned long)lengths[j], &cast_ks,
1936ebfedea0SLionel Sambuc iv, CAST_ENCRYPT);
1937ebfedea0SLionel Sambuc d = Time_F(STOP);
1938ebfedea0SLionel Sambuc print_result(D_CBC_CAST, j, count, d);
1939ebfedea0SLionel Sambuc }
1940ebfedea0SLionel Sambuc }
1941ebfedea0SLionel Sambuc # endif
1942ebfedea0SLionel Sambuc
1943*0a6a1f1dSLionel Sambuc if (doit[D_EVP]) {
1944*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
1945*0a6a1f1dSLionel Sambuc if (evp_cipher) {
1946ebfedea0SLionel Sambuc EVP_CIPHER_CTX ctx;
1947ebfedea0SLionel Sambuc int outl;
1948ebfedea0SLionel Sambuc
1949ebfedea0SLionel Sambuc names[D_EVP] = OBJ_nid2ln(evp_cipher->nid);
1950*0a6a1f1dSLionel Sambuc /*
1951*0a6a1f1dSLionel Sambuc * -O3 -fschedule-insns messes up an optimization here!
1952*0a6a1f1dSLionel Sambuc * names[D_EVP] somehow becomes NULL
1953*0a6a1f1dSLionel Sambuc */
1954*0a6a1f1dSLionel Sambuc print_message(names[D_EVP], save_count, lengths[j]);
1955ebfedea0SLionel Sambuc
1956ebfedea0SLionel Sambuc EVP_CIPHER_CTX_init(&ctx);
1957ebfedea0SLionel Sambuc if (decrypt)
1958ebfedea0SLionel Sambuc EVP_DecryptInit_ex(&ctx, evp_cipher, NULL, key16, iv);
1959ebfedea0SLionel Sambuc else
1960ebfedea0SLionel Sambuc EVP_EncryptInit_ex(&ctx, evp_cipher, NULL, key16, iv);
1961ebfedea0SLionel Sambuc EVP_CIPHER_CTX_set_padding(&ctx, 0);
1962ebfedea0SLionel Sambuc
1963ebfedea0SLionel Sambuc Time_F(START);
1964ebfedea0SLionel Sambuc if (decrypt)
1965*0a6a1f1dSLionel Sambuc for (count = 0, run = 1;
1966*0a6a1f1dSLionel Sambuc COND(save_count * 4 * lengths[0] / lengths[j]);
1967*0a6a1f1dSLionel Sambuc count++)
1968ebfedea0SLionel Sambuc EVP_DecryptUpdate(&ctx, buf, &outl, buf, lengths[j]);
1969ebfedea0SLionel Sambuc else
1970*0a6a1f1dSLionel Sambuc for (count = 0, run = 1;
1971*0a6a1f1dSLionel Sambuc COND(save_count * 4 * lengths[0] / lengths[j]);
1972*0a6a1f1dSLionel Sambuc count++)
1973ebfedea0SLionel Sambuc EVP_EncryptUpdate(&ctx, buf, &outl, buf, lengths[j]);
1974ebfedea0SLionel Sambuc if (decrypt)
1975ebfedea0SLionel Sambuc EVP_DecryptFinal_ex(&ctx, buf, &outl);
1976ebfedea0SLionel Sambuc else
1977ebfedea0SLionel Sambuc EVP_EncryptFinal_ex(&ctx, buf, &outl);
1978ebfedea0SLionel Sambuc d = Time_F(STOP);
1979ebfedea0SLionel Sambuc EVP_CIPHER_CTX_cleanup(&ctx);
1980ebfedea0SLionel Sambuc }
1981*0a6a1f1dSLionel Sambuc if (evp_md) {
1982ebfedea0SLionel Sambuc names[D_EVP] = OBJ_nid2ln(evp_md->type);
1983*0a6a1f1dSLionel Sambuc print_message(names[D_EVP], save_count, lengths[j]);
1984ebfedea0SLionel Sambuc
1985ebfedea0SLionel Sambuc Time_F(START);
1986*0a6a1f1dSLionel Sambuc for (count = 0, run = 1;
1987*0a6a1f1dSLionel Sambuc COND(save_count * 4 * lengths[0] / lengths[j]); count++)
1988ebfedea0SLionel Sambuc EVP_Digest(buf, lengths[j], &(md[0]), NULL, evp_md, NULL);
1989ebfedea0SLionel Sambuc
1990ebfedea0SLionel Sambuc d = Time_F(STOP);
1991ebfedea0SLionel Sambuc }
1992ebfedea0SLionel Sambuc print_result(D_EVP, j, count, d);
1993ebfedea0SLionel Sambuc }
1994ebfedea0SLionel Sambuc }
1995ebfedea0SLionel Sambuc
1996ebfedea0SLionel Sambuc RAND_pseudo_bytes(buf, 36);
1997ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
1998*0a6a1f1dSLionel Sambuc for (j = 0; j < RSA_NUM; j++) {
1999ebfedea0SLionel Sambuc int ret;
2000*0a6a1f1dSLionel Sambuc if (!rsa_doit[j])
2001*0a6a1f1dSLionel Sambuc continue;
2002ebfedea0SLionel Sambuc ret = RSA_sign(NID_md5_sha1, buf, 36, buf2, &rsa_num, rsa_key[j]);
2003*0a6a1f1dSLionel Sambuc if (ret == 0) {
2004*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2005*0a6a1f1dSLionel Sambuc "RSA sign failure. No RSA sign will be done.\n");
2006ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2007ebfedea0SLionel Sambuc rsa_count = 1;
2008*0a6a1f1dSLionel Sambuc } else {
2009ebfedea0SLionel Sambuc pkey_print_message("private", "rsa",
2010*0a6a1f1dSLionel Sambuc rsa_c[j][0], rsa_bits[j], RSA_SECONDS);
2011ebfedea0SLionel Sambuc /* RSA_blinding_on(rsa_key[j],NULL); */
2012ebfedea0SLionel Sambuc Time_F(START);
2013*0a6a1f1dSLionel Sambuc for (count = 0, run = 1; COND(rsa_c[j][0]); count++) {
2014ebfedea0SLionel Sambuc ret = RSA_sign(NID_md5_sha1, buf, 36, buf2,
2015ebfedea0SLionel Sambuc &rsa_num, rsa_key[j]);
2016*0a6a1f1dSLionel Sambuc if (ret == 0) {
2017*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, "RSA sign failure\n");
2018ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2019ebfedea0SLionel Sambuc count = 1;
2020ebfedea0SLionel Sambuc break;
2021ebfedea0SLionel Sambuc }
2022ebfedea0SLionel Sambuc }
2023ebfedea0SLionel Sambuc d = Time_F(STOP);
2024*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2025*0a6a1f1dSLionel Sambuc mr ? "+R1:%ld:%d:%.2f\n"
2026ebfedea0SLionel Sambuc : "%ld %d bit private RSA's in %.2fs\n",
2027ebfedea0SLionel Sambuc count, rsa_bits[j], d);
2028ebfedea0SLionel Sambuc rsa_results[j][0] = d / (double)count;
2029ebfedea0SLionel Sambuc rsa_count = count;
2030ebfedea0SLionel Sambuc }
2031ebfedea0SLionel Sambuc
2032ebfedea0SLionel Sambuc # if 1
2033ebfedea0SLionel Sambuc ret = RSA_verify(NID_md5_sha1, buf, 36, buf2, rsa_num, rsa_key[j]);
2034*0a6a1f1dSLionel Sambuc if (ret <= 0) {
2035*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2036*0a6a1f1dSLionel Sambuc "RSA verify failure. No RSA verify will be done.\n");
2037ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2038ebfedea0SLionel Sambuc rsa_doit[j] = 0;
2039*0a6a1f1dSLionel Sambuc } else {
2040ebfedea0SLionel Sambuc pkey_print_message("public", "rsa",
2041*0a6a1f1dSLionel Sambuc rsa_c[j][1], rsa_bits[j], RSA_SECONDS);
2042ebfedea0SLionel Sambuc Time_F(START);
2043*0a6a1f1dSLionel Sambuc for (count = 0, run = 1; COND(rsa_c[j][1]); count++) {
2044ebfedea0SLionel Sambuc ret = RSA_verify(NID_md5_sha1, buf, 36, buf2,
2045ebfedea0SLionel Sambuc rsa_num, rsa_key[j]);
2046*0a6a1f1dSLionel Sambuc if (ret <= 0) {
2047*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, "RSA verify failure\n");
2048ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2049ebfedea0SLionel Sambuc count = 1;
2050ebfedea0SLionel Sambuc break;
2051ebfedea0SLionel Sambuc }
2052ebfedea0SLionel Sambuc }
2053ebfedea0SLionel Sambuc d = Time_F(STOP);
2054*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2055*0a6a1f1dSLionel Sambuc mr ? "+R2:%ld:%d:%.2f\n"
2056ebfedea0SLionel Sambuc : "%ld %d bit public RSA's in %.2fs\n",
2057ebfedea0SLionel Sambuc count, rsa_bits[j], d);
2058ebfedea0SLionel Sambuc rsa_results[j][1] = d / (double)count;
2059ebfedea0SLionel Sambuc }
2060ebfedea0SLionel Sambuc # endif
2061ebfedea0SLionel Sambuc
2062*0a6a1f1dSLionel Sambuc if (rsa_count <= 1) {
2063ebfedea0SLionel Sambuc /* if longer than 10s, don't do any more */
2064ebfedea0SLionel Sambuc for (j++; j < RSA_NUM; j++)
2065ebfedea0SLionel Sambuc rsa_doit[j] = 0;
2066ebfedea0SLionel Sambuc }
2067ebfedea0SLionel Sambuc }
2068ebfedea0SLionel Sambuc # endif
2069ebfedea0SLionel Sambuc
2070ebfedea0SLionel Sambuc RAND_pseudo_bytes(buf, 20);
2071ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
2072*0a6a1f1dSLionel Sambuc if (RAND_status() != 1) {
2073ebfedea0SLionel Sambuc RAND_seed(rnd_seed, sizeof rnd_seed);
2074ebfedea0SLionel Sambuc rnd_fake = 1;
2075ebfedea0SLionel Sambuc }
2076*0a6a1f1dSLionel Sambuc for (j = 0; j < DSA_NUM; j++) {
2077ebfedea0SLionel Sambuc unsigned int kk;
2078ebfedea0SLionel Sambuc int ret;
2079ebfedea0SLionel Sambuc
2080*0a6a1f1dSLionel Sambuc if (!dsa_doit[j])
2081*0a6a1f1dSLionel Sambuc continue;
2082*0a6a1f1dSLionel Sambuc
2083ebfedea0SLionel Sambuc /* DSA_generate_key(dsa_key[j]); */
2084ebfedea0SLionel Sambuc /* DSA_sign_setup(dsa_key[j],NULL); */
2085*0a6a1f1dSLionel Sambuc ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2, &kk, dsa_key[j]);
2086*0a6a1f1dSLionel Sambuc if (ret == 0) {
2087*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2088*0a6a1f1dSLionel Sambuc "DSA sign failure. No DSA sign will be done.\n");
2089ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2090ebfedea0SLionel Sambuc rsa_count = 1;
2091*0a6a1f1dSLionel Sambuc } else {
2092ebfedea0SLionel Sambuc pkey_print_message("sign", "dsa",
2093*0a6a1f1dSLionel Sambuc dsa_c[j][0], dsa_bits[j], DSA_SECONDS);
2094ebfedea0SLionel Sambuc Time_F(START);
2095*0a6a1f1dSLionel Sambuc for (count = 0, run = 1; COND(dsa_c[j][0]); count++) {
2096*0a6a1f1dSLionel Sambuc ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2, &kk, dsa_key[j]);
2097*0a6a1f1dSLionel Sambuc if (ret == 0) {
2098*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, "DSA sign failure\n");
2099ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2100ebfedea0SLionel Sambuc count = 1;
2101ebfedea0SLionel Sambuc break;
2102ebfedea0SLionel Sambuc }
2103ebfedea0SLionel Sambuc }
2104ebfedea0SLionel Sambuc d = Time_F(STOP);
2105*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2106*0a6a1f1dSLionel Sambuc mr ? "+R3:%ld:%d:%.2f\n"
2107ebfedea0SLionel Sambuc : "%ld %d bit DSA signs in %.2fs\n",
2108ebfedea0SLionel Sambuc count, dsa_bits[j], d);
2109ebfedea0SLionel Sambuc dsa_results[j][0] = d / (double)count;
2110ebfedea0SLionel Sambuc rsa_count = count;
2111ebfedea0SLionel Sambuc }
2112ebfedea0SLionel Sambuc
2113*0a6a1f1dSLionel Sambuc ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2, kk, dsa_key[j]);
2114*0a6a1f1dSLionel Sambuc if (ret <= 0) {
2115*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2116*0a6a1f1dSLionel Sambuc "DSA verify failure. No DSA verify will be done.\n");
2117ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2118ebfedea0SLionel Sambuc dsa_doit[j] = 0;
2119*0a6a1f1dSLionel Sambuc } else {
2120ebfedea0SLionel Sambuc pkey_print_message("verify", "dsa",
2121*0a6a1f1dSLionel Sambuc dsa_c[j][1], dsa_bits[j], DSA_SECONDS);
2122ebfedea0SLionel Sambuc Time_F(START);
2123*0a6a1f1dSLionel Sambuc for (count = 0, run = 1; COND(dsa_c[j][1]); count++) {
2124*0a6a1f1dSLionel Sambuc ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2, kk, dsa_key[j]);
2125*0a6a1f1dSLionel Sambuc if (ret <= 0) {
2126*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, "DSA verify failure\n");
2127ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2128ebfedea0SLionel Sambuc count = 1;
2129ebfedea0SLionel Sambuc break;
2130ebfedea0SLionel Sambuc }
2131ebfedea0SLionel Sambuc }
2132ebfedea0SLionel Sambuc d = Time_F(STOP);
2133*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2134*0a6a1f1dSLionel Sambuc mr ? "+R4:%ld:%d:%.2f\n"
2135ebfedea0SLionel Sambuc : "%ld %d bit DSA verify in %.2fs\n",
2136ebfedea0SLionel Sambuc count, dsa_bits[j], d);
2137ebfedea0SLionel Sambuc dsa_results[j][1] = d / (double)count;
2138ebfedea0SLionel Sambuc }
2139ebfedea0SLionel Sambuc
2140*0a6a1f1dSLionel Sambuc if (rsa_count <= 1) {
2141ebfedea0SLionel Sambuc /* if longer than 10s, don't do any more */
2142ebfedea0SLionel Sambuc for (j++; j < DSA_NUM; j++)
2143ebfedea0SLionel Sambuc dsa_doit[j] = 0;
2144ebfedea0SLionel Sambuc }
2145ebfedea0SLionel Sambuc }
2146*0a6a1f1dSLionel Sambuc if (rnd_fake)
2147*0a6a1f1dSLionel Sambuc RAND_cleanup();
2148ebfedea0SLionel Sambuc # endif
2149ebfedea0SLionel Sambuc
2150ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
2151*0a6a1f1dSLionel Sambuc if (RAND_status() != 1) {
2152ebfedea0SLionel Sambuc RAND_seed(rnd_seed, sizeof rnd_seed);
2153ebfedea0SLionel Sambuc rnd_fake = 1;
2154ebfedea0SLionel Sambuc }
2155*0a6a1f1dSLionel Sambuc for (j = 0; j < EC_NUM; j++) {
2156ebfedea0SLionel Sambuc int ret;
2157ebfedea0SLionel Sambuc
2158*0a6a1f1dSLionel Sambuc if (!ecdsa_doit[j])
2159*0a6a1f1dSLionel Sambuc continue; /* Ignore Curve */
2160ebfedea0SLionel Sambuc ecdsa[j] = EC_KEY_new_by_curve_name(test_curves[j]);
2161*0a6a1f1dSLionel Sambuc if (ecdsa[j] == NULL) {
2162ebfedea0SLionel Sambuc BIO_printf(bio_err, "ECDSA failure.\n");
2163ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2164ebfedea0SLionel Sambuc rsa_count = 1;
2165*0a6a1f1dSLionel Sambuc } else {
2166ebfedea0SLionel Sambuc # if 1
2167ebfedea0SLionel Sambuc EC_KEY_precompute_mult(ecdsa[j], NULL);
2168ebfedea0SLionel Sambuc # endif
2169ebfedea0SLionel Sambuc /* Perform ECDSA signature test */
2170ebfedea0SLionel Sambuc EC_KEY_generate_key(ecdsa[j]);
2171*0a6a1f1dSLionel Sambuc ret = ECDSA_sign(0, buf, 20, ecdsasig, &ecdsasiglen, ecdsa[j]);
2172*0a6a1f1dSLionel Sambuc if (ret == 0) {
2173*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2174*0a6a1f1dSLionel Sambuc "ECDSA sign failure. No ECDSA sign will be done.\n");
2175ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2176ebfedea0SLionel Sambuc rsa_count = 1;
2177*0a6a1f1dSLionel Sambuc } else {
2178ebfedea0SLionel Sambuc pkey_print_message("sign", "ecdsa",
2179ebfedea0SLionel Sambuc ecdsa_c[j][0],
2180*0a6a1f1dSLionel Sambuc test_curves_bits[j], ECDSA_SECONDS);
2181ebfedea0SLionel Sambuc
2182ebfedea0SLionel Sambuc Time_F(START);
2183*0a6a1f1dSLionel Sambuc for (count = 0, run = 1; COND(ecdsa_c[j][0]); count++) {
2184ebfedea0SLionel Sambuc ret = ECDSA_sign(0, buf, 20,
2185*0a6a1f1dSLionel Sambuc ecdsasig, &ecdsasiglen, ecdsa[j]);
2186*0a6a1f1dSLionel Sambuc if (ret == 0) {
2187ebfedea0SLionel Sambuc BIO_printf(bio_err, "ECDSA sign failure\n");
2188ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2189ebfedea0SLionel Sambuc count = 1;
2190ebfedea0SLionel Sambuc break;
2191ebfedea0SLionel Sambuc }
2192ebfedea0SLionel Sambuc }
2193ebfedea0SLionel Sambuc d = Time_F(STOP);
2194ebfedea0SLionel Sambuc
2195*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2196*0a6a1f1dSLionel Sambuc mr ? "+R5:%ld:%d:%.2f\n" :
2197ebfedea0SLionel Sambuc "%ld %d bit ECDSA signs in %.2fs \n",
2198ebfedea0SLionel Sambuc count, test_curves_bits[j], d);
2199ebfedea0SLionel Sambuc ecdsa_results[j][0] = d / (double)count;
2200ebfedea0SLionel Sambuc rsa_count = count;
2201ebfedea0SLionel Sambuc }
2202ebfedea0SLionel Sambuc
2203ebfedea0SLionel Sambuc /* Perform ECDSA verification test */
2204*0a6a1f1dSLionel Sambuc ret = ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]);
2205*0a6a1f1dSLionel Sambuc if (ret != 1) {
2206*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2207*0a6a1f1dSLionel Sambuc "ECDSA verify failure. No ECDSA verify will be done.\n");
2208ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2209ebfedea0SLionel Sambuc ecdsa_doit[j] = 0;
2210*0a6a1f1dSLionel Sambuc } else {
2211ebfedea0SLionel Sambuc pkey_print_message("verify", "ecdsa",
2212ebfedea0SLionel Sambuc ecdsa_c[j][1],
2213*0a6a1f1dSLionel Sambuc test_curves_bits[j], ECDSA_SECONDS);
2214ebfedea0SLionel Sambuc Time_F(START);
2215*0a6a1f1dSLionel Sambuc for (count = 0, run = 1; COND(ecdsa_c[j][1]); count++) {
2216*0a6a1f1dSLionel Sambuc ret =
2217*0a6a1f1dSLionel Sambuc ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen,
2218*0a6a1f1dSLionel Sambuc ecdsa[j]);
2219*0a6a1f1dSLionel Sambuc if (ret != 1) {
2220ebfedea0SLionel Sambuc BIO_printf(bio_err, "ECDSA verify failure\n");
2221ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2222ebfedea0SLionel Sambuc count = 1;
2223ebfedea0SLionel Sambuc break;
2224ebfedea0SLionel Sambuc }
2225ebfedea0SLionel Sambuc }
2226ebfedea0SLionel Sambuc d = Time_F(STOP);
2227*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2228*0a6a1f1dSLionel Sambuc mr ? "+R6:%ld:%d:%.2f\n"
2229ebfedea0SLionel Sambuc : "%ld %d bit ECDSA verify in %.2fs\n",
2230ebfedea0SLionel Sambuc count, test_curves_bits[j], d);
2231ebfedea0SLionel Sambuc ecdsa_results[j][1] = d / (double)count;
2232ebfedea0SLionel Sambuc }
2233ebfedea0SLionel Sambuc
2234*0a6a1f1dSLionel Sambuc if (rsa_count <= 1) {
2235ebfedea0SLionel Sambuc /* if longer than 10s, don't do any more */
2236ebfedea0SLionel Sambuc for (j++; j < EC_NUM; j++)
2237ebfedea0SLionel Sambuc ecdsa_doit[j] = 0;
2238ebfedea0SLionel Sambuc }
2239ebfedea0SLionel Sambuc }
2240ebfedea0SLionel Sambuc }
2241*0a6a1f1dSLionel Sambuc if (rnd_fake)
2242*0a6a1f1dSLionel Sambuc RAND_cleanup();
2243ebfedea0SLionel Sambuc # endif
2244ebfedea0SLionel Sambuc
2245ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
2246*0a6a1f1dSLionel Sambuc if (RAND_status() != 1) {
2247ebfedea0SLionel Sambuc RAND_seed(rnd_seed, sizeof rnd_seed);
2248ebfedea0SLionel Sambuc rnd_fake = 1;
2249ebfedea0SLionel Sambuc }
2250*0a6a1f1dSLionel Sambuc for (j = 0; j < EC_NUM; j++) {
2251*0a6a1f1dSLionel Sambuc if (!ecdh_doit[j])
2252*0a6a1f1dSLionel Sambuc continue;
2253ebfedea0SLionel Sambuc ecdh_a[j] = EC_KEY_new_by_curve_name(test_curves[j]);
2254ebfedea0SLionel Sambuc ecdh_b[j] = EC_KEY_new_by_curve_name(test_curves[j]);
2255*0a6a1f1dSLionel Sambuc if ((ecdh_a[j] == NULL) || (ecdh_b[j] == NULL)) {
2256ebfedea0SLionel Sambuc BIO_printf(bio_err, "ECDH failure.\n");
2257ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2258ebfedea0SLionel Sambuc rsa_count = 1;
2259*0a6a1f1dSLionel Sambuc } else {
2260ebfedea0SLionel Sambuc /* generate two ECDH key pairs */
2261ebfedea0SLionel Sambuc if (!EC_KEY_generate_key(ecdh_a[j]) ||
2262*0a6a1f1dSLionel Sambuc !EC_KEY_generate_key(ecdh_b[j])) {
2263ebfedea0SLionel Sambuc BIO_printf(bio_err, "ECDH key generation failure.\n");
2264ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2265ebfedea0SLionel Sambuc rsa_count = 1;
2266*0a6a1f1dSLionel Sambuc } else {
2267*0a6a1f1dSLionel Sambuc /*
2268*0a6a1f1dSLionel Sambuc * If field size is not more than 24 octets, then use SHA-1
2269*0a6a1f1dSLionel Sambuc * hash of result; otherwise, use result (see section 4.8 of
2270*0a6a1f1dSLionel Sambuc * draft-ietf-tls-ecc-03.txt).
2271ebfedea0SLionel Sambuc */
2272ebfedea0SLionel Sambuc int field_size, outlen;
2273*0a6a1f1dSLionel Sambuc void *(*kdf) (const void *in, size_t inlen, void *out,
2274*0a6a1f1dSLionel Sambuc size_t *xoutlen);
2275*0a6a1f1dSLionel Sambuc field_size =
2276*0a6a1f1dSLionel Sambuc EC_GROUP_get_degree(EC_KEY_get0_group(ecdh_a[j]));
2277*0a6a1f1dSLionel Sambuc if (field_size <= 24 * 8) {
2278ebfedea0SLionel Sambuc outlen = KDF1_SHA1_len;
2279ebfedea0SLionel Sambuc kdf = KDF1_SHA1;
2280*0a6a1f1dSLionel Sambuc } else {
2281ebfedea0SLionel Sambuc outlen = (field_size + 7) / 8;
2282ebfedea0SLionel Sambuc kdf = NULL;
2283ebfedea0SLionel Sambuc }
2284*0a6a1f1dSLionel Sambuc secret_size_a =
2285*0a6a1f1dSLionel Sambuc ECDH_compute_key(secret_a, outlen,
2286ebfedea0SLionel Sambuc EC_KEY_get0_public_key(ecdh_b[j]),
2287ebfedea0SLionel Sambuc ecdh_a[j], kdf);
2288*0a6a1f1dSLionel Sambuc secret_size_b =
2289*0a6a1f1dSLionel Sambuc ECDH_compute_key(secret_b, outlen,
2290ebfedea0SLionel Sambuc EC_KEY_get0_public_key(ecdh_a[j]),
2291ebfedea0SLionel Sambuc ecdh_b[j], kdf);
2292ebfedea0SLionel Sambuc if (secret_size_a != secret_size_b)
2293ebfedea0SLionel Sambuc ecdh_checks = 0;
2294ebfedea0SLionel Sambuc else
2295ebfedea0SLionel Sambuc ecdh_checks = 1;
2296ebfedea0SLionel Sambuc
2297*0a6a1f1dSLionel Sambuc for (secret_idx = 0; (secret_idx < secret_size_a)
2298*0a6a1f1dSLionel Sambuc && (ecdh_checks == 1); secret_idx++) {
2299ebfedea0SLionel Sambuc if (secret_a[secret_idx] != secret_b[secret_idx])
2300ebfedea0SLionel Sambuc ecdh_checks = 0;
2301ebfedea0SLionel Sambuc }
2302ebfedea0SLionel Sambuc
2303*0a6a1f1dSLionel Sambuc if (ecdh_checks == 0) {
2304ebfedea0SLionel Sambuc BIO_printf(bio_err, "ECDH computations don't match.\n");
2305ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2306ebfedea0SLionel Sambuc rsa_count = 1;
2307ebfedea0SLionel Sambuc }
2308ebfedea0SLionel Sambuc
2309ebfedea0SLionel Sambuc pkey_print_message("", "ecdh",
2310ebfedea0SLionel Sambuc ecdh_c[j][0],
2311*0a6a1f1dSLionel Sambuc test_curves_bits[j], ECDH_SECONDS);
2312ebfedea0SLionel Sambuc Time_F(START);
2313*0a6a1f1dSLionel Sambuc for (count = 0, run = 1; COND(ecdh_c[j][0]); count++) {
2314ebfedea0SLionel Sambuc ECDH_compute_key(secret_a, outlen,
2315ebfedea0SLionel Sambuc EC_KEY_get0_public_key(ecdh_b[j]),
2316ebfedea0SLionel Sambuc ecdh_a[j], kdf);
2317ebfedea0SLionel Sambuc }
2318ebfedea0SLionel Sambuc d = Time_F(STOP);
2319*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2320*0a6a1f1dSLionel Sambuc mr ? "+R7:%ld:%d:%.2f\n" :
2321*0a6a1f1dSLionel Sambuc "%ld %d-bit ECDH ops in %.2fs\n", count,
2322*0a6a1f1dSLionel Sambuc test_curves_bits[j], d);
2323ebfedea0SLionel Sambuc ecdh_results[j][0] = d / (double)count;
2324ebfedea0SLionel Sambuc rsa_count = count;
2325ebfedea0SLionel Sambuc }
2326ebfedea0SLionel Sambuc }
2327ebfedea0SLionel Sambuc
2328*0a6a1f1dSLionel Sambuc if (rsa_count <= 1) {
2329ebfedea0SLionel Sambuc /* if longer than 10s, don't do any more */
2330ebfedea0SLionel Sambuc for (j++; j < EC_NUM; j++)
2331ebfedea0SLionel Sambuc ecdh_doit[j] = 0;
2332ebfedea0SLionel Sambuc }
2333ebfedea0SLionel Sambuc }
2334*0a6a1f1dSLionel Sambuc if (rnd_fake)
2335*0a6a1f1dSLionel Sambuc RAND_cleanup();
2336ebfedea0SLionel Sambuc # endif
2337ebfedea0SLionel Sambuc # ifndef NO_FORK
2338ebfedea0SLionel Sambuc show_res:
2339ebfedea0SLionel Sambuc # endif
2340*0a6a1f1dSLionel Sambuc if (!mr) {
2341ebfedea0SLionel Sambuc fprintf(stdout, "%s\n", SSLeay_version(SSLEAY_VERSION));
2342ebfedea0SLionel Sambuc fprintf(stdout, "%s\n", SSLeay_version(SSLEAY_BUILT_ON));
2343ebfedea0SLionel Sambuc printf("options:");
2344ebfedea0SLionel Sambuc printf("%s ", BN_options());
2345ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_MD2
2346ebfedea0SLionel Sambuc printf("%s ", MD2_options());
2347ebfedea0SLionel Sambuc # endif
2348ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RC4
2349ebfedea0SLionel Sambuc printf("%s ", RC4_options());
2350ebfedea0SLionel Sambuc # endif
2351ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DES
2352ebfedea0SLionel Sambuc printf("%s ", DES_options());
2353ebfedea0SLionel Sambuc # endif
2354ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_AES
2355ebfedea0SLionel Sambuc printf("%s ", AES_options());
2356ebfedea0SLionel Sambuc # endif
2357ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_IDEA
2358ebfedea0SLionel Sambuc printf("%s ", idea_options());
2359ebfedea0SLionel Sambuc # endif
2360ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_BF
2361ebfedea0SLionel Sambuc printf("%s ", BF_options());
2362ebfedea0SLionel Sambuc # endif
2363ebfedea0SLionel Sambuc fprintf(stdout, "\n%s\n", SSLeay_version(SSLEAY_CFLAGS));
2364ebfedea0SLionel Sambuc }
2365ebfedea0SLionel Sambuc
2366*0a6a1f1dSLionel Sambuc if (pr_header) {
2367ebfedea0SLionel Sambuc if (mr)
2368ebfedea0SLionel Sambuc fprintf(stdout, "+H");
2369*0a6a1f1dSLionel Sambuc else {
2370*0a6a1f1dSLionel Sambuc fprintf(stdout,
2371*0a6a1f1dSLionel Sambuc "The 'numbers' are in 1000s of bytes per second processed.\n");
2372ebfedea0SLionel Sambuc fprintf(stdout, "type ");
2373ebfedea0SLionel Sambuc }
2374ebfedea0SLionel Sambuc for (j = 0; j < SIZE_NUM; j++)
2375ebfedea0SLionel Sambuc fprintf(stdout, mr ? ":%d" : "%7d bytes", lengths[j]);
2376ebfedea0SLionel Sambuc fprintf(stdout, "\n");
2377ebfedea0SLionel Sambuc }
2378ebfedea0SLionel Sambuc
2379*0a6a1f1dSLionel Sambuc for (k = 0; k < ALGOR_NUM; k++) {
2380*0a6a1f1dSLionel Sambuc if (!doit[k])
2381*0a6a1f1dSLionel Sambuc continue;
2382ebfedea0SLionel Sambuc if (mr)
2383ebfedea0SLionel Sambuc fprintf(stdout, "+F:%d:%s", k, names[k]);
2384ebfedea0SLionel Sambuc else
2385ebfedea0SLionel Sambuc fprintf(stdout, "%-13s", names[k]);
2386*0a6a1f1dSLionel Sambuc for (j = 0; j < SIZE_NUM; j++) {
2387ebfedea0SLionel Sambuc if (results[k][j] > 10000 && !mr)
2388ebfedea0SLionel Sambuc fprintf(stdout, " %11.2fk", results[k][j] / 1e3);
2389ebfedea0SLionel Sambuc else
2390ebfedea0SLionel Sambuc fprintf(stdout, mr ? ":%.2f" : " %11.2f ", results[k][j]);
2391ebfedea0SLionel Sambuc }
2392ebfedea0SLionel Sambuc fprintf(stdout, "\n");
2393ebfedea0SLionel Sambuc }
2394ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
2395ebfedea0SLionel Sambuc j = 1;
2396*0a6a1f1dSLionel Sambuc for (k = 0; k < RSA_NUM; k++) {
2397*0a6a1f1dSLionel Sambuc if (!rsa_doit[k])
2398*0a6a1f1dSLionel Sambuc continue;
2399*0a6a1f1dSLionel Sambuc if (j && !mr) {
2400ebfedea0SLionel Sambuc printf("%18ssign verify sign/s verify/s\n", " ");
2401ebfedea0SLionel Sambuc j = 0;
2402ebfedea0SLionel Sambuc }
2403ebfedea0SLionel Sambuc if (mr)
2404ebfedea0SLionel Sambuc fprintf(stdout, "+F2:%u:%u:%f:%f\n",
2405*0a6a1f1dSLionel Sambuc k, rsa_bits[k], rsa_results[k][0], rsa_results[k][1]);
2406ebfedea0SLionel Sambuc else
2407ebfedea0SLionel Sambuc fprintf(stdout, "rsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
2408ebfedea0SLionel Sambuc rsa_bits[k], rsa_results[k][0], rsa_results[k][1],
2409ebfedea0SLionel Sambuc 1.0 / rsa_results[k][0], 1.0 / rsa_results[k][1]);
2410ebfedea0SLionel Sambuc }
2411ebfedea0SLionel Sambuc # endif
2412ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
2413ebfedea0SLionel Sambuc j = 1;
2414*0a6a1f1dSLionel Sambuc for (k = 0; k < DSA_NUM; k++) {
2415*0a6a1f1dSLionel Sambuc if (!dsa_doit[k])
2416*0a6a1f1dSLionel Sambuc continue;
2417*0a6a1f1dSLionel Sambuc if (j && !mr) {
2418ebfedea0SLionel Sambuc printf("%18ssign verify sign/s verify/s\n", " ");
2419ebfedea0SLionel Sambuc j = 0;
2420ebfedea0SLionel Sambuc }
2421ebfedea0SLionel Sambuc if (mr)
2422ebfedea0SLionel Sambuc fprintf(stdout, "+F3:%u:%u:%f:%f\n",
2423ebfedea0SLionel Sambuc k, dsa_bits[k], dsa_results[k][0], dsa_results[k][1]);
2424ebfedea0SLionel Sambuc else
2425ebfedea0SLionel Sambuc fprintf(stdout, "dsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
2426ebfedea0SLionel Sambuc dsa_bits[k], dsa_results[k][0], dsa_results[k][1],
2427ebfedea0SLionel Sambuc 1.0 / dsa_results[k][0], 1.0 / dsa_results[k][1]);
2428ebfedea0SLionel Sambuc }
2429ebfedea0SLionel Sambuc # endif
2430ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
2431ebfedea0SLionel Sambuc j = 1;
2432*0a6a1f1dSLionel Sambuc for (k = 0; k < EC_NUM; k++) {
2433*0a6a1f1dSLionel Sambuc if (!ecdsa_doit[k])
2434*0a6a1f1dSLionel Sambuc continue;
2435*0a6a1f1dSLionel Sambuc if (j && !mr) {
2436ebfedea0SLionel Sambuc printf("%30ssign verify sign/s verify/s\n", " ");
2437ebfedea0SLionel Sambuc j = 0;
2438ebfedea0SLionel Sambuc }
2439ebfedea0SLionel Sambuc
2440ebfedea0SLionel Sambuc if (mr)
2441ebfedea0SLionel Sambuc fprintf(stdout, "+F4:%u:%u:%f:%f\n",
2442ebfedea0SLionel Sambuc k, test_curves_bits[k],
2443ebfedea0SLionel Sambuc ecdsa_results[k][0], ecdsa_results[k][1]);
2444ebfedea0SLionel Sambuc else
2445ebfedea0SLionel Sambuc fprintf(stdout,
2446ebfedea0SLionel Sambuc "%4u bit ecdsa (%s) %8.4fs %8.4fs %8.1f %8.1f\n",
2447ebfedea0SLionel Sambuc test_curves_bits[k],
2448ebfedea0SLionel Sambuc test_curves_names[k],
2449ebfedea0SLionel Sambuc ecdsa_results[k][0], ecdsa_results[k][1],
2450ebfedea0SLionel Sambuc 1.0 / ecdsa_results[k][0], 1.0 / ecdsa_results[k][1]);
2451ebfedea0SLionel Sambuc }
2452ebfedea0SLionel Sambuc # endif
2453ebfedea0SLionel Sambuc
2454ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
2455ebfedea0SLionel Sambuc j = 1;
2456*0a6a1f1dSLionel Sambuc for (k = 0; k < EC_NUM; k++) {
2457*0a6a1f1dSLionel Sambuc if (!ecdh_doit[k])
2458*0a6a1f1dSLionel Sambuc continue;
2459*0a6a1f1dSLionel Sambuc if (j && !mr) {
2460ebfedea0SLionel Sambuc printf("%30sop op/s\n", " ");
2461ebfedea0SLionel Sambuc j = 0;
2462ebfedea0SLionel Sambuc }
2463ebfedea0SLionel Sambuc if (mr)
2464ebfedea0SLionel Sambuc fprintf(stdout, "+F5:%u:%u:%f:%f\n",
2465ebfedea0SLionel Sambuc k, test_curves_bits[k],
2466ebfedea0SLionel Sambuc ecdh_results[k][0], 1.0 / ecdh_results[k][0]);
2467ebfedea0SLionel Sambuc
2468ebfedea0SLionel Sambuc else
2469ebfedea0SLionel Sambuc fprintf(stdout, "%4u bit ecdh (%s) %8.4fs %8.1f\n",
2470ebfedea0SLionel Sambuc test_curves_bits[k],
2471ebfedea0SLionel Sambuc test_curves_names[k],
2472ebfedea0SLionel Sambuc ecdh_results[k][0], 1.0 / ecdh_results[k][0]);
2473ebfedea0SLionel Sambuc }
2474ebfedea0SLionel Sambuc # endif
2475ebfedea0SLionel Sambuc
2476ebfedea0SLionel Sambuc mret = 0;
2477ebfedea0SLionel Sambuc
2478ebfedea0SLionel Sambuc end:
2479ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
2480*0a6a1f1dSLionel Sambuc if (buf != NULL)
2481*0a6a1f1dSLionel Sambuc OPENSSL_free(buf);
2482*0a6a1f1dSLionel Sambuc if (buf2 != NULL)
2483*0a6a1f1dSLionel Sambuc OPENSSL_free(buf2);
2484ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
2485ebfedea0SLionel Sambuc for (i = 0; i < RSA_NUM; i++)
2486ebfedea0SLionel Sambuc if (rsa_key[i] != NULL)
2487ebfedea0SLionel Sambuc RSA_free(rsa_key[i]);
2488ebfedea0SLionel Sambuc # endif
2489ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
2490ebfedea0SLionel Sambuc for (i = 0; i < DSA_NUM; i++)
2491ebfedea0SLionel Sambuc if (dsa_key[i] != NULL)
2492ebfedea0SLionel Sambuc DSA_free(dsa_key[i]);
2493ebfedea0SLionel Sambuc # endif
2494ebfedea0SLionel Sambuc
2495ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
2496ebfedea0SLionel Sambuc for (i = 0; i < EC_NUM; i++)
2497ebfedea0SLionel Sambuc if (ecdsa[i] != NULL)
2498ebfedea0SLionel Sambuc EC_KEY_free(ecdsa[i]);
2499ebfedea0SLionel Sambuc # endif
2500ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
2501*0a6a1f1dSLionel Sambuc for (i = 0; i < EC_NUM; i++) {
2502ebfedea0SLionel Sambuc if (ecdh_a[i] != NULL)
2503ebfedea0SLionel Sambuc EC_KEY_free(ecdh_a[i]);
2504ebfedea0SLionel Sambuc if (ecdh_b[i] != NULL)
2505ebfedea0SLionel Sambuc EC_KEY_free(ecdh_b[i]);
2506ebfedea0SLionel Sambuc }
2507ebfedea0SLionel Sambuc # endif
2508ebfedea0SLionel Sambuc
2509ebfedea0SLionel Sambuc apps_shutdown();
2510ebfedea0SLionel Sambuc OPENSSL_EXIT(mret);
2511ebfedea0SLionel Sambuc }
2512ebfedea0SLionel Sambuc
print_message(const char * s,long num,int length)2513ebfedea0SLionel Sambuc static void print_message(const char *s, long num, int length)
2514ebfedea0SLionel Sambuc {
2515ebfedea0SLionel Sambuc # ifdef SIGALRM
2516*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2517*0a6a1f1dSLionel Sambuc mr ? "+DT:%s:%d:%d\n"
2518ebfedea0SLionel Sambuc : "Doing %s for %ds on %d size blocks: ", s, SECONDS, length);
2519ebfedea0SLionel Sambuc (void)BIO_flush(bio_err);
2520ebfedea0SLionel Sambuc alarm(SECONDS);
2521ebfedea0SLionel Sambuc # else
2522*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2523*0a6a1f1dSLionel Sambuc mr ? "+DN:%s:%ld:%d\n"
2524ebfedea0SLionel Sambuc : "Doing %s %ld times on %d size blocks: ", s, num, length);
2525ebfedea0SLionel Sambuc (void)BIO_flush(bio_err);
2526ebfedea0SLionel Sambuc # endif
2527ebfedea0SLionel Sambuc # ifdef LINT
2528ebfedea0SLionel Sambuc num = num;
2529ebfedea0SLionel Sambuc # endif
2530ebfedea0SLionel Sambuc }
2531ebfedea0SLionel Sambuc
pkey_print_message(const char * str,const char * str2,long num,int bits,int tm)2532ebfedea0SLionel Sambuc static void pkey_print_message(const char *str, const char *str2, long num,
2533ebfedea0SLionel Sambuc int bits, int tm)
2534ebfedea0SLionel Sambuc {
2535ebfedea0SLionel Sambuc # ifdef SIGALRM
2536*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2537*0a6a1f1dSLionel Sambuc mr ? "+DTP:%d:%s:%s:%d\n"
2538ebfedea0SLionel Sambuc : "Doing %d bit %s %s's for %ds: ", bits, str, str2, tm);
2539ebfedea0SLionel Sambuc (void)BIO_flush(bio_err);
2540ebfedea0SLionel Sambuc alarm(tm);
2541ebfedea0SLionel Sambuc # else
2542*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2543*0a6a1f1dSLionel Sambuc mr ? "+DNP:%ld:%d:%s:%s\n"
2544ebfedea0SLionel Sambuc : "Doing %ld %d bit %s %s's: ", num, bits, str, str2);
2545ebfedea0SLionel Sambuc (void)BIO_flush(bio_err);
2546ebfedea0SLionel Sambuc # endif
2547ebfedea0SLionel Sambuc # ifdef LINT
2548ebfedea0SLionel Sambuc num = num;
2549ebfedea0SLionel Sambuc # endif
2550ebfedea0SLionel Sambuc }
2551ebfedea0SLionel Sambuc
print_result(int alg,int run_no,int count,double time_used)2552ebfedea0SLionel Sambuc static void print_result(int alg, int run_no, int count, double time_used)
2553ebfedea0SLionel Sambuc {
2554*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
2555*0a6a1f1dSLionel Sambuc mr ? "+R:%d:%s:%f\n"
2556ebfedea0SLionel Sambuc : "%d %s's in %.2fs\n", count, names[alg], time_used);
2557ebfedea0SLionel Sambuc results[alg][run_no] = ((double)count) / time_used * lengths[run_no];
2558ebfedea0SLionel Sambuc }
2559ebfedea0SLionel Sambuc
2560ebfedea0SLionel Sambuc # ifndef NO_FORK
sstrsep(char ** string,const char * delim)2561ebfedea0SLionel Sambuc static char *sstrsep(char **string, const char *delim)
2562ebfedea0SLionel Sambuc {
2563ebfedea0SLionel Sambuc char isdelim[256];
2564ebfedea0SLionel Sambuc char *token = *string;
2565ebfedea0SLionel Sambuc
2566ebfedea0SLionel Sambuc if (**string == 0)
2567ebfedea0SLionel Sambuc return NULL;
2568ebfedea0SLionel Sambuc
2569ebfedea0SLionel Sambuc memset(isdelim, 0, sizeof isdelim);
2570ebfedea0SLionel Sambuc isdelim[0] = 1;
2571ebfedea0SLionel Sambuc
2572*0a6a1f1dSLionel Sambuc while (*delim) {
2573ebfedea0SLionel Sambuc isdelim[(unsigned char)(*delim)] = 1;
2574ebfedea0SLionel Sambuc delim++;
2575ebfedea0SLionel Sambuc }
2576ebfedea0SLionel Sambuc
2577*0a6a1f1dSLionel Sambuc while (!isdelim[(unsigned char)(**string)]) {
2578ebfedea0SLionel Sambuc (*string)++;
2579ebfedea0SLionel Sambuc }
2580ebfedea0SLionel Sambuc
2581*0a6a1f1dSLionel Sambuc if (**string) {
2582ebfedea0SLionel Sambuc **string = 0;
2583ebfedea0SLionel Sambuc (*string)++;
2584ebfedea0SLionel Sambuc }
2585ebfedea0SLionel Sambuc
2586ebfedea0SLionel Sambuc return token;
2587ebfedea0SLionel Sambuc }
2588ebfedea0SLionel Sambuc
do_multi(int multi)2589ebfedea0SLionel Sambuc static int do_multi(int multi)
2590ebfedea0SLionel Sambuc {
2591ebfedea0SLionel Sambuc int n;
2592ebfedea0SLionel Sambuc int fd[2];
2593ebfedea0SLionel Sambuc int *fds;
2594ebfedea0SLionel Sambuc static char sep[] = ":";
2595ebfedea0SLionel Sambuc
2596ebfedea0SLionel Sambuc fds = malloc(multi * sizeof *fds);
2597*0a6a1f1dSLionel Sambuc for (n = 0; n < multi; ++n) {
2598*0a6a1f1dSLionel Sambuc if (pipe(fd) == -1) {
2599ebfedea0SLionel Sambuc fprintf(stderr, "pipe failure\n");
2600ebfedea0SLionel Sambuc exit(1);
2601ebfedea0SLionel Sambuc }
2602ebfedea0SLionel Sambuc fflush(stdout);
2603ebfedea0SLionel Sambuc fflush(stderr);
2604*0a6a1f1dSLionel Sambuc if (fork()) {
2605ebfedea0SLionel Sambuc close(fd[1]);
2606ebfedea0SLionel Sambuc fds[n] = fd[0];
2607*0a6a1f1dSLionel Sambuc } else {
2608ebfedea0SLionel Sambuc close(fd[0]);
2609ebfedea0SLionel Sambuc close(1);
2610*0a6a1f1dSLionel Sambuc if (dup(fd[1]) == -1) {
2611ebfedea0SLionel Sambuc fprintf(stderr, "dup failed\n");
2612ebfedea0SLionel Sambuc exit(1);
2613ebfedea0SLionel Sambuc }
2614ebfedea0SLionel Sambuc close(fd[1]);
2615ebfedea0SLionel Sambuc mr = 1;
2616ebfedea0SLionel Sambuc usertime = 0;
2617ebfedea0SLionel Sambuc free(fds);
2618ebfedea0SLionel Sambuc return 0;
2619ebfedea0SLionel Sambuc }
2620ebfedea0SLionel Sambuc printf("Forked child %d\n", n);
2621ebfedea0SLionel Sambuc }
2622ebfedea0SLionel Sambuc
2623ebfedea0SLionel Sambuc /* for now, assume the pipe is long enough to take all the output */
2624*0a6a1f1dSLionel Sambuc for (n = 0; n < multi; ++n) {
2625ebfedea0SLionel Sambuc FILE *f;
2626ebfedea0SLionel Sambuc char buf[1024];
2627ebfedea0SLionel Sambuc char *p;
2628ebfedea0SLionel Sambuc
2629ebfedea0SLionel Sambuc f = fdopen(fds[n], "r");
2630*0a6a1f1dSLionel Sambuc while (fgets(buf, sizeof buf, f)) {
2631ebfedea0SLionel Sambuc p = strchr(buf, '\n');
2632ebfedea0SLionel Sambuc if (p)
2633ebfedea0SLionel Sambuc *p = '\0';
2634*0a6a1f1dSLionel Sambuc if (buf[0] != '+') {
2635ebfedea0SLionel Sambuc fprintf(stderr, "Don't understand line '%s' from child %d\n",
2636ebfedea0SLionel Sambuc buf, n);
2637ebfedea0SLionel Sambuc continue;
2638ebfedea0SLionel Sambuc }
2639ebfedea0SLionel Sambuc printf("Got: %s from %d\n", buf, n);
2640*0a6a1f1dSLionel Sambuc if (!strncmp(buf, "+F:", 3)) {
2641ebfedea0SLionel Sambuc int alg;
2642ebfedea0SLionel Sambuc int j;
2643ebfedea0SLionel Sambuc
2644ebfedea0SLionel Sambuc p = buf + 3;
2645ebfedea0SLionel Sambuc alg = atoi(sstrsep(&p, sep));
2646ebfedea0SLionel Sambuc sstrsep(&p, sep);
2647ebfedea0SLionel Sambuc for (j = 0; j < SIZE_NUM; ++j)
2648ebfedea0SLionel Sambuc results[alg][j] += atof(sstrsep(&p, sep));
2649*0a6a1f1dSLionel Sambuc } else if (!strncmp(buf, "+F2:", 4)) {
2650ebfedea0SLionel Sambuc int k;
2651ebfedea0SLionel Sambuc double d;
2652ebfedea0SLionel Sambuc
2653ebfedea0SLionel Sambuc p = buf + 4;
2654ebfedea0SLionel Sambuc k = atoi(sstrsep(&p, sep));
2655ebfedea0SLionel Sambuc sstrsep(&p, sep);
2656ebfedea0SLionel Sambuc
2657ebfedea0SLionel Sambuc d = atof(sstrsep(&p, sep));
2658ebfedea0SLionel Sambuc if (n)
2659ebfedea0SLionel Sambuc rsa_results[k][0] = 1 / (1 / rsa_results[k][0] + 1 / d);
2660ebfedea0SLionel Sambuc else
2661ebfedea0SLionel Sambuc rsa_results[k][0] = d;
2662ebfedea0SLionel Sambuc
2663ebfedea0SLionel Sambuc d = atof(sstrsep(&p, sep));
2664ebfedea0SLionel Sambuc if (n)
2665ebfedea0SLionel Sambuc rsa_results[k][1] = 1 / (1 / rsa_results[k][1] + 1 / d);
2666ebfedea0SLionel Sambuc else
2667ebfedea0SLionel Sambuc rsa_results[k][1] = d;
2668ebfedea0SLionel Sambuc }
2669ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
2670*0a6a1f1dSLionel Sambuc else if (!strncmp(buf, "+F3:", 4)) {
2671ebfedea0SLionel Sambuc int k;
2672ebfedea0SLionel Sambuc double d;
2673ebfedea0SLionel Sambuc
2674ebfedea0SLionel Sambuc p = buf + 4;
2675ebfedea0SLionel Sambuc k = atoi(sstrsep(&p, sep));
2676ebfedea0SLionel Sambuc sstrsep(&p, sep);
2677ebfedea0SLionel Sambuc
2678ebfedea0SLionel Sambuc d = atof(sstrsep(&p, sep));
2679ebfedea0SLionel Sambuc if (n)
2680ebfedea0SLionel Sambuc dsa_results[k][0] = 1 / (1 / dsa_results[k][0] + 1 / d);
2681ebfedea0SLionel Sambuc else
2682ebfedea0SLionel Sambuc dsa_results[k][0] = d;
2683ebfedea0SLionel Sambuc
2684ebfedea0SLionel Sambuc d = atof(sstrsep(&p, sep));
2685ebfedea0SLionel Sambuc if (n)
2686ebfedea0SLionel Sambuc dsa_results[k][1] = 1 / (1 / dsa_results[k][1] + 1 / d);
2687ebfedea0SLionel Sambuc else
2688ebfedea0SLionel Sambuc dsa_results[k][1] = d;
2689ebfedea0SLionel Sambuc }
2690ebfedea0SLionel Sambuc # endif
2691ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDSA
2692*0a6a1f1dSLionel Sambuc else if (!strncmp(buf, "+F4:", 4)) {
2693ebfedea0SLionel Sambuc int k;
2694ebfedea0SLionel Sambuc double d;
2695ebfedea0SLionel Sambuc
2696ebfedea0SLionel Sambuc p = buf + 4;
2697ebfedea0SLionel Sambuc k = atoi(sstrsep(&p, sep));
2698ebfedea0SLionel Sambuc sstrsep(&p, sep);
2699ebfedea0SLionel Sambuc
2700ebfedea0SLionel Sambuc d = atof(sstrsep(&p, sep));
2701ebfedea0SLionel Sambuc if (n)
2702*0a6a1f1dSLionel Sambuc ecdsa_results[k][0] =
2703*0a6a1f1dSLionel Sambuc 1 / (1 / ecdsa_results[k][0] + 1 / d);
2704ebfedea0SLionel Sambuc else
2705ebfedea0SLionel Sambuc ecdsa_results[k][0] = d;
2706ebfedea0SLionel Sambuc
2707ebfedea0SLionel Sambuc d = atof(sstrsep(&p, sep));
2708ebfedea0SLionel Sambuc if (n)
2709*0a6a1f1dSLionel Sambuc ecdsa_results[k][1] =
2710*0a6a1f1dSLionel Sambuc 1 / (1 / ecdsa_results[k][1] + 1 / d);
2711ebfedea0SLionel Sambuc else
2712ebfedea0SLionel Sambuc ecdsa_results[k][1] = d;
2713ebfedea0SLionel Sambuc }
2714ebfedea0SLionel Sambuc # endif
2715ebfedea0SLionel Sambuc
2716ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ECDH
2717*0a6a1f1dSLionel Sambuc else if (!strncmp(buf, "+F5:", 4)) {
2718ebfedea0SLionel Sambuc int k;
2719ebfedea0SLionel Sambuc double d;
2720ebfedea0SLionel Sambuc
2721ebfedea0SLionel Sambuc p = buf + 4;
2722ebfedea0SLionel Sambuc k = atoi(sstrsep(&p, sep));
2723ebfedea0SLionel Sambuc sstrsep(&p, sep);
2724ebfedea0SLionel Sambuc
2725ebfedea0SLionel Sambuc d = atof(sstrsep(&p, sep));
2726ebfedea0SLionel Sambuc if (n)
2727ebfedea0SLionel Sambuc ecdh_results[k][0] = 1 / (1 / ecdh_results[k][0] + 1 / d);
2728ebfedea0SLionel Sambuc else
2729ebfedea0SLionel Sambuc ecdh_results[k][0] = d;
2730ebfedea0SLionel Sambuc
2731ebfedea0SLionel Sambuc }
2732ebfedea0SLionel Sambuc # endif
2733ebfedea0SLionel Sambuc
2734*0a6a1f1dSLionel Sambuc else if (!strncmp(buf, "+H:", 3)) {
2735*0a6a1f1dSLionel Sambuc } else
2736ebfedea0SLionel Sambuc fprintf(stderr, "Unknown type '%s' from child %d\n", buf, n);
2737ebfedea0SLionel Sambuc }
2738ebfedea0SLionel Sambuc
2739ebfedea0SLionel Sambuc fclose(f);
2740ebfedea0SLionel Sambuc }
2741ebfedea0SLionel Sambuc free(fds);
2742ebfedea0SLionel Sambuc return 1;
2743ebfedea0SLionel Sambuc }
2744ebfedea0SLionel Sambuc # endif
2745ebfedea0SLionel Sambuc #endif
2746