1*fab492f1Stb /* $OpenBSD: speed.c,v 1.41 2025/01/02 13:37:43 tb Exp $ */ 2dab3f910Sjsing /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3dab3f910Sjsing * All rights reserved. 4dab3f910Sjsing * 5dab3f910Sjsing * This package is an SSL implementation written 6dab3f910Sjsing * by Eric Young (eay@cryptsoft.com). 7dab3f910Sjsing * The implementation was written so as to conform with Netscapes SSL. 8dab3f910Sjsing * 9dab3f910Sjsing * This library is free for commercial and non-commercial use as long as 10dab3f910Sjsing * the following conditions are aheared to. The following conditions 11dab3f910Sjsing * apply to all code found in this distribution, be it the RC4, RSA, 12dab3f910Sjsing * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13dab3f910Sjsing * included with this distribution is covered by the same copyright terms 14dab3f910Sjsing * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15dab3f910Sjsing * 16dab3f910Sjsing * Copyright remains Eric Young's, and as such any Copyright notices in 17dab3f910Sjsing * the code are not to be removed. 18dab3f910Sjsing * If this package is used in a product, Eric Young should be given attribution 19dab3f910Sjsing * as the author of the parts of the library used. 20dab3f910Sjsing * This can be in the form of a textual message at program startup or 21dab3f910Sjsing * in documentation (online or textual) provided with the package. 22dab3f910Sjsing * 23dab3f910Sjsing * Redistribution and use in source and binary forms, with or without 24dab3f910Sjsing * modification, are permitted provided that the following conditions 25dab3f910Sjsing * are met: 26dab3f910Sjsing * 1. Redistributions of source code must retain the copyright 27dab3f910Sjsing * notice, this list of conditions and the following disclaimer. 28dab3f910Sjsing * 2. Redistributions in binary form must reproduce the above copyright 29dab3f910Sjsing * notice, this list of conditions and the following disclaimer in the 30dab3f910Sjsing * documentation and/or other materials provided with the distribution. 31dab3f910Sjsing * 3. All advertising materials mentioning features or use of this software 32dab3f910Sjsing * must display the following acknowledgement: 33dab3f910Sjsing * "This product includes cryptographic software written by 34dab3f910Sjsing * Eric Young (eay@cryptsoft.com)" 35dab3f910Sjsing * The word 'cryptographic' can be left out if the rouines from the library 36dab3f910Sjsing * being used are not cryptographic related :-). 37dab3f910Sjsing * 4. If you include any Windows specific code (or a derivative thereof) from 38dab3f910Sjsing * the apps directory (application code) you must include an acknowledgement: 39dab3f910Sjsing * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40dab3f910Sjsing * 41dab3f910Sjsing * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42dab3f910Sjsing * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43dab3f910Sjsing * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44dab3f910Sjsing * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45dab3f910Sjsing * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46dab3f910Sjsing * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47dab3f910Sjsing * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48dab3f910Sjsing * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49dab3f910Sjsing * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50dab3f910Sjsing * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51dab3f910Sjsing * SUCH DAMAGE. 52dab3f910Sjsing * 53dab3f910Sjsing * The licence and distribution terms for any publically available version or 54dab3f910Sjsing * derivative of this code cannot be changed. i.e. this code cannot simply be 55dab3f910Sjsing * copied and put under another distribution licence 56dab3f910Sjsing * [including the GNU Public Licence.] 57dab3f910Sjsing */ 58dab3f910Sjsing /* ==================================================================== 59dab3f910Sjsing * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 60dab3f910Sjsing * 61dab3f910Sjsing * Portions of the attached software ("Contribution") are developed by 62dab3f910Sjsing * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. 63dab3f910Sjsing * 64dab3f910Sjsing * The Contribution is licensed pursuant to the OpenSSL open source 65dab3f910Sjsing * license provided above. 66dab3f910Sjsing * 67dab3f910Sjsing * The ECDH and ECDSA speed test software is originally written by 68dab3f910Sjsing * Sumit Gupta of Sun Microsystems Laboratories. 69dab3f910Sjsing * 70dab3f910Sjsing */ 71dab3f910Sjsing 72dab3f910Sjsing /* most of this code has been pilfered from my libdes speed.c program */ 73dab3f910Sjsing 74dab3f910Sjsing #ifndef OPENSSL_NO_SPEED 75dab3f910Sjsing 76dab3f910Sjsing #define SECONDS 3 77dab3f910Sjsing #define RSA_SECONDS 10 78dab3f910Sjsing #define DSA_SECONDS 10 79dab3f910Sjsing #define ECDSA_SECONDS 10 80dab3f910Sjsing #define ECDH_SECONDS 10 81dab3f910Sjsing 821aa981a4Stb #define MAX_UNALIGN 16 831aa981a4Stb 84dab3f910Sjsing #include <math.h> 85dab3f910Sjsing #include <signal.h> 86dab3f910Sjsing #include <stdio.h> 87dab3f910Sjsing #include <stdlib.h> 88dab3f910Sjsing #include <limits.h> 89dab3f910Sjsing #include <string.h> 90dab3f910Sjsing #include <unistd.h> 91dab3f910Sjsing 92dab3f910Sjsing #include "apps.h" 93dab3f910Sjsing 94dab3f910Sjsing #include <openssl/bn.h> 95dab3f910Sjsing #include <openssl/crypto.h> 96dab3f910Sjsing #include <openssl/err.h> 97dab3f910Sjsing #include <openssl/evp.h> 98dab3f910Sjsing #include <openssl/modes.h> 99dab3f910Sjsing #include <openssl/objects.h> 100dab3f910Sjsing #include <openssl/x509.h> 101dab3f910Sjsing 102dab3f910Sjsing #ifndef OPENSSL_NO_AES 103dab3f910Sjsing #include <openssl/aes.h> 104dab3f910Sjsing #endif 105dab3f910Sjsing #ifndef OPENSSL_NO_BF 106dab3f910Sjsing #include <openssl/blowfish.h> 107dab3f910Sjsing #endif 108dab3f910Sjsing #ifndef OPENSSL_NO_CAST 109dab3f910Sjsing #include <openssl/cast.h> 110dab3f910Sjsing #endif 111dab3f910Sjsing #ifndef OPENSSL_NO_CAMELLIA 112dab3f910Sjsing #include <openssl/camellia.h> 113dab3f910Sjsing #endif 114dab3f910Sjsing #ifndef OPENSSL_NO_DES 115dab3f910Sjsing #include <openssl/des.h> 116dab3f910Sjsing #endif 117dab3f910Sjsing #include <openssl/dsa.h> 118dab3f910Sjsing #include <openssl/ecdh.h> 119dab3f910Sjsing #include <openssl/ecdsa.h> 120dab3f910Sjsing #ifndef OPENSSL_NO_HMAC 121dab3f910Sjsing #include <openssl/hmac.h> 122dab3f910Sjsing #endif 123dab3f910Sjsing #ifndef OPENSSL_NO_IDEA 124dab3f910Sjsing #include <openssl/idea.h> 125dab3f910Sjsing #endif 12600b7ba7eSdoug #ifndef OPENSSL_NO_MD4 12700b7ba7eSdoug #include <openssl/md4.h> 12800b7ba7eSdoug #endif 129dab3f910Sjsing #ifndef OPENSSL_NO_MD5 130dab3f910Sjsing #include <openssl/md5.h> 131dab3f910Sjsing #endif 132dab3f910Sjsing #ifndef OPENSSL_NO_RC2 133dab3f910Sjsing #include <openssl/rc2.h> 134dab3f910Sjsing #endif 135dab3f910Sjsing #ifndef OPENSSL_NO_RC4 136dab3f910Sjsing #include <openssl/rc4.h> 137dab3f910Sjsing #endif 138dab3f910Sjsing #include <openssl/rsa.h> 139dab3f910Sjsing #ifndef OPENSSL_NO_RIPEMD 140dab3f910Sjsing #include <openssl/ripemd.h> 141dab3f910Sjsing #endif 142dab3f910Sjsing #ifndef OPENSSL_NO_SHA 143dab3f910Sjsing #include <openssl/sha.h> 144dab3f910Sjsing #endif 145dab3f910Sjsing #ifndef OPENSSL_NO_WHIRLPOOL 146dab3f910Sjsing #include <openssl/whrlpool.h> 147dab3f910Sjsing #endif 148dab3f910Sjsing 149fb93d8bbSbcook #define BUFSIZE (1024*8+64) 1509a1b6330Sderaadt volatile sig_atomic_t run; 151dab3f910Sjsing 152dab3f910Sjsing static int mr = 0; 153dab3f910Sjsing static int usertime = 1; 154dab3f910Sjsing 155dab3f910Sjsing static double Time_F(int s); 156dab3f910Sjsing static void print_message(const char *s, long num, int length); 157dab3f910Sjsing static void 158dab3f910Sjsing pkey_print_message(const char *str, const char *str2, 159dab3f910Sjsing long num, int bits, int sec); 160dab3f910Sjsing static void print_result(int alg, int run_no, int count, double time_used); 161dab3f910Sjsing static int do_multi(int multi); 162dab3f910Sjsing 163922ac556Smiod #define ALGOR_NUM 32 164dab3f910Sjsing #define SIZE_NUM 5 165dab3f910Sjsing #define RSA_NUM 4 166dab3f910Sjsing #define DSA_NUM 3 167dab3f910Sjsing 168ee8ccd1fStb #define EC_NUM 4 169dab3f910Sjsing #define MAX_ECDH_SIZE 256 170dab3f910Sjsing 171dab3f910Sjsing static const char *names[ALGOR_NUM] = { 172922ac556Smiod "md2", "md4", "md5", "hmac(md5)", "sha1", "rmd160", 173352ab555Smiod "rc4", "des cbc", "des ede3", "idea cbc", "seed cbc", 174dab3f910Sjsing "rc2 cbc", "rc5-32/12 cbc", "blowfish cbc", "cast cbc", 175dab3f910Sjsing "aes-128 cbc", "aes-192 cbc", "aes-256 cbc", 176dab3f910Sjsing "camellia-128 cbc", "camellia-192 cbc", "camellia-256 cbc", 177dab3f910Sjsing "evp", "sha256", "sha512", "whirlpool", 178fb93d8bbSbcook "aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash", 179fb93d8bbSbcook "aes-128 gcm", "aes-256 gcm", "chacha20 poly1305", 180fb93d8bbSbcook }; 181dab3f910Sjsing static double results[ALGOR_NUM][SIZE_NUM]; 182dab3f910Sjsing static int lengths[SIZE_NUM] = {16, 64, 256, 1024, 8 * 1024}; 183dab3f910Sjsing static double rsa_results[RSA_NUM][2]; 184dab3f910Sjsing static double dsa_results[DSA_NUM][2]; 185dab3f910Sjsing static double ecdsa_results[EC_NUM][2]; 186dab3f910Sjsing static double ecdh_results[EC_NUM][1]; 187dab3f910Sjsing 188dab3f910Sjsing static void sig_done(int sig); 189dab3f910Sjsing 190*fab492f1Stb static DSA * 191*fab492f1Stb get_dsa(const unsigned char *priv, size_t priv_size, 192*fab492f1Stb const unsigned char *pub, size_t pub_size, 193*fab492f1Stb const unsigned char *p_char, size_t p_size, 194*fab492f1Stb const unsigned char *q_char, size_t q_size, 195*fab492f1Stb const unsigned char *g_char, size_t g_size) 196*fab492f1Stb { 197*fab492f1Stb DSA *dsa; 198*fab492f1Stb BIGNUM *priv_key = NULL, *pub_key = NULL; 199*fab492f1Stb BIGNUM *p = NULL, *q = NULL, *g = NULL; 200*fab492f1Stb 201*fab492f1Stb if ((dsa = DSA_new()) == NULL) 202*fab492f1Stb return (NULL); 203*fab492f1Stb 204*fab492f1Stb priv_key = BN_bin2bn(priv, priv_size, NULL); 205*fab492f1Stb pub_key = BN_bin2bn(pub, pub_size, NULL); 206*fab492f1Stb if (priv_key == NULL || pub_key == NULL) 207*fab492f1Stb goto err; 208*fab492f1Stb 209*fab492f1Stb if (!DSA_set0_key(dsa, pub_key, priv_key)) 210*fab492f1Stb goto err; 211*fab492f1Stb pub_key = NULL; 212*fab492f1Stb priv_key = NULL; 213*fab492f1Stb 214*fab492f1Stb p = BN_bin2bn(p_char, p_size, NULL); 215*fab492f1Stb q = BN_bin2bn(q_char, q_size, NULL); 216*fab492f1Stb g = BN_bin2bn(g_char, g_size, NULL); 217*fab492f1Stb if (p == NULL || q == NULL || g == NULL) 218*fab492f1Stb goto err; 219*fab492f1Stb 220*fab492f1Stb if (!DSA_set0_pqg(dsa, p, q, g)) 221*fab492f1Stb goto err; 222*fab492f1Stb p = NULL; 223*fab492f1Stb q = NULL; 224*fab492f1Stb g = NULL; 225*fab492f1Stb 226*fab492f1Stb return dsa; 227*fab492f1Stb 228*fab492f1Stb err: 229*fab492f1Stb DSA_free(dsa); 230*fab492f1Stb BN_free(priv_key); 231*fab492f1Stb BN_free(pub_key); 232*fab492f1Stb BN_free(p); 233*fab492f1Stb BN_free(q); 234*fab492f1Stb BN_free(g); 235*fab492f1Stb 236*fab492f1Stb return NULL; 237*fab492f1Stb } 238*fab492f1Stb 239*fab492f1Stb 240*fab492f1Stb static const unsigned char dsa512_priv[] = { 241*fab492f1Stb 0x65, 0xe5, 0xc7, 0x38, 0x60, 0x24, 0xb5, 0x89, 0xd4, 0x9c, 0xeb, 0x4c, 242*fab492f1Stb 0x9c, 0x1d, 0x7a, 0x22, 0xbd, 0xd1, 0xc2, 0xd2, 243*fab492f1Stb }; 244*fab492f1Stb 245*fab492f1Stb static const unsigned char dsa512_pub[] = { 246*fab492f1Stb 0x00, 0x95, 0xa7, 0x0d, 0xec, 0x93, 0x68, 0xba, 0x5f, 0xf7, 0x5f, 0x07, 247*fab492f1Stb 0xf2, 0x3b, 0xad, 0x6b, 0x01, 0xdc, 0xbe, 0xec, 0xde, 0x04, 0x7a, 0x3a, 248*fab492f1Stb 0x27, 0xb3, 0xec, 0x49, 0xfd, 0x08, 0x43, 0x3d, 0x7e, 0xa8, 0x2c, 0x5e, 249*fab492f1Stb 0x7b, 0xbb, 0xfc, 0xf4, 0x6e, 0xeb, 0x6c, 0xb0, 0x6e, 0xf8, 0x02, 0x12, 250*fab492f1Stb 0x8c, 0x38, 0x5d, 0x83, 0x56, 0x7d, 0xee, 0x53, 0x05, 0x3e, 0x24, 0x84, 251*fab492f1Stb 0xbe, 0xba, 0x0a, 0x6b, 0xc8, 252*fab492f1Stb }; 253*fab492f1Stb 254*fab492f1Stb static const unsigned char dsa512_p[] = { 255*fab492f1Stb 0x9D, 0x1B, 0x69, 0x8E, 0x26, 0xDB, 0xF2, 0x2B, 0x11, 0x70, 0x19, 0x86, 256*fab492f1Stb 0xF6, 0x19, 0xC8, 0xF8, 0x19, 0xF2, 0x18, 0x53, 0x94, 0x46, 0x06, 0xD0, 257*fab492f1Stb 0x62, 0x50, 0x33, 0x4B, 0x02, 0x3C, 0x52, 0x30, 0x03, 0x8B, 0x3B, 0xF9, 258*fab492f1Stb 0x5F, 0xD1, 0x24, 0x06, 0x4F, 0x7B, 0x4C, 0xBA, 0xAA, 0x40, 0x9B, 0xFD, 259*fab492f1Stb 0x96, 0xE4, 0x37, 0x33, 0xBB, 0x2D, 0x5A, 0xD7, 0x5A, 0x11, 0x40, 0x66, 260*fab492f1Stb 0xA2, 0x76, 0x7D, 0x31, 261*fab492f1Stb }; 262*fab492f1Stb 263*fab492f1Stb static const unsigned char dsa512_q[] = { 264*fab492f1Stb 0xFB, 0x53, 0xEF, 0x50, 0xB4, 0x40, 0x92, 0x31, 0x56, 0x86, 0x53, 0x7A, 265*fab492f1Stb 0xE8, 0x8B, 0x22, 0x9A, 0x49, 0xFB, 0x71, 0x8F, 266*fab492f1Stb }; 267*fab492f1Stb 268*fab492f1Stb static const unsigned char dsa512_g[] = { 269*fab492f1Stb 0x83, 0x3E, 0x88, 0xE5, 0xC5, 0x89, 0x73, 0xCE, 0x3B, 0x6C, 0x01, 0x49, 270*fab492f1Stb 0xBF, 0xB3, 0xC7, 0x9F, 0x0A, 0xEA, 0x44, 0x91, 0xE5, 0x30, 0xAA, 0xD9, 271*fab492f1Stb 0xBE, 0x5B, 0x5F, 0xB7, 0x10, 0xD7, 0x89, 0xB7, 0x8E, 0x74, 0xFB, 0xCF, 272*fab492f1Stb 0x29, 0x1E, 0xEB, 0xA8, 0x2C, 0x54, 0x51, 0xB8, 0x10, 0xDE, 0xA0, 0xCE, 273*fab492f1Stb 0x2F, 0xCC, 0x24, 0x6B, 0x90, 0x77, 0xDE, 0xA2, 0x68, 0xA6, 0x52, 0x12, 274*fab492f1Stb 0xA2, 0x03, 0x9D, 0x20, 275*fab492f1Stb }; 276*fab492f1Stb 277*fab492f1Stb static DSA * 278*fab492f1Stb get_dsa512(void) 279*fab492f1Stb { 280*fab492f1Stb return get_dsa(dsa512_priv, sizeof(dsa512_priv), 281*fab492f1Stb dsa512_pub, sizeof(dsa512_pub), dsa512_p, sizeof(dsa512_p), 282*fab492f1Stb dsa512_q, sizeof(dsa512_q), dsa512_g, sizeof(dsa512_g)); 283*fab492f1Stb } 284*fab492f1Stb 285*fab492f1Stb static const unsigned char dsa1024_priv[] = { 286*fab492f1Stb 0x7d, 0x21, 0xda, 0xbb, 0x62, 0x15, 0x47, 0x36, 0x07, 0x67, 0x12, 0xe8, 287*fab492f1Stb 0x8c, 0xaa, 0x1c, 0xcd, 0x38, 0x12, 0x61, 0x18, 288*fab492f1Stb }; 289*fab492f1Stb 290*fab492f1Stb static const unsigned char dsa1024_pub[] = { 291*fab492f1Stb 0x3c, 0x4e, 0x9c, 0x2a, 0x7f, 0x16, 0xc1, 0x25, 0xeb, 0xac, 0x78, 0x63, 292*fab492f1Stb 0x90, 0x14, 0x8c, 0x8b, 0xf4, 0x68, 0x43, 0x3c, 0x2d, 0xee, 0x65, 0x50, 293*fab492f1Stb 0x7d, 0x9c, 0x8f, 0x8c, 0x8a, 0x51, 0xd6, 0x11, 0x2b, 0x99, 0xaf, 0x1e, 294*fab492f1Stb 0x90, 0x97, 0xb5, 0xd3, 0xa6, 0x20, 0x25, 0xd6, 0xfe, 0x43, 0x02, 0xd5, 295*fab492f1Stb 0x91, 0x7d, 0xa7, 0x8c, 0xdb, 0xc9, 0x85, 0xa3, 0x36, 0x48, 0xf7, 0x68, 296*fab492f1Stb 0xaa, 0x60, 0xb1, 0xf7, 0x05, 0x68, 0x3a, 0xa3, 0x3f, 0xd3, 0x19, 0x82, 297*fab492f1Stb 0xd8, 0x82, 0x7a, 0x77, 0xfb, 0xef, 0xf4, 0x15, 0x0a, 0xeb, 0x06, 0x04, 298*fab492f1Stb 0x7f, 0x53, 0x07, 0x0c, 0xbc, 0xcb, 0x2d, 0x83, 0xdb, 0x3e, 0xd1, 0x28, 299*fab492f1Stb 0xa5, 0xa1, 0x31, 0xe0, 0x67, 0xfa, 0x50, 0xde, 0x9b, 0x07, 0x83, 0x7e, 300*fab492f1Stb 0x2c, 0x0b, 0xc3, 0x13, 0x50, 0x61, 0xe5, 0xad, 0xbd, 0x36, 0xb8, 0x97, 301*fab492f1Stb 0x4e, 0x40, 0x7d, 0xe8, 0x83, 0x0d, 0xbc, 0x4b 302*fab492f1Stb }; 303*fab492f1Stb 304*fab492f1Stb static const unsigned char dsa1024_p[] = { 305*fab492f1Stb 0xA7, 0x3F, 0x6E, 0x85, 0xBF, 0x41, 0x6A, 0x29, 0x7D, 0xF0, 0x9F, 0x47, 306*fab492f1Stb 0x19, 0x30, 0x90, 0x9A, 0x09, 0x1D, 0xDA, 0x6A, 0x33, 0x1E, 0xC5, 0x3D, 307*fab492f1Stb 0x86, 0x96, 0xB3, 0x15, 0xE0, 0x53, 0x2E, 0x8F, 0xE0, 0x59, 0x82, 0x73, 308*fab492f1Stb 0x90, 0x3E, 0x75, 0x31, 0x99, 0x47, 0x7A, 0x52, 0xFB, 0x85, 0xE4, 0xD9, 309*fab492f1Stb 0xA6, 0x7B, 0x38, 0x9B, 0x68, 0x8A, 0x84, 0x9B, 0x87, 0xC6, 0x1E, 0xB5, 310*fab492f1Stb 0x7E, 0x86, 0x4B, 0x53, 0x5B, 0x59, 0xCF, 0x71, 0x65, 0x19, 0x88, 0x6E, 311*fab492f1Stb 0xCE, 0x66, 0xAE, 0x6B, 0x88, 0x36, 0xFB, 0xEC, 0x28, 0xDC, 0xC2, 0xD7, 312*fab492f1Stb 0xA5, 0xBB, 0xE5, 0x2C, 0x39, 0x26, 0x4B, 0xDA, 0x9A, 0x70, 0x18, 0x95, 313*fab492f1Stb 0x37, 0x95, 0x10, 0x56, 0x23, 0xF6, 0x15, 0xED, 0xBA, 0x04, 0x5E, 0xDE, 314*fab492f1Stb 0x39, 0x4F, 0xFD, 0xB7, 0x43, 0x1F, 0xB5, 0xA4, 0x65, 0x6F, 0xCD, 0x80, 315*fab492f1Stb 0x11, 0xE4, 0x70, 0x95, 0x5B, 0x50, 0xCD, 0x49, 316*fab492f1Stb }; 317*fab492f1Stb 318*fab492f1Stb static const unsigned char dsa1024_q[] = { 319*fab492f1Stb 0xF7, 0x07, 0x31, 0xED, 0xFA, 0x6C, 0x06, 0x03, 0xD5, 0x85, 0x8A, 0x1C, 320*fab492f1Stb 0xAC, 0x9C, 0x65, 0xE7, 0x50, 0x66, 0x65, 0x6F, 321*fab492f1Stb }; 322*fab492f1Stb 323*fab492f1Stb static const unsigned char dsa1024_g[] = { 324*fab492f1Stb 0x4D, 0xDF, 0x4C, 0x03, 0xA6, 0x91, 0x8A, 0xF5, 0x19, 0x6F, 0x50, 0x46, 325*fab492f1Stb 0x25, 0x99, 0xE5, 0x68, 0x6F, 0x30, 0xE3, 0x69, 0xE1, 0xE5, 0xB3, 0x5D, 326*fab492f1Stb 0x98, 0xBB, 0x28, 0x86, 0x48, 0xFC, 0xDE, 0x99, 0x04, 0x3F, 0x5F, 0x88, 327*fab492f1Stb 0x0C, 0x9C, 0x73, 0x24, 0x0D, 0x20, 0x5D, 0xB9, 0x2A, 0x9A, 0x3F, 0x18, 328*fab492f1Stb 0x96, 0x27, 0xE4, 0x62, 0x87, 0xC1, 0x7B, 0x74, 0x62, 0x53, 0xFC, 0x61, 329*fab492f1Stb 0x27, 0xA8, 0x7A, 0x91, 0x09, 0x9D, 0xB6, 0xF1, 0x4D, 0x9C, 0x54, 0x0F, 330*fab492f1Stb 0x58, 0x06, 0xEE, 0x49, 0x74, 0x07, 0xCE, 0x55, 0x7E, 0x23, 0xCE, 0x16, 331*fab492f1Stb 0xF6, 0xCA, 0xDC, 0x5A, 0x61, 0x01, 0x7E, 0xC9, 0x71, 0xB5, 0x4D, 0xF6, 332*fab492f1Stb 0xDC, 0x34, 0x29, 0x87, 0x68, 0xF6, 0x5E, 0x20, 0x93, 0xB3, 0xDB, 0xF5, 333*fab492f1Stb 0xE4, 0x09, 0x6C, 0x41, 0x17, 0x95, 0x92, 0xEB, 0x01, 0xB5, 0x73, 0xA5, 334*fab492f1Stb 0x6A, 0x7E, 0xD8, 0x32, 0xED, 0x0E, 0x02, 0xB8, 335*fab492f1Stb }; 336*fab492f1Stb 337*fab492f1Stb static DSA * 338*fab492f1Stb get_dsa1024(void) 339*fab492f1Stb { 340*fab492f1Stb return get_dsa(dsa1024_priv, sizeof(dsa1024_priv), 341*fab492f1Stb dsa1024_pub, sizeof(dsa1024_pub), dsa1024_p, sizeof(dsa1024_p), 342*fab492f1Stb dsa1024_q, sizeof(dsa1024_q), dsa1024_g, sizeof(dsa1024_g)); 343*fab492f1Stb } 344*fab492f1Stb 345*fab492f1Stb static const unsigned char dsa2048_priv[] = { 346*fab492f1Stb 0x32, 0x67, 0x92, 0xf6, 0xc4, 0xe2, 0xe2, 0xe8, 0xa0, 0x8b, 0x6b, 0x45, 347*fab492f1Stb 0x0c, 0x8a, 0x76, 0xb0, 0xee, 0xcf, 0x91, 0xa7, 348*fab492f1Stb }; 349*fab492f1Stb 350*fab492f1Stb static const unsigned char dsa2048_pub[] = { 351*fab492f1Stb 0x17, 0x8f, 0xa8, 0x11, 0x84, 0x92, 0xec, 0x83, 0x47, 0xc7, 0x6a, 0xb0, 352*fab492f1Stb 0x92, 0xaf, 0x5a, 0x20, 0x37, 0xa3, 0x64, 0x79, 0xd2, 0xd0, 0x3d, 0xcd, 353*fab492f1Stb 0xe0, 0x61, 0x88, 0x88, 0x21, 0xcc, 0x74, 0x5d, 0xce, 0x4c, 0x51, 0x47, 354*fab492f1Stb 0xf0, 0xc5, 0x5c, 0x4c, 0x82, 0x7a, 0xaf, 0x72, 0xad, 0xb9, 0xe0, 0x53, 355*fab492f1Stb 0xf2, 0x78, 0xb7, 0xf0, 0xb5, 0x48, 0x7f, 0x8a, 0x3a, 0x18, 0xd1, 0x9f, 356*fab492f1Stb 0x8b, 0x7d, 0xa5, 0x47, 0xb7, 0x95, 0xab, 0x98, 0xf8, 0x7b, 0x74, 0x50, 357*fab492f1Stb 0x56, 0x8e, 0x57, 0xf0, 0xee, 0xf5, 0xb7, 0xba, 0xab, 0x85, 0x86, 0xf9, 358*fab492f1Stb 0x2b, 0xef, 0x41, 0x56, 0xa0, 0xa4, 0x9f, 0xb7, 0x38, 0x00, 0x46, 0x0a, 359*fab492f1Stb 0xa6, 0xf1, 0xfc, 0x1f, 0xd8, 0x4e, 0x85, 0x44, 0x92, 0x43, 0x21, 0x5d, 360*fab492f1Stb 0x6e, 0xcc, 0xc2, 0xcb, 0x26, 0x31, 0x0d, 0x21, 0xc4, 0xbd, 0x8d, 0x24, 361*fab492f1Stb 0xbc, 0xd9, 0x18, 0x19, 0xd7, 0xdc, 0xf1, 0xe7, 0x93, 0x50, 0x48, 0x03, 362*fab492f1Stb 0x2c, 0xae, 0x2e, 0xe7, 0x49, 0x88, 0x5f, 0x93, 0x57, 0x27, 0x99, 0x36, 363*fab492f1Stb 0xb4, 0x20, 0xab, 0xfc, 0xa7, 0x2b, 0xf2, 0xd9, 0x98, 0xd7, 0xd4, 0x34, 364*fab492f1Stb 0x9d, 0x96, 0x50, 0x58, 0x9a, 0xea, 0x54, 0xf3, 0xee, 0xf5, 0x63, 0x14, 365*fab492f1Stb 0xee, 0x85, 0x83, 0x74, 0x76, 0xe1, 0x52, 0x95, 0xc3, 0xf7, 0xeb, 0x04, 366*fab492f1Stb 0x04, 0x7b, 0xa7, 0x28, 0x1b, 0xcc, 0xea, 0x4a, 0x4e, 0x84, 0xda, 0xd8, 367*fab492f1Stb 0x9c, 0x79, 0xd8, 0x9b, 0x66, 0x89, 0x2f, 0xcf, 0xac, 0xd7, 0x79, 0xf9, 368*fab492f1Stb 0xa9, 0xd8, 0x45, 0x13, 0x78, 0xb9, 0x00, 0x14, 0xc9, 0x7e, 0x22, 0x51, 369*fab492f1Stb 0x86, 0x67, 0xb0, 0x9f, 0x26, 0x11, 0x23, 0xc8, 0x38, 0xd7, 0x70, 0x1d, 370*fab492f1Stb 0x15, 0x8e, 0x4d, 0x4f, 0x95, 0x97, 0x40, 0xa1, 0xc2, 0x7e, 0x01, 0x18, 371*fab492f1Stb 0x72, 0xf4, 0x10, 0xe6, 0x8d, 0x52, 0x16, 0x7f, 0xf2, 0xc9, 0xf8, 0x33, 372*fab492f1Stb 0x8b, 0x33, 0xb7, 0xce, 373*fab492f1Stb }; 374*fab492f1Stb 375*fab492f1Stb static const unsigned char dsa2048_p[] = { 376*fab492f1Stb 0xA0, 0x25, 0xFA, 0xAD, 0xF4, 0x8E, 0xB9, 0xE5, 0x99, 0xF3, 0x5D, 0x6F, 377*fab492f1Stb 0x4F, 0x83, 0x34, 0xE2, 0x7E, 0xCF, 0x6F, 0xBF, 0x30, 0xAF, 0x6F, 0x81, 378*fab492f1Stb 0xEB, 0xF8, 0xC4, 0x13, 0xD9, 0xA0, 0x5D, 0x8B, 0x5C, 0x8E, 0xDC, 0xC2, 379*fab492f1Stb 0x1D, 0x0B, 0x41, 0x32, 0xB0, 0x1F, 0xFE, 0xEF, 0x0C, 0xC2, 0xA2, 0x7E, 380*fab492f1Stb 0x68, 0x5C, 0x28, 0x21, 0xE9, 0xF5, 0xB1, 0x58, 0x12, 0x63, 0x4C, 0x19, 381*fab492f1Stb 0x4E, 0xFF, 0x02, 0x4B, 0x92, 0xED, 0xD2, 0x07, 0x11, 0x4D, 0x8C, 0x58, 382*fab492f1Stb 0x16, 0x5C, 0x55, 0x8E, 0xAD, 0xA3, 0x67, 0x7D, 0xB9, 0x86, 0x6E, 0x0B, 383*fab492f1Stb 0xE6, 0x54, 0x6F, 0x40, 0xAE, 0x0E, 0x67, 0x4C, 0xF9, 0x12, 0x5B, 0x3C, 384*fab492f1Stb 0x08, 0x7A, 0xF7, 0xFC, 0x67, 0x86, 0x69, 0xE7, 0x0A, 0x94, 0x40, 0xBF, 385*fab492f1Stb 0x8B, 0x76, 0xFE, 0x26, 0xD1, 0xF2, 0xA1, 0x1A, 0x84, 0xA1, 0x43, 0x56, 386*fab492f1Stb 0x28, 0xBC, 0x9A, 0x5F, 0xD7, 0x3B, 0x69, 0x89, 0x8A, 0x36, 0x2C, 0x51, 387*fab492f1Stb 0xDF, 0x12, 0x77, 0x2F, 0x57, 0x7B, 0xA0, 0xAA, 0xDD, 0x7F, 0xA1, 0x62, 388*fab492f1Stb 0x3B, 0x40, 0x7B, 0x68, 0x1A, 0x8F, 0x0D, 0x38, 0xBB, 0x21, 0x5D, 0x18, 389*fab492f1Stb 0xFC, 0x0F, 0x46, 0xF7, 0xA3, 0xB0, 0x1D, 0x23, 0xC3, 0xD2, 0xC7, 0x72, 390*fab492f1Stb 0x51, 0x18, 0xDF, 0x46, 0x95, 0x79, 0xD9, 0xBD, 0xB5, 0x19, 0x02, 0x2C, 391*fab492f1Stb 0x87, 0xDC, 0xE7, 0x57, 0x82, 0x7E, 0xF1, 0x8B, 0x06, 0x3D, 0x00, 0xA5, 392*fab492f1Stb 0x7B, 0x6B, 0x26, 0x27, 0x91, 0x0F, 0x6A, 0x77, 0xE4, 0xD5, 0x04, 0xE4, 393*fab492f1Stb 0x12, 0x2C, 0x42, 0xFF, 0xD2, 0x88, 0xBB, 0xD3, 0x92, 0xA0, 0xF9, 0xC8, 394*fab492f1Stb 0x51, 0x64, 0x14, 0x5C, 0xD8, 0xF9, 0x6C, 0x47, 0x82, 0xB4, 0x1C, 0x7F, 395*fab492f1Stb 0x09, 0xB8, 0xF0, 0x25, 0x83, 0x1D, 0x3F, 0x3F, 0x05, 0xB3, 0x21, 0x0A, 396*fab492f1Stb 0x5D, 0xA7, 0xD8, 0x54, 0xC3, 0x65, 0x7D, 0xC3, 0xB0, 0x1D, 0xBF, 0xAE, 397*fab492f1Stb 0xF8, 0x68, 0xCF, 0x9B, 398*fab492f1Stb }; 399*fab492f1Stb 400*fab492f1Stb static const unsigned char dsa2048_q[] = { 401*fab492f1Stb 0x97, 0xE7, 0x33, 0x4D, 0xD3, 0x94, 0x3E, 0x0B, 0xDB, 0x62, 0x74, 0xC6, 402*fab492f1Stb 0xA1, 0x08, 0xDD, 0x19, 0xA3, 0x75, 0x17, 0x1B, 403*fab492f1Stb }; 404*fab492f1Stb 405*fab492f1Stb static const unsigned char dsa2048_g[] = { 406*fab492f1Stb 0x2C, 0x78, 0x16, 0x59, 0x34, 0x63, 0xF4, 0xF3, 0x92, 0xFC, 0xB5, 0xA5, 407*fab492f1Stb 0x4F, 0x13, 0xDE, 0x2F, 0x1C, 0xA4, 0x3C, 0xAE, 0xAD, 0x38, 0x3F, 0x7E, 408*fab492f1Stb 0x90, 0xBF, 0x96, 0xA6, 0xAE, 0x25, 0x90, 0x72, 0xF5, 0x8E, 0x80, 0x0C, 409*fab492f1Stb 0x39, 0x1C, 0xD9, 0xEC, 0xBA, 0x90, 0x5B, 0x3A, 0xE8, 0x58, 0x6C, 0x9E, 410*fab492f1Stb 0x30, 0x42, 0x37, 0x02, 0x31, 0x82, 0xBC, 0x6A, 0xDF, 0x6A, 0x09, 0x29, 411*fab492f1Stb 0xE3, 0xC0, 0x46, 0xD1, 0xCB, 0x85, 0xEC, 0x0C, 0x30, 0x5E, 0xEA, 0xC8, 412*fab492f1Stb 0x39, 0x8E, 0x22, 0x9F, 0x22, 0x10, 0xD2, 0x34, 0x61, 0x68, 0x37, 0x3D, 413*fab492f1Stb 0x2E, 0x4A, 0x5B, 0x9A, 0xF5, 0xC1, 0x48, 0xC6, 0xF6, 0xDC, 0x63, 0x1A, 414*fab492f1Stb 0xD3, 0x96, 0x64, 0xBA, 0x34, 0xC9, 0xD1, 0xA0, 0xD1, 0xAE, 0x6C, 0x2F, 415*fab492f1Stb 0x48, 0x17, 0x93, 0x14, 0x43, 0xED, 0xF0, 0x21, 0x30, 0x19, 0xC3, 0x1B, 416*fab492f1Stb 0x5F, 0xDE, 0xA3, 0xF0, 0x70, 0x78, 0x18, 0xE1, 0xA8, 0xE4, 0xEE, 0x2E, 417*fab492f1Stb 0x00, 0xA5, 0xE4, 0xB3, 0x17, 0xC8, 0x0C, 0x7D, 0x6E, 0x42, 0xDC, 0xB7, 418*fab492f1Stb 0x46, 0x00, 0x36, 0x4D, 0xD4, 0x46, 0xAA, 0x3D, 0x3C, 0x46, 0x89, 0x40, 419*fab492f1Stb 0xBF, 0x1D, 0x84, 0x77, 0x0A, 0x75, 0xF3, 0x87, 0x1D, 0x08, 0x4C, 0xA6, 420*fab492f1Stb 0xD1, 0xA9, 0x1C, 0x1E, 0x12, 0x1E, 0xE1, 0xC7, 0x30, 0x28, 0x76, 0xA5, 421*fab492f1Stb 0x7F, 0x6C, 0x85, 0x96, 0x2B, 0x6F, 0xDB, 0x80, 0x66, 0x26, 0xAE, 0xF5, 422*fab492f1Stb 0x93, 0xC7, 0x8E, 0xAE, 0x9A, 0xED, 0xE4, 0xCA, 0x04, 0xEA, 0x3B, 0x72, 423*fab492f1Stb 0xEF, 0xDC, 0x87, 0xED, 0x0D, 0xA5, 0x4C, 0x4A, 0xDD, 0x71, 0x22, 0x64, 424*fab492f1Stb 0x59, 0x69, 0x4E, 0x8E, 0xBF, 0x43, 0xDC, 0xAB, 0x8E, 0x66, 0xBB, 0x01, 425*fab492f1Stb 0xB6, 0xF4, 0xE7, 0xFD, 0xD2, 0xAD, 0x9F, 0x36, 0xC1, 0xA0, 0x29, 0x99, 426*fab492f1Stb 0xD1, 0x96, 0x70, 0x59, 0x06, 0x78, 0x35, 0xBD, 0x65, 0x55, 0x52, 0x9E, 427*fab492f1Stb 0xF8, 0xB2, 0xE5, 0x38, 428*fab492f1Stb }; 429*fab492f1Stb 430*fab492f1Stb static DSA * 431*fab492f1Stb get_dsa2048(void) 432*fab492f1Stb { 433*fab492f1Stb return get_dsa(dsa2048_priv, sizeof(dsa2048_priv), 434*fab492f1Stb dsa2048_pub, sizeof(dsa2048_pub), dsa2048_p, sizeof(dsa2048_p), 435*fab492f1Stb dsa2048_q, sizeof(dsa2048_q), dsa2048_g, sizeof(dsa2048_g)); 436*fab492f1Stb } 437*fab492f1Stb 438*fab492f1Stb static const unsigned char test512[] = { 439*fab492f1Stb 0x30, 0x82, 0x01, 0x3a, 0x02, 0x01, 0x00, 0x02, 0x41, 0x00, 440*fab492f1Stb 0xd6, 0x33, 0xb9, 0xc8, 0xfb, 0x4f, 0x3c, 0x7d, 0xc0, 0x01, 441*fab492f1Stb 0x86, 0xd0, 0xe7, 0xa0, 0x55, 0xf2, 0x95, 0x93, 0xcc, 0x4f, 442*fab492f1Stb 0xb7, 0x5b, 0x67, 0x5b, 0x94, 0x68, 0xc9, 0x34, 0x15, 0xde, 443*fab492f1Stb 0xa5, 0x2e, 0x1c, 0x33, 0xc2, 0x6e, 0xfc, 0x34, 0x5e, 0x71, 444*fab492f1Stb 0x13, 0xb7, 0xd6, 0xee, 0xd8, 0xa5, 0x65, 0x05, 0x72, 0x87, 445*fab492f1Stb 0xa8, 0xb0, 0x77, 0xfe, 0x57, 0xf5, 0xfc, 0x5f, 0x55, 0x83, 446*fab492f1Stb 0x87, 0xdd, 0x57, 0x49, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 447*fab492f1Stb 0x41, 0x00, 0xa7, 0xf7, 0x91, 0xc5, 0x0f, 0x84, 0x57, 0xdc, 448*fab492f1Stb 0x07, 0xf7, 0x6a, 0x7f, 0x60, 0x52, 0xb3, 0x72, 0xf1, 0x66, 449*fab492f1Stb 0x1f, 0x7d, 0x97, 0x3b, 0x9e, 0xb6, 0x0a, 0x8f, 0x8c, 0xcf, 450*fab492f1Stb 0x42, 0x23, 0x00, 0x04, 0xd4, 0x28, 0x0e, 0x1c, 0x90, 0xc4, 451*fab492f1Stb 0x11, 0x25, 0x25, 0xa5, 0x93, 0xa5, 0x2f, 0x70, 0x02, 0xdf, 452*fab492f1Stb 0x81, 0x9c, 0x49, 0x03, 0xa0, 0xf8, 0x6d, 0x54, 0x2e, 0x26, 453*fab492f1Stb 0xde, 0xaa, 0x85, 0x59, 0xa8, 0x31, 0x02, 0x21, 0x00, 0xeb, 454*fab492f1Stb 0x47, 0xd7, 0x3b, 0xf6, 0xc3, 0xdd, 0x5a, 0x46, 0xc5, 0xb9, 455*fab492f1Stb 0x2b, 0x9a, 0xa0, 0x09, 0x8f, 0xa6, 0xfb, 0xf3, 0x78, 0x7a, 456*fab492f1Stb 0x33, 0x70, 0x9d, 0x0f, 0x42, 0x6b, 0x13, 0x68, 0x24, 0xd3, 457*fab492f1Stb 0x15, 0x02, 0x21, 0x00, 0xe9, 0x10, 0xb0, 0xb3, 0x0d, 0xe2, 458*fab492f1Stb 0x82, 0x68, 0x77, 0x8a, 0x6e, 0x7c, 0xda, 0xbc, 0x3e, 0x53, 459*fab492f1Stb 0x83, 0xfb, 0xd6, 0x22, 0xe7, 0xb5, 0xae, 0x6e, 0x80, 0xda, 460*fab492f1Stb 0x00, 0x55, 0x97, 0xc1, 0xd0, 0x65, 0x02, 0x20, 0x4c, 0xf8, 461*fab492f1Stb 0x73, 0xb1, 0x6a, 0x49, 0x29, 0x61, 0x1f, 0x46, 0x10, 0x0d, 462*fab492f1Stb 0xf3, 0xc7, 0xe7, 0x58, 0xd7, 0x88, 0x15, 0x5e, 0x94, 0x9b, 463*fab492f1Stb 0xbf, 0x7b, 0xa2, 0x42, 0x58, 0x45, 0x41, 0x0c, 0xcb, 0x01, 464*fab492f1Stb 0x02, 0x20, 0x12, 0x11, 0xba, 0x31, 0x57, 0x9d, 0x3d, 0x11, 465*fab492f1Stb 0x0e, 0x5b, 0x8c, 0x2f, 0x5f, 0xe2, 0x02, 0x4f, 0x05, 0x47, 466*fab492f1Stb 0x8c, 0x15, 0x8e, 0xb3, 0x56, 0x3f, 0xb8, 0xfb, 0xad, 0xd4, 467*fab492f1Stb 0xf4, 0xfc, 0x10, 0xc5, 0x02, 0x20, 0x18, 0xa1, 0x29, 0x99, 468*fab492f1Stb 0x5b, 0xd9, 0xc8, 0xd4, 0xfc, 0x49, 0x7a, 0x2a, 0x21, 0x2c, 469*fab492f1Stb 0x49, 0xe4, 0x4f, 0xeb, 0xef, 0x51, 0xf1, 0xab, 0x6d, 0xfb, 470*fab492f1Stb 0x4b, 0x14, 0xe9, 0x4b, 0x52, 0xb5, 0x82, 0x2c, 471*fab492f1Stb }; 472*fab492f1Stb 473*fab492f1Stb static const unsigned char test1024[] = { 474*fab492f1Stb 0x30, 0x82, 0x02, 0x5c, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 475*fab492f1Stb 0x00, 0xdc, 0x98, 0x43, 0xe8, 0x3d, 0x43, 0x5b, 0xe4, 0x05, 476*fab492f1Stb 0xcd, 0xd0, 0xa9, 0x3e, 0xcb, 0x83, 0x75, 0xf6, 0xb5, 0xa5, 477*fab492f1Stb 0x9f, 0x6b, 0xe9, 0x34, 0x41, 0x29, 0x18, 0xfa, 0x6a, 0x55, 478*fab492f1Stb 0x4d, 0x70, 0xfc, 0xec, 0xae, 0x87, 0x38, 0x0a, 0x20, 0xa9, 479*fab492f1Stb 0xc0, 0x45, 0x77, 0x6e, 0x57, 0x60, 0x57, 0xf4, 0xed, 0x96, 480*fab492f1Stb 0x22, 0xcb, 0x8f, 0xe1, 0x33, 0x3a, 0x17, 0x1f, 0xed, 0x37, 481*fab492f1Stb 0xa5, 0x6f, 0xeb, 0xa6, 0xbc, 0x12, 0x80, 0x1d, 0x53, 0xbd, 482*fab492f1Stb 0x70, 0xeb, 0x21, 0x76, 0x3e, 0xc9, 0x2f, 0x1a, 0x45, 0x24, 483*fab492f1Stb 0x82, 0xff, 0xcd, 0x59, 0x32, 0x06, 0x2e, 0x12, 0x3b, 0x23, 484*fab492f1Stb 0x78, 0xed, 0x12, 0x3d, 0xe0, 0x8d, 0xf9, 0x67, 0x4f, 0x37, 485*fab492f1Stb 0x4e, 0x47, 0x02, 0x4c, 0x2d, 0xc0, 0x4f, 0x1f, 0xb3, 0x94, 486*fab492f1Stb 0xe1, 0x41, 0x2e, 0x2d, 0x90, 0x10, 0xfc, 0x82, 0x91, 0x8b, 487*fab492f1Stb 0x0f, 0x22, 0xd4, 0xf2, 0xfc, 0x2c, 0xab, 0x53, 0x55, 0x02, 488*fab492f1Stb 0x03, 0x01, 0x00, 0x01, 0x02, 0x81, 0x80, 0x2b, 0xcc, 0x3f, 489*fab492f1Stb 0x8f, 0x58, 0xba, 0x8b, 0x00, 0x16, 0xf6, 0xea, 0x3a, 0xf0, 490*fab492f1Stb 0x30, 0xd0, 0x05, 0x17, 0xda, 0xb0, 0xeb, 0x9a, 0x2d, 0x4f, 491*fab492f1Stb 0x26, 0xb0, 0xd6, 0x38, 0xc1, 0xeb, 0xf5, 0xd8, 0x3d, 0x1f, 492*fab492f1Stb 0x70, 0xf7, 0x7f, 0xf4, 0xe2, 0xcf, 0x51, 0x51, 0x79, 0x88, 493*fab492f1Stb 0xfa, 0xe8, 0x32, 0x0e, 0x7b, 0x2d, 0x97, 0xf2, 0xfa, 0xba, 494*fab492f1Stb 0x27, 0xc5, 0x9c, 0xd9, 0xc5, 0xeb, 0x8a, 0x79, 0x52, 0x3c, 495*fab492f1Stb 0x64, 0x34, 0x7d, 0xc2, 0xcf, 0x28, 0xc7, 0x4e, 0xd5, 0x43, 496*fab492f1Stb 0x0b, 0xd1, 0xa6, 0xca, 0x6d, 0x03, 0x2d, 0x72, 0x23, 0xbc, 497*fab492f1Stb 0x6d, 0x05, 0xfa, 0x16, 0x09, 0x2f, 0x2e, 0x5c, 0xb6, 0xee, 498*fab492f1Stb 0x74, 0xdd, 0xd2, 0x48, 0x8e, 0x36, 0x0c, 0x06, 0x3d, 0x4d, 499*fab492f1Stb 0xe5, 0x10, 0x82, 0xeb, 0x6a, 0xf3, 0x4b, 0x9f, 0xd6, 0xed, 500*fab492f1Stb 0x11, 0xb1, 0x6e, 0xec, 0xf4, 0xfe, 0x8e, 0x75, 0x94, 0x20, 501*fab492f1Stb 0x2f, 0xcb, 0xac, 0x46, 0xf1, 0x02, 0x41, 0x00, 0xf9, 0x8c, 502*fab492f1Stb 0xa3, 0x85, 0xb1, 0xdd, 0x29, 0xaf, 0x65, 0xc1, 0x33, 0xf3, 503*fab492f1Stb 0x95, 0xc5, 0x52, 0x68, 0x0b, 0xd4, 0xf1, 0xe5, 0x0e, 0x02, 504*fab492f1Stb 0x9f, 0x4f, 0xfa, 0x77, 0xdc, 0x46, 0x9e, 0xc7, 0xa6, 0xe4, 505*fab492f1Stb 0x16, 0x29, 0xda, 0xb0, 0x07, 0xcf, 0x5b, 0xa9, 0x12, 0x8a, 506*fab492f1Stb 0xdd, 0x63, 0x0a, 0xde, 0x2e, 0x8c, 0x66, 0x8b, 0x8c, 0xdc, 507*fab492f1Stb 0x19, 0xa3, 0x7e, 0xf4, 0x3b, 0xd0, 0x1a, 0x8c, 0xa4, 0xc2, 508*fab492f1Stb 0xe1, 0xd3, 0x02, 0x41, 0x00, 0xe2, 0x4c, 0x05, 0xf2, 0x04, 509*fab492f1Stb 0x86, 0x4e, 0x61, 0x43, 0xdb, 0xb0, 0xb9, 0x96, 0x86, 0x52, 510*fab492f1Stb 0x2c, 0xca, 0x8d, 0x7b, 0xab, 0x0b, 0x13, 0x0d, 0x7e, 0x38, 511*fab492f1Stb 0x5b, 0xe2, 0x2e, 0x7b, 0x0e, 0xe7, 0x19, 0x99, 0x38, 0xe7, 512*fab492f1Stb 0xf2, 0x21, 0xbd, 0x85, 0x85, 0xe3, 0xfd, 0x28, 0x77, 0x20, 513*fab492f1Stb 0x31, 0x71, 0x2c, 0xd0, 0xff, 0xfb, 0x2e, 0xaf, 0x85, 0xb4, 514*fab492f1Stb 0x86, 0xca, 0xf3, 0xbb, 0xca, 0xaa, 0x0f, 0x95, 0x37, 0x02, 515*fab492f1Stb 0x40, 0x0e, 0x41, 0x9a, 0x95, 0xe8, 0xb3, 0x59, 0xce, 0x4b, 516*fab492f1Stb 0x61, 0xde, 0x35, 0xec, 0x38, 0x79, 0x9c, 0xb8, 0x10, 0x52, 517*fab492f1Stb 0x41, 0x63, 0xab, 0x82, 0xae, 0x6f, 0x00, 0xa9, 0xf4, 0xde, 518*fab492f1Stb 0xdd, 0x49, 0x0b, 0x7e, 0xb8, 0xa5, 0x65, 0xa9, 0x0c, 0x8f, 519*fab492f1Stb 0x8f, 0xf9, 0x1f, 0x35, 0xc6, 0x92, 0xb8, 0x5e, 0xb0, 0x66, 520*fab492f1Stb 0xab, 0x52, 0x40, 0xc0, 0xb6, 0x36, 0x6a, 0x7d, 0x80, 0x46, 521*fab492f1Stb 0x04, 0x02, 0xe5, 0x9f, 0x41, 0x02, 0x41, 0x00, 0xc0, 0xad, 522*fab492f1Stb 0xcc, 0x4e, 0x21, 0xee, 0x1d, 0x24, 0x91, 0xfb, 0xa7, 0x80, 523*fab492f1Stb 0x8d, 0x9a, 0xb6, 0xb3, 0x2e, 0x8f, 0xc2, 0xe1, 0x82, 0xdf, 524*fab492f1Stb 0x69, 0x18, 0xb4, 0x71, 0xff, 0xa6, 0x65, 0xde, 0xed, 0x84, 525*fab492f1Stb 0x8d, 0x42, 0xb7, 0xb3, 0x21, 0x69, 0x56, 0x1c, 0x07, 0x60, 526*fab492f1Stb 0x51, 0x29, 0x04, 0xff, 0x34, 0x06, 0xdd, 0xb9, 0x67, 0x2c, 527*fab492f1Stb 0x7c, 0x04, 0x93, 0x0e, 0x46, 0x15, 0xbb, 0x2a, 0xb7, 0x1b, 528*fab492f1Stb 0xe7, 0x87, 0x02, 0x40, 0x78, 0xda, 0x5d, 0x07, 0x51, 0x0c, 529*fab492f1Stb 0x16, 0x7a, 0x9f, 0x29, 0x20, 0x84, 0x0d, 0x42, 0xfa, 0xd7, 530*fab492f1Stb 0x00, 0xd8, 0x77, 0x7e, 0xb0, 0xb0, 0x6b, 0xd6, 0x5b, 0x53, 531*fab492f1Stb 0xb8, 0x9b, 0x7a, 0xcd, 0xc7, 0x2b, 0xb8, 0x6a, 0x63, 0xa9, 532*fab492f1Stb 0xfb, 0x6f, 0xa4, 0x72, 0xbf, 0x4c, 0x5d, 0x00, 0x14, 0xba, 533*fab492f1Stb 0xfa, 0x59, 0x88, 0xed, 0xe4, 0xe0, 0x8c, 0xa2, 0xec, 0x14, 534*fab492f1Stb 0x7e, 0x2d, 0xe2, 0xf0, 0x46, 0x49, 0x95, 0x45, 535*fab492f1Stb }; 536*fab492f1Stb 537*fab492f1Stb static const unsigned char test2048[] = { 538*fab492f1Stb 0x30, 0x82, 0x04, 0xa3, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 539*fab492f1Stb 0x01, 0x00, 0xc0, 0xc0, 0xce, 0x3e, 0x3c, 0x53, 0x67, 0x3f, 540*fab492f1Stb 0x4f, 0xc5, 0x2f, 0xa4, 0xc2, 0x5a, 0x2f, 0x58, 0xfd, 0x27, 541*fab492f1Stb 0x52, 0x6a, 0xe8, 0xcf, 0x4a, 0x73, 0x47, 0x8d, 0x25, 0x0f, 542*fab492f1Stb 0x5f, 0x03, 0x26, 0x78, 0xef, 0xf0, 0x22, 0x12, 0xd3, 0xde, 543*fab492f1Stb 0x47, 0xb2, 0x1c, 0x0b, 0x38, 0x63, 0x1a, 0x6c, 0x85, 0x7a, 544*fab492f1Stb 0x80, 0xc6, 0x8f, 0xa0, 0x41, 0xaf, 0x62, 0xc4, 0x67, 0x32, 545*fab492f1Stb 0x88, 0xf8, 0xa6, 0x9c, 0xf5, 0x23, 0x1d, 0xe4, 0xac, 0x3f, 546*fab492f1Stb 0x29, 0xf9, 0xec, 0xe1, 0x8b, 0x26, 0x03, 0x2c, 0xb2, 0xab, 547*fab492f1Stb 0xf3, 0x7d, 0xb5, 0xca, 0x49, 0xc0, 0x8f, 0x1c, 0xdf, 0x33, 548*fab492f1Stb 0x3a, 0x60, 0xda, 0x3c, 0xb0, 0x16, 0xf8, 0xa9, 0x12, 0x8f, 549*fab492f1Stb 0x64, 0xac, 0x23, 0x0c, 0x69, 0x64, 0x97, 0x5d, 0x99, 0xd4, 550*fab492f1Stb 0x09, 0x83, 0x9b, 0x61, 0xd3, 0xac, 0xf0, 0xde, 0xdd, 0x5e, 551*fab492f1Stb 0x9f, 0x44, 0x94, 0xdb, 0x3a, 0x4d, 0x97, 0xe8, 0x52, 0x29, 552*fab492f1Stb 0xf7, 0xdb, 0x94, 0x07, 0x45, 0x90, 0x78, 0x1e, 0x31, 0x0b, 553*fab492f1Stb 0x80, 0xf7, 0x57, 0xad, 0x1c, 0x79, 0xc5, 0xcb, 0x32, 0xb0, 554*fab492f1Stb 0xce, 0xcd, 0x74, 0xb3, 0xe2, 0x94, 0xc5, 0x78, 0x2f, 0x34, 555*fab492f1Stb 0x1a, 0x45, 0xf7, 0x8c, 0x52, 0xa5, 0xbc, 0x8d, 0xec, 0xd1, 556*fab492f1Stb 0x2f, 0x31, 0x3b, 0xf0, 0x49, 0x59, 0x5e, 0x88, 0x9d, 0x15, 557*fab492f1Stb 0x92, 0x35, 0x32, 0xc1, 0xe7, 0x61, 0xec, 0x50, 0x48, 0x7c, 558*fab492f1Stb 0xba, 0x05, 0xf9, 0xf8, 0xf8, 0xa7, 0x8c, 0x83, 0xe8, 0x66, 559*fab492f1Stb 0x5b, 0xeb, 0xfe, 0xd8, 0x4f, 0xdd, 0x6d, 0x36, 0xc0, 0xb2, 560*fab492f1Stb 0x90, 0x0f, 0xb8, 0x52, 0xf9, 0x04, 0x9b, 0x40, 0x2c, 0x27, 561*fab492f1Stb 0xd6, 0x36, 0x8e, 0xc2, 0x1b, 0x44, 0xf3, 0x92, 0xd5, 0x15, 562*fab492f1Stb 0x9e, 0x9a, 0xbc, 0xf3, 0x7d, 0x03, 0xd7, 0x02, 0x14, 0x20, 563*fab492f1Stb 0xe9, 0x10, 0x92, 0xfd, 0xf9, 0xfc, 0x8f, 0xe5, 0x18, 0xe1, 564*fab492f1Stb 0x95, 0xcc, 0x9e, 0x60, 0xa6, 0xfa, 0x38, 0x4d, 0x02, 0x03, 565*fab492f1Stb 0x01, 0x00, 0x01, 0x02, 0x82, 0x01, 0x00, 0x00, 0xc3, 0xc3, 566*fab492f1Stb 0x0d, 0xb4, 0x27, 0x90, 0x8d, 0x4b, 0xbf, 0xb8, 0x84, 0xaa, 567*fab492f1Stb 0xd0, 0xb8, 0xc7, 0x5d, 0x99, 0xbe, 0x55, 0xf6, 0x3e, 0x7c, 568*fab492f1Stb 0x49, 0x20, 0xcb, 0x8a, 0x8e, 0x19, 0x0e, 0x66, 0x24, 0xac, 569*fab492f1Stb 0xaf, 0x03, 0x33, 0x97, 0xeb, 0x95, 0xd5, 0x3b, 0x0f, 0x40, 570*fab492f1Stb 0x56, 0x04, 0x50, 0xd1, 0xe6, 0xbe, 0x84, 0x0b, 0x25, 0xd3, 571*fab492f1Stb 0x9c, 0xe2, 0x83, 0x6c, 0xf5, 0x62, 0x5d, 0xba, 0x2b, 0x7d, 572*fab492f1Stb 0x3d, 0x7a, 0x6c, 0xe1, 0xd2, 0x0e, 0x54, 0x93, 0x80, 0x01, 573*fab492f1Stb 0x91, 0x51, 0x09, 0xe8, 0x5b, 0x8e, 0x47, 0xbd, 0x64, 0xe4, 574*fab492f1Stb 0x0e, 0x03, 0x83, 0x55, 0xcf, 0x5a, 0x37, 0xf0, 0x25, 0xb5, 575*fab492f1Stb 0x7d, 0x21, 0xd7, 0x69, 0xdf, 0x6f, 0xc2, 0xcf, 0x10, 0xc9, 576*fab492f1Stb 0x8a, 0x40, 0x9f, 0x7a, 0x70, 0xc0, 0xe8, 0xe8, 0xc0, 0xe6, 577*fab492f1Stb 0x9a, 0x15, 0x0a, 0x8d, 0x4e, 0x46, 0xcb, 0x7a, 0xdb, 0xb3, 578*fab492f1Stb 0xcb, 0x83, 0x02, 0xc4, 0xf0, 0xab, 0xeb, 0x02, 0x01, 0x0e, 579*fab492f1Stb 0x23, 0xfc, 0x1d, 0xc4, 0xbd, 0xd4, 0xaa, 0x5d, 0x31, 0x46, 580*fab492f1Stb 0x99, 0xce, 0x9e, 0xf8, 0x04, 0x75, 0x10, 0x67, 0xc4, 0x53, 581*fab492f1Stb 0x47, 0x44, 0xfa, 0xc2, 0x25, 0x73, 0x7e, 0xd0, 0x8e, 0x59, 582*fab492f1Stb 0xd1, 0xb2, 0x5a, 0xf4, 0xc7, 0x18, 0x92, 0x2f, 0x39, 0xab, 583*fab492f1Stb 0xcd, 0xa3, 0xb5, 0xc2, 0xb9, 0xc7, 0xb9, 0x1b, 0x9f, 0x48, 584*fab492f1Stb 0xfa, 0x13, 0xc6, 0x98, 0x4d, 0xca, 0x84, 0x9c, 0x06, 0xca, 585*fab492f1Stb 0xe7, 0x89, 0x01, 0x04, 0xc4, 0x6c, 0xfd, 0x29, 0x59, 0x35, 586*fab492f1Stb 0xe7, 0xf3, 0xdd, 0xce, 0x64, 0x59, 0xbf, 0x21, 0x13, 0xa9, 587*fab492f1Stb 0x9f, 0x0e, 0xc5, 0xff, 0xbd, 0x33, 0x00, 0xec, 0xac, 0x6b, 588*fab492f1Stb 0x11, 0xef, 0x51, 0x5e, 0xad, 0x07, 0x15, 0xde, 0xb8, 0x5f, 589*fab492f1Stb 0xc6, 0xb9, 0xa3, 0x22, 0x65, 0x46, 0x83, 0x14, 0xdf, 0xd0, 590*fab492f1Stb 0xf1, 0x44, 0x8a, 0xe1, 0x9c, 0x23, 0x33, 0xb4, 0x97, 0x33, 591*fab492f1Stb 0xe6, 0x6b, 0x81, 0x02, 0x81, 0x81, 0x00, 0xec, 0x12, 0xa7, 592*fab492f1Stb 0x59, 0x74, 0x6a, 0xde, 0x3e, 0xad, 0xd8, 0x36, 0x80, 0x50, 593*fab492f1Stb 0xa2, 0xd5, 0x21, 0x81, 0x07, 0xf1, 0xd0, 0x91, 0xf2, 0x6c, 594*fab492f1Stb 0x12, 0x2f, 0x9d, 0x1a, 0x26, 0xf8, 0x30, 0x65, 0xdf, 0xe8, 595*fab492f1Stb 0xc0, 0x9b, 0x6a, 0x30, 0x98, 0x82, 0x87, 0xec, 0xa2, 0x56, 596*fab492f1Stb 0x87, 0x62, 0x6f, 0xe7, 0x9f, 0xf6, 0x56, 0xe6, 0x71, 0x8f, 597*fab492f1Stb 0x49, 0x86, 0x93, 0x5a, 0x4d, 0x34, 0x58, 0xfe, 0xd9, 0x04, 598*fab492f1Stb 0x13, 0xaf, 0x79, 0xb7, 0xad, 0x11, 0xd1, 0x30, 0x9a, 0x14, 599*fab492f1Stb 0x06, 0xa0, 0xfa, 0xb7, 0x55, 0xdc, 0x6c, 0x5a, 0x4c, 0x2c, 600*fab492f1Stb 0x59, 0x56, 0xf6, 0xe8, 0x9d, 0xaf, 0x0a, 0x78, 0x99, 0x06, 601*fab492f1Stb 0x06, 0x9e, 0xe7, 0x9c, 0x51, 0x55, 0x43, 0xfc, 0x3b, 0x6c, 602*fab492f1Stb 0x0b, 0xbf, 0x2d, 0x41, 0xa7, 0xaf, 0xb7, 0xe0, 0xe8, 0x28, 603*fab492f1Stb 0x18, 0xb4, 0x13, 0xd1, 0xe6, 0x97, 0xd0, 0x9f, 0x6a, 0x80, 604*fab492f1Stb 0xca, 0xdd, 0x1a, 0x7e, 0x15, 0x02, 0x81, 0x81, 0x00, 0xd1, 605*fab492f1Stb 0x06, 0x0c, 0x1f, 0xe3, 0xd0, 0xab, 0xd6, 0xca, 0x7c, 0xbc, 606*fab492f1Stb 0x7d, 0x13, 0x35, 0xce, 0x27, 0xcd, 0xd8, 0x49, 0x51, 0x63, 607*fab492f1Stb 0x64, 0x0f, 0xca, 0x06, 0x12, 0xfc, 0x07, 0x3e, 0xaf, 0x61, 608*fab492f1Stb 0x6d, 0xe2, 0x53, 0x39, 0x27, 0xae, 0xc3, 0x11, 0x9e, 0x94, 609*fab492f1Stb 0x01, 0x4f, 0xe3, 0xf3, 0x67, 0xf9, 0x77, 0xf9, 0xe7, 0x95, 610*fab492f1Stb 0x3a, 0x6f, 0xe2, 0x20, 0x73, 0x3e, 0xa4, 0x7a, 0x28, 0xd4, 611*fab492f1Stb 0x61, 0x97, 0xf6, 0x17, 0xa0, 0x23, 0x10, 0x2b, 0xce, 0x84, 612*fab492f1Stb 0x57, 0x7e, 0x25, 0x1f, 0xf4, 0xa8, 0x54, 0xd2, 0x65, 0x94, 613*fab492f1Stb 0xcc, 0x95, 0x0a, 0xab, 0x30, 0xc1, 0x59, 0x1f, 0x61, 0x8e, 614*fab492f1Stb 0xb9, 0x6b, 0xd7, 0x4e, 0xb9, 0x83, 0x43, 0x79, 0x85, 0x11, 615*fab492f1Stb 0xbc, 0x0f, 0xae, 0x25, 0x20, 0x05, 0xbc, 0xd2, 0x48, 0xa1, 616*fab492f1Stb 0x68, 0x09, 0x84, 0xf6, 0x12, 0x9a, 0x66, 0xb9, 0x2b, 0xbb, 617*fab492f1Stb 0x76, 0x03, 0x17, 0x46, 0x4e, 0x97, 0x59, 0x02, 0x81, 0x80, 618*fab492f1Stb 0x09, 0x4c, 0xfa, 0xd6, 0xe5, 0x65, 0x48, 0x78, 0x43, 0xb5, 619*fab492f1Stb 0x1f, 0x00, 0x93, 0x2c, 0xb7, 0x24, 0xe8, 0xc6, 0x7d, 0x5a, 620*fab492f1Stb 0x70, 0x45, 0x92, 0xc8, 0x6c, 0xa3, 0xcd, 0xe1, 0xf7, 0x29, 621*fab492f1Stb 0x40, 0xfa, 0x3f, 0x5b, 0x47, 0x44, 0x39, 0xc1, 0xe8, 0x72, 622*fab492f1Stb 0x9e, 0x7a, 0x0e, 0xda, 0xaa, 0xa0, 0x2a, 0x09, 0xfd, 0x54, 623*fab492f1Stb 0x93, 0x23, 0xaa, 0x37, 0x85, 0x5b, 0xcc, 0xd4, 0xf9, 0xd8, 624*fab492f1Stb 0xff, 0xc1, 0x61, 0x0d, 0xbd, 0x7e, 0x18, 0x24, 0x73, 0x6d, 625*fab492f1Stb 0x40, 0x72, 0xf1, 0x93, 0x09, 0x48, 0x97, 0x6c, 0x84, 0x90, 626*fab492f1Stb 0xa8, 0x46, 0x14, 0x01, 0x39, 0x11, 0xe5, 0x3c, 0x41, 0x27, 627*fab492f1Stb 0x32, 0x75, 0x24, 0xed, 0xa1, 0xd9, 0x12, 0x29, 0x8a, 0x28, 628*fab492f1Stb 0x71, 0x89, 0x8d, 0xca, 0x30, 0xb0, 0x01, 0xc4, 0x2f, 0x82, 629*fab492f1Stb 0x19, 0x14, 0x4c, 0x70, 0x1c, 0xb8, 0x23, 0x2e, 0xe8, 0x90, 630*fab492f1Stb 0x49, 0x97, 0x92, 0x97, 0x6b, 0x7a, 0x9d, 0xb9, 0x02, 0x81, 631*fab492f1Stb 0x80, 0x0f, 0x0e, 0xa1, 0x76, 0xf6, 0xa1, 0x44, 0x8f, 0xaf, 632*fab492f1Stb 0x7c, 0x76, 0xd3, 0x87, 0xbb, 0xbb, 0x83, 0x10, 0x88, 0x01, 633*fab492f1Stb 0x18, 0x14, 0xd1, 0xd3, 0x75, 0x59, 0x24, 0xaa, 0xf5, 0x16, 634*fab492f1Stb 0xa5, 0xe9, 0x9d, 0xd1, 0xcc, 0xee, 0xf4, 0x15, 0xd9, 0xc5, 635*fab492f1Stb 0x7e, 0x27, 0xe9, 0x44, 0x49, 0x06, 0x72, 0xb9, 0xfc, 0xd3, 636*fab492f1Stb 0x8a, 0xc4, 0x2c, 0x36, 0x7d, 0x12, 0x9b, 0x5a, 0xaa, 0xdc, 637*fab492f1Stb 0x85, 0xee, 0x6e, 0xad, 0x54, 0xb3, 0xf4, 0xfc, 0x31, 0xa1, 638*fab492f1Stb 0x06, 0x3a, 0x70, 0x57, 0x0c, 0xf3, 0x95, 0x5b, 0x3e, 0xe8, 639*fab492f1Stb 0xfd, 0x1a, 0x4f, 0xf6, 0x78, 0x93, 0x46, 0x6a, 0xd7, 0x31, 640*fab492f1Stb 0xb4, 0x84, 0x64, 0x85, 0x09, 0x38, 0x89, 0x92, 0x94, 0x1c, 641*fab492f1Stb 0xbf, 0xe2, 0x3c, 0x2a, 0xe0, 0xff, 0x99, 0xa3, 0xf0, 0x2b, 642*fab492f1Stb 0x31, 0xc2, 0x36, 0xcd, 0x60, 0xbf, 0x9d, 0x2d, 0x74, 0x32, 643*fab492f1Stb 0xe8, 0x9c, 0x93, 0x6e, 0xbb, 0x91, 0x7b, 0xfd, 0xd9, 0x02, 644*fab492f1Stb 0x81, 0x81, 0x00, 0xa2, 0x71, 0x25, 0x38, 0xeb, 0x2a, 0xe9, 645*fab492f1Stb 0x37, 0xcd, 0xfe, 0x44, 0xce, 0x90, 0x3f, 0x52, 0x87, 0x84, 646*fab492f1Stb 0x52, 0x1b, 0xae, 0x8d, 0x22, 0x94, 0xce, 0x38, 0xe6, 0x04, 647*fab492f1Stb 0x88, 0x76, 0x85, 0x9a, 0xd3, 0x14, 0x09, 0xe5, 0x69, 0x9a, 648*fab492f1Stb 0xff, 0x58, 0x92, 0x02, 0x6a, 0x7d, 0x7c, 0x1e, 0x2c, 0xfd, 649*fab492f1Stb 0xa8, 0xca, 0x32, 0x14, 0x4f, 0x0d, 0x84, 0x0d, 0x37, 0x43, 650*fab492f1Stb 0xbf, 0xe4, 0x5d, 0x12, 0xc8, 0x24, 0x91, 0x27, 0x8d, 0x46, 651*fab492f1Stb 0xd9, 0x54, 0x53, 0xe7, 0x62, 0x71, 0xa8, 0x2b, 0x71, 0x41, 652*fab492f1Stb 0x8d, 0x75, 0xf8, 0x3a, 0xa0, 0x61, 0x29, 0x46, 0xa6, 0xe5, 653*fab492f1Stb 0x82, 0xfa, 0x3a, 0xd9, 0x08, 0xfa, 0xfc, 0x63, 0xfd, 0x6b, 654*fab492f1Stb 0x30, 0xbc, 0xf4, 0x4e, 0x9e, 0x8c, 0x25, 0x0c, 0xb6, 0x55, 655*fab492f1Stb 0xe7, 0x3c, 0xd4, 0x4e, 0x0b, 0xfd, 0x8b, 0xc3, 0x0e, 0x1d, 656*fab492f1Stb 0x9c, 0x44, 0x57, 0x8f, 0x1f, 0x86, 0xf7, 0xd5, 0x1b, 0xe4, 657*fab492f1Stb 0x95, 658*fab492f1Stb }; 659*fab492f1Stb 660*fab492f1Stb static const unsigned char test4096[] = { 661*fab492f1Stb 0x30, 0x82, 0x09, 0x29, 0x02, 0x01, 0x00, 0x02, 0x82, 0x02, 662*fab492f1Stb 0x01, 0x00, 0xc0, 0x71, 0xac, 0x1a, 0x13, 0x88, 0x82, 0x43, 663*fab492f1Stb 0x3b, 0x51, 0x57, 0x71, 0x8d, 0xb6, 0x2b, 0x82, 0x65, 0x21, 664*fab492f1Stb 0x53, 0x5f, 0x28, 0x29, 0x4f, 0x8d, 0x7c, 0x8a, 0xb9, 0x44, 665*fab492f1Stb 0xb3, 0x28, 0x41, 0x4f, 0xd3, 0xfa, 0x6a, 0xf8, 0xb9, 0x28, 666*fab492f1Stb 0x50, 0x39, 0x67, 0x53, 0x2c, 0x3c, 0xd7, 0xcb, 0x96, 0x41, 667*fab492f1Stb 0x40, 0x32, 0xbb, 0xeb, 0x70, 0xae, 0x1f, 0xb0, 0x65, 0xf7, 668*fab492f1Stb 0x3a, 0xd9, 0x22, 0xfd, 0x10, 0xae, 0xbd, 0x02, 0xe2, 0xdd, 669*fab492f1Stb 0xf3, 0xc2, 0x79, 0x3c, 0xc6, 0xfc, 0x75, 0xbb, 0xaf, 0x4e, 670*fab492f1Stb 0x3a, 0x36, 0xc2, 0x4f, 0xea, 0x25, 0xdf, 0x13, 0x16, 0x4b, 671*fab492f1Stb 0x20, 0xfe, 0x4b, 0x69, 0x16, 0xc4, 0x7f, 0x1a, 0x43, 0xa6, 672*fab492f1Stb 0x17, 0x1b, 0xb9, 0x0a, 0xf3, 0x09, 0x86, 0x28, 0x89, 0xcf, 673*fab492f1Stb 0x2c, 0xd0, 0xd4, 0x81, 0xaf, 0xc6, 0x6d, 0xe6, 0x21, 0x8d, 674*fab492f1Stb 0xee, 0xef, 0xea, 0xdc, 0xb7, 0xc6, 0x3b, 0x63, 0x9f, 0x0e, 675*fab492f1Stb 0xad, 0x89, 0x78, 0x23, 0x18, 0xbf, 0x70, 0x7e, 0x84, 0xe0, 676*fab492f1Stb 0x37, 0xec, 0xdb, 0x8e, 0x9c, 0x3e, 0x6a, 0x19, 0xcc, 0x99, 677*fab492f1Stb 0x72, 0xe6, 0xb5, 0x7d, 0x6d, 0xfa, 0xe5, 0xd3, 0xe4, 0x90, 678*fab492f1Stb 0xb5, 0xb2, 0xb2, 0x12, 0x70, 0x4e, 0xca, 0xf8, 0x10, 0xf8, 679*fab492f1Stb 0xa3, 0x14, 0xc2, 0x48, 0x19, 0xeb, 0x60, 0x99, 0xbb, 0x2a, 680*fab492f1Stb 0x1f, 0xb1, 0x7a, 0xb1, 0x3d, 0x24, 0xfb, 0xa0, 0x29, 0xda, 681*fab492f1Stb 0xbd, 0x1b, 0xd7, 0xa4, 0xbf, 0xef, 0x60, 0x2d, 0x22, 0xca, 682*fab492f1Stb 0x65, 0x98, 0xf1, 0xc4, 0xe1, 0xc9, 0x02, 0x6b, 0x16, 0x28, 683*fab492f1Stb 0x2f, 0xa1, 0xaa, 0x79, 0x00, 0xda, 0xdc, 0x7c, 0x43, 0xf7, 684*fab492f1Stb 0x42, 0x3c, 0xa0, 0xef, 0x68, 0xf7, 0xdf, 0xb9, 0x69, 0xfb, 685*fab492f1Stb 0x8e, 0x01, 0xed, 0x01, 0x42, 0xb5, 0x4e, 0x57, 0xa6, 0x26, 686*fab492f1Stb 0xb8, 0xd0, 0x7b, 0x56, 0x6d, 0x03, 0xc6, 0x40, 0x8c, 0x8c, 687*fab492f1Stb 0x2a, 0x55, 0xd7, 0x9c, 0x35, 0x00, 0x94, 0x93, 0xec, 0x03, 688*fab492f1Stb 0xeb, 0x22, 0xef, 0x77, 0xbb, 0x79, 0x13, 0x3f, 0x15, 0xa1, 689*fab492f1Stb 0x8f, 0xca, 0xdf, 0xfd, 0xd3, 0xb8, 0xe1, 0xd4, 0xcc, 0x09, 690*fab492f1Stb 0x3f, 0x3c, 0x2c, 0xdb, 0xd1, 0x49, 0x7f, 0x38, 0x07, 0x83, 691*fab492f1Stb 0x6d, 0xeb, 0x08, 0x66, 0xe9, 0x06, 0x44, 0x12, 0xac, 0x95, 692*fab492f1Stb 0x22, 0x90, 0x23, 0x67, 0xd4, 0x08, 0xcc, 0xf4, 0xb7, 0xdc, 693*fab492f1Stb 0xcc, 0x87, 0xd4, 0xac, 0x69, 0x35, 0x4c, 0xb5, 0x39, 0x36, 694*fab492f1Stb 0xcd, 0xa4, 0xd2, 0x95, 0xca, 0x0d, 0xc5, 0xda, 0xc2, 0xc5, 695*fab492f1Stb 0x22, 0x32, 0x28, 0x08, 0xe3, 0xd2, 0x8b, 0x38, 0x30, 0xdc, 696*fab492f1Stb 0x8c, 0x75, 0x4f, 0x6a, 0xec, 0x7a, 0xac, 0x16, 0x3e, 0xa8, 697*fab492f1Stb 0xd4, 0x6a, 0x45, 0xe1, 0xa8, 0x4f, 0x2e, 0x80, 0x34, 0xaa, 698*fab492f1Stb 0x54, 0x1b, 0x02, 0x95, 0x7d, 0x8a, 0x6d, 0xcc, 0x79, 0xca, 699*fab492f1Stb 0xf2, 0xa4, 0x2e, 0x8d, 0xfb, 0xfe, 0x15, 0x51, 0x10, 0x0e, 700*fab492f1Stb 0x4d, 0x88, 0xb1, 0xc7, 0xf4, 0x79, 0xdb, 0xf0, 0xb4, 0x56, 701*fab492f1Stb 0x44, 0x37, 0xca, 0x5a, 0xc1, 0x8c, 0x48, 0xac, 0xae, 0x48, 702*fab492f1Stb 0x80, 0x83, 0x01, 0x3f, 0xde, 0xd9, 0xd3, 0x2c, 0x51, 0x46, 703*fab492f1Stb 0xb1, 0x41, 0xb6, 0xc6, 0x91, 0x72, 0xf9, 0x83, 0x55, 0x1b, 704*fab492f1Stb 0x8c, 0xba, 0xf3, 0x73, 0xe5, 0x2c, 0x74, 0x50, 0x3a, 0xbe, 705*fab492f1Stb 0xc5, 0x2f, 0xa7, 0xb2, 0x6d, 0x8c, 0x9e, 0x13, 0x77, 0xa3, 706*fab492f1Stb 0x13, 0xcd, 0x6d, 0x8c, 0x45, 0xe1, 0xfc, 0x0b, 0xb7, 0x69, 707*fab492f1Stb 0xe9, 0x27, 0xbc, 0x65, 0xc3, 0xfa, 0x9b, 0xd0, 0xef, 0xfe, 708*fab492f1Stb 0xe8, 0x1f, 0xb3, 0x5e, 0x34, 0xf4, 0x8c, 0xea, 0xfc, 0xd3, 709*fab492f1Stb 0x81, 0xbf, 0x3d, 0x30, 0xb2, 0xb4, 0x01, 0xe8, 0x43, 0x0f, 710*fab492f1Stb 0xba, 0x02, 0x23, 0x42, 0x76, 0x82, 0x31, 0x73, 0x91, 0xed, 711*fab492f1Stb 0x07, 0x46, 0x61, 0x0d, 0x39, 0x83, 0x40, 0xce, 0x7a, 0xd4, 712*fab492f1Stb 0xdb, 0x80, 0x2c, 0x1f, 0x0d, 0xd1, 0x34, 0xd4, 0x92, 0xe3, 713*fab492f1Stb 0xd4, 0xf1, 0xc2, 0x01, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 714*fab492f1Stb 0x82, 0x02, 0x01, 0x00, 0x97, 0x6c, 0xda, 0x6e, 0xea, 0x4f, 715*fab492f1Stb 0xcf, 0xaf, 0xf7, 0x4c, 0xd9, 0xf1, 0x90, 0x00, 0x77, 0xdb, 716*fab492f1Stb 0xf2, 0x97, 0x76, 0x72, 0xb9, 0xb7, 0x47, 0xd1, 0x9c, 0xdd, 717*fab492f1Stb 0xcb, 0x4a, 0x33, 0x6e, 0xc9, 0x75, 0x76, 0xe6, 0xe4, 0xa5, 718*fab492f1Stb 0x31, 0x8c, 0x77, 0x13, 0xb4, 0x29, 0xcd, 0xf5, 0x52, 0x17, 719*fab492f1Stb 0xef, 0xf3, 0x08, 0x00, 0xe3, 0xbd, 0x2e, 0xbc, 0xd4, 0x52, 720*fab492f1Stb 0x88, 0xe9, 0x30, 0x75, 0x0b, 0x02, 0xf5, 0xcd, 0x89, 0x0c, 721*fab492f1Stb 0x6c, 0x57, 0x19, 0x27, 0x3d, 0x1e, 0x85, 0xb4, 0xc1, 0x2f, 722*fab492f1Stb 0x1d, 0x92, 0x00, 0x5c, 0x76, 0x29, 0x4b, 0xa4, 0xe1, 0x12, 723*fab492f1Stb 0xb3, 0xc8, 0x09, 0xfe, 0x0e, 0x78, 0x72, 0x61, 0xcb, 0x61, 724*fab492f1Stb 0x6f, 0x39, 0x91, 0x95, 0x4e, 0xd5, 0x3e, 0xc7, 0x8f, 0xb8, 725*fab492f1Stb 0xf6, 0x36, 0xfe, 0x9c, 0x93, 0x9a, 0x38, 0x25, 0x7a, 0xf4, 726*fab492f1Stb 0x4a, 0x12, 0xd4, 0xa0, 0x13, 0xbd, 0xf9, 0x1d, 0x12, 0x3e, 727*fab492f1Stb 0x21, 0x39, 0xfb, 0x72, 0xe0, 0x05, 0x3d, 0xc3, 0xe5, 0x50, 728*fab492f1Stb 0xa8, 0x5d, 0x85, 0xa3, 0xea, 0x5f, 0x1c, 0xb2, 0x3f, 0xea, 729*fab492f1Stb 0x6d, 0x03, 0x91, 0x55, 0xd8, 0x19, 0x0a, 0x21, 0x12, 0x16, 730*fab492f1Stb 0xd9, 0x12, 0xc4, 0xe6, 0x07, 0x18, 0x5b, 0x26, 0xa4, 0xae, 731*fab492f1Stb 0xed, 0x2b, 0xb7, 0xa6, 0xed, 0xf8, 0xad, 0xec, 0x77, 0xe6, 732*fab492f1Stb 0x7f, 0x4f, 0x76, 0x00, 0xc0, 0xfa, 0x15, 0x92, 0xb4, 0x2c, 733*fab492f1Stb 0x22, 0xc2, 0xeb, 0x6a, 0xad, 0x14, 0x05, 0xb2, 0xe5, 0x8a, 734*fab492f1Stb 0x9e, 0x85, 0x83, 0xcc, 0x04, 0xf1, 0x56, 0x78, 0x44, 0x5e, 735*fab492f1Stb 0xde, 0xe0, 0x60, 0x1a, 0x65, 0x79, 0x31, 0x23, 0x05, 0xbb, 736*fab492f1Stb 0x01, 0xff, 0xdd, 0x2e, 0xb7, 0xb3, 0xaa, 0x74, 0xe0, 0xa5, 737*fab492f1Stb 0x94, 0xaf, 0x4b, 0xde, 0x58, 0x0f, 0x55, 0xde, 0x33, 0xf6, 738*fab492f1Stb 0xe3, 0xd6, 0x34, 0x36, 0x57, 0xd6, 0x79, 0x91, 0x2e, 0xbe, 739*fab492f1Stb 0x3b, 0xd9, 0x4e, 0xb6, 0x9d, 0x21, 0x5c, 0xd3, 0x48, 0x14, 740*fab492f1Stb 0x7f, 0x4a, 0xc4, 0x60, 0xa9, 0x29, 0xf8, 0x53, 0x7f, 0x88, 741*fab492f1Stb 0x11, 0x2d, 0xb5, 0xc5, 0x2d, 0x6f, 0xee, 0x85, 0x0b, 0xf7, 742*fab492f1Stb 0x8d, 0x9a, 0xbe, 0xb0, 0x42, 0xf2, 0x2e, 0x71, 0xaf, 0x19, 743*fab492f1Stb 0x31, 0x6d, 0xec, 0xcd, 0x6f, 0x2b, 0x23, 0xdf, 0xb4, 0x40, 744*fab492f1Stb 0xaf, 0x2c, 0x0a, 0xc3, 0x1b, 0x7d, 0x7d, 0x03, 0x1d, 0x4b, 745*fab492f1Stb 0xf3, 0xb5, 0xe0, 0x85, 0xd8, 0xdf, 0x91, 0x6b, 0x0a, 0x69, 746*fab492f1Stb 0xf7, 0xf2, 0x69, 0x66, 0x5b, 0xf1, 0xcf, 0x46, 0x7d, 0xe9, 747*fab492f1Stb 0x70, 0xfa, 0x6d, 0x7e, 0x75, 0x4e, 0xa9, 0x77, 0xe6, 0x8c, 748*fab492f1Stb 0x02, 0xf7, 0x14, 0x4d, 0xa5, 0x41, 0x8f, 0x3f, 0xc1, 0x62, 749*fab492f1Stb 0x1e, 0x71, 0x5e, 0x38, 0xb4, 0xd6, 0xe6, 0xe1, 0x4b, 0xc2, 750*fab492f1Stb 0x2c, 0x30, 0x83, 0x81, 0x6f, 0x49, 0x2e, 0x96, 0xe6, 0xc9, 751*fab492f1Stb 0x9a, 0xf7, 0x5d, 0x09, 0xa0, 0x55, 0x02, 0xa5, 0x3a, 0x25, 752*fab492f1Stb 0x23, 0xd0, 0x92, 0xc3, 0xa3, 0xe3, 0x0e, 0x12, 0x2f, 0x4d, 753*fab492f1Stb 0xef, 0xf3, 0x55, 0x5a, 0xbe, 0xe6, 0x19, 0x86, 0x31, 0xab, 754*fab492f1Stb 0x75, 0x9a, 0xd3, 0xf0, 0x2c, 0xc5, 0x41, 0x92, 0xd9, 0x1f, 755*fab492f1Stb 0x5f, 0x11, 0x8c, 0x75, 0x1c, 0x63, 0xd0, 0x02, 0x80, 0x2c, 756*fab492f1Stb 0x68, 0xcb, 0x93, 0xfb, 0x51, 0x73, 0x49, 0xb4, 0x60, 0xda, 757*fab492f1Stb 0xe2, 0x26, 0xaf, 0xa9, 0x46, 0x12, 0xb8, 0xec, 0x50, 0xdd, 758*fab492f1Stb 0x12, 0x06, 0x5f, 0xce, 0x59, 0xe6, 0xf6, 0x1c, 0xe0, 0x54, 759*fab492f1Stb 0x10, 0xad, 0xf6, 0xcd, 0x98, 0xcc, 0x0f, 0xfb, 0xcb, 0x41, 760*fab492f1Stb 0x14, 0x9d, 0xed, 0xe4, 0xb4, 0x74, 0x5f, 0x09, 0x60, 0xc7, 761*fab492f1Stb 0x12, 0xf6, 0x7b, 0x3c, 0x8f, 0xa7, 0x20, 0xbc, 0xe4, 0xb1, 762*fab492f1Stb 0xef, 0xeb, 0xa4, 0x93, 0xc5, 0x06, 0xca, 0x9a, 0x27, 0x9d, 763*fab492f1Stb 0x87, 0xf3, 0xde, 0xca, 0xe5, 0xe7, 0xf6, 0x1c, 0x01, 0x65, 764*fab492f1Stb 0x5b, 0xfb, 0x19, 0x79, 0x6e, 0x08, 0x26, 0xc5, 0xc8, 0x28, 765*fab492f1Stb 0x0e, 0xb6, 0x3b, 0x07, 0x08, 0xc1, 0x02, 0x82, 0x01, 0x01, 766*fab492f1Stb 0x00, 0xe8, 0x1c, 0x73, 0xa6, 0xb8, 0xe0, 0x0e, 0x6d, 0x8d, 767*fab492f1Stb 0x1b, 0xb9, 0x53, 0xed, 0x58, 0x94, 0xe6, 0x1d, 0x60, 0x14, 768*fab492f1Stb 0x5c, 0x76, 0x43, 0xc4, 0x58, 0x19, 0xc4, 0x24, 0xe8, 0xbc, 769*fab492f1Stb 0x1b, 0x3b, 0x0b, 0x13, 0x24, 0x45, 0x54, 0x0e, 0xcc, 0x37, 770*fab492f1Stb 0xf0, 0xe0, 0x63, 0x7d, 0xc3, 0xf7, 0xfb, 0x81, 0x74, 0x81, 771*fab492f1Stb 0xc4, 0x0f, 0x1a, 0x21, 0x48, 0xaf, 0xce, 0xc1, 0xc4, 0x94, 772*fab492f1Stb 0x18, 0x06, 0x44, 0x8d, 0xd3, 0xd2, 0x22, 0x2d, 0x2d, 0x3e, 773*fab492f1Stb 0x5a, 0x31, 0xdc, 0x95, 0x8e, 0xf4, 0x41, 0xfc, 0x58, 0xc9, 774*fab492f1Stb 0x40, 0x92, 0x17, 0x5f, 0xe3, 0xda, 0xac, 0x9e, 0x3f, 0x1c, 775*fab492f1Stb 0x2a, 0x6b, 0x58, 0x5f, 0x48, 0x78, 0x20, 0xb1, 0xaf, 0x24, 776*fab492f1Stb 0x9b, 0x3c, 0x20, 0x8b, 0x93, 0x25, 0x9e, 0xe6, 0x6b, 0xbc, 777*fab492f1Stb 0x13, 0x42, 0x14, 0x6c, 0x36, 0x31, 0xff, 0x7a, 0xd1, 0xc1, 778*fab492f1Stb 0x1a, 0x26, 0x14, 0x7f, 0xa9, 0x76, 0xa7, 0x0c, 0xf8, 0xcc, 779*fab492f1Stb 0xed, 0x07, 0x6a, 0xd2, 0xdf, 0x62, 0xee, 0x0a, 0x7c, 0x84, 780*fab492f1Stb 0xcb, 0x49, 0x90, 0xb2, 0x03, 0x0d, 0xa2, 0x82, 0x06, 0x77, 781*fab492f1Stb 0xf1, 0xcd, 0x67, 0xf2, 0x47, 0x21, 0x02, 0x3f, 0x43, 0x21, 782*fab492f1Stb 0xf0, 0x46, 0x30, 0x62, 0x51, 0x72, 0xb1, 0xe7, 0x48, 0xc6, 783*fab492f1Stb 0x67, 0x12, 0xcd, 0x9e, 0xd6, 0x15, 0xe5, 0x21, 0xed, 0xfa, 784*fab492f1Stb 0x8f, 0x30, 0xa6, 0x41, 0xfe, 0xb6, 0xfa, 0x8f, 0x34, 0x14, 785*fab492f1Stb 0x19, 0xe8, 0x11, 0xf7, 0xa5, 0x77, 0x3e, 0xb7, 0xf9, 0x39, 786*fab492f1Stb 0x07, 0x8c, 0x67, 0x2a, 0xab, 0x7b, 0x08, 0xf8, 0xb0, 0x06, 787*fab492f1Stb 0xa8, 0xea, 0x2f, 0x8f, 0xfa, 0xcc, 0xcc, 0x40, 0xce, 0xf3, 788*fab492f1Stb 0x70, 0x4f, 0x3f, 0x7f, 0xe2, 0x0c, 0xea, 0x76, 0x4a, 0x35, 789*fab492f1Stb 0x4e, 0x47, 0xad, 0x2b, 0xa7, 0x97, 0x5d, 0x74, 0x43, 0x97, 790*fab492f1Stb 0x90, 0xd2, 0xfb, 0xd9, 0xf9, 0x96, 0x01, 0x33, 0x05, 0xed, 791*fab492f1Stb 0x7b, 0x03, 0x05, 0xad, 0xf8, 0x49, 0x03, 0x02, 0x82, 0x01, 792*fab492f1Stb 0x01, 0x00, 0xd4, 0x40, 0x17, 0x66, 0x10, 0x92, 0x95, 0xc8, 793*fab492f1Stb 0xec, 0x62, 0xa9, 0x7a, 0xcb, 0x93, 0x8e, 0xe6, 0x53, 0xd4, 794*fab492f1Stb 0x80, 0x48, 0x27, 0x4b, 0x41, 0xce, 0x61, 0xdf, 0xbf, 0x94, 795*fab492f1Stb 0xa4, 0x3d, 0x71, 0x03, 0x0b, 0xed, 0x25, 0x71, 0x98, 0xa4, 796*fab492f1Stb 0xd6, 0xd5, 0x4a, 0x57, 0xf5, 0x6c, 0x1b, 0xda, 0x21, 0x7d, 797*fab492f1Stb 0x35, 0x45, 0xb3, 0xf3, 0x6a, 0xd9, 0xd3, 0x43, 0xe8, 0x5c, 798*fab492f1Stb 0x54, 0x1c, 0x83, 0x1b, 0xb4, 0x5f, 0xf2, 0x97, 0x24, 0x2e, 799*fab492f1Stb 0xdc, 0x40, 0xde, 0x92, 0x23, 0x59, 0x8e, 0xbc, 0xd2, 0xa1, 800*fab492f1Stb 0xf2, 0xe0, 0x4c, 0xdd, 0x0b, 0xd1, 0xe7, 0xae, 0x65, 0xbc, 801*fab492f1Stb 0xb5, 0xf5, 0x5b, 0x98, 0xe9, 0xd7, 0xc2, 0xb7, 0x0e, 0x55, 802*fab492f1Stb 0x71, 0x0e, 0x3c, 0x0a, 0x24, 0x6b, 0xa6, 0xe6, 0x14, 0x61, 803*fab492f1Stb 0x11, 0xfd, 0x33, 0x42, 0x99, 0x2b, 0x84, 0x77, 0x74, 0x92, 804*fab492f1Stb 0x91, 0xf5, 0x79, 0x79, 0xcf, 0xad, 0x8e, 0x04, 0xef, 0x80, 805*fab492f1Stb 0x1e, 0x57, 0xf4, 0x14, 0xf5, 0x35, 0x09, 0x74, 0xb2, 0x13, 806*fab492f1Stb 0x71, 0x58, 0x6b, 0xea, 0x32, 0x5d, 0xf3, 0xd3, 0x76, 0x48, 807*fab492f1Stb 0x39, 0x10, 0x23, 0x84, 0x9d, 0xbe, 0x92, 0x77, 0x4a, 0xed, 808*fab492f1Stb 0x70, 0x3e, 0x1a, 0xa2, 0x6c, 0xb3, 0x81, 0x00, 0xc3, 0xc9, 809*fab492f1Stb 0xe4, 0x52, 0xc8, 0x24, 0x88, 0x0c, 0x41, 0xad, 0x87, 0x5a, 810*fab492f1Stb 0xea, 0xa3, 0x7a, 0x85, 0x1c, 0x5e, 0x31, 0x7f, 0xc3, 0x35, 811*fab492f1Stb 0xc6, 0xfa, 0x10, 0xc8, 0x75, 0x10, 0xc4, 0x96, 0x99, 0xe7, 812*fab492f1Stb 0xfe, 0x01, 0xb4, 0x74, 0xdb, 0xb4, 0x11, 0xc3, 0xc8, 0x8c, 813*fab492f1Stb 0xf6, 0xf7, 0x3b, 0x66, 0x50, 0xfc, 0xdb, 0xeb, 0xca, 0x47, 814*fab492f1Stb 0x85, 0x89, 0xe1, 0x65, 0xd9, 0x62, 0x34, 0x3c, 0x70, 0xd8, 815*fab492f1Stb 0x2e, 0xb4, 0x2f, 0x65, 0x3c, 0x4a, 0xa6, 0x2a, 0xe7, 0xc7, 816*fab492f1Stb 0xd8, 0x41, 0x8f, 0x8a, 0x43, 0xbf, 0x42, 0xf2, 0x4d, 0xbc, 817*fab492f1Stb 0xfc, 0x9e, 0x27, 0x95, 0xfb, 0x75, 0xff, 0xab, 0x02, 0x82, 818*fab492f1Stb 0x01, 0x00, 0x41, 0x2f, 0x44, 0x57, 0x6d, 0x12, 0x17, 0x5b, 819*fab492f1Stb 0x32, 0xc6, 0xb7, 0x6c, 0x57, 0x7a, 0x8a, 0x0e, 0x79, 0xef, 820*fab492f1Stb 0x72, 0xa8, 0x68, 0xda, 0x2d, 0x38, 0xe4, 0xbb, 0x8d, 0xf6, 821*fab492f1Stb 0x02, 0x65, 0xcf, 0x56, 0x13, 0xe1, 0x1a, 0xcb, 0x39, 0x80, 822*fab492f1Stb 0xa6, 0xb1, 0x32, 0x03, 0x1e, 0xdd, 0xbb, 0x35, 0xd9, 0xac, 823*fab492f1Stb 0x43, 0x89, 0x31, 0x08, 0x90, 0x92, 0x5e, 0x35, 0x3d, 0x7b, 824*fab492f1Stb 0x9c, 0x6f, 0x86, 0xcb, 0x17, 0xdd, 0x85, 0xe4, 0xed, 0x35, 825*fab492f1Stb 0x08, 0x8e, 0xc1, 0xf4, 0x05, 0xd8, 0x68, 0xc6, 0x63, 0x3c, 826*fab492f1Stb 0xf7, 0xff, 0xf7, 0x47, 0x33, 0x39, 0xc5, 0x3e, 0xb7, 0x0e, 827*fab492f1Stb 0x58, 0x35, 0x9d, 0x81, 0xea, 0xf8, 0x6a, 0x2c, 0x1c, 0x5a, 828*fab492f1Stb 0x68, 0x78, 0x64, 0x11, 0x6b, 0xc1, 0x3e, 0x4e, 0x7a, 0xbd, 829*fab492f1Stb 0x84, 0xcb, 0x0f, 0xc2, 0xb6, 0x85, 0x1d, 0xd3, 0x76, 0xc5, 830*fab492f1Stb 0x93, 0x6a, 0x69, 0x89, 0x56, 0x34, 0xdc, 0x4a, 0x9b, 0xbc, 831*fab492f1Stb 0xff, 0xa8, 0x0d, 0x6e, 0x35, 0x9c, 0x60, 0xa7, 0x23, 0x30, 832*fab492f1Stb 0xc7, 0x06, 0x64, 0x39, 0x8b, 0x94, 0x89, 0xee, 0xba, 0x7f, 833*fab492f1Stb 0x60, 0x8d, 0xfa, 0xb6, 0x97, 0x76, 0xdc, 0x51, 0x4a, 0x3c, 834*fab492f1Stb 0xeb, 0x3a, 0x14, 0x2c, 0x20, 0x60, 0x69, 0x4a, 0x86, 0xfe, 835*fab492f1Stb 0x8c, 0x21, 0x84, 0x49, 0x54, 0xb3, 0x20, 0xe1, 0x01, 0x7f, 836*fab492f1Stb 0x58, 0xdf, 0x7f, 0xb5, 0x21, 0x51, 0x8c, 0x47, 0x9f, 0x91, 837*fab492f1Stb 0xeb, 0x97, 0x3e, 0xf2, 0x54, 0xcf, 0x16, 0x46, 0xf9, 0xd9, 838*fab492f1Stb 0xb6, 0xe7, 0x64, 0xc9, 0xd0, 0x54, 0xea, 0x2f, 0xa1, 0xcf, 839*fab492f1Stb 0xa5, 0x7f, 0x28, 0x8d, 0x84, 0xec, 0xd5, 0x39, 0x03, 0x76, 840*fab492f1Stb 0x5b, 0x2d, 0x8e, 0x43, 0xf2, 0x01, 0x24, 0xc9, 0x6f, 0xc0, 841*fab492f1Stb 0xf5, 0x69, 0x6f, 0x7d, 0xb5, 0x85, 0xd2, 0x5f, 0x7f, 0x78, 842*fab492f1Stb 0x40, 0x07, 0x7f, 0x09, 0x15, 0xb5, 0x1f, 0x28, 0x65, 0x10, 843*fab492f1Stb 0xe4, 0x19, 0xa8, 0xc6, 0x9e, 0x8d, 0xdc, 0xcb, 0x02, 0x82, 844*fab492f1Stb 0x01, 0x00, 0x13, 0x01, 0xee, 0x56, 0x80, 0x93, 0x70, 0x00, 845*fab492f1Stb 0x7f, 0x52, 0xd2, 0x94, 0xa1, 0x98, 0x84, 0x4a, 0x92, 0x25, 846*fab492f1Stb 0x4c, 0x9b, 0xa9, 0x91, 0x2e, 0xc2, 0x79, 0xb7, 0x5c, 0xe3, 847*fab492f1Stb 0xc5, 0xd5, 0x8e, 0xc2, 0x54, 0x16, 0x17, 0xad, 0x55, 0x9b, 848*fab492f1Stb 0x25, 0x76, 0x12, 0x63, 0x50, 0x22, 0x2f, 0x58, 0x58, 0x79, 849*fab492f1Stb 0x6b, 0x04, 0xe3, 0xf9, 0x9f, 0x8f, 0x04, 0x41, 0x67, 0x94, 850*fab492f1Stb 0xa5, 0x1f, 0xac, 0x8a, 0x15, 0x9c, 0x26, 0x10, 0x6c, 0xf8, 851*fab492f1Stb 0x19, 0x57, 0x61, 0xd7, 0x3a, 0x7d, 0x31, 0xb0, 0x2d, 0x38, 852*fab492f1Stb 0xbd, 0x94, 0x62, 0xad, 0xc4, 0xfa, 0x36, 0x42, 0x42, 0xf0, 853*fab492f1Stb 0x24, 0x67, 0x65, 0x9d, 0x8b, 0x0b, 0x7c, 0x6f, 0x82, 0x44, 854*fab492f1Stb 0x1a, 0x8c, 0xc8, 0xc9, 0xab, 0xbb, 0x4c, 0x45, 0xfc, 0x7b, 855*fab492f1Stb 0x38, 0xee, 0x30, 0xe1, 0xfc, 0xef, 0x8d, 0xbc, 0x58, 0xdf, 856*fab492f1Stb 0x2b, 0x5d, 0x0d, 0x54, 0xe0, 0x49, 0x4d, 0x97, 0x99, 0x8f, 857*fab492f1Stb 0x22, 0xa8, 0x83, 0xbe, 0x40, 0xbb, 0x50, 0x2e, 0x78, 0x28, 858*fab492f1Stb 0x0f, 0x95, 0x78, 0x8c, 0x8f, 0x98, 0x24, 0x56, 0xc2, 0x97, 859*fab492f1Stb 0xf3, 0x2c, 0x43, 0xd2, 0x03, 0x82, 0x66, 0x81, 0x72, 0x5f, 860*fab492f1Stb 0x53, 0x16, 0xec, 0xb1, 0xb1, 0x04, 0x5e, 0x40, 0x20, 0x48, 861*fab492f1Stb 0x7b, 0x3f, 0x02, 0x97, 0x6a, 0xeb, 0x96, 0x12, 0x21, 0x35, 862*fab492f1Stb 0xfe, 0x1f, 0x47, 0xc0, 0x95, 0xea, 0xc5, 0x8a, 0x08, 0x84, 863*fab492f1Stb 0x4f, 0x5e, 0x63, 0x94, 0x60, 0x0f, 0x71, 0x5b, 0x7f, 0x4a, 864*fab492f1Stb 0xec, 0x4f, 0x60, 0xc6, 0xba, 0x4a, 0x24, 0xf1, 0x20, 0x8b, 865*fab492f1Stb 0xa7, 0x2e, 0x3a, 0xce, 0x8d, 0xe0, 0x27, 0x1d, 0xb5, 0x8e, 866*fab492f1Stb 0xb4, 0x21, 0xc5, 0xe2, 0xa6, 0x16, 0x0a, 0x51, 0x83, 0x55, 867*fab492f1Stb 0x88, 0xd1, 0x30, 0x11, 0x63, 0xd5, 0xd7, 0x8d, 0xae, 0x16, 868*fab492f1Stb 0x12, 0x82, 0xc4, 0x85, 0x00, 0x4e, 0x27, 0x83, 0xa5, 0x7c, 869*fab492f1Stb 0x90, 0x2e, 0xe5, 0xa2, 0xa3, 0xd3, 0x4c, 0x63, 0x02, 0x82, 870*fab492f1Stb 0x01, 0x01, 0x00, 0x86, 0x08, 0x98, 0x98, 0xa5, 0x00, 0x05, 871*fab492f1Stb 0x39, 0x77, 0xd9, 0x66, 0xb3, 0xcf, 0xca, 0xa0, 0x71, 0xb3, 872*fab492f1Stb 0x50, 0xce, 0x3d, 0xb1, 0x93, 0x95, 0x35, 0xc4, 0xd4, 0x2e, 873*fab492f1Stb 0x90, 0xdf, 0x0f, 0xfc, 0x60, 0xc1, 0x94, 0x68, 0x61, 0x43, 874*fab492f1Stb 0xca, 0x9a, 0x23, 0x4a, 0x1e, 0x45, 0x72, 0x99, 0xb5, 0x1e, 875*fab492f1Stb 0x61, 0x8d, 0x77, 0x0f, 0xa0, 0xbb, 0xd7, 0x77, 0xb4, 0x2a, 876*fab492f1Stb 0x15, 0x11, 0x88, 0x2d, 0xb3, 0x56, 0x61, 0x5e, 0x6a, 0xed, 877*fab492f1Stb 0xa4, 0x46, 0x4a, 0x3f, 0x50, 0x11, 0xd6, 0xba, 0xb6, 0xd7, 878*fab492f1Stb 0x95, 0x65, 0x53, 0xc3, 0xa1, 0x8f, 0xe0, 0xa3, 0xf5, 0x1c, 879*fab492f1Stb 0xfd, 0xaf, 0x6e, 0x43, 0xd7, 0x17, 0xa7, 0xd3, 0x81, 0x1b, 880*fab492f1Stb 0xa4, 0xdf, 0xe0, 0x97, 0x8a, 0x46, 0x03, 0xd3, 0x46, 0x0e, 881*fab492f1Stb 0x83, 0x48, 0x4e, 0xd2, 0x02, 0xcb, 0xc0, 0xad, 0x79, 0x95, 882*fab492f1Stb 0x8c, 0x96, 0xba, 0x40, 0x34, 0x11, 0x71, 0x5e, 0xe9, 0x11, 883*fab492f1Stb 0xf9, 0xc5, 0x4a, 0x5e, 0x91, 0x9d, 0xf5, 0x92, 0x4f, 0xeb, 884*fab492f1Stb 0xc6, 0x70, 0x02, 0x2d, 0x3d, 0x04, 0xaa, 0xe9, 0x3a, 0x8e, 885*fab492f1Stb 0xd5, 0xa8, 0xad, 0xf7, 0xce, 0x0d, 0x16, 0xb2, 0xec, 0x0a, 886*fab492f1Stb 0x9c, 0xf5, 0x94, 0x39, 0xb9, 0x8a, 0xfc, 0x1e, 0xf9, 0xcc, 887*fab492f1Stb 0xf2, 0x5f, 0x21, 0x31, 0x74, 0x72, 0x6b, 0x64, 0xae, 0x35, 888*fab492f1Stb 0x61, 0x8d, 0x0d, 0xcb, 0xe7, 0xda, 0x39, 0xca, 0xf3, 0x21, 889*fab492f1Stb 0x66, 0x0b, 0x95, 0xd7, 0x0a, 0x7c, 0xca, 0xa1, 0xa9, 0x5a, 890*fab492f1Stb 0xe8, 0xac, 0xe0, 0x71, 0x54, 0xaf, 0x28, 0xcf, 0xd5, 0x70, 891*fab492f1Stb 0x89, 0xe0, 0xf3, 0x9e, 0x43, 0x6c, 0x8d, 0x7b, 0x99, 0x01, 892*fab492f1Stb 0x68, 0x4d, 0xa1, 0x45, 0x46, 0x0c, 0x43, 0xbc, 0xcc, 0x2c, 893*fab492f1Stb 0xdd, 0xc5, 0x46, 0xc8, 0x4e, 0x0e, 0xbe, 0xed, 0xb9, 0x26, 894*fab492f1Stb 0xab, 0x2e, 0xdb, 0xeb, 0x8f, 0xff, 0xdb, 0xb0, 0xc6, 0x55, 895*fab492f1Stb 0xaf, 0xf8, 0x2a, 0x91, 0x9d, 0x50, 0x44, 0x21, 0x17, 896*fab492f1Stb }; 897*fab492f1Stb 898dab3f910Sjsing static void 899dab3f910Sjsing sig_done(int sig) 900dab3f910Sjsing { 901dab3f910Sjsing run = 0; 902dab3f910Sjsing } 903dab3f910Sjsing 904f5e75c9eScheloha #define START TM_RESET 905f5e75c9eScheloha #define STOP TM_GET 906dab3f910Sjsing 907dab3f910Sjsing 908dab3f910Sjsing static double 909dab3f910Sjsing Time_F(int s) 910dab3f910Sjsing { 9112bd895b2Sjca if (usertime) 9122bd895b2Sjca return app_timer_user(s); 9132bd895b2Sjca else 9142bd895b2Sjca return app_timer_real(s); 915dab3f910Sjsing } 916dab3f910Sjsing 917dab3f910Sjsing 918dab3f910Sjsing static const int KDF1_SHA1_len = 20; 919dab3f910Sjsing static void * 920dab3f910Sjsing KDF1_SHA1(const void *in, size_t inlen, void *out, size_t * outlen) 921dab3f910Sjsing { 922dab3f910Sjsing #ifndef OPENSSL_NO_SHA 923dab3f910Sjsing if (*outlen < SHA_DIGEST_LENGTH) 924dab3f910Sjsing return NULL; 925dab3f910Sjsing else 926dab3f910Sjsing *outlen = SHA_DIGEST_LENGTH; 927dab3f910Sjsing return SHA1(in, inlen, out); 928dab3f910Sjsing #else 929dab3f910Sjsing return NULL; 930dab3f910Sjsing #endif /* OPENSSL_NO_SHA */ 931dab3f910Sjsing } 932dab3f910Sjsing 933dab3f910Sjsing int 934dab3f910Sjsing speed_main(int argc, char **argv) 935dab3f910Sjsing { 9361aa981a4Stb unsigned char *real_buf = NULL, *real_buf2 = NULL; 937dab3f910Sjsing unsigned char *buf = NULL, *buf2 = NULL; 9381aa981a4Stb size_t unaligned = 0; 939dab3f910Sjsing int mret = 1; 940dab3f910Sjsing long count = 0, save_count = 0; 941dab3f910Sjsing int i, j, k; 942dab3f910Sjsing long rsa_count; 943dab3f910Sjsing unsigned rsa_num; 944dab3f910Sjsing unsigned char md[EVP_MAX_MD_SIZE]; 94500b7ba7eSdoug #ifndef OPENSSL_NO_MD4 94600b7ba7eSdoug unsigned char md4[MD4_DIGEST_LENGTH]; 94700b7ba7eSdoug #endif 948dab3f910Sjsing #ifndef OPENSSL_NO_MD5 949dab3f910Sjsing unsigned char md5[MD5_DIGEST_LENGTH]; 950dab3f910Sjsing unsigned char hmac[MD5_DIGEST_LENGTH]; 951dab3f910Sjsing #endif 952dab3f910Sjsing #ifndef OPENSSL_NO_SHA 953dab3f910Sjsing unsigned char sha[SHA_DIGEST_LENGTH]; 954dab3f910Sjsing #ifndef OPENSSL_NO_SHA256 955dab3f910Sjsing unsigned char sha256[SHA256_DIGEST_LENGTH]; 956dab3f910Sjsing #endif 957dab3f910Sjsing #ifndef OPENSSL_NO_SHA512 958dab3f910Sjsing unsigned char sha512[SHA512_DIGEST_LENGTH]; 959dab3f910Sjsing #endif 960dab3f910Sjsing #endif 961dab3f910Sjsing #ifndef OPENSSL_NO_WHIRLPOOL 962dab3f910Sjsing unsigned char whirlpool[WHIRLPOOL_DIGEST_LENGTH]; 963dab3f910Sjsing #endif 964dab3f910Sjsing #ifndef OPENSSL_NO_RIPEMD 965dab3f910Sjsing unsigned char rmd160[RIPEMD160_DIGEST_LENGTH]; 966dab3f910Sjsing #endif 967dab3f910Sjsing #ifndef OPENSSL_NO_RC4 968dab3f910Sjsing RC4_KEY rc4_ks; 969dab3f910Sjsing #endif 970dab3f910Sjsing #ifndef OPENSSL_NO_RC2 971dab3f910Sjsing RC2_KEY rc2_ks; 972dab3f910Sjsing #endif 973dab3f910Sjsing #ifndef OPENSSL_NO_IDEA 974dab3f910Sjsing IDEA_KEY_SCHEDULE idea_ks; 975dab3f910Sjsing #endif 976dab3f910Sjsing #ifndef OPENSSL_NO_BF 977dab3f910Sjsing BF_KEY bf_ks; 978dab3f910Sjsing #endif 979dab3f910Sjsing #ifndef OPENSSL_NO_CAST 980dab3f910Sjsing CAST_KEY cast_ks; 981dab3f910Sjsing #endif 982dab3f910Sjsing static const unsigned char key16[16] = 983dab3f910Sjsing {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 984dab3f910Sjsing 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12}; 985dab3f910Sjsing #ifndef OPENSSL_NO_AES 986dab3f910Sjsing static const unsigned char key24[24] = 987dab3f910Sjsing {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 988dab3f910Sjsing 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 989dab3f910Sjsing 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34}; 990dab3f910Sjsing static const unsigned char key32[32] = 991dab3f910Sjsing {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 992dab3f910Sjsing 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 993dab3f910Sjsing 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 994dab3f910Sjsing 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56}; 995dab3f910Sjsing #endif 996dab3f910Sjsing #ifndef OPENSSL_NO_CAMELLIA 997dab3f910Sjsing static const unsigned char ckey24[24] = 998dab3f910Sjsing {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 999dab3f910Sjsing 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 1000dab3f910Sjsing 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34}; 1001dab3f910Sjsing static const unsigned char ckey32[32] = 1002dab3f910Sjsing {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 1003dab3f910Sjsing 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 1004dab3f910Sjsing 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 1005dab3f910Sjsing 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56}; 1006dab3f910Sjsing #endif 1007dab3f910Sjsing #ifndef OPENSSL_NO_AES 1008dab3f910Sjsing #define MAX_BLOCK_SIZE 128 1009dab3f910Sjsing #else 1010dab3f910Sjsing #define MAX_BLOCK_SIZE 64 1011dab3f910Sjsing #endif 1012dab3f910Sjsing unsigned char DES_iv[8]; 1013dab3f910Sjsing unsigned char iv[2 * MAX_BLOCK_SIZE / 8]; 1014dab3f910Sjsing #ifndef OPENSSL_NO_DES 1015dab3f910Sjsing static DES_cblock key = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0}; 1016dab3f910Sjsing static DES_cblock key2 = {0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12}; 1017dab3f910Sjsing static DES_cblock key3 = {0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34}; 1018dab3f910Sjsing DES_key_schedule sch; 1019dab3f910Sjsing DES_key_schedule sch2; 1020dab3f910Sjsing DES_key_schedule sch3; 1021dab3f910Sjsing #endif 1022dab3f910Sjsing #ifndef OPENSSL_NO_AES 1023dab3f910Sjsing AES_KEY aes_ks1, aes_ks2, aes_ks3; 1024dab3f910Sjsing #endif 1025dab3f910Sjsing #ifndef OPENSSL_NO_CAMELLIA 1026dab3f910Sjsing CAMELLIA_KEY camellia_ks1, camellia_ks2, camellia_ks3; 1027dab3f910Sjsing #endif 1028dab3f910Sjsing #define D_MD2 0 1029922ac556Smiod #define D_MD4 1 1030922ac556Smiod #define D_MD5 2 1031922ac556Smiod #define D_HMAC 3 1032922ac556Smiod #define D_SHA1 4 1033922ac556Smiod #define D_RMD160 5 1034922ac556Smiod #define D_RC4 6 1035922ac556Smiod #define D_CBC_DES 7 1036922ac556Smiod #define D_EDE3_DES 8 1037922ac556Smiod #define D_CBC_IDEA 9 1038922ac556Smiod #define D_CBC_SEED 10 1039922ac556Smiod #define D_CBC_RC2 11 1040922ac556Smiod #define D_CBC_RC5 12 1041922ac556Smiod #define D_CBC_BF 13 1042922ac556Smiod #define D_CBC_CAST 14 1043922ac556Smiod #define D_CBC_128_AES 15 1044922ac556Smiod #define D_CBC_192_AES 16 1045922ac556Smiod #define D_CBC_256_AES 17 1046922ac556Smiod #define D_CBC_128_CML 18 1047922ac556Smiod #define D_CBC_192_CML 19 1048922ac556Smiod #define D_CBC_256_CML 20 1049922ac556Smiod #define D_EVP 21 1050922ac556Smiod #define D_SHA256 22 1051922ac556Smiod #define D_SHA512 23 1052922ac556Smiod #define D_WHIRLPOOL 24 1053922ac556Smiod #define D_IGE_128_AES 25 1054922ac556Smiod #define D_IGE_192_AES 26 1055922ac556Smiod #define D_IGE_256_AES 27 1056922ac556Smiod #define D_GHASH 28 1057922ac556Smiod #define D_AES_128_GCM 29 1058922ac556Smiod #define D_AES_256_GCM 30 1059922ac556Smiod #define D_CHACHA20_POLY1305 31 1060dab3f910Sjsing double d = 0.0; 1061dab3f910Sjsing long c[ALGOR_NUM][SIZE_NUM]; 1062dab3f910Sjsing #define R_DSA_512 0 1063dab3f910Sjsing #define R_DSA_1024 1 1064dab3f910Sjsing #define R_DSA_2048 2 1065dab3f910Sjsing #define R_RSA_512 0 1066dab3f910Sjsing #define R_RSA_1024 1 1067dab3f910Sjsing #define R_RSA_2048 2 1068dab3f910Sjsing #define R_RSA_4096 3 1069dab3f910Sjsing 1070ee8ccd1fStb #define R_EC_P224 0 1071ee8ccd1fStb #define R_EC_P256 1 1072ee8ccd1fStb #define R_EC_P384 2 1073ee8ccd1fStb #define R_EC_P521 3 1074dab3f910Sjsing 1075dab3f910Sjsing RSA *rsa_key[RSA_NUM]; 1076dab3f910Sjsing long rsa_c[RSA_NUM][2]; 1077dab3f910Sjsing static unsigned int rsa_bits[RSA_NUM] = {512, 1024, 2048, 4096}; 1078*fab492f1Stb static const unsigned char *rsa_data[RSA_NUM] = 1079dab3f910Sjsing {test512, test1024, test2048, test4096}; 1080dab3f910Sjsing static int rsa_data_length[RSA_NUM] = { 1081dab3f910Sjsing sizeof(test512), sizeof(test1024), 1082dab3f910Sjsing sizeof(test2048), sizeof(test4096)}; 1083dab3f910Sjsing DSA *dsa_key[DSA_NUM]; 1084dab3f910Sjsing long dsa_c[DSA_NUM][2]; 1085dab3f910Sjsing static unsigned int dsa_bits[DSA_NUM] = {512, 1024, 2048}; 1086dab3f910Sjsing #ifndef OPENSSL_NO_EC 1087dab3f910Sjsing /* 1088dab3f910Sjsing * We only test over the following curves as they are representative, 1089dab3f910Sjsing * To add tests over more curves, simply add the curve NID and curve 1090dab3f910Sjsing * name to the following arrays and increase the EC_NUM value 1091dab3f910Sjsing * accordingly. 1092dab3f910Sjsing */ 1093d1d64fe6Stb static unsigned int test_curves[EC_NUM] = { 1094dab3f910Sjsing NID_secp224r1, 1095dab3f910Sjsing NID_X9_62_prime256v1, 1096dab3f910Sjsing NID_secp384r1, 1097dab3f910Sjsing NID_secp521r1, 1098dab3f910Sjsing }; 1099d1d64fe6Stb static const char *test_curves_names[EC_NUM] = { 1100dab3f910Sjsing "nistp224", 1101dab3f910Sjsing "nistp256", 1102dab3f910Sjsing "nistp384", 1103dab3f910Sjsing "nistp521", 1104dab3f910Sjsing }; 1105d1d64fe6Stb static int test_curves_bits[EC_NUM] = { 1106ee8ccd1fStb 224, 256, 384, 521, 1107dab3f910Sjsing }; 1108dab3f910Sjsing 1109dab3f910Sjsing #endif 1110dab3f910Sjsing 1111dab3f910Sjsing unsigned char ecdsasig[256]; 1112dab3f910Sjsing unsigned int ecdsasiglen; 1113dab3f910Sjsing EC_KEY *ecdsa[EC_NUM]; 1114dab3f910Sjsing long ecdsa_c[EC_NUM][2]; 1115dab3f910Sjsing 1116dab3f910Sjsing EC_KEY *ecdh_a[EC_NUM], *ecdh_b[EC_NUM]; 1117dab3f910Sjsing unsigned char secret_a[MAX_ECDH_SIZE], secret_b[MAX_ECDH_SIZE]; 1118dab3f910Sjsing int secret_size_a, secret_size_b; 1119dab3f910Sjsing int ecdh_checks = 0; 1120dab3f910Sjsing int secret_idx = 0; 1121dab3f910Sjsing long ecdh_c[EC_NUM][2]; 1122dab3f910Sjsing 1123dab3f910Sjsing int rsa_doit[RSA_NUM]; 1124dab3f910Sjsing int dsa_doit[DSA_NUM]; 1125dab3f910Sjsing int ecdsa_doit[EC_NUM]; 1126dab3f910Sjsing int ecdh_doit[EC_NUM]; 1127dab3f910Sjsing int doit[ALGOR_NUM]; 1128dab3f910Sjsing int pr_header = 0; 1129dab3f910Sjsing const EVP_CIPHER *evp_cipher = NULL; 1130dab3f910Sjsing const EVP_MD *evp_md = NULL; 1131dab3f910Sjsing int decrypt = 0; 1132dab3f910Sjsing int multi = 0; 1133ee713cadSderaadt struct sigaction sa; 1134e77b5eb2Stb const char *errstr = NULL; 1135dab3f910Sjsing 1136e370f0eeSdoug if (pledge("stdio proc", NULL) == -1) { 11379bc487adSdoug perror("pledge"); 1138e370f0eeSdoug exit(1); 1139e370f0eeSdoug } 11409bc487adSdoug 1141dab3f910Sjsing usertime = -1; 1142dab3f910Sjsing 1143dab3f910Sjsing memset(results, 0, sizeof(results)); 1144dab3f910Sjsing memset(dsa_key, 0, sizeof(dsa_key)); 1145dab3f910Sjsing for (i = 0; i < EC_NUM; i++) 1146dab3f910Sjsing ecdsa[i] = NULL; 1147dab3f910Sjsing for (i = 0; i < EC_NUM; i++) { 1148dab3f910Sjsing ecdh_a[i] = NULL; 1149dab3f910Sjsing ecdh_b[i] = NULL; 1150dab3f910Sjsing } 1151dab3f910Sjsing 1152dab3f910Sjsing memset(rsa_key, 0, sizeof(rsa_key)); 1153dab3f910Sjsing for (i = 0; i < RSA_NUM; i++) 1154dab3f910Sjsing rsa_key[i] = NULL; 1155dab3f910Sjsing 11561aa981a4Stb if ((buf = real_buf = malloc(BUFSIZE + MAX_UNALIGN)) == NULL) { 1157dab3f910Sjsing BIO_printf(bio_err, "out of memory\n"); 1158dab3f910Sjsing goto end; 1159dab3f910Sjsing } 11601aa981a4Stb if ((buf2 = real_buf2 = malloc(BUFSIZE + MAX_UNALIGN)) == NULL) { 1161dab3f910Sjsing BIO_printf(bio_err, "out of memory\n"); 1162dab3f910Sjsing goto end; 1163dab3f910Sjsing } 1164dab3f910Sjsing memset(c, 0, sizeof(c)); 1165dab3f910Sjsing memset(DES_iv, 0, sizeof(DES_iv)); 1166dab3f910Sjsing memset(iv, 0, sizeof(iv)); 1167dab3f910Sjsing 1168dab3f910Sjsing for (i = 0; i < ALGOR_NUM; i++) 1169dab3f910Sjsing doit[i] = 0; 1170dab3f910Sjsing for (i = 0; i < RSA_NUM; i++) 1171dab3f910Sjsing rsa_doit[i] = 0; 1172dab3f910Sjsing for (i = 0; i < DSA_NUM; i++) 1173dab3f910Sjsing dsa_doit[i] = 0; 1174dab3f910Sjsing for (i = 0; i < EC_NUM; i++) 1175dab3f910Sjsing ecdsa_doit[i] = 0; 1176dab3f910Sjsing for (i = 0; i < EC_NUM; i++) 1177dab3f910Sjsing ecdh_doit[i] = 0; 1178dab3f910Sjsing 1179dab3f910Sjsing 1180dab3f910Sjsing j = 0; 1181dab3f910Sjsing argc--; 1182dab3f910Sjsing argv++; 1183dab3f910Sjsing while (argc) { 11848f2041aeStb if (argc > 0 && strcmp(*argv, "-elapsed") == 0) { 1185dab3f910Sjsing usertime = 0; 1186dab3f910Sjsing j--; /* Otherwise, -elapsed gets confused with an 1187dab3f910Sjsing * algorithm. */ 11888f2041aeStb } else if (argc > 0 && strcmp(*argv, "-evp") == 0) { 1189dab3f910Sjsing argc--; 1190dab3f910Sjsing argv++; 1191dab3f910Sjsing if (argc == 0) { 1192dab3f910Sjsing BIO_printf(bio_err, "no EVP given\n"); 1193dab3f910Sjsing goto end; 1194dab3f910Sjsing } 1195dab3f910Sjsing evp_cipher = EVP_get_cipherbyname(*argv); 1196dab3f910Sjsing if (!evp_cipher) { 1197dab3f910Sjsing evp_md = EVP_get_digestbyname(*argv); 1198dab3f910Sjsing } 1199dab3f910Sjsing if (!evp_cipher && !evp_md) { 1200dab3f910Sjsing BIO_printf(bio_err, "%s is an unknown cipher or digest\n", *argv); 1201dab3f910Sjsing goto end; 1202dab3f910Sjsing } 1203dab3f910Sjsing doit[D_EVP] = 1; 12048f2041aeStb } else if (argc > 0 && strcmp(*argv, "-decrypt") == 0) { 1205dab3f910Sjsing decrypt = 1; 120643c847c3Sguenther j--; /* Otherwise, -decrypt gets confused with an 1207dab3f910Sjsing * algorithm. */ 12088f2041aeStb } else if (argc > 0 && strcmp(*argv, "-multi") == 0) { 1209dab3f910Sjsing argc--; 1210dab3f910Sjsing argv++; 1211dab3f910Sjsing if (argc == 0) { 1212dab3f910Sjsing BIO_printf(bio_err, "no multi count given\n"); 1213dab3f910Sjsing goto end; 1214dab3f910Sjsing } 1215dab3f910Sjsing multi = strtonum(argv[0], 1, INT_MAX, &errstr); 1216dab3f910Sjsing if (errstr) { 1217dab3f910Sjsing BIO_printf(bio_err, "bad multi count: %s", errstr); 1218dab3f910Sjsing goto end; 1219dab3f910Sjsing } 122043c847c3Sguenther j--; /* Otherwise, -multi gets confused with an 1221dab3f910Sjsing * algorithm. */ 12221aa981a4Stb } else if (argc > 0 && strcmp(*argv, "-unaligned") == 0) { 12231aa981a4Stb argc--; 12241aa981a4Stb argv++; 12251aa981a4Stb if (argc == 0) { 12261aa981a4Stb BIO_printf(bio_err, "no alignment offset given\n"); 12271aa981a4Stb goto end; 12281aa981a4Stb } 12291aa981a4Stb unaligned = strtonum(argv[0], 0, MAX_UNALIGN, &errstr); 12301aa981a4Stb if (errstr) { 12311aa981a4Stb BIO_printf(bio_err, "bad alignment offset: %s", 12321aa981a4Stb errstr); 12331aa981a4Stb goto end; 12341aa981a4Stb } 12351aa981a4Stb buf = real_buf + unaligned; 12361aa981a4Stb buf2 = real_buf2 + unaligned; 12371aa981a4Stb j--; /* Otherwise, -unaligned gets confused with an 12381aa981a4Stb * algorithm. */ 12398f2041aeStb } else if (argc > 0 && strcmp(*argv, "-mr") == 0) { 1240dab3f910Sjsing mr = 1; 1241dab3f910Sjsing j--; /* Otherwise, -mr gets confused with an 1242dab3f910Sjsing * algorithm. */ 1243dab3f910Sjsing } else 124400b7ba7eSdoug #ifndef OPENSSL_NO_MD4 124500b7ba7eSdoug if (strcmp(*argv, "md4") == 0) 124600b7ba7eSdoug doit[D_MD4] = 1; 124700b7ba7eSdoug else 124800b7ba7eSdoug #endif 1249dab3f910Sjsing #ifndef OPENSSL_NO_MD5 1250dab3f910Sjsing if (strcmp(*argv, "md5") == 0) 1251dab3f910Sjsing doit[D_MD5] = 1; 1252dab3f910Sjsing else 1253dab3f910Sjsing #endif 1254dab3f910Sjsing #ifndef OPENSSL_NO_MD5 1255dab3f910Sjsing if (strcmp(*argv, "hmac") == 0) 1256dab3f910Sjsing doit[D_HMAC] = 1; 1257dab3f910Sjsing else 1258dab3f910Sjsing #endif 1259dab3f910Sjsing #ifndef OPENSSL_NO_SHA 1260dab3f910Sjsing if (strcmp(*argv, "sha1") == 0) 1261dab3f910Sjsing doit[D_SHA1] = 1; 1262dab3f910Sjsing else if (strcmp(*argv, "sha") == 0) 1263dab3f910Sjsing doit[D_SHA1] = 1, 1264dab3f910Sjsing doit[D_SHA256] = 1, 1265dab3f910Sjsing doit[D_SHA512] = 1; 1266dab3f910Sjsing else 1267dab3f910Sjsing #ifndef OPENSSL_NO_SHA256 1268dab3f910Sjsing if (strcmp(*argv, "sha256") == 0) 1269dab3f910Sjsing doit[D_SHA256] = 1; 1270dab3f910Sjsing else 1271dab3f910Sjsing #endif 1272dab3f910Sjsing #ifndef OPENSSL_NO_SHA512 1273dab3f910Sjsing if (strcmp(*argv, "sha512") == 0) 1274dab3f910Sjsing doit[D_SHA512] = 1; 1275dab3f910Sjsing else 1276dab3f910Sjsing #endif 1277dab3f910Sjsing #endif 1278dab3f910Sjsing #ifndef OPENSSL_NO_WHIRLPOOL 1279dab3f910Sjsing if (strcmp(*argv, "whirlpool") == 0) 1280dab3f910Sjsing doit[D_WHIRLPOOL] = 1; 1281dab3f910Sjsing else 1282dab3f910Sjsing #endif 1283dab3f910Sjsing #ifndef OPENSSL_NO_RIPEMD 1284dab3f910Sjsing if (strcmp(*argv, "ripemd") == 0) 1285dab3f910Sjsing doit[D_RMD160] = 1; 1286dab3f910Sjsing else if (strcmp(*argv, "rmd160") == 0) 1287dab3f910Sjsing doit[D_RMD160] = 1; 1288dab3f910Sjsing else if (strcmp(*argv, "ripemd160") == 0) 1289dab3f910Sjsing doit[D_RMD160] = 1; 1290dab3f910Sjsing else 1291dab3f910Sjsing #endif 1292dab3f910Sjsing #ifndef OPENSSL_NO_RC4 1293dab3f910Sjsing if (strcmp(*argv, "rc4") == 0) 1294dab3f910Sjsing doit[D_RC4] = 1; 1295dab3f910Sjsing else 1296dab3f910Sjsing #endif 1297dab3f910Sjsing #ifndef OPENSSL_NO_DES 1298dab3f910Sjsing if (strcmp(*argv, "des-cbc") == 0) 1299dab3f910Sjsing doit[D_CBC_DES] = 1; 1300dab3f910Sjsing else if (strcmp(*argv, "des-ede3") == 0) 1301dab3f910Sjsing doit[D_EDE3_DES] = 1; 1302dab3f910Sjsing else 1303dab3f910Sjsing #endif 1304dab3f910Sjsing #ifndef OPENSSL_NO_AES 1305dab3f910Sjsing if (strcmp(*argv, "aes-128-cbc") == 0) 1306dab3f910Sjsing doit[D_CBC_128_AES] = 1; 1307dab3f910Sjsing else if (strcmp(*argv, "aes-192-cbc") == 0) 1308dab3f910Sjsing doit[D_CBC_192_AES] = 1; 1309dab3f910Sjsing else if (strcmp(*argv, "aes-256-cbc") == 0) 1310dab3f910Sjsing doit[D_CBC_256_AES] = 1; 1311dab3f910Sjsing else if (strcmp(*argv, "aes-128-ige") == 0) 1312dab3f910Sjsing doit[D_IGE_128_AES] = 1; 1313dab3f910Sjsing else if (strcmp(*argv, "aes-192-ige") == 0) 1314dab3f910Sjsing doit[D_IGE_192_AES] = 1; 1315dab3f910Sjsing else if (strcmp(*argv, "aes-256-ige") == 0) 1316dab3f910Sjsing doit[D_IGE_256_AES] = 1; 1317dab3f910Sjsing else 1318dab3f910Sjsing #endif 1319dab3f910Sjsing #ifndef OPENSSL_NO_CAMELLIA 1320dab3f910Sjsing if (strcmp(*argv, "camellia-128-cbc") == 0) 1321dab3f910Sjsing doit[D_CBC_128_CML] = 1; 1322dab3f910Sjsing else if (strcmp(*argv, "camellia-192-cbc") == 0) 1323dab3f910Sjsing doit[D_CBC_192_CML] = 1; 1324dab3f910Sjsing else if (strcmp(*argv, "camellia-256-cbc") == 0) 1325dab3f910Sjsing doit[D_CBC_256_CML] = 1; 1326dab3f910Sjsing else 1327dab3f910Sjsing #endif 1328dab3f910Sjsing #ifndef RSA_NULL 1329dab3f910Sjsing if (strcmp(*argv, "openssl") == 0) { 1330dab3f910Sjsing RSA_set_default_method(RSA_PKCS1_SSLeay()); 1331dab3f910Sjsing j--; 1332dab3f910Sjsing } else 1333dab3f910Sjsing #endif 1334dab3f910Sjsing if (strcmp(*argv, "dsa512") == 0) 1335dab3f910Sjsing dsa_doit[R_DSA_512] = 2; 1336dab3f910Sjsing else if (strcmp(*argv, "dsa1024") == 0) 1337dab3f910Sjsing dsa_doit[R_DSA_1024] = 2; 1338dab3f910Sjsing else if (strcmp(*argv, "dsa2048") == 0) 1339dab3f910Sjsing dsa_doit[R_DSA_2048] = 2; 1340dab3f910Sjsing else if (strcmp(*argv, "rsa512") == 0) 1341dab3f910Sjsing rsa_doit[R_RSA_512] = 2; 1342dab3f910Sjsing else if (strcmp(*argv, "rsa1024") == 0) 1343dab3f910Sjsing rsa_doit[R_RSA_1024] = 2; 1344dab3f910Sjsing else if (strcmp(*argv, "rsa2048") == 0) 1345dab3f910Sjsing rsa_doit[R_RSA_2048] = 2; 1346dab3f910Sjsing else if (strcmp(*argv, "rsa4096") == 0) 1347dab3f910Sjsing rsa_doit[R_RSA_4096] = 2; 1348dab3f910Sjsing else 1349dab3f910Sjsing #ifndef OPENSSL_NO_RC2 1350dab3f910Sjsing if (strcmp(*argv, "rc2-cbc") == 0) 1351dab3f910Sjsing doit[D_CBC_RC2] = 1; 1352dab3f910Sjsing else if (strcmp(*argv, "rc2") == 0) 1353dab3f910Sjsing doit[D_CBC_RC2] = 1; 1354dab3f910Sjsing else 1355dab3f910Sjsing #endif 1356dab3f910Sjsing #ifndef OPENSSL_NO_IDEA 1357dab3f910Sjsing if (strcmp(*argv, "idea-cbc") == 0) 1358dab3f910Sjsing doit[D_CBC_IDEA] = 1; 1359dab3f910Sjsing else if (strcmp(*argv, "idea") == 0) 1360dab3f910Sjsing doit[D_CBC_IDEA] = 1; 1361dab3f910Sjsing else 1362dab3f910Sjsing #endif 1363dab3f910Sjsing #ifndef OPENSSL_NO_BF 1364dab3f910Sjsing if (strcmp(*argv, "bf-cbc") == 0) 1365dab3f910Sjsing doit[D_CBC_BF] = 1; 1366dab3f910Sjsing else if (strcmp(*argv, "blowfish") == 0) 1367dab3f910Sjsing doit[D_CBC_BF] = 1; 1368dab3f910Sjsing else if (strcmp(*argv, "bf") == 0) 1369dab3f910Sjsing doit[D_CBC_BF] = 1; 1370dab3f910Sjsing else 1371dab3f910Sjsing #endif 1372dab3f910Sjsing #ifndef OPENSSL_NO_CAST 1373dab3f910Sjsing if (strcmp(*argv, "cast-cbc") == 0) 1374dab3f910Sjsing doit[D_CBC_CAST] = 1; 1375dab3f910Sjsing else if (strcmp(*argv, "cast") == 0) 1376dab3f910Sjsing doit[D_CBC_CAST] = 1; 1377dab3f910Sjsing else if (strcmp(*argv, "cast5") == 0) 1378dab3f910Sjsing doit[D_CBC_CAST] = 1; 1379dab3f910Sjsing else 1380dab3f910Sjsing #endif 1381dab3f910Sjsing #ifndef OPENSSL_NO_DES 1382dab3f910Sjsing if (strcmp(*argv, "des") == 0) { 1383dab3f910Sjsing doit[D_CBC_DES] = 1; 1384dab3f910Sjsing doit[D_EDE3_DES] = 1; 1385dab3f910Sjsing } else 1386dab3f910Sjsing #endif 1387dab3f910Sjsing #ifndef OPENSSL_NO_AES 1388dab3f910Sjsing if (strcmp(*argv, "aes") == 0) { 1389dab3f910Sjsing doit[D_CBC_128_AES] = 1; 1390dab3f910Sjsing doit[D_CBC_192_AES] = 1; 1391dab3f910Sjsing doit[D_CBC_256_AES] = 1; 1392fb93d8bbSbcook } else if (strcmp(*argv, "ghash") == 0) 1393dab3f910Sjsing doit[D_GHASH] = 1; 1394fb93d8bbSbcook else if (strcmp(*argv,"aes-128-gcm") == 0) 1395fb93d8bbSbcook doit[D_AES_128_GCM]=1; 1396fb93d8bbSbcook else if (strcmp(*argv,"aes-256-gcm") == 0) 1397fb93d8bbSbcook doit[D_AES_256_GCM]=1; 1398fb93d8bbSbcook else 1399dab3f910Sjsing #endif 1400dab3f910Sjsing #ifndef OPENSSL_NO_CAMELLIA 1401dab3f910Sjsing if (strcmp(*argv, "camellia") == 0) { 1402dab3f910Sjsing doit[D_CBC_128_CML] = 1; 1403dab3f910Sjsing doit[D_CBC_192_CML] = 1; 1404dab3f910Sjsing doit[D_CBC_256_CML] = 1; 1405dab3f910Sjsing } else 1406dab3f910Sjsing #endif 1407fb93d8bbSbcook #if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) 1408fb93d8bbSbcook if (strcmp(*argv,"chacha20-poly1305") == 0) 1409fb93d8bbSbcook doit[D_CHACHA20_POLY1305]=1; 1410fb93d8bbSbcook else 1411fb93d8bbSbcook #endif 1412dab3f910Sjsing if (strcmp(*argv, "rsa") == 0) { 1413dab3f910Sjsing rsa_doit[R_RSA_512] = 1; 1414dab3f910Sjsing rsa_doit[R_RSA_1024] = 1; 1415dab3f910Sjsing rsa_doit[R_RSA_2048] = 1; 1416dab3f910Sjsing rsa_doit[R_RSA_4096] = 1; 1417bb0f3b26Sderaadt } else if (strcmp(*argv, "dsa") == 0) { 1418dab3f910Sjsing dsa_doit[R_DSA_512] = 1; 1419dab3f910Sjsing dsa_doit[R_DSA_1024] = 1; 1420dab3f910Sjsing dsa_doit[R_DSA_2048] = 1; 1421ee8ccd1fStb } else if (strcmp(*argv, "ecdsap224") == 0) 1422dab3f910Sjsing ecdsa_doit[R_EC_P224] = 2; 1423dab3f910Sjsing else if (strcmp(*argv, "ecdsap256") == 0) 1424dab3f910Sjsing ecdsa_doit[R_EC_P256] = 2; 1425dab3f910Sjsing else if (strcmp(*argv, "ecdsap384") == 0) 1426dab3f910Sjsing ecdsa_doit[R_EC_P384] = 2; 1427dab3f910Sjsing else if (strcmp(*argv, "ecdsap521") == 0) 1428dab3f910Sjsing ecdsa_doit[R_EC_P521] = 2; 1429dab3f910Sjsing else if (strcmp(*argv, "ecdsa") == 0) { 1430dab3f910Sjsing for (i = 0; i < EC_NUM; i++) 1431dab3f910Sjsing ecdsa_doit[i] = 1; 1432ee8ccd1fStb } else if (strcmp(*argv, "ecdhp224") == 0) 1433dab3f910Sjsing ecdh_doit[R_EC_P224] = 2; 1434dab3f910Sjsing else if (strcmp(*argv, "ecdhp256") == 0) 1435dab3f910Sjsing ecdh_doit[R_EC_P256] = 2; 1436dab3f910Sjsing else if (strcmp(*argv, "ecdhp384") == 0) 1437dab3f910Sjsing ecdh_doit[R_EC_P384] = 2; 1438dab3f910Sjsing else if (strcmp(*argv, "ecdhp521") == 0) 1439dab3f910Sjsing ecdh_doit[R_EC_P521] = 2; 1440dab3f910Sjsing else if (strcmp(*argv, "ecdh") == 0) { 1441dab3f910Sjsing for (i = 0; i < EC_NUM; i++) 1442dab3f910Sjsing ecdh_doit[i] = 1; 1443bb0f3b26Sderaadt } else { 1444dab3f910Sjsing BIO_printf(bio_err, "Error: bad option or value\n"); 1445dab3f910Sjsing BIO_printf(bio_err, "\n"); 1446dab3f910Sjsing BIO_printf(bio_err, "Available values:\n"); 144700b7ba7eSdoug #ifndef OPENSSL_NO_MD4 144800b7ba7eSdoug BIO_printf(bio_err, "md4 "); 144900b7ba7eSdoug #endif 1450dab3f910Sjsing #ifndef OPENSSL_NO_MD5 1451dab3f910Sjsing BIO_printf(bio_err, "md5 "); 1452dab3f910Sjsing #ifndef OPENSSL_NO_HMAC 1453dab3f910Sjsing BIO_printf(bio_err, "hmac "); 1454dab3f910Sjsing #endif 1455dab3f910Sjsing #endif 1456dab3f910Sjsing #ifndef OPENSSL_NO_SHA1 1457dab3f910Sjsing BIO_printf(bio_err, "sha1 "); 1458dab3f910Sjsing #endif 1459dab3f910Sjsing #ifndef OPENSSL_NO_SHA256 1460dab3f910Sjsing BIO_printf(bio_err, "sha256 "); 1461dab3f910Sjsing #endif 1462dab3f910Sjsing #ifndef OPENSSL_NO_SHA512 1463dab3f910Sjsing BIO_printf(bio_err, "sha512 "); 1464dab3f910Sjsing #endif 1465dab3f910Sjsing #ifndef OPENSSL_NO_WHIRLPOOL 1466dab3f910Sjsing BIO_printf(bio_err, "whirlpool"); 1467dab3f910Sjsing #endif 1468dab3f910Sjsing #ifndef OPENSSL_NO_RIPEMD160 1469dab3f910Sjsing BIO_printf(bio_err, "rmd160"); 1470dab3f910Sjsing #endif 1471b9b6a34eSdoug #if !defined(OPENSSL_NO_MD2) || \ 147200b7ba7eSdoug !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \ 1473dab3f910Sjsing !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160) || \ 1474dab3f910Sjsing !defined(OPENSSL_NO_WHIRLPOOL) 1475dab3f910Sjsing BIO_printf(bio_err, "\n"); 1476dab3f910Sjsing #endif 1477dab3f910Sjsing 1478dab3f910Sjsing #ifndef OPENSSL_NO_IDEA 1479dab3f910Sjsing BIO_printf(bio_err, "idea-cbc "); 1480dab3f910Sjsing #endif 1481dab3f910Sjsing #ifndef OPENSSL_NO_RC2 1482dab3f910Sjsing BIO_printf(bio_err, "rc2-cbc "); 1483dab3f910Sjsing #endif 1484dab3f910Sjsing #ifndef OPENSSL_NO_BF 1485dab3f910Sjsing BIO_printf(bio_err, "bf-cbc "); 1486dab3f910Sjsing #endif 1487dab3f910Sjsing #ifndef OPENSSL_NO_DES 1488fb93d8bbSbcook BIO_printf(bio_err, "des-cbc des-ede3\n"); 1489dab3f910Sjsing #endif 1490dab3f910Sjsing #ifndef OPENSSL_NO_AES 1491dab3f910Sjsing BIO_printf(bio_err, "aes-128-cbc aes-192-cbc aes-256-cbc "); 1492fb93d8bbSbcook BIO_printf(bio_err, "aes-128-ige aes-192-ige aes-256-ige\n"); 1493fb93d8bbSbcook BIO_printf(bio_err, "aes-128-gcm aes-256-gcm "); 1494dab3f910Sjsing #endif 1495dab3f910Sjsing #ifndef OPENSSL_NO_CAMELLIA 1496dab3f910Sjsing BIO_printf(bio_err, "\n"); 1497dab3f910Sjsing BIO_printf(bio_err, "camellia-128-cbc camellia-192-cbc camellia-256-cbc "); 1498dab3f910Sjsing #endif 1499dab3f910Sjsing #ifndef OPENSSL_NO_RC4 1500dab3f910Sjsing BIO_printf(bio_err, "rc4"); 1501dab3f910Sjsing #endif 1502fb93d8bbSbcook #if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) 1503fb93d8bbSbcook BIO_printf(bio_err," chacha20-poly1305"); 1504fb93d8bbSbcook #endif 1505dab3f910Sjsing BIO_printf(bio_err, "\n"); 1506dab3f910Sjsing 1507dab3f910Sjsing BIO_printf(bio_err, "rsa512 rsa1024 rsa2048 rsa4096\n"); 1508dab3f910Sjsing 1509dab3f910Sjsing BIO_printf(bio_err, "dsa512 dsa1024 dsa2048\n"); 1510ee8ccd1fStb BIO_printf(bio_err, "ecdsap224 ecdsap256 ecdsap384 ecdsap521\n"); 1511ee8ccd1fStb BIO_printf(bio_err, "ecdhp224 ecdhp256 ecdhp384 ecdhp521\n"); 1512dab3f910Sjsing 1513dab3f910Sjsing #ifndef OPENSSL_NO_IDEA 1514dab3f910Sjsing BIO_printf(bio_err, "idea "); 1515dab3f910Sjsing #endif 1516dab3f910Sjsing #ifndef OPENSSL_NO_RC2 1517dab3f910Sjsing BIO_printf(bio_err, "rc2 "); 1518dab3f910Sjsing #endif 1519dab3f910Sjsing #ifndef OPENSSL_NO_DES 1520dab3f910Sjsing BIO_printf(bio_err, "des "); 1521dab3f910Sjsing #endif 1522dab3f910Sjsing #ifndef OPENSSL_NO_AES 1523dab3f910Sjsing BIO_printf(bio_err, "aes "); 1524dab3f910Sjsing #endif 1525dab3f910Sjsing #ifndef OPENSSL_NO_CAMELLIA 1526dab3f910Sjsing BIO_printf(bio_err, "camellia "); 1527dab3f910Sjsing #endif 1528dab3f910Sjsing BIO_printf(bio_err, "rsa "); 1529dab3f910Sjsing #ifndef OPENSSL_NO_BF 1530dab3f910Sjsing BIO_printf(bio_err, "blowfish"); 1531dab3f910Sjsing #endif 1532dab3f910Sjsing #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_SEED) || \ 1533dab3f910Sjsing !defined(OPENSSL_NO_RC2) || !defined(OPENSSL_NO_DES) || \ 1534dab3f910Sjsing !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_BF) || \ 1535dab3f910Sjsing !defined(OPENSSL_NO_AES) || !defined(OPENSSL_NO_CAMELLIA) 1536dab3f910Sjsing BIO_printf(bio_err, "\n"); 1537dab3f910Sjsing #endif 1538dab3f910Sjsing 1539dab3f910Sjsing BIO_printf(bio_err, "\n"); 1540dab3f910Sjsing BIO_printf(bio_err, "Available options:\n"); 1541dab3f910Sjsing BIO_printf(bio_err, "-elapsed measure time in real time instead of CPU user time.\n"); 1542dab3f910Sjsing BIO_printf(bio_err, "-evp e use EVP e.\n"); 1543dab3f910Sjsing BIO_printf(bio_err, "-decrypt time decryption instead of encryption (only EVP).\n"); 1544dab3f910Sjsing BIO_printf(bio_err, "-mr produce machine readable output.\n"); 1545dab3f910Sjsing BIO_printf(bio_err, "-multi n run n benchmarks in parallel.\n"); 15461aa981a4Stb BIO_printf(bio_err, "-unaligned n use buffers with offset n from proper alignment.\n"); 1547dab3f910Sjsing goto end; 1548dab3f910Sjsing } 1549dab3f910Sjsing argc--; 1550dab3f910Sjsing argv++; 1551dab3f910Sjsing j++; 1552dab3f910Sjsing } 1553dab3f910Sjsing 1554dab3f910Sjsing if (multi && do_multi(multi)) 1555dab3f910Sjsing goto show_res; 1556dab3f910Sjsing 1557dab3f910Sjsing if (j == 0) { 1558dab3f910Sjsing for (i = 0; i < ALGOR_NUM; i++) { 1559dab3f910Sjsing if (i != D_EVP) 1560dab3f910Sjsing doit[i] = 1; 1561dab3f910Sjsing } 1562dab3f910Sjsing for (i = 0; i < RSA_NUM; i++) 1563dab3f910Sjsing rsa_doit[i] = 1; 1564dab3f910Sjsing for (i = 0; i < DSA_NUM; i++) 1565dab3f910Sjsing dsa_doit[i] = 1; 1566dab3f910Sjsing for (i = 0; i < EC_NUM; i++) 1567dab3f910Sjsing ecdsa_doit[i] = 1; 1568dab3f910Sjsing for (i = 0; i < EC_NUM; i++) 1569dab3f910Sjsing ecdh_doit[i] = 1; 1570dab3f910Sjsing } 1571dab3f910Sjsing for (i = 0; i < ALGOR_NUM; i++) 1572dab3f910Sjsing if (doit[i]) 1573dab3f910Sjsing pr_header++; 1574dab3f910Sjsing 1575dab3f910Sjsing if (usertime == 0 && !mr) 1576dab3f910Sjsing BIO_printf(bio_err, "You have chosen to measure elapsed time instead of user CPU time.\n"); 1577dab3f910Sjsing 1578dab3f910Sjsing for (i = 0; i < RSA_NUM; i++) { 1579dab3f910Sjsing const unsigned char *p; 1580dab3f910Sjsing 1581dab3f910Sjsing p = rsa_data[i]; 1582dab3f910Sjsing rsa_key[i] = d2i_RSAPrivateKey(NULL, &p, rsa_data_length[i]); 1583dab3f910Sjsing if (rsa_key[i] == NULL) { 1584dab3f910Sjsing BIO_printf(bio_err, "internal error loading RSA key number %d\n", i); 1585dab3f910Sjsing goto end; 1586dab3f910Sjsing } 1587dab3f910Sjsing } 1588dab3f910Sjsing 1589dab3f910Sjsing dsa_key[0] = get_dsa512(); 1590dab3f910Sjsing dsa_key[1] = get_dsa1024(); 1591dab3f910Sjsing dsa_key[2] = get_dsa2048(); 1592dab3f910Sjsing 1593dab3f910Sjsing #ifndef OPENSSL_NO_DES 1594dab3f910Sjsing DES_set_key_unchecked(&key, &sch); 1595dab3f910Sjsing DES_set_key_unchecked(&key2, &sch2); 1596dab3f910Sjsing DES_set_key_unchecked(&key3, &sch3); 1597dab3f910Sjsing #endif 1598dab3f910Sjsing #ifndef OPENSSL_NO_AES 1599dab3f910Sjsing AES_set_encrypt_key(key16, 128, &aes_ks1); 1600dab3f910Sjsing AES_set_encrypt_key(key24, 192, &aes_ks2); 1601dab3f910Sjsing AES_set_encrypt_key(key32, 256, &aes_ks3); 1602dab3f910Sjsing #endif 1603dab3f910Sjsing #ifndef OPENSSL_NO_CAMELLIA 1604dab3f910Sjsing Camellia_set_key(key16, 128, &camellia_ks1); 1605dab3f910Sjsing Camellia_set_key(ckey24, 192, &camellia_ks2); 1606dab3f910Sjsing Camellia_set_key(ckey32, 256, &camellia_ks3); 1607dab3f910Sjsing #endif 1608dab3f910Sjsing #ifndef OPENSSL_NO_IDEA 1609dab3f910Sjsing idea_set_encrypt_key(key16, &idea_ks); 1610dab3f910Sjsing #endif 1611dab3f910Sjsing #ifndef OPENSSL_NO_RC4 1612dab3f910Sjsing RC4_set_key(&rc4_ks, 16, key16); 1613dab3f910Sjsing #endif 1614dab3f910Sjsing #ifndef OPENSSL_NO_RC2 1615dab3f910Sjsing RC2_set_key(&rc2_ks, 16, key16, 128); 1616dab3f910Sjsing #endif 1617dab3f910Sjsing #ifndef OPENSSL_NO_BF 1618dab3f910Sjsing BF_set_key(&bf_ks, 16, key16); 1619dab3f910Sjsing #endif 1620dab3f910Sjsing #ifndef OPENSSL_NO_CAST 1621dab3f910Sjsing CAST_set_key(&cast_ks, 16, key16); 1622dab3f910Sjsing #endif 1623dab3f910Sjsing memset(rsa_c, 0, sizeof(rsa_c)); 1624dab3f910Sjsing #define COND(c) (run && count<0x7fffffff) 1625dab3f910Sjsing #define COUNT(d) (count) 1626ee713cadSderaadt 1627ee713cadSderaadt memset(&sa, 0, sizeof(sa)); 1628ee713cadSderaadt sigemptyset(&sa.sa_mask); 1629ee713cadSderaadt sa.sa_flags = SA_RESTART; 1630ee713cadSderaadt sa.sa_handler = sig_done; 1631ee713cadSderaadt sigaction(SIGALRM, &sa, NULL); 1632dab3f910Sjsing 163300b7ba7eSdoug #ifndef OPENSSL_NO_MD4 163400b7ba7eSdoug if (doit[D_MD4]) { 163500b7ba7eSdoug for (j = 0; j < SIZE_NUM; j++) { 163600b7ba7eSdoug print_message(names[D_MD4], c[D_MD4][j], lengths[j]); 163700b7ba7eSdoug Time_F(START); 163800b7ba7eSdoug for (count = 0, run = 1; COND(c[D_MD4][j]); count++) 163900b7ba7eSdoug EVP_Digest(&(buf[0]), (unsigned long) lengths[j], &(md4[0]), NULL, EVP_md4(), NULL); 164000b7ba7eSdoug d = Time_F(STOP); 164100b7ba7eSdoug print_result(D_MD4, j, count, d); 164200b7ba7eSdoug } 164300b7ba7eSdoug } 164400b7ba7eSdoug #endif 164500b7ba7eSdoug 1646dab3f910Sjsing #ifndef OPENSSL_NO_MD5 1647dab3f910Sjsing if (doit[D_MD5]) { 1648dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1649dab3f910Sjsing print_message(names[D_MD5], c[D_MD5][j], lengths[j]); 1650dab3f910Sjsing Time_F(START); 1651dab3f910Sjsing for (count = 0, run = 1; COND(c[D_MD5][j]); count++) 1652dab3f910Sjsing EVP_Digest(&(buf[0]), (unsigned long) lengths[j], &(md5[0]), NULL, EVP_get_digestbyname("md5"), NULL); 1653dab3f910Sjsing d = Time_F(STOP); 1654dab3f910Sjsing print_result(D_MD5, j, count, d); 1655dab3f910Sjsing } 1656dab3f910Sjsing } 1657dab3f910Sjsing #endif 1658dab3f910Sjsing 1659dab3f910Sjsing #if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC) 1660dab3f910Sjsing if (doit[D_HMAC]) { 16613110bdd5Stb HMAC_CTX *hctx; 1662dab3f910Sjsing 16633110bdd5Stb if ((hctx = HMAC_CTX_new()) == NULL) { 16643110bdd5Stb BIO_printf(bio_err, "Failed to allocate HMAC context.\n"); 1665bd6dc48bStb goto end; 16663110bdd5Stb } 16673110bdd5Stb 16683110bdd5Stb HMAC_Init_ex(hctx, (unsigned char *) "This is a key...", 1669dab3f910Sjsing 16, EVP_md5(), NULL); 1670dab3f910Sjsing 1671dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1672dab3f910Sjsing print_message(names[D_HMAC], c[D_HMAC][j], lengths[j]); 1673dab3f910Sjsing Time_F(START); 1674dab3f910Sjsing for (count = 0, run = 1; COND(c[D_HMAC][j]); count++) { 1675415eed49Stb if (!HMAC_Init_ex(hctx, NULL, 0, NULL, NULL)) { 1676415eed49Stb HMAC_CTX_free(hctx); 1677415eed49Stb goto end; 1678415eed49Stb } 1679415eed49Stb if (!HMAC_Update(hctx, buf, lengths[j])) { 1680415eed49Stb HMAC_CTX_free(hctx); 1681415eed49Stb goto end; 1682415eed49Stb } 1683415eed49Stb if (!HMAC_Final(hctx, &(hmac[0]), NULL)) { 1684415eed49Stb HMAC_CTX_free(hctx); 1685415eed49Stb goto end; 1686415eed49Stb } 1687dab3f910Sjsing } 1688dab3f910Sjsing d = Time_F(STOP); 1689dab3f910Sjsing print_result(D_HMAC, j, count, d); 1690dab3f910Sjsing } 16913110bdd5Stb HMAC_CTX_free(hctx); 1692dab3f910Sjsing } 1693dab3f910Sjsing #endif 1694dab3f910Sjsing #ifndef OPENSSL_NO_SHA 1695dab3f910Sjsing if (doit[D_SHA1]) { 1696dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1697dab3f910Sjsing print_message(names[D_SHA1], c[D_SHA1][j], lengths[j]); 1698dab3f910Sjsing Time_F(START); 1699dab3f910Sjsing for (count = 0, run = 1; COND(c[D_SHA1][j]); count++) 1700dab3f910Sjsing EVP_Digest(buf, (unsigned long) lengths[j], &(sha[0]), NULL, EVP_sha1(), NULL); 1701dab3f910Sjsing d = Time_F(STOP); 1702dab3f910Sjsing print_result(D_SHA1, j, count, d); 1703dab3f910Sjsing } 1704dab3f910Sjsing } 1705dab3f910Sjsing #ifndef OPENSSL_NO_SHA256 1706dab3f910Sjsing if (doit[D_SHA256]) { 1707dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1708dab3f910Sjsing print_message(names[D_SHA256], c[D_SHA256][j], lengths[j]); 1709dab3f910Sjsing Time_F(START); 1710dab3f910Sjsing for (count = 0, run = 1; COND(c[D_SHA256][j]); count++) 1711dab3f910Sjsing SHA256(buf, lengths[j], sha256); 1712dab3f910Sjsing d = Time_F(STOP); 1713dab3f910Sjsing print_result(D_SHA256, j, count, d); 1714dab3f910Sjsing } 1715dab3f910Sjsing } 1716dab3f910Sjsing #endif 1717dab3f910Sjsing 1718dab3f910Sjsing #ifndef OPENSSL_NO_SHA512 1719dab3f910Sjsing if (doit[D_SHA512]) { 1720dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1721dab3f910Sjsing print_message(names[D_SHA512], c[D_SHA512][j], lengths[j]); 1722dab3f910Sjsing Time_F(START); 1723dab3f910Sjsing for (count = 0, run = 1; COND(c[D_SHA512][j]); count++) 1724dab3f910Sjsing SHA512(buf, lengths[j], sha512); 1725dab3f910Sjsing d = Time_F(STOP); 1726dab3f910Sjsing print_result(D_SHA512, j, count, d); 1727dab3f910Sjsing } 1728dab3f910Sjsing } 1729dab3f910Sjsing #endif 1730dab3f910Sjsing #endif 1731dab3f910Sjsing 1732dab3f910Sjsing #ifndef OPENSSL_NO_WHIRLPOOL 1733dab3f910Sjsing if (doit[D_WHIRLPOOL]) { 1734dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1735dab3f910Sjsing print_message(names[D_WHIRLPOOL], c[D_WHIRLPOOL][j], lengths[j]); 1736dab3f910Sjsing Time_F(START); 1737dab3f910Sjsing for (count = 0, run = 1; COND(c[D_WHIRLPOOL][j]); count++) 1738dab3f910Sjsing WHIRLPOOL(buf, lengths[j], whirlpool); 1739dab3f910Sjsing d = Time_F(STOP); 1740dab3f910Sjsing print_result(D_WHIRLPOOL, j, count, d); 1741dab3f910Sjsing } 1742dab3f910Sjsing } 1743dab3f910Sjsing #endif 1744dab3f910Sjsing 1745dab3f910Sjsing #ifndef OPENSSL_NO_RIPEMD 1746dab3f910Sjsing if (doit[D_RMD160]) { 1747dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1748dab3f910Sjsing print_message(names[D_RMD160], c[D_RMD160][j], lengths[j]); 1749dab3f910Sjsing Time_F(START); 1750dab3f910Sjsing for (count = 0, run = 1; COND(c[D_RMD160][j]); count++) 1751dab3f910Sjsing EVP_Digest(buf, (unsigned long) lengths[j], &(rmd160[0]), NULL, EVP_ripemd160(), NULL); 1752dab3f910Sjsing d = Time_F(STOP); 1753dab3f910Sjsing print_result(D_RMD160, j, count, d); 1754dab3f910Sjsing } 1755dab3f910Sjsing } 1756dab3f910Sjsing #endif 1757dab3f910Sjsing #ifndef OPENSSL_NO_RC4 1758dab3f910Sjsing if (doit[D_RC4]) { 1759dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1760dab3f910Sjsing print_message(names[D_RC4], c[D_RC4][j], lengths[j]); 1761dab3f910Sjsing Time_F(START); 1762dab3f910Sjsing for (count = 0, run = 1; COND(c[D_RC4][j]); count++) 1763dab3f910Sjsing RC4(&rc4_ks, (unsigned int) lengths[j], 1764dab3f910Sjsing buf, buf); 1765dab3f910Sjsing d = Time_F(STOP); 1766dab3f910Sjsing print_result(D_RC4, j, count, d); 1767dab3f910Sjsing } 1768dab3f910Sjsing } 1769dab3f910Sjsing #endif 1770dab3f910Sjsing #ifndef OPENSSL_NO_DES 1771dab3f910Sjsing if (doit[D_CBC_DES]) { 1772dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1773dab3f910Sjsing print_message(names[D_CBC_DES], c[D_CBC_DES][j], lengths[j]); 1774dab3f910Sjsing Time_F(START); 1775dab3f910Sjsing for (count = 0, run = 1; COND(c[D_CBC_DES][j]); count++) 1776dab3f910Sjsing DES_ncbc_encrypt(buf, buf, lengths[j], &sch, 1777dab3f910Sjsing &DES_iv, DES_ENCRYPT); 1778dab3f910Sjsing d = Time_F(STOP); 1779dab3f910Sjsing print_result(D_CBC_DES, j, count, d); 1780dab3f910Sjsing } 1781dab3f910Sjsing } 1782dab3f910Sjsing if (doit[D_EDE3_DES]) { 1783dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1784dab3f910Sjsing print_message(names[D_EDE3_DES], c[D_EDE3_DES][j], lengths[j]); 1785dab3f910Sjsing Time_F(START); 1786dab3f910Sjsing for (count = 0, run = 1; COND(c[D_EDE3_DES][j]); count++) 1787dab3f910Sjsing DES_ede3_cbc_encrypt(buf, buf, lengths[j], 1788dab3f910Sjsing &sch, &sch2, &sch3, 1789dab3f910Sjsing &DES_iv, DES_ENCRYPT); 1790dab3f910Sjsing d = Time_F(STOP); 1791dab3f910Sjsing print_result(D_EDE3_DES, j, count, d); 1792dab3f910Sjsing } 1793dab3f910Sjsing } 1794dab3f910Sjsing #endif 1795dab3f910Sjsing #ifndef OPENSSL_NO_AES 1796dab3f910Sjsing if (doit[D_CBC_128_AES]) { 1797dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1798dab3f910Sjsing print_message(names[D_CBC_128_AES], c[D_CBC_128_AES][j], lengths[j]); 1799dab3f910Sjsing Time_F(START); 1800dab3f910Sjsing for (count = 0, run = 1; COND(c[D_CBC_128_AES][j]); count++) 1801dab3f910Sjsing AES_cbc_encrypt(buf, buf, 1802dab3f910Sjsing (unsigned long) lengths[j], &aes_ks1, 1803dab3f910Sjsing iv, AES_ENCRYPT); 1804dab3f910Sjsing d = Time_F(STOP); 1805dab3f910Sjsing print_result(D_CBC_128_AES, j, count, d); 1806dab3f910Sjsing } 1807dab3f910Sjsing } 1808dab3f910Sjsing if (doit[D_CBC_192_AES]) { 1809dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1810dab3f910Sjsing print_message(names[D_CBC_192_AES], c[D_CBC_192_AES][j], lengths[j]); 1811dab3f910Sjsing Time_F(START); 1812dab3f910Sjsing for (count = 0, run = 1; COND(c[D_CBC_192_AES][j]); count++) 1813dab3f910Sjsing AES_cbc_encrypt(buf, buf, 1814dab3f910Sjsing (unsigned long) lengths[j], &aes_ks2, 1815dab3f910Sjsing iv, AES_ENCRYPT); 1816dab3f910Sjsing d = Time_F(STOP); 1817dab3f910Sjsing print_result(D_CBC_192_AES, j, count, d); 1818dab3f910Sjsing } 1819dab3f910Sjsing } 1820dab3f910Sjsing if (doit[D_CBC_256_AES]) { 1821dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1822dab3f910Sjsing print_message(names[D_CBC_256_AES], c[D_CBC_256_AES][j], lengths[j]); 1823dab3f910Sjsing Time_F(START); 1824dab3f910Sjsing for (count = 0, run = 1; COND(c[D_CBC_256_AES][j]); count++) 1825dab3f910Sjsing AES_cbc_encrypt(buf, buf, 1826dab3f910Sjsing (unsigned long) lengths[j], &aes_ks3, 1827dab3f910Sjsing iv, AES_ENCRYPT); 1828dab3f910Sjsing d = Time_F(STOP); 1829dab3f910Sjsing print_result(D_CBC_256_AES, j, count, d); 1830dab3f910Sjsing } 1831dab3f910Sjsing } 1832dab3f910Sjsing if (doit[D_IGE_128_AES]) { 1833dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1834dab3f910Sjsing print_message(names[D_IGE_128_AES], c[D_IGE_128_AES][j], lengths[j]); 1835dab3f910Sjsing Time_F(START); 1836dab3f910Sjsing for (count = 0, run = 1; COND(c[D_IGE_128_AES][j]); count++) 1837dab3f910Sjsing AES_ige_encrypt(buf, buf2, 1838dab3f910Sjsing (unsigned long) lengths[j], &aes_ks1, 1839dab3f910Sjsing iv, AES_ENCRYPT); 1840dab3f910Sjsing d = Time_F(STOP); 1841dab3f910Sjsing print_result(D_IGE_128_AES, j, count, d); 1842dab3f910Sjsing } 1843dab3f910Sjsing } 1844dab3f910Sjsing if (doit[D_IGE_192_AES]) { 1845dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1846dab3f910Sjsing print_message(names[D_IGE_192_AES], c[D_IGE_192_AES][j], lengths[j]); 1847dab3f910Sjsing Time_F(START); 1848dab3f910Sjsing for (count = 0, run = 1; COND(c[D_IGE_192_AES][j]); count++) 1849dab3f910Sjsing AES_ige_encrypt(buf, buf2, 1850dab3f910Sjsing (unsigned long) lengths[j], &aes_ks2, 1851dab3f910Sjsing iv, AES_ENCRYPT); 1852dab3f910Sjsing d = Time_F(STOP); 1853dab3f910Sjsing print_result(D_IGE_192_AES, j, count, d); 1854dab3f910Sjsing } 1855dab3f910Sjsing } 1856dab3f910Sjsing if (doit[D_IGE_256_AES]) { 1857dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1858dab3f910Sjsing print_message(names[D_IGE_256_AES], c[D_IGE_256_AES][j], lengths[j]); 1859dab3f910Sjsing Time_F(START); 1860dab3f910Sjsing for (count = 0, run = 1; COND(c[D_IGE_256_AES][j]); count++) 1861dab3f910Sjsing AES_ige_encrypt(buf, buf2, 1862dab3f910Sjsing (unsigned long) lengths[j], &aes_ks3, 1863dab3f910Sjsing iv, AES_ENCRYPT); 1864dab3f910Sjsing d = Time_F(STOP); 1865dab3f910Sjsing print_result(D_IGE_256_AES, j, count, d); 1866dab3f910Sjsing } 1867dab3f910Sjsing } 1868dab3f910Sjsing if (doit[D_GHASH]) { 1869dab3f910Sjsing GCM128_CONTEXT *ctx = CRYPTO_gcm128_new(&aes_ks1, (block128_f) AES_encrypt); 1870dab3f910Sjsing CRYPTO_gcm128_setiv(ctx, (unsigned char *) "0123456789ab", 12); 1871dab3f910Sjsing 1872dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1873dab3f910Sjsing print_message(names[D_GHASH], c[D_GHASH][j], lengths[j]); 1874dab3f910Sjsing Time_F(START); 1875dab3f910Sjsing for (count = 0, run = 1; COND(c[D_GHASH][j]); count++) 1876dab3f910Sjsing CRYPTO_gcm128_aad(ctx, buf, lengths[j]); 1877dab3f910Sjsing d = Time_F(STOP); 1878dab3f910Sjsing print_result(D_GHASH, j, count, d); 1879dab3f910Sjsing } 1880dab3f910Sjsing CRYPTO_gcm128_release(ctx); 1881dab3f910Sjsing } 1882fb93d8bbSbcook if (doit[D_AES_128_GCM]) { 1883fb93d8bbSbcook const EVP_AEAD *aead = EVP_aead_aes_128_gcm(); 1884fb93d8bbSbcook static const unsigned char nonce[32] = {0}; 1885fb93d8bbSbcook size_t buf_len, nonce_len; 1886b30977f7Stb EVP_AEAD_CTX *ctx; 1887fb93d8bbSbcook 1888b30977f7Stb if ((ctx = EVP_AEAD_CTX_new()) == NULL) { 1889b30977f7Stb BIO_printf(bio_err, 1890b30977f7Stb "Failed to allocate aead context.\n"); 1891b30977f7Stb goto end; 1892b30977f7Stb } 1893b30977f7Stb 1894b30977f7Stb EVP_AEAD_CTX_init(ctx, aead, key32, EVP_AEAD_key_length(aead), 1895fb93d8bbSbcook EVP_AEAD_DEFAULT_TAG_LENGTH, NULL); 1896fb93d8bbSbcook nonce_len = EVP_AEAD_nonce_length(aead); 1897fb93d8bbSbcook 1898fb93d8bbSbcook for (j = 0; j < SIZE_NUM; j++) { 1899fb93d8bbSbcook print_message(names[D_AES_128_GCM],c[D_AES_128_GCM][j],lengths[j]); 1900fb93d8bbSbcook Time_F(START); 1901fb93d8bbSbcook for (count = 0, run = 1; COND(c[D_AES_128_GCM][j]); count++) 1902b30977f7Stb EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, 1903fb93d8bbSbcook nonce_len, buf, lengths[j], NULL, 0); 1904fb93d8bbSbcook d=Time_F(STOP); 1905fb93d8bbSbcook print_result(D_AES_128_GCM,j,count,d); 1906fb93d8bbSbcook } 1907b30977f7Stb EVP_AEAD_CTX_free(ctx); 1908fb93d8bbSbcook } 1909fb93d8bbSbcook 1910fb93d8bbSbcook if (doit[D_AES_256_GCM]) { 1911fb93d8bbSbcook const EVP_AEAD *aead = EVP_aead_aes_256_gcm(); 1912fb93d8bbSbcook static const unsigned char nonce[32] = {0}; 1913fb93d8bbSbcook size_t buf_len, nonce_len; 1914b30977f7Stb EVP_AEAD_CTX *ctx; 1915fb93d8bbSbcook 1916b30977f7Stb if ((ctx = EVP_AEAD_CTX_new()) == NULL) { 1917b30977f7Stb BIO_printf(bio_err, 1918b30977f7Stb "Failed to allocate aead context.\n"); 1919b30977f7Stb goto end; 1920b30977f7Stb } 1921b30977f7Stb 1922b30977f7Stb EVP_AEAD_CTX_init(ctx, aead, key32, EVP_AEAD_key_length(aead), 1923fb93d8bbSbcook EVP_AEAD_DEFAULT_TAG_LENGTH, NULL); 1924fb93d8bbSbcook nonce_len = EVP_AEAD_nonce_length(aead); 1925fb93d8bbSbcook 1926fb93d8bbSbcook for (j = 0; j < SIZE_NUM; j++) { 1927fb93d8bbSbcook print_message(names[D_AES_256_GCM],c[D_AES_256_GCM][j],lengths[j]); 1928fb93d8bbSbcook Time_F(START); 1929fb93d8bbSbcook for (count = 0, run = 1; COND(c[D_AES_256_GCM][j]); count++) 1930b30977f7Stb EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, 1931fb93d8bbSbcook nonce_len, buf, lengths[j], NULL, 0); 1932fb93d8bbSbcook d=Time_F(STOP); 1933fb93d8bbSbcook print_result(D_AES_256_GCM, j, count, d); 1934fb93d8bbSbcook } 1935b30977f7Stb EVP_AEAD_CTX_free(ctx); 1936fb93d8bbSbcook } 1937fb93d8bbSbcook #endif 1938fb93d8bbSbcook #if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) 1939fb93d8bbSbcook if (doit[D_CHACHA20_POLY1305]) { 1940fb93d8bbSbcook const EVP_AEAD *aead = EVP_aead_chacha20_poly1305(); 1941fb93d8bbSbcook static const unsigned char nonce[32] = {0}; 1942fb93d8bbSbcook size_t buf_len, nonce_len; 1943b30977f7Stb EVP_AEAD_CTX *ctx; 1944fb93d8bbSbcook 1945b30977f7Stb if ((ctx = EVP_AEAD_CTX_new()) == NULL) { 1946b30977f7Stb BIO_printf(bio_err, 1947b30977f7Stb "Failed to allocate aead context.\n"); 1948b30977f7Stb goto end; 1949b30977f7Stb } 1950b30977f7Stb 1951b30977f7Stb EVP_AEAD_CTX_init(ctx, aead, key32, EVP_AEAD_key_length(aead), 1952fb93d8bbSbcook EVP_AEAD_DEFAULT_TAG_LENGTH, NULL); 1953fb93d8bbSbcook nonce_len = EVP_AEAD_nonce_length(aead); 1954fb93d8bbSbcook 1955fb93d8bbSbcook for (j = 0; j < SIZE_NUM; j++) { 1956fb93d8bbSbcook print_message(names[D_CHACHA20_POLY1305], 1957fb93d8bbSbcook c[D_CHACHA20_POLY1305][j], lengths[j]); 1958fb93d8bbSbcook Time_F(START); 1959fb93d8bbSbcook for (count = 0, run = 1; COND(c[D_CHACHA20_POLY1305][j]); count++) 1960b30977f7Stb EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, 1961fb93d8bbSbcook nonce_len, buf, lengths[j], NULL, 0); 1962fb93d8bbSbcook d=Time_F(STOP); 1963fb93d8bbSbcook print_result(D_CHACHA20_POLY1305, j, count, d); 1964fb93d8bbSbcook } 1965b30977f7Stb EVP_AEAD_CTX_free(ctx); 1966fb93d8bbSbcook } 1967dab3f910Sjsing #endif 1968dab3f910Sjsing #ifndef OPENSSL_NO_CAMELLIA 1969dab3f910Sjsing if (doit[D_CBC_128_CML]) { 1970dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1971dab3f910Sjsing print_message(names[D_CBC_128_CML], c[D_CBC_128_CML][j], lengths[j]); 1972dab3f910Sjsing Time_F(START); 1973dab3f910Sjsing for (count = 0, run = 1; COND(c[D_CBC_128_CML][j]); count++) 1974dab3f910Sjsing Camellia_cbc_encrypt(buf, buf, 1975dab3f910Sjsing (unsigned long) lengths[j], &camellia_ks1, 1976dab3f910Sjsing iv, CAMELLIA_ENCRYPT); 1977dab3f910Sjsing d = Time_F(STOP); 1978dab3f910Sjsing print_result(D_CBC_128_CML, j, count, d); 1979dab3f910Sjsing } 1980dab3f910Sjsing } 1981dab3f910Sjsing if (doit[D_CBC_192_CML]) { 1982dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1983dab3f910Sjsing print_message(names[D_CBC_192_CML], c[D_CBC_192_CML][j], lengths[j]); 1984dab3f910Sjsing Time_F(START); 1985dab3f910Sjsing for (count = 0, run = 1; COND(c[D_CBC_192_CML][j]); count++) 1986dab3f910Sjsing Camellia_cbc_encrypt(buf, buf, 1987dab3f910Sjsing (unsigned long) lengths[j], &camellia_ks2, 1988dab3f910Sjsing iv, CAMELLIA_ENCRYPT); 1989dab3f910Sjsing d = Time_F(STOP); 1990dab3f910Sjsing print_result(D_CBC_192_CML, j, count, d); 1991dab3f910Sjsing } 1992dab3f910Sjsing } 1993dab3f910Sjsing if (doit[D_CBC_256_CML]) { 1994dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 1995dab3f910Sjsing print_message(names[D_CBC_256_CML], c[D_CBC_256_CML][j], lengths[j]); 1996dab3f910Sjsing Time_F(START); 1997dab3f910Sjsing for (count = 0, run = 1; COND(c[D_CBC_256_CML][j]); count++) 1998dab3f910Sjsing Camellia_cbc_encrypt(buf, buf, 1999dab3f910Sjsing (unsigned long) lengths[j], &camellia_ks3, 2000dab3f910Sjsing iv, CAMELLIA_ENCRYPT); 2001dab3f910Sjsing d = Time_F(STOP); 2002dab3f910Sjsing print_result(D_CBC_256_CML, j, count, d); 2003dab3f910Sjsing } 2004dab3f910Sjsing } 2005dab3f910Sjsing #endif 2006dab3f910Sjsing #ifndef OPENSSL_NO_IDEA 2007dab3f910Sjsing if (doit[D_CBC_IDEA]) { 2008dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 2009dab3f910Sjsing print_message(names[D_CBC_IDEA], c[D_CBC_IDEA][j], lengths[j]); 2010dab3f910Sjsing Time_F(START); 2011dab3f910Sjsing for (count = 0, run = 1; COND(c[D_CBC_IDEA][j]); count++) 2012dab3f910Sjsing idea_cbc_encrypt(buf, buf, 2013dab3f910Sjsing (unsigned long) lengths[j], &idea_ks, 2014dab3f910Sjsing iv, IDEA_ENCRYPT); 2015dab3f910Sjsing d = Time_F(STOP); 2016dab3f910Sjsing print_result(D_CBC_IDEA, j, count, d); 2017dab3f910Sjsing } 2018dab3f910Sjsing } 2019dab3f910Sjsing #endif 2020dab3f910Sjsing #ifndef OPENSSL_NO_RC2 2021dab3f910Sjsing if (doit[D_CBC_RC2]) { 2022dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 2023dab3f910Sjsing print_message(names[D_CBC_RC2], c[D_CBC_RC2][j], lengths[j]); 2024dab3f910Sjsing Time_F(START); 2025dab3f910Sjsing for (count = 0, run = 1; COND(c[D_CBC_RC2][j]); count++) 2026dab3f910Sjsing RC2_cbc_encrypt(buf, buf, 2027dab3f910Sjsing (unsigned long) lengths[j], &rc2_ks, 2028dab3f910Sjsing iv, RC2_ENCRYPT); 2029dab3f910Sjsing d = Time_F(STOP); 2030dab3f910Sjsing print_result(D_CBC_RC2, j, count, d); 2031dab3f910Sjsing } 2032dab3f910Sjsing } 2033dab3f910Sjsing #endif 2034dab3f910Sjsing #ifndef OPENSSL_NO_BF 2035dab3f910Sjsing if (doit[D_CBC_BF]) { 2036dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 2037dab3f910Sjsing print_message(names[D_CBC_BF], c[D_CBC_BF][j], lengths[j]); 2038dab3f910Sjsing Time_F(START); 2039dab3f910Sjsing for (count = 0, run = 1; COND(c[D_CBC_BF][j]); count++) 2040dab3f910Sjsing BF_cbc_encrypt(buf, buf, 2041dab3f910Sjsing (unsigned long) lengths[j], &bf_ks, 2042dab3f910Sjsing iv, BF_ENCRYPT); 2043dab3f910Sjsing d = Time_F(STOP); 2044dab3f910Sjsing print_result(D_CBC_BF, j, count, d); 2045dab3f910Sjsing } 2046dab3f910Sjsing } 2047dab3f910Sjsing #endif 2048dab3f910Sjsing #ifndef OPENSSL_NO_CAST 2049dab3f910Sjsing if (doit[D_CBC_CAST]) { 2050dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 2051dab3f910Sjsing print_message(names[D_CBC_CAST], c[D_CBC_CAST][j], lengths[j]); 2052dab3f910Sjsing Time_F(START); 2053dab3f910Sjsing for (count = 0, run = 1; COND(c[D_CBC_CAST][j]); count++) 2054dab3f910Sjsing CAST_cbc_encrypt(buf, buf, 2055dab3f910Sjsing (unsigned long) lengths[j], &cast_ks, 2056dab3f910Sjsing iv, CAST_ENCRYPT); 2057dab3f910Sjsing d = Time_F(STOP); 2058dab3f910Sjsing print_result(D_CBC_CAST, j, count, d); 2059dab3f910Sjsing } 2060dab3f910Sjsing } 2061dab3f910Sjsing #endif 2062dab3f910Sjsing 2063dab3f910Sjsing if (doit[D_EVP]) { 2064dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 2065dab3f910Sjsing if (evp_cipher) { 20663110bdd5Stb EVP_CIPHER_CTX *ctx; 2067dab3f910Sjsing int outl; 2068dab3f910Sjsing 20693110bdd5Stb names[D_EVP] = 20703110bdd5Stb OBJ_nid2ln(EVP_CIPHER_nid(evp_cipher)); 2071dab3f910Sjsing /* 2072dab3f910Sjsing * -O3 -fschedule-insns messes up an 2073dab3f910Sjsing * optimization here! names[D_EVP] somehow 2074dab3f910Sjsing * becomes NULL 2075dab3f910Sjsing */ 2076dab3f910Sjsing print_message(names[D_EVP], save_count, 2077dab3f910Sjsing lengths[j]); 2078dab3f910Sjsing 20793110bdd5Stb if ((ctx = EVP_CIPHER_CTX_new()) == NULL) { 20803110bdd5Stb BIO_printf(bio_err, "Failed to " 20813110bdd5Stb "allocate cipher context.\n"); 2082245dcd08Stb goto end; 20833110bdd5Stb } 2084dab3f910Sjsing if (decrypt) 20853110bdd5Stb EVP_DecryptInit_ex(ctx, evp_cipher, NULL, key16, iv); 2086dab3f910Sjsing else 20873110bdd5Stb EVP_EncryptInit_ex(ctx, evp_cipher, NULL, key16, iv); 20883110bdd5Stb EVP_CIPHER_CTX_set_padding(ctx, 0); 2089dab3f910Sjsing 2090dab3f910Sjsing Time_F(START); 2091dab3f910Sjsing if (decrypt) 2092dab3f910Sjsing for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++) 20933110bdd5Stb EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[j]); 2094dab3f910Sjsing else 2095dab3f910Sjsing for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++) 20963110bdd5Stb EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[j]); 2097dab3f910Sjsing if (decrypt) 20983110bdd5Stb EVP_DecryptFinal_ex(ctx, buf, &outl); 2099dab3f910Sjsing else 21003110bdd5Stb EVP_EncryptFinal_ex(ctx, buf, &outl); 2101dab3f910Sjsing d = Time_F(STOP); 21023110bdd5Stb EVP_CIPHER_CTX_free(ctx); 2103dab3f910Sjsing } 2104dab3f910Sjsing if (evp_md) { 21053110bdd5Stb names[D_EVP] = OBJ_nid2ln(EVP_MD_type(evp_md)); 2106dab3f910Sjsing print_message(names[D_EVP], save_count, 2107dab3f910Sjsing lengths[j]); 2108dab3f910Sjsing 2109dab3f910Sjsing Time_F(START); 2110dab3f910Sjsing for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++) 2111dab3f910Sjsing EVP_Digest(buf, lengths[j], &(md[0]), NULL, evp_md, NULL); 2112dab3f910Sjsing 2113dab3f910Sjsing d = Time_F(STOP); 2114dab3f910Sjsing } 2115dab3f910Sjsing print_result(D_EVP, j, count, d); 2116dab3f910Sjsing } 2117dab3f910Sjsing } 2118fd6ab616Sjsing arc4random_buf(buf, 36); 2119dab3f910Sjsing for (j = 0; j < RSA_NUM; j++) { 2120dab3f910Sjsing int ret; 2121dab3f910Sjsing if (!rsa_doit[j]) 2122dab3f910Sjsing continue; 2123dab3f910Sjsing ret = RSA_sign(NID_md5_sha1, buf, 36, buf2, &rsa_num, rsa_key[j]); 2124dab3f910Sjsing if (ret == 0) { 2125dab3f910Sjsing BIO_printf(bio_err, "RSA sign failure. No RSA sign will be done.\n"); 2126dab3f910Sjsing ERR_print_errors(bio_err); 2127dab3f910Sjsing rsa_count = 1; 2128dab3f910Sjsing } else { 2129dab3f910Sjsing pkey_print_message("private", "rsa", 2130dab3f910Sjsing rsa_c[j][0], rsa_bits[j], 2131dab3f910Sjsing RSA_SECONDS); 2132dab3f910Sjsing /* RSA_blinding_on(rsa_key[j],NULL); */ 2133dab3f910Sjsing Time_F(START); 2134dab3f910Sjsing for (count = 0, run = 1; COND(rsa_c[j][0]); count++) { 2135dab3f910Sjsing ret = RSA_sign(NID_md5_sha1, buf, 36, buf2, 2136dab3f910Sjsing &rsa_num, rsa_key[j]); 2137dab3f910Sjsing if (ret == 0) { 2138dab3f910Sjsing BIO_printf(bio_err, 2139dab3f910Sjsing "RSA sign failure\n"); 2140dab3f910Sjsing ERR_print_errors(bio_err); 2141dab3f910Sjsing count = 1; 2142dab3f910Sjsing break; 2143dab3f910Sjsing } 2144dab3f910Sjsing } 2145dab3f910Sjsing d = Time_F(STOP); 2146dab3f910Sjsing BIO_printf(bio_err, mr ? "+R1:%ld:%d:%.2f\n" 2147c1e2a033Stb : "%ld %d bit private RSA in %.2fs\n", 2148dab3f910Sjsing count, rsa_bits[j], d); 2149dab3f910Sjsing rsa_results[j][0] = d / (double) count; 2150dab3f910Sjsing rsa_count = count; 2151dab3f910Sjsing } 2152dab3f910Sjsing 2153dab3f910Sjsing ret = RSA_verify(NID_md5_sha1, buf, 36, buf2, rsa_num, rsa_key[j]); 2154dab3f910Sjsing if (ret <= 0) { 2155dab3f910Sjsing BIO_printf(bio_err, "RSA verify failure. No RSA verify will be done.\n"); 2156dab3f910Sjsing ERR_print_errors(bio_err); 2157dab3f910Sjsing rsa_doit[j] = 0; 2158dab3f910Sjsing } else { 2159dab3f910Sjsing pkey_print_message("public", "rsa", 2160dab3f910Sjsing rsa_c[j][1], rsa_bits[j], 2161dab3f910Sjsing RSA_SECONDS); 2162dab3f910Sjsing Time_F(START); 2163dab3f910Sjsing for (count = 0, run = 1; COND(rsa_c[j][1]); count++) { 2164dab3f910Sjsing ret = RSA_verify(NID_md5_sha1, buf, 36, buf2, 2165dab3f910Sjsing rsa_num, rsa_key[j]); 2166dab3f910Sjsing if (ret <= 0) { 2167dab3f910Sjsing BIO_printf(bio_err, 2168dab3f910Sjsing "RSA verify failure\n"); 2169dab3f910Sjsing ERR_print_errors(bio_err); 2170dab3f910Sjsing count = 1; 2171dab3f910Sjsing break; 2172dab3f910Sjsing } 2173dab3f910Sjsing } 2174dab3f910Sjsing d = Time_F(STOP); 2175dab3f910Sjsing BIO_printf(bio_err, mr ? "+R2:%ld:%d:%.2f\n" 2176c1e2a033Stb : "%ld %d bit public RSA in %.2fs\n", 2177dab3f910Sjsing count, rsa_bits[j], d); 2178dab3f910Sjsing rsa_results[j][1] = d / (double) count; 2179dab3f910Sjsing } 2180dab3f910Sjsing 2181dab3f910Sjsing if (rsa_count <= 1) { 2182dab3f910Sjsing /* if longer than 10s, don't do any more */ 2183dab3f910Sjsing for (j++; j < RSA_NUM; j++) 2184dab3f910Sjsing rsa_doit[j] = 0; 2185dab3f910Sjsing } 2186dab3f910Sjsing } 2187dab3f910Sjsing 2188fd6ab616Sjsing arc4random_buf(buf, 20); 2189dab3f910Sjsing for (j = 0; j < DSA_NUM; j++) { 2190dab3f910Sjsing unsigned int kk; 2191dab3f910Sjsing int ret; 2192dab3f910Sjsing 2193dab3f910Sjsing if (!dsa_doit[j]) 2194dab3f910Sjsing continue; 2195dab3f910Sjsing /* DSA_generate_key(dsa_key[j]); */ 2196dab3f910Sjsing /* DSA_sign_setup(dsa_key[j],NULL); */ 2197dab3f910Sjsing ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2, 2198dab3f910Sjsing &kk, dsa_key[j]); 2199dab3f910Sjsing if (ret == 0) { 2200dab3f910Sjsing BIO_printf(bio_err, "DSA sign failure. No DSA sign will be done.\n"); 2201dab3f910Sjsing ERR_print_errors(bio_err); 2202dab3f910Sjsing rsa_count = 1; 2203dab3f910Sjsing } else { 2204dab3f910Sjsing pkey_print_message("sign", "dsa", 2205dab3f910Sjsing dsa_c[j][0], dsa_bits[j], 2206dab3f910Sjsing DSA_SECONDS); 2207dab3f910Sjsing Time_F(START); 2208dab3f910Sjsing for (count = 0, run = 1; COND(dsa_c[j][0]); count++) { 2209dab3f910Sjsing ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2, 2210dab3f910Sjsing &kk, dsa_key[j]); 2211dab3f910Sjsing if (ret == 0) { 2212dab3f910Sjsing BIO_printf(bio_err, 2213dab3f910Sjsing "DSA sign failure\n"); 2214dab3f910Sjsing ERR_print_errors(bio_err); 2215dab3f910Sjsing count = 1; 2216dab3f910Sjsing break; 2217dab3f910Sjsing } 2218dab3f910Sjsing } 2219dab3f910Sjsing d = Time_F(STOP); 2220dab3f910Sjsing BIO_printf(bio_err, mr ? "+R3:%ld:%d:%.2f\n" 2221dab3f910Sjsing : "%ld %d bit DSA signs in %.2fs\n", 2222dab3f910Sjsing count, dsa_bits[j], d); 2223dab3f910Sjsing dsa_results[j][0] = d / (double) count; 2224dab3f910Sjsing rsa_count = count; 2225dab3f910Sjsing } 2226dab3f910Sjsing 2227dab3f910Sjsing ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2, 2228dab3f910Sjsing kk, dsa_key[j]); 2229dab3f910Sjsing if (ret <= 0) { 2230dab3f910Sjsing BIO_printf(bio_err, "DSA verify failure. No DSA verify will be done.\n"); 2231dab3f910Sjsing ERR_print_errors(bio_err); 2232dab3f910Sjsing dsa_doit[j] = 0; 2233dab3f910Sjsing } else { 2234dab3f910Sjsing pkey_print_message("verify", "dsa", 2235dab3f910Sjsing dsa_c[j][1], dsa_bits[j], 2236dab3f910Sjsing DSA_SECONDS); 2237dab3f910Sjsing Time_F(START); 2238dab3f910Sjsing for (count = 0, run = 1; COND(dsa_c[j][1]); count++) { 2239dab3f910Sjsing ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2, 2240dab3f910Sjsing kk, dsa_key[j]); 2241dab3f910Sjsing if (ret <= 0) { 2242dab3f910Sjsing BIO_printf(bio_err, 2243dab3f910Sjsing "DSA verify failure\n"); 2244dab3f910Sjsing ERR_print_errors(bio_err); 2245dab3f910Sjsing count = 1; 2246dab3f910Sjsing break; 2247dab3f910Sjsing } 2248dab3f910Sjsing } 2249dab3f910Sjsing d = Time_F(STOP); 2250dab3f910Sjsing BIO_printf(bio_err, mr ? "+R4:%ld:%d:%.2f\n" 2251dab3f910Sjsing : "%ld %d bit DSA verify in %.2fs\n", 2252dab3f910Sjsing count, dsa_bits[j], d); 2253dab3f910Sjsing dsa_results[j][1] = d / (double) count; 2254dab3f910Sjsing } 2255dab3f910Sjsing 2256dab3f910Sjsing if (rsa_count <= 1) { 2257dab3f910Sjsing /* if longer than 10s, don't do any more */ 2258dab3f910Sjsing for (j++; j < DSA_NUM; j++) 2259dab3f910Sjsing dsa_doit[j] = 0; 2260dab3f910Sjsing } 2261dab3f910Sjsing } 2262dab3f910Sjsing 2263dab3f910Sjsing for (j = 0; j < EC_NUM; j++) { 2264dab3f910Sjsing int ret; 2265dab3f910Sjsing 2266dab3f910Sjsing if (!ecdsa_doit[j]) 2267dab3f910Sjsing continue; /* Ignore Curve */ 2268dab3f910Sjsing ecdsa[j] = EC_KEY_new_by_curve_name(test_curves[j]); 2269dab3f910Sjsing if (ecdsa[j] == NULL) { 2270dab3f910Sjsing BIO_printf(bio_err, "ECDSA failure.\n"); 2271dab3f910Sjsing ERR_print_errors(bio_err); 2272dab3f910Sjsing rsa_count = 1; 2273dab3f910Sjsing } else { 2274dab3f910Sjsing EC_KEY_precompute_mult(ecdsa[j], NULL); 2275275363c2Sdoug 2276dab3f910Sjsing /* Perform ECDSA signature test */ 2277dab3f910Sjsing EC_KEY_generate_key(ecdsa[j]); 2278dab3f910Sjsing ret = ECDSA_sign(0, buf, 20, ecdsasig, 2279dab3f910Sjsing &ecdsasiglen, ecdsa[j]); 2280dab3f910Sjsing if (ret == 0) { 2281dab3f910Sjsing BIO_printf(bio_err, "ECDSA sign failure. No ECDSA sign will be done.\n"); 2282dab3f910Sjsing ERR_print_errors(bio_err); 2283dab3f910Sjsing rsa_count = 1; 2284dab3f910Sjsing } else { 2285dab3f910Sjsing pkey_print_message("sign", "ecdsa", 2286dab3f910Sjsing ecdsa_c[j][0], 2287dab3f910Sjsing test_curves_bits[j], 2288dab3f910Sjsing ECDSA_SECONDS); 2289dab3f910Sjsing 2290dab3f910Sjsing Time_F(START); 2291dab3f910Sjsing for (count = 0, run = 1; COND(ecdsa_c[j][0]); 2292dab3f910Sjsing count++) { 2293dab3f910Sjsing ret = ECDSA_sign(0, buf, 20, 2294dab3f910Sjsing ecdsasig, &ecdsasiglen, 2295dab3f910Sjsing ecdsa[j]); 2296dab3f910Sjsing if (ret == 0) { 2297dab3f910Sjsing BIO_printf(bio_err, "ECDSA sign failure\n"); 2298dab3f910Sjsing ERR_print_errors(bio_err); 2299dab3f910Sjsing count = 1; 2300dab3f910Sjsing break; 2301dab3f910Sjsing } 2302dab3f910Sjsing } 2303dab3f910Sjsing d = Time_F(STOP); 2304dab3f910Sjsing 2305dab3f910Sjsing BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" : 2306dab3f910Sjsing "%ld %d bit ECDSA signs in %.2fs \n", 2307dab3f910Sjsing count, test_curves_bits[j], d); 2308dab3f910Sjsing ecdsa_results[j][0] = d / (double) count; 2309dab3f910Sjsing rsa_count = count; 2310dab3f910Sjsing } 2311dab3f910Sjsing 2312dab3f910Sjsing /* Perform ECDSA verification test */ 2313dab3f910Sjsing ret = ECDSA_verify(0, buf, 20, ecdsasig, 2314dab3f910Sjsing ecdsasiglen, ecdsa[j]); 2315dab3f910Sjsing if (ret != 1) { 2316dab3f910Sjsing BIO_printf(bio_err, "ECDSA verify failure. No ECDSA verify will be done.\n"); 2317dab3f910Sjsing ERR_print_errors(bio_err); 2318dab3f910Sjsing ecdsa_doit[j] = 0; 2319dab3f910Sjsing } else { 2320dab3f910Sjsing pkey_print_message("verify", "ecdsa", 2321dab3f910Sjsing ecdsa_c[j][1], 2322dab3f910Sjsing test_curves_bits[j], 2323dab3f910Sjsing ECDSA_SECONDS); 2324dab3f910Sjsing Time_F(START); 2325dab3f910Sjsing for (count = 0, run = 1; COND(ecdsa_c[j][1]); count++) { 2326dab3f910Sjsing ret = ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]); 2327dab3f910Sjsing if (ret != 1) { 2328dab3f910Sjsing BIO_printf(bio_err, "ECDSA verify failure\n"); 2329dab3f910Sjsing ERR_print_errors(bio_err); 2330dab3f910Sjsing count = 1; 2331dab3f910Sjsing break; 2332dab3f910Sjsing } 2333dab3f910Sjsing } 2334dab3f910Sjsing d = Time_F(STOP); 2335dab3f910Sjsing BIO_printf(bio_err, mr ? "+R6:%ld:%d:%.2f\n" 2336dab3f910Sjsing : "%ld %d bit ECDSA verify in %.2fs\n", 2337dab3f910Sjsing count, test_curves_bits[j], d); 2338dab3f910Sjsing ecdsa_results[j][1] = d / (double) count; 2339dab3f910Sjsing } 2340dab3f910Sjsing 2341dab3f910Sjsing if (rsa_count <= 1) { 2342dab3f910Sjsing /* if longer than 10s, don't do any more */ 2343dab3f910Sjsing for (j++; j < EC_NUM; j++) 2344dab3f910Sjsing ecdsa_doit[j] = 0; 2345dab3f910Sjsing } 2346dab3f910Sjsing } 2347dab3f910Sjsing } 2348dab3f910Sjsing 2349dab3f910Sjsing for (j = 0; j < EC_NUM; j++) { 2350dab3f910Sjsing if (!ecdh_doit[j]) 2351dab3f910Sjsing continue; 2352dab3f910Sjsing ecdh_a[j] = EC_KEY_new_by_curve_name(test_curves[j]); 2353dab3f910Sjsing ecdh_b[j] = EC_KEY_new_by_curve_name(test_curves[j]); 2354dab3f910Sjsing if ((ecdh_a[j] == NULL) || (ecdh_b[j] == NULL)) { 2355dab3f910Sjsing BIO_printf(bio_err, "ECDH failure.\n"); 2356dab3f910Sjsing ERR_print_errors(bio_err); 2357dab3f910Sjsing rsa_count = 1; 2358dab3f910Sjsing } else { 2359dab3f910Sjsing /* generate two ECDH key pairs */ 2360dab3f910Sjsing if (!EC_KEY_generate_key(ecdh_a[j]) || 2361dab3f910Sjsing !EC_KEY_generate_key(ecdh_b[j])) { 2362dab3f910Sjsing BIO_printf(bio_err, "ECDH key generation failure.\n"); 2363dab3f910Sjsing ERR_print_errors(bio_err); 2364dab3f910Sjsing rsa_count = 1; 2365dab3f910Sjsing } else { 2366dab3f910Sjsing /* 2367dab3f910Sjsing * If field size is not more than 24 octets, 2368dab3f910Sjsing * then use SHA-1 hash of result; otherwise, 2369dab3f910Sjsing * use result (see section 4.8 of 2370dab3f910Sjsing * draft-ietf-tls-ecc-03.txt). 2371dab3f910Sjsing */ 2372dab3f910Sjsing int field_size, outlen; 2373dab3f910Sjsing void *(*kdf) (const void *in, size_t inlen, void *out, size_t * xoutlen); 2374dab3f910Sjsing field_size = EC_GROUP_get_degree(EC_KEY_get0_group(ecdh_a[j])); 2375dab3f910Sjsing if (field_size <= 24 * 8) { 2376dab3f910Sjsing outlen = KDF1_SHA1_len; 2377dab3f910Sjsing kdf = KDF1_SHA1; 2378dab3f910Sjsing } else { 2379dab3f910Sjsing outlen = (field_size + 7) / 8; 2380dab3f910Sjsing kdf = NULL; 2381dab3f910Sjsing } 2382dab3f910Sjsing secret_size_a = ECDH_compute_key(secret_a, outlen, 2383dab3f910Sjsing EC_KEY_get0_public_key(ecdh_b[j]), 2384dab3f910Sjsing ecdh_a[j], kdf); 2385dab3f910Sjsing secret_size_b = ECDH_compute_key(secret_b, outlen, 2386dab3f910Sjsing EC_KEY_get0_public_key(ecdh_a[j]), 2387dab3f910Sjsing ecdh_b[j], kdf); 2388dab3f910Sjsing if (secret_size_a != secret_size_b) 2389dab3f910Sjsing ecdh_checks = 0; 2390dab3f910Sjsing else 2391dab3f910Sjsing ecdh_checks = 1; 2392dab3f910Sjsing 2393dab3f910Sjsing for (secret_idx = 0; 2394dab3f910Sjsing (secret_idx < secret_size_a) 2395dab3f910Sjsing && (ecdh_checks == 1); 2396dab3f910Sjsing secret_idx++) { 2397dab3f910Sjsing if (secret_a[secret_idx] != secret_b[secret_idx]) 2398dab3f910Sjsing ecdh_checks = 0; 2399dab3f910Sjsing } 2400dab3f910Sjsing 2401dab3f910Sjsing if (ecdh_checks == 0) { 24022c23547eSdoug BIO_printf(bio_err, 24032c23547eSdoug "ECDH computations don't match.\n"); 2404dab3f910Sjsing ERR_print_errors(bio_err); 2405dab3f910Sjsing rsa_count = 1; 24062c23547eSdoug } else { 2407dab3f910Sjsing pkey_print_message("", "ecdh", 2408dab3f910Sjsing ecdh_c[j][0], 2409dab3f910Sjsing test_curves_bits[j], 2410dab3f910Sjsing ECDH_SECONDS); 2411dab3f910Sjsing Time_F(START); 24122c23547eSdoug for (count = 0, run = 1; 24132c23547eSdoug COND(ecdh_c[j][0]); count++) { 24142c23547eSdoug ECDH_compute_key(secret_a, 24152c23547eSdoug outlen, 2416dab3f910Sjsing EC_KEY_get0_public_key(ecdh_b[j]), 2417dab3f910Sjsing ecdh_a[j], kdf); 2418dab3f910Sjsing } 2419dab3f910Sjsing d = Time_F(STOP); 24202c23547eSdoug BIO_printf(bio_err, mr 24212c23547eSdoug ? "+R7:%ld:%d:%.2f\n" 24222c23547eSdoug : "%ld %d-bit ECDH ops in %.2fs\n", 2423dab3f910Sjsing count, test_curves_bits[j], d); 2424dab3f910Sjsing ecdh_results[j][0] = d / (double) count; 2425dab3f910Sjsing rsa_count = count; 2426dab3f910Sjsing } 2427dab3f910Sjsing } 24282c23547eSdoug } 2429dab3f910Sjsing 2430dab3f910Sjsing 2431dab3f910Sjsing if (rsa_count <= 1) { 2432dab3f910Sjsing /* if longer than 10s, don't do any more */ 2433dab3f910Sjsing for (j++; j < EC_NUM; j++) 2434dab3f910Sjsing ecdh_doit[j] = 0; 2435dab3f910Sjsing } 2436dab3f910Sjsing } 2437dab3f910Sjsing show_res: 2438dab3f910Sjsing if (!mr) { 2439dab3f910Sjsing fprintf(stdout, "%s\n", SSLeay_version(SSLEAY_VERSION)); 2440dab3f910Sjsing fprintf(stdout, "%s\n", SSLeay_version(SSLEAY_BUILT_ON)); 2441418576f2Stb fprintf(stdout, "%s\n", SSLeay_version(SSLEAY_CFLAGS)); 2442dab3f910Sjsing } 2443dab3f910Sjsing if (pr_header) { 2444dab3f910Sjsing if (mr) 2445dab3f910Sjsing fprintf(stdout, "+H"); 2446dab3f910Sjsing else { 2447dab3f910Sjsing fprintf(stdout, "The 'numbers' are in 1000s of bytes per second processed.\n"); 2448dab3f910Sjsing fprintf(stdout, "type "); 2449dab3f910Sjsing } 2450dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) 2451dab3f910Sjsing fprintf(stdout, mr ? ":%d" : "%7d bytes", lengths[j]); 2452dab3f910Sjsing fprintf(stdout, "\n"); 2453dab3f910Sjsing } 2454dab3f910Sjsing for (k = 0; k < ALGOR_NUM; k++) { 2455dab3f910Sjsing if (!doit[k]) 2456dab3f910Sjsing continue; 2457dab3f910Sjsing if (mr) 2458dab3f910Sjsing fprintf(stdout, "+F:%d:%s", k, names[k]); 2459dab3f910Sjsing else 2460dab3f910Sjsing fprintf(stdout, "%-13s", names[k]); 2461dab3f910Sjsing for (j = 0; j < SIZE_NUM; j++) { 2462dab3f910Sjsing if (results[k][j] > 10000 && !mr) 2463dab3f910Sjsing fprintf(stdout, " %11.2fk", results[k][j] / 1e3); 2464dab3f910Sjsing else 2465dab3f910Sjsing fprintf(stdout, mr ? ":%.2f" : " %11.2f ", results[k][j]); 2466dab3f910Sjsing } 2467dab3f910Sjsing fprintf(stdout, "\n"); 2468dab3f910Sjsing } 2469dab3f910Sjsing j = 1; 2470dab3f910Sjsing for (k = 0; k < RSA_NUM; k++) { 2471dab3f910Sjsing if (!rsa_doit[k]) 2472dab3f910Sjsing continue; 2473dab3f910Sjsing if (j && !mr) { 2474dab3f910Sjsing printf("%18ssign verify sign/s verify/s\n", " "); 2475dab3f910Sjsing j = 0; 2476dab3f910Sjsing } 2477dab3f910Sjsing if (mr) 2478dab3f910Sjsing fprintf(stdout, "+F2:%u:%u:%f:%f\n", 2479dab3f910Sjsing k, rsa_bits[k], rsa_results[k][0], 2480dab3f910Sjsing rsa_results[k][1]); 2481dab3f910Sjsing else 2482dab3f910Sjsing fprintf(stdout, "rsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n", 2483dab3f910Sjsing rsa_bits[k], rsa_results[k][0], rsa_results[k][1], 2484dab3f910Sjsing 1.0 / rsa_results[k][0], 1.0 / rsa_results[k][1]); 2485dab3f910Sjsing } 2486dab3f910Sjsing j = 1; 2487dab3f910Sjsing for (k = 0; k < DSA_NUM; k++) { 2488dab3f910Sjsing if (!dsa_doit[k]) 2489dab3f910Sjsing continue; 2490dab3f910Sjsing if (j && !mr) { 2491dab3f910Sjsing printf("%18ssign verify sign/s verify/s\n", " "); 2492dab3f910Sjsing j = 0; 2493dab3f910Sjsing } 2494dab3f910Sjsing if (mr) 2495dab3f910Sjsing fprintf(stdout, "+F3:%u:%u:%f:%f\n", 2496dab3f910Sjsing k, dsa_bits[k], dsa_results[k][0], dsa_results[k][1]); 2497dab3f910Sjsing else 2498dab3f910Sjsing fprintf(stdout, "dsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n", 2499dab3f910Sjsing dsa_bits[k], dsa_results[k][0], dsa_results[k][1], 2500dab3f910Sjsing 1.0 / dsa_results[k][0], 1.0 / dsa_results[k][1]); 2501dab3f910Sjsing } 2502dab3f910Sjsing j = 1; 2503dab3f910Sjsing for (k = 0; k < EC_NUM; k++) { 2504dab3f910Sjsing if (!ecdsa_doit[k]) 2505dab3f910Sjsing continue; 2506dab3f910Sjsing if (j && !mr) { 2507dab3f910Sjsing printf("%30ssign verify sign/s verify/s\n", " "); 2508dab3f910Sjsing j = 0; 2509dab3f910Sjsing } 2510dab3f910Sjsing if (mr) 2511dab3f910Sjsing fprintf(stdout, "+F4:%u:%u:%f:%f\n", 2512dab3f910Sjsing k, test_curves_bits[k], 2513dab3f910Sjsing ecdsa_results[k][0], ecdsa_results[k][1]); 2514dab3f910Sjsing else 2515dab3f910Sjsing fprintf(stdout, 2516dab3f910Sjsing "%4u bit ecdsa (%s) %8.4fs %8.4fs %8.1f %8.1f\n", 2517dab3f910Sjsing test_curves_bits[k], 2518dab3f910Sjsing test_curves_names[k], 2519dab3f910Sjsing ecdsa_results[k][0], ecdsa_results[k][1], 2520dab3f910Sjsing 1.0 / ecdsa_results[k][0], 1.0 / ecdsa_results[k][1]); 2521dab3f910Sjsing } 2522dab3f910Sjsing 2523dab3f910Sjsing 2524dab3f910Sjsing j = 1; 2525dab3f910Sjsing for (k = 0; k < EC_NUM; k++) { 2526dab3f910Sjsing if (!ecdh_doit[k]) 2527dab3f910Sjsing continue; 2528dab3f910Sjsing if (j && !mr) { 2529dab3f910Sjsing printf("%30sop op/s\n", " "); 2530dab3f910Sjsing j = 0; 2531dab3f910Sjsing } 2532dab3f910Sjsing if (mr) 2533dab3f910Sjsing fprintf(stdout, "+F5:%u:%u:%f:%f\n", 2534dab3f910Sjsing k, test_curves_bits[k], 2535dab3f910Sjsing ecdh_results[k][0], 1.0 / ecdh_results[k][0]); 2536dab3f910Sjsing 2537dab3f910Sjsing else 2538dab3f910Sjsing fprintf(stdout, "%4u bit ecdh (%s) %8.4fs %8.1f\n", 2539dab3f910Sjsing test_curves_bits[k], 2540dab3f910Sjsing test_curves_names[k], 2541dab3f910Sjsing ecdh_results[k][0], 1.0 / ecdh_results[k][0]); 2542dab3f910Sjsing } 2543dab3f910Sjsing 2544dab3f910Sjsing mret = 0; 2545dab3f910Sjsing 2546dab3f910Sjsing end: 2547dab3f910Sjsing ERR_print_errors(bio_err); 25481aa981a4Stb free(real_buf); 25491aa981a4Stb free(real_buf2); 2550dab3f910Sjsing for (i = 0; i < RSA_NUM; i++) 2551dab3f910Sjsing if (rsa_key[i] != NULL) 2552dab3f910Sjsing RSA_free(rsa_key[i]); 2553dab3f910Sjsing for (i = 0; i < DSA_NUM; i++) 2554dab3f910Sjsing if (dsa_key[i] != NULL) 2555dab3f910Sjsing DSA_free(dsa_key[i]); 2556dab3f910Sjsing 2557dab3f910Sjsing for (i = 0; i < EC_NUM; i++) 2558dab3f910Sjsing if (ecdsa[i] != NULL) 2559dab3f910Sjsing EC_KEY_free(ecdsa[i]); 2560dab3f910Sjsing for (i = 0; i < EC_NUM; i++) { 2561dab3f910Sjsing if (ecdh_a[i] != NULL) 2562dab3f910Sjsing EC_KEY_free(ecdh_a[i]); 2563dab3f910Sjsing if (ecdh_b[i] != NULL) 2564dab3f910Sjsing EC_KEY_free(ecdh_b[i]); 2565dab3f910Sjsing } 2566dab3f910Sjsing 2567dab3f910Sjsing 2568dab3f910Sjsing return (mret); 2569dab3f910Sjsing } 2570dab3f910Sjsing 2571dab3f910Sjsing static void 2572dab3f910Sjsing print_message(const char *s, long num, int length) 2573dab3f910Sjsing { 2574dab3f910Sjsing BIO_printf(bio_err, mr ? "+DT:%s:%d:%d\n" 2575dab3f910Sjsing : "Doing %s for %ds on %d size blocks: ", s, SECONDS, length); 2576dab3f910Sjsing (void) BIO_flush(bio_err); 2577dab3f910Sjsing alarm(SECONDS); 2578dab3f910Sjsing } 2579dab3f910Sjsing 2580dab3f910Sjsing static void 2581dab3f910Sjsing pkey_print_message(const char *str, const char *str2, long num, 2582dab3f910Sjsing int bits, int tm) 2583dab3f910Sjsing { 2584dab3f910Sjsing BIO_printf(bio_err, mr ? "+DTP:%d:%s:%s:%d\n" 2585c1e2a033Stb : "Doing %d bit %s %s for %ds: ", bits, str, str2, tm); 2586dab3f910Sjsing (void) BIO_flush(bio_err); 2587dab3f910Sjsing alarm(tm); 2588dab3f910Sjsing } 2589dab3f910Sjsing 2590dab3f910Sjsing static void 2591dab3f910Sjsing print_result(int alg, int run_no, int count, double time_used) 2592dab3f910Sjsing { 2593dab3f910Sjsing BIO_printf(bio_err, mr ? "+R:%d:%s:%f\n" 2594c1e2a033Stb : "%d %s in %.2fs\n", count, names[alg], time_used); 2595dab3f910Sjsing results[alg][run_no] = ((double) count) / time_used * lengths[run_no]; 2596dab3f910Sjsing } 2597dab3f910Sjsing 2598dab3f910Sjsing static char * 2599dab3f910Sjsing sstrsep(char **string, const char *delim) 2600dab3f910Sjsing { 2601dab3f910Sjsing char isdelim[256]; 2602dab3f910Sjsing char *token = *string; 2603dab3f910Sjsing 2604dab3f910Sjsing if (**string == 0) 2605dab3f910Sjsing return NULL; 2606dab3f910Sjsing 2607dab3f910Sjsing memset(isdelim, 0, sizeof isdelim); 2608dab3f910Sjsing isdelim[0] = 1; 2609dab3f910Sjsing 2610dab3f910Sjsing while (*delim) { 2611dab3f910Sjsing isdelim[(unsigned char) (*delim)] = 1; 2612dab3f910Sjsing delim++; 2613dab3f910Sjsing } 2614dab3f910Sjsing 2615dab3f910Sjsing while (!isdelim[(unsigned char) (**string)]) { 2616dab3f910Sjsing (*string)++; 2617dab3f910Sjsing } 2618dab3f910Sjsing 2619dab3f910Sjsing if (**string) { 2620dab3f910Sjsing **string = 0; 2621dab3f910Sjsing (*string)++; 2622dab3f910Sjsing } 2623dab3f910Sjsing return token; 2624dab3f910Sjsing } 2625dab3f910Sjsing 2626dab3f910Sjsing static int 2627dab3f910Sjsing do_multi(int multi) 2628dab3f910Sjsing { 2629dab3f910Sjsing int n; 2630dab3f910Sjsing int fd[2]; 2631dab3f910Sjsing int *fds; 2632dab3f910Sjsing static char sep[] = ":"; 2633dab3f910Sjsing const char *errstr = NULL; 2634dab3f910Sjsing 2635dab3f910Sjsing fds = reallocarray(NULL, multi, sizeof *fds); 263640b191f1Slteo if (fds == NULL) { 263740b191f1Slteo fprintf(stderr, "reallocarray failure\n"); 263840b191f1Slteo exit(1); 263940b191f1Slteo } 2640dab3f910Sjsing for (n = 0; n < multi; ++n) { 2641dab3f910Sjsing if (pipe(fd) == -1) { 2642dab3f910Sjsing fprintf(stderr, "pipe failure\n"); 2643dab3f910Sjsing exit(1); 2644dab3f910Sjsing } 2645dab3f910Sjsing fflush(stdout); 2646dab3f910Sjsing fflush(stderr); 2647dab3f910Sjsing if (fork()) { 2648dab3f910Sjsing close(fd[1]); 2649dab3f910Sjsing fds[n] = fd[0]; 2650dab3f910Sjsing } else { 2651dab3f910Sjsing close(fd[0]); 2652dab3f910Sjsing close(1); 2653dab3f910Sjsing if (dup(fd[1]) == -1) { 2654dab3f910Sjsing fprintf(stderr, "dup failed\n"); 2655dab3f910Sjsing exit(1); 2656dab3f910Sjsing } 2657dab3f910Sjsing close(fd[1]); 2658dab3f910Sjsing mr = 1; 2659dab3f910Sjsing usertime = 0; 2660dab3f910Sjsing free(fds); 2661dab3f910Sjsing return 0; 2662dab3f910Sjsing } 2663dab3f910Sjsing printf("Forked child %d\n", n); 2664dab3f910Sjsing } 2665dab3f910Sjsing 2666dab3f910Sjsing /* for now, assume the pipe is long enough to take all the output */ 2667dab3f910Sjsing for (n = 0; n < multi; ++n) { 2668dab3f910Sjsing FILE *f; 2669dab3f910Sjsing char buf[1024]; 2670dab3f910Sjsing char *p; 2671dab3f910Sjsing 2672dab3f910Sjsing f = fdopen(fds[n], "r"); 2673dab3f910Sjsing while (fgets(buf, sizeof buf, f)) { 2674dab3f910Sjsing p = strchr(buf, '\n'); 2675dab3f910Sjsing if (p) 2676dab3f910Sjsing *p = '\0'; 2677dab3f910Sjsing if (buf[0] != '+') { 2678dab3f910Sjsing fprintf(stderr, "Don't understand line '%s' from child %d\n", 2679dab3f910Sjsing buf, n); 2680dab3f910Sjsing continue; 2681dab3f910Sjsing } 2682dab3f910Sjsing printf("Got: %s from %d\n", buf, n); 2683dab3f910Sjsing if (!strncmp(buf, "+F:", 3)) { 2684dab3f910Sjsing int alg; 2685dab3f910Sjsing int j; 2686dab3f910Sjsing 2687dab3f910Sjsing p = buf + 3; 2688dab3f910Sjsing alg = strtonum(sstrsep(&p, sep), 2689dab3f910Sjsing 0, ALGOR_NUM - 1, &errstr); 2690dab3f910Sjsing sstrsep(&p, sep); 2691dab3f910Sjsing for (j = 0; j < SIZE_NUM; ++j) 2692dab3f910Sjsing results[alg][j] += atof(sstrsep(&p, sep)); 2693dab3f910Sjsing } else if (!strncmp(buf, "+F2:", 4)) { 2694dab3f910Sjsing int k; 2695dab3f910Sjsing double d; 2696dab3f910Sjsing 2697dab3f910Sjsing p = buf + 4; 2698dab3f910Sjsing k = strtonum(sstrsep(&p, sep), 2699dab3f910Sjsing 0, ALGOR_NUM - 1, &errstr); 2700dab3f910Sjsing sstrsep(&p, sep); 2701dab3f910Sjsing 2702dab3f910Sjsing d = atof(sstrsep(&p, sep)); 2703dab3f910Sjsing if (n) 2704dab3f910Sjsing rsa_results[k][0] = 1 / (1 / rsa_results[k][0] + 1 / d); 2705dab3f910Sjsing else 2706dab3f910Sjsing rsa_results[k][0] = d; 2707dab3f910Sjsing 2708dab3f910Sjsing d = atof(sstrsep(&p, sep)); 2709dab3f910Sjsing if (n) 2710dab3f910Sjsing rsa_results[k][1] = 1 / (1 / rsa_results[k][1] + 1 / d); 2711dab3f910Sjsing else 2712dab3f910Sjsing rsa_results[k][1] = d; 2713dab3f910Sjsing } else if (!strncmp(buf, "+F2:", 4)) { 2714dab3f910Sjsing int k; 2715dab3f910Sjsing double d; 2716dab3f910Sjsing 2717dab3f910Sjsing p = buf + 4; 2718dab3f910Sjsing k = strtonum(sstrsep(&p, sep), 2719dab3f910Sjsing 0, ALGOR_NUM - 1, &errstr); 2720dab3f910Sjsing sstrsep(&p, sep); 2721dab3f910Sjsing 2722dab3f910Sjsing d = atof(sstrsep(&p, sep)); 2723dab3f910Sjsing if (n) 2724dab3f910Sjsing rsa_results[k][0] = 1 / (1 / rsa_results[k][0] + 1 / d); 2725dab3f910Sjsing else 2726dab3f910Sjsing rsa_results[k][0] = d; 2727dab3f910Sjsing 2728dab3f910Sjsing d = atof(sstrsep(&p, sep)); 2729dab3f910Sjsing if (n) 2730dab3f910Sjsing rsa_results[k][1] = 1 / (1 / rsa_results[k][1] + 1 / d); 2731dab3f910Sjsing else 2732dab3f910Sjsing rsa_results[k][1] = d; 2733bb0f3b26Sderaadt } else if (!strncmp(buf, "+F3:", 4)) { 2734dab3f910Sjsing int k; 2735dab3f910Sjsing double d; 2736dab3f910Sjsing 2737dab3f910Sjsing p = buf + 4; 2738dab3f910Sjsing k = strtonum(sstrsep(&p, sep), 2739dab3f910Sjsing 0, ALGOR_NUM - 1, &errstr); 2740dab3f910Sjsing sstrsep(&p, sep); 2741dab3f910Sjsing 2742dab3f910Sjsing d = atof(sstrsep(&p, sep)); 2743dab3f910Sjsing if (n) 2744dab3f910Sjsing dsa_results[k][0] = 1 / (1 / dsa_results[k][0] + 1 / d); 2745dab3f910Sjsing else 2746dab3f910Sjsing dsa_results[k][0] = d; 2747dab3f910Sjsing 2748dab3f910Sjsing d = atof(sstrsep(&p, sep)); 2749dab3f910Sjsing if (n) 2750dab3f910Sjsing dsa_results[k][1] = 1 / (1 / dsa_results[k][1] + 1 / d); 2751dab3f910Sjsing else 2752dab3f910Sjsing dsa_results[k][1] = d; 2753bb0f3b26Sderaadt } else if (!strncmp(buf, "+F4:", 4)) { 2754dab3f910Sjsing int k; 2755dab3f910Sjsing double d; 2756dab3f910Sjsing 2757dab3f910Sjsing p = buf + 4; 2758dab3f910Sjsing k = strtonum(sstrsep(&p, sep), 2759dab3f910Sjsing 0, ALGOR_NUM - 1, &errstr); 2760dab3f910Sjsing sstrsep(&p, sep); 2761dab3f910Sjsing 2762dab3f910Sjsing d = atof(sstrsep(&p, sep)); 2763dab3f910Sjsing if (n) 2764dab3f910Sjsing ecdsa_results[k][0] = 1 / (1 / ecdsa_results[k][0] + 1 / d); 2765dab3f910Sjsing else 2766dab3f910Sjsing ecdsa_results[k][0] = d; 2767dab3f910Sjsing 2768dab3f910Sjsing d = atof(sstrsep(&p, sep)); 2769dab3f910Sjsing if (n) 2770dab3f910Sjsing ecdsa_results[k][1] = 1 / (1 / ecdsa_results[k][1] + 1 / d); 2771dab3f910Sjsing else 2772dab3f910Sjsing ecdsa_results[k][1] = d; 2773bb0f3b26Sderaadt } else if (!strncmp(buf, "+F5:", 4)) { 2774dab3f910Sjsing int k; 2775dab3f910Sjsing double d; 2776dab3f910Sjsing 2777dab3f910Sjsing p = buf + 4; 2778dab3f910Sjsing k = strtonum(sstrsep(&p, sep), 2779dab3f910Sjsing 0, ALGOR_NUM - 1, &errstr); 2780dab3f910Sjsing sstrsep(&p, sep); 2781dab3f910Sjsing 2782dab3f910Sjsing d = atof(sstrsep(&p, sep)); 2783dab3f910Sjsing if (n) 2784dab3f910Sjsing ecdh_results[k][0] = 1 / (1 / ecdh_results[k][0] + 1 / d); 2785dab3f910Sjsing else 2786dab3f910Sjsing ecdh_results[k][0] = d; 2787dab3f910Sjsing 2788bb0f3b26Sderaadt } else if (!strncmp(buf, "+H:", 3)) { 2789dab3f910Sjsing } else 2790dab3f910Sjsing fprintf(stderr, "Unknown type '%s' from child %d\n", buf, n); 2791dab3f910Sjsing } 2792dab3f910Sjsing 2793dab3f910Sjsing fclose(f); 2794dab3f910Sjsing } 2795dab3f910Sjsing free(fds); 2796dab3f910Sjsing return 1; 2797dab3f910Sjsing } 2798*fab492f1Stb 2799*fab492f1Stb #endif /* OPENSSL_NO_SPEED */ 2800