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