[BACK]Return to speed.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / openssl

Annotation of src/usr.bin/openssl/speed.c, Revision 1.1

1.1     ! jsing       1: /* $OpenBSD: speed.c,v 1.52 2014/07/14 00:35:10 deraadt 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: /* 11-Sep-92 Andrew Daviel   Support for Silicon Graphics IRIX added */
        !            83: /* 06-Apr-92 Luke Brennan    Support for VMS and add extra signal calls */
        !            84:
        !            85: #include <math.h>
        !            86: #include <signal.h>
        !            87: #include <stdio.h>
        !            88: #include <stdlib.h>
        !            89: #include <limits.h>
        !            90: #include <string.h>
        !            91: #include <unistd.h>
        !            92:
        !            93: #include "apps.h"
        !            94:
        !            95: #include <openssl/bn.h>
        !            96: #include <openssl/crypto.h>
        !            97: #include <openssl/err.h>
        !            98: #include <openssl/evp.h>
        !            99: #include <openssl/modes.h>
        !           100: #include <openssl/objects.h>
        !           101: #include <openssl/rand.h>
        !           102: #include <openssl/x509.h>
        !           103:
        !           104: #ifndef OPENSSL_NO_AES
        !           105: #include <openssl/aes.h>
        !           106: #endif
        !           107: #ifndef OPENSSL_NO_BF
        !           108: #include <openssl/blowfish.h>
        !           109: #endif
        !           110: #ifndef OPENSSL_NO_CAST
        !           111: #include <openssl/cast.h>
        !           112: #endif
        !           113: #ifndef OPENSSL_NO_CAMELLIA
        !           114: #include <openssl/camellia.h>
        !           115: #endif
        !           116: #ifndef OPENSSL_NO_DES
        !           117: #include <openssl/des.h>
        !           118: #endif
        !           119: #include <openssl/dsa.h>
        !           120: #include <openssl/ecdh.h>
        !           121: #include <openssl/ecdsa.h>
        !           122: #ifndef OPENSSL_NO_HMAC
        !           123: #include <openssl/hmac.h>
        !           124: #endif
        !           125: #ifndef OPENSSL_NO_IDEA
        !           126: #include <openssl/idea.h>
        !           127: #endif
        !           128: #ifndef OPENSSL_NO_MDC2
        !           129: #include <openssl/mdc2.h>
        !           130: #endif
        !           131: #ifndef OPENSSL_NO_MD4
        !           132: #include <openssl/md4.h>
        !           133: #endif
        !           134: #ifndef OPENSSL_NO_MD5
        !           135: #include <openssl/md5.h>
        !           136: #endif
        !           137: #ifndef OPENSSL_NO_RC2
        !           138: #include <openssl/rc2.h>
        !           139: #endif
        !           140: #ifndef OPENSSL_NO_RC4
        !           141: #include <openssl/rc4.h>
        !           142: #endif
        !           143: #ifndef OPENSSL_NO_RC5
        !           144: #include <openssl/rc5.h>
        !           145: #endif
        !           146: #include <openssl/rsa.h>
        !           147: #ifndef OPENSSL_NO_RIPEMD
        !           148: #include <openssl/ripemd.h>
        !           149: #endif
        !           150: #ifndef OPENSSL_NO_SHA
        !           151: #include <openssl/sha.h>
        !           152: #endif
        !           153: #ifndef OPENSSL_NO_WHIRLPOOL
        !           154: #include <openssl/whrlpool.h>
        !           155: #endif
        !           156:
        !           157: #include "./testdsa.h"
        !           158: #include "./testrsa.h"
        !           159:
        !           160: #define BUFSIZE        ((long)1024*8+1)
        !           161: int run = 0;
        !           162:
        !           163: static int mr = 0;
        !           164: static int usertime = 1;
        !           165:
        !           166: static double Time_F(int s);
        !           167: static void print_message(const char *s, long num, int length);
        !           168: static void
        !           169: pkey_print_message(const char *str, const char *str2,
        !           170:     long num, int bits, int sec);
        !           171: static void print_result(int alg, int run_no, int count, double time_used);
        !           172: static int do_multi(int multi);
        !           173:
        !           174: #define ALGOR_NUM      30
        !           175: #define SIZE_NUM       5
        !           176: #define RSA_NUM                4
        !           177: #define DSA_NUM                3
        !           178:
        !           179: #define EC_NUM       16
        !           180: #define MAX_ECDH_SIZE 256
        !           181:
        !           182: static const char *names[ALGOR_NUM] = {
        !           183:        "md2", "mdc2", "md4", "md5", "hmac(md5)", "sha1", "rmd160", "rc4",
        !           184:        "des cbc", "des ede3", "idea cbc", "seed cbc",
        !           185:        "rc2 cbc", "rc5-32/12 cbc", "blowfish cbc", "cast cbc",
        !           186:        "aes-128 cbc", "aes-192 cbc", "aes-256 cbc",
        !           187:        "camellia-128 cbc", "camellia-192 cbc", "camellia-256 cbc",
        !           188:        "evp", "sha256", "sha512", "whirlpool",
        !           189: "aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash"};
        !           190: static double results[ALGOR_NUM][SIZE_NUM];
        !           191: static int lengths[SIZE_NUM] = {16, 64, 256, 1024, 8 * 1024};
        !           192: static double rsa_results[RSA_NUM][2];
        !           193: static double dsa_results[DSA_NUM][2];
        !           194: static double ecdsa_results[EC_NUM][2];
        !           195: static double ecdh_results[EC_NUM][1];
        !           196:
        !           197: static void sig_done(int sig);
        !           198:
        !           199: static void
        !           200: sig_done(int sig)
        !           201: {
        !           202:        signal(SIGALRM, sig_done);
        !           203:        run = 0;
        !           204: }
        !           205:
        !           206: #define START  0
        !           207: #define STOP   1
        !           208:
        !           209:
        !           210: static double
        !           211: Time_F(int s)
        !           212: {
        !           213:        return app_tminterval(s, usertime);
        !           214: }
        !           215:
        !           216:
        !           217: static const int KDF1_SHA1_len = 20;
        !           218: static void *
        !           219: KDF1_SHA1(const void *in, size_t inlen, void *out, size_t * outlen)
        !           220: {
        !           221: #ifndef OPENSSL_NO_SHA
        !           222:        if (*outlen < SHA_DIGEST_LENGTH)
        !           223:                return NULL;
        !           224:        else
        !           225:                *outlen = SHA_DIGEST_LENGTH;
        !           226:        return SHA1(in, inlen, out);
        !           227: #else
        !           228:        return NULL;
        !           229: #endif                         /* OPENSSL_NO_SHA */
        !           230: }
        !           231:
        !           232:
        !           233: int speed_main(int, char **);
        !           234:
        !           235: int
        !           236: speed_main(int argc, char **argv)
        !           237: {
        !           238:        unsigned char *buf = NULL, *buf2 = NULL;
        !           239:        int mret = 1;
        !           240:        long count = 0, save_count = 0;
        !           241:        int i, j, k;
        !           242:        long rsa_count;
        !           243:        unsigned rsa_num;
        !           244:        unsigned char md[EVP_MAX_MD_SIZE];
        !           245: #ifndef OPENSSL_NO_MDC2
        !           246:        unsigned char mdc2[MDC2_DIGEST_LENGTH];
        !           247: #endif
        !           248: #ifndef OPENSSL_NO_MD4
        !           249:        unsigned char md4[MD4_DIGEST_LENGTH];
        !           250: #endif
        !           251: #ifndef OPENSSL_NO_MD5
        !           252:        unsigned char md5[MD5_DIGEST_LENGTH];
        !           253:        unsigned char hmac[MD5_DIGEST_LENGTH];
        !           254: #endif
        !           255: #ifndef OPENSSL_NO_SHA
        !           256:        unsigned char sha[SHA_DIGEST_LENGTH];
        !           257: #ifndef OPENSSL_NO_SHA256
        !           258:        unsigned char sha256[SHA256_DIGEST_LENGTH];
        !           259: #endif
        !           260: #ifndef OPENSSL_NO_SHA512
        !           261:        unsigned char sha512[SHA512_DIGEST_LENGTH];
        !           262: #endif
        !           263: #endif
        !           264: #ifndef OPENSSL_NO_WHIRLPOOL
        !           265:        unsigned char whirlpool[WHIRLPOOL_DIGEST_LENGTH];
        !           266: #endif
        !           267: #ifndef OPENSSL_NO_RIPEMD
        !           268:        unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];
        !           269: #endif
        !           270: #ifndef OPENSSL_NO_RC4
        !           271:        RC4_KEY rc4_ks;
        !           272: #endif
        !           273: #ifndef OPENSSL_NO_RC5
        !           274:        RC5_32_KEY rc5_ks;
        !           275: #endif
        !           276: #ifndef OPENSSL_NO_RC2
        !           277:        RC2_KEY rc2_ks;
        !           278: #endif
        !           279: #ifndef OPENSSL_NO_IDEA
        !           280:        IDEA_KEY_SCHEDULE idea_ks;
        !           281: #endif
        !           282: #ifndef OPENSSL_NO_BF
        !           283:        BF_KEY bf_ks;
        !           284: #endif
        !           285: #ifndef OPENSSL_NO_CAST
        !           286:        CAST_KEY cast_ks;
        !           287: #endif
        !           288:        static const unsigned char key16[16] =
        !           289:        {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
        !           290:        0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12};
        !           291: #ifndef OPENSSL_NO_AES
        !           292:        static const unsigned char key24[24] =
        !           293:        {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
        !           294:                0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
        !           295:        0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34};
        !           296:        static const unsigned char key32[32] =
        !           297:        {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
        !           298:                0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
        !           299:                0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,
        !           300:        0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56};
        !           301: #endif
        !           302: #ifndef OPENSSL_NO_CAMELLIA
        !           303:        static const unsigned char ckey24[24] =
        !           304:        {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
        !           305:                0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
        !           306:        0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34};
        !           307:        static const unsigned char ckey32[32] =
        !           308:        {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
        !           309:                0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,
        !           310:                0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,
        !           311:        0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56};
        !           312: #endif
        !           313: #ifndef OPENSSL_NO_AES
        !           314: #define MAX_BLOCK_SIZE 128
        !           315: #else
        !           316: #define MAX_BLOCK_SIZE 64
        !           317: #endif
        !           318:        unsigned char DES_iv[8];
        !           319:        unsigned char iv[2 * MAX_BLOCK_SIZE / 8];
        !           320: #ifndef OPENSSL_NO_DES
        !           321:        static DES_cblock key = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0};
        !           322:        static DES_cblock key2 = {0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12};
        !           323:        static DES_cblock key3 = {0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34};
        !           324:        DES_key_schedule sch;
        !           325:        DES_key_schedule sch2;
        !           326:        DES_key_schedule sch3;
        !           327: #endif
        !           328: #ifndef OPENSSL_NO_AES
        !           329:        AES_KEY aes_ks1, aes_ks2, aes_ks3;
        !           330: #endif
        !           331: #ifndef OPENSSL_NO_CAMELLIA
        !           332:        CAMELLIA_KEY camellia_ks1, camellia_ks2, camellia_ks3;
        !           333: #endif
        !           334: #define        D_MD2           0
        !           335: #define        D_MDC2          1
        !           336: #define        D_MD4           2
        !           337: #define        D_MD5           3
        !           338: #define        D_HMAC          4
        !           339: #define        D_SHA1          5
        !           340: #define D_RMD160       6
        !           341: #define        D_RC4           7
        !           342: #define        D_CBC_DES       8
        !           343: #define        D_EDE3_DES      9
        !           344: #define        D_CBC_IDEA      10
        !           345: #define        D_CBC_SEED      11
        !           346: #define        D_CBC_RC2       12
        !           347: #define        D_CBC_RC5       13
        !           348: #define        D_CBC_BF        14
        !           349: #define        D_CBC_CAST      15
        !           350: #define D_CBC_128_AES  16
        !           351: #define D_CBC_192_AES  17
        !           352: #define D_CBC_256_AES  18
        !           353: #define D_CBC_128_CML   19
        !           354: #define D_CBC_192_CML   20
        !           355: #define D_CBC_256_CML   21
        !           356: #define D_EVP          22
        !           357: #define D_SHA256       23
        !           358: #define D_SHA512       24
        !           359: #define D_WHIRLPOOL    25
        !           360: #define D_IGE_128_AES   26
        !           361: #define D_IGE_192_AES   27
        !           362: #define D_IGE_256_AES   28
        !           363: #define D_GHASH                29
        !           364:        double d = 0.0;
        !           365:        long c[ALGOR_NUM][SIZE_NUM];
        !           366: #define        R_DSA_512       0
        !           367: #define        R_DSA_1024      1
        !           368: #define        R_DSA_2048      2
        !           369: #define        R_RSA_512       0
        !           370: #define        R_RSA_1024      1
        !           371: #define        R_RSA_2048      2
        !           372: #define        R_RSA_4096      3
        !           373:
        !           374: #define R_EC_P160    0
        !           375: #define R_EC_P192    1
        !           376: #define R_EC_P224    2
        !           377: #define R_EC_P256    3
        !           378: #define R_EC_P384    4
        !           379: #define R_EC_P521    5
        !           380: #define R_EC_K163    6
        !           381: #define R_EC_K233    7
        !           382: #define R_EC_K283    8
        !           383: #define R_EC_K409    9
        !           384: #define R_EC_K571    10
        !           385: #define R_EC_B163    11
        !           386: #define R_EC_B233    12
        !           387: #define R_EC_B283    13
        !           388: #define R_EC_B409    14
        !           389: #define R_EC_B571    15
        !           390:
        !           391:        RSA *rsa_key[RSA_NUM];
        !           392:        long rsa_c[RSA_NUM][2];
        !           393:        static unsigned int rsa_bits[RSA_NUM] = {512, 1024, 2048, 4096};
        !           394:        static unsigned char *rsa_data[RSA_NUM] =
        !           395:        {test512, test1024, test2048, test4096};
        !           396:        static int rsa_data_length[RSA_NUM] = {
        !           397:                sizeof(test512), sizeof(test1024),
        !           398:        sizeof(test2048), sizeof(test4096)};
        !           399:        DSA *dsa_key[DSA_NUM];
        !           400:        long dsa_c[DSA_NUM][2];
        !           401:        static unsigned int dsa_bits[DSA_NUM] = {512, 1024, 2048};
        !           402: #ifndef OPENSSL_NO_EC
        !           403:        /*
        !           404:         * We only test over the following curves as they are representative,
        !           405:         * To add tests over more curves, simply add the curve NID and curve
        !           406:         * name to the following arrays and increase the EC_NUM value
        !           407:         * accordingly.
        !           408:         */
        !           409:        static unsigned int test_curves[EC_NUM] =
        !           410:        {
        !           411:                /* Prime Curves */
        !           412:                NID_secp160r1,
        !           413:                NID_X9_62_prime192v1,
        !           414:                NID_secp224r1,
        !           415:                NID_X9_62_prime256v1,
        !           416:                NID_secp384r1,
        !           417:                NID_secp521r1,
        !           418:                /* Binary Curves */
        !           419:                NID_sect163k1,
        !           420:                NID_sect233k1,
        !           421:                NID_sect283k1,
        !           422:                NID_sect409k1,
        !           423:                NID_sect571k1,
        !           424:                NID_sect163r2,
        !           425:                NID_sect233r1,
        !           426:                NID_sect283r1,
        !           427:                NID_sect409r1,
        !           428:                NID_sect571r1
        !           429:        };
        !           430:        static const char *test_curves_names[EC_NUM] =
        !           431:        {
        !           432:                /* Prime Curves */
        !           433:                "secp160r1",
        !           434:                "nistp192",
        !           435:                "nistp224",
        !           436:                "nistp256",
        !           437:                "nistp384",
        !           438:                "nistp521",
        !           439:                /* Binary Curves */
        !           440:                "nistk163",
        !           441:                "nistk233",
        !           442:                "nistk283",
        !           443:                "nistk409",
        !           444:                "nistk571",
        !           445:                "nistb163",
        !           446:                "nistb233",
        !           447:                "nistb283",
        !           448:                "nistb409",
        !           449:                "nistb571"
        !           450:        };
        !           451:        static int test_curves_bits[EC_NUM] =
        !           452:        {
        !           453:                160, 192, 224, 256, 384, 521,
        !           454:                163, 233, 283, 409, 571,
        !           455:                163, 233, 283, 409, 571
        !           456:        };
        !           457:
        !           458: #endif
        !           459:
        !           460:        unsigned char ecdsasig[256];
        !           461:        unsigned int ecdsasiglen;
        !           462:        EC_KEY *ecdsa[EC_NUM];
        !           463:        long ecdsa_c[EC_NUM][2];
        !           464:
        !           465:        EC_KEY *ecdh_a[EC_NUM], *ecdh_b[EC_NUM];
        !           466:        unsigned char secret_a[MAX_ECDH_SIZE], secret_b[MAX_ECDH_SIZE];
        !           467:        int secret_size_a, secret_size_b;
        !           468:        int ecdh_checks = 0;
        !           469:        int secret_idx = 0;
        !           470:        long ecdh_c[EC_NUM][2];
        !           471:
        !           472:        int rsa_doit[RSA_NUM];
        !           473:        int dsa_doit[DSA_NUM];
        !           474:        int ecdsa_doit[EC_NUM];
        !           475:        int ecdh_doit[EC_NUM];
        !           476:        int doit[ALGOR_NUM];
        !           477:        int pr_header = 0;
        !           478:        const EVP_CIPHER *evp_cipher = NULL;
        !           479:        const EVP_MD *evp_md = NULL;
        !           480:        int decrypt = 0;
        !           481:        int multi = 0;
        !           482:        const char *errstr = NULL;
        !           483:
        !           484: #ifndef TIMES
        !           485:        usertime = -1;
        !           486: #endif
        !           487:
        !           488:        memset(results, 0, sizeof(results));
        !           489:        memset(dsa_key, 0, sizeof(dsa_key));
        !           490:        for (i = 0; i < EC_NUM; i++)
        !           491:                ecdsa[i] = NULL;
        !           492:        for (i = 0; i < EC_NUM; i++) {
        !           493:                ecdh_a[i] = NULL;
        !           494:                ecdh_b[i] = NULL;
        !           495:        }
        !           496:
        !           497:        memset(rsa_key, 0, sizeof(rsa_key));
        !           498:        for (i = 0; i < RSA_NUM; i++)
        !           499:                rsa_key[i] = NULL;
        !           500:
        !           501:        if ((buf = malloc((int) BUFSIZE)) == NULL) {
        !           502:                BIO_printf(bio_err, "out of memory\n");
        !           503:                goto end;
        !           504:        }
        !           505:        if ((buf2 = malloc((int) BUFSIZE)) == NULL) {
        !           506:                BIO_printf(bio_err, "out of memory\n");
        !           507:                goto end;
        !           508:        }
        !           509:        memset(c, 0, sizeof(c));
        !           510:        memset(DES_iv, 0, sizeof(DES_iv));
        !           511:        memset(iv, 0, sizeof(iv));
        !           512:
        !           513:        for (i = 0; i < ALGOR_NUM; i++)
        !           514:                doit[i] = 0;
        !           515:        for (i = 0; i < RSA_NUM; i++)
        !           516:                rsa_doit[i] = 0;
        !           517:        for (i = 0; i < DSA_NUM; i++)
        !           518:                dsa_doit[i] = 0;
        !           519:        for (i = 0; i < EC_NUM; i++)
        !           520:                ecdsa_doit[i] = 0;
        !           521:        for (i = 0; i < EC_NUM; i++)
        !           522:                ecdh_doit[i] = 0;
        !           523:
        !           524:
        !           525:        j = 0;
        !           526:        argc--;
        !           527:        argv++;
        !           528:        while (argc) {
        !           529:                if ((argc > 0) && (strcmp(*argv, "-elapsed") == 0)) {
        !           530:                        usertime = 0;
        !           531:                        j--;    /* Otherwise, -elapsed gets confused with an
        !           532:                                 * algorithm. */
        !           533:                } else if ((argc > 0) && (strcmp(*argv, "-evp") == 0)) {
        !           534:                        argc--;
        !           535:                        argv++;
        !           536:                        if (argc == 0) {
        !           537:                                BIO_printf(bio_err, "no EVP given\n");
        !           538:                                goto end;
        !           539:                        }
        !           540:                        evp_cipher = EVP_get_cipherbyname(*argv);
        !           541:                        if (!evp_cipher) {
        !           542:                                evp_md = EVP_get_digestbyname(*argv);
        !           543:                        }
        !           544:                        if (!evp_cipher && !evp_md) {
        !           545:                                BIO_printf(bio_err, "%s is an unknown cipher or digest\n", *argv);
        !           546:                                goto end;
        !           547:                        }
        !           548:                        doit[D_EVP] = 1;
        !           549:                } else if (argc > 0 && !strcmp(*argv, "-decrypt")) {
        !           550:                        decrypt = 1;
        !           551:                        j--;    /* Otherwise, -elapsed gets confused with an
        !           552:                                 * algorithm. */
        !           553:                }
        !           554: #ifndef OPENSSL_NO_ENGINE
        !           555:                else if ((argc > 0) && (strcmp(*argv, "-engine") == 0)) {
        !           556:                        argc--;
        !           557:                        argv++;
        !           558:                        if (argc == 0) {
        !           559:                                BIO_printf(bio_err, "no engine given\n");
        !           560:                                goto end;
        !           561:                        }
        !           562:                        setup_engine(bio_err, *argv, 0);
        !           563:                        /*
        !           564:                         * j will be increased again further down.  We just
        !           565:                         * don't want speed to confuse an engine with an
        !           566:                         * algorithm, especially when none is given (which
        !           567:                         * means all of them should be run)
        !           568:                         */
        !           569:                        j--;
        !           570:                }
        !           571: #endif
        !           572:                else if ((argc > 0) && (strcmp(*argv, "-multi") == 0)) {
        !           573:                        argc--;
        !           574:                        argv++;
        !           575:                        if (argc == 0) {
        !           576:                                BIO_printf(bio_err, "no multi count given\n");
        !           577:                                goto end;
        !           578:                        }
        !           579:                        multi = strtonum(argv[0], 1, INT_MAX, &errstr);
        !           580:                        if (errstr) {
        !           581:                                BIO_printf(bio_err, "bad multi count: %s", errstr);
        !           582:                                goto end;
        !           583:                        }
        !           584:                        j--;    /* Otherwise, -mr gets confused with an
        !           585:                                 * algorithm. */
        !           586:                }
        !           587:                else if (argc > 0 && !strcmp(*argv, "-mr")) {
        !           588:                        mr = 1;
        !           589:                        j--;    /* Otherwise, -mr gets confused with an
        !           590:                                 * algorithm. */
        !           591:                } else
        !           592: #ifndef OPENSSL_NO_MDC2
        !           593:                if (strcmp(*argv, "mdc2") == 0)
        !           594:                        doit[D_MDC2] = 1;
        !           595:                else
        !           596: #endif
        !           597: #ifndef OPENSSL_NO_MD4
        !           598:                if (strcmp(*argv, "md4") == 0)
        !           599:                        doit[D_MD4] = 1;
        !           600:                else
        !           601: #endif
        !           602: #ifndef OPENSSL_NO_MD5
        !           603:                if (strcmp(*argv, "md5") == 0)
        !           604:                        doit[D_MD5] = 1;
        !           605:                else
        !           606: #endif
        !           607: #ifndef OPENSSL_NO_MD5
        !           608:                if (strcmp(*argv, "hmac") == 0)
        !           609:                        doit[D_HMAC] = 1;
        !           610:                else
        !           611: #endif
        !           612: #ifndef OPENSSL_NO_SHA
        !           613:                if (strcmp(*argv, "sha1") == 0)
        !           614:                        doit[D_SHA1] = 1;
        !           615:                else if (strcmp(*argv, "sha") == 0)
        !           616:                        doit[D_SHA1] = 1,
        !           617:                            doit[D_SHA256] = 1,
        !           618:                            doit[D_SHA512] = 1;
        !           619:                else
        !           620: #ifndef OPENSSL_NO_SHA256
        !           621:                if (strcmp(*argv, "sha256") == 0)
        !           622:                        doit[D_SHA256] = 1;
        !           623:                else
        !           624: #endif
        !           625: #ifndef OPENSSL_NO_SHA512
        !           626:                if (strcmp(*argv, "sha512") == 0)
        !           627:                        doit[D_SHA512] = 1;
        !           628:                else
        !           629: #endif
        !           630: #endif
        !           631: #ifndef OPENSSL_NO_WHIRLPOOL
        !           632:                if (strcmp(*argv, "whirlpool") == 0)
        !           633:                        doit[D_WHIRLPOOL] = 1;
        !           634:                else
        !           635: #endif
        !           636: #ifndef OPENSSL_NO_RIPEMD
        !           637:                if (strcmp(*argv, "ripemd") == 0)
        !           638:                        doit[D_RMD160] = 1;
        !           639:                else if (strcmp(*argv, "rmd160") == 0)
        !           640:                        doit[D_RMD160] = 1;
        !           641:                else if (strcmp(*argv, "ripemd160") == 0)
        !           642:                        doit[D_RMD160] = 1;
        !           643:                else
        !           644: #endif
        !           645: #ifndef OPENSSL_NO_RC4
        !           646:                if (strcmp(*argv, "rc4") == 0)
        !           647:                        doit[D_RC4] = 1;
        !           648:                else
        !           649: #endif
        !           650: #ifndef OPENSSL_NO_DES
        !           651:                if (strcmp(*argv, "des-cbc") == 0)
        !           652:                        doit[D_CBC_DES] = 1;
        !           653:                else if (strcmp(*argv, "des-ede3") == 0)
        !           654:                        doit[D_EDE3_DES] = 1;
        !           655:                else
        !           656: #endif
        !           657: #ifndef OPENSSL_NO_AES
        !           658:                if (strcmp(*argv, "aes-128-cbc") == 0)
        !           659:                        doit[D_CBC_128_AES] = 1;
        !           660:                else if (strcmp(*argv, "aes-192-cbc") == 0)
        !           661:                        doit[D_CBC_192_AES] = 1;
        !           662:                else if (strcmp(*argv, "aes-256-cbc") == 0)
        !           663:                        doit[D_CBC_256_AES] = 1;
        !           664:                else if (strcmp(*argv, "aes-128-ige") == 0)
        !           665:                        doit[D_IGE_128_AES] = 1;
        !           666:                else if (strcmp(*argv, "aes-192-ige") == 0)
        !           667:                        doit[D_IGE_192_AES] = 1;
        !           668:                else if (strcmp(*argv, "aes-256-ige") == 0)
        !           669:                        doit[D_IGE_256_AES] = 1;
        !           670:                else
        !           671: #endif
        !           672: #ifndef OPENSSL_NO_CAMELLIA
        !           673:                if (strcmp(*argv, "camellia-128-cbc") == 0)
        !           674:                        doit[D_CBC_128_CML] = 1;
        !           675:                else if (strcmp(*argv, "camellia-192-cbc") == 0)
        !           676:                        doit[D_CBC_192_CML] = 1;
        !           677:                else if (strcmp(*argv, "camellia-256-cbc") == 0)
        !           678:                        doit[D_CBC_256_CML] = 1;
        !           679:                else
        !           680: #endif
        !           681: #if 0                          /* was: #ifdef RSAref */
        !           682:                if (strcmp(*argv, "rsaref") == 0) {
        !           683:                        RSA_set_default_openssl_method(RSA_PKCS1_RSAref());
        !           684:                        j--;
        !           685:                } else
        !           686: #endif
        !           687: #ifndef RSA_NULL
        !           688:                if (strcmp(*argv, "openssl") == 0) {
        !           689:                        RSA_set_default_method(RSA_PKCS1_SSLeay());
        !           690:                        j--;
        !           691:                } else
        !           692: #endif
        !           693:                if (strcmp(*argv, "dsa512") == 0)
        !           694:                        dsa_doit[R_DSA_512] = 2;
        !           695:                else if (strcmp(*argv, "dsa1024") == 0)
        !           696:                        dsa_doit[R_DSA_1024] = 2;
        !           697:                else if (strcmp(*argv, "dsa2048") == 0)
        !           698:                        dsa_doit[R_DSA_2048] = 2;
        !           699:                else if (strcmp(*argv, "rsa512") == 0)
        !           700:                        rsa_doit[R_RSA_512] = 2;
        !           701:                else if (strcmp(*argv, "rsa1024") == 0)
        !           702:                        rsa_doit[R_RSA_1024] = 2;
        !           703:                else if (strcmp(*argv, "rsa2048") == 0)
        !           704:                        rsa_doit[R_RSA_2048] = 2;
        !           705:                else if (strcmp(*argv, "rsa4096") == 0)
        !           706:                        rsa_doit[R_RSA_4096] = 2;
        !           707:                else
        !           708: #ifndef OPENSSL_NO_RC2
        !           709:                if (strcmp(*argv, "rc2-cbc") == 0)
        !           710:                        doit[D_CBC_RC2] = 1;
        !           711:                else if (strcmp(*argv, "rc2") == 0)
        !           712:                        doit[D_CBC_RC2] = 1;
        !           713:                else
        !           714: #endif
        !           715: #ifndef OPENSSL_NO_RC5
        !           716:                if (strcmp(*argv, "rc5-cbc") == 0)
        !           717:                        doit[D_CBC_RC5] = 1;
        !           718:                else if (strcmp(*argv, "rc5") == 0)
        !           719:                        doit[D_CBC_RC5] = 1;
        !           720:                else
        !           721: #endif
        !           722: #ifndef OPENSSL_NO_IDEA
        !           723:                if (strcmp(*argv, "idea-cbc") == 0)
        !           724:                        doit[D_CBC_IDEA] = 1;
        !           725:                else if (strcmp(*argv, "idea") == 0)
        !           726:                        doit[D_CBC_IDEA] = 1;
        !           727:                else
        !           728: #endif
        !           729: #ifndef OPENSSL_NO_BF
        !           730:                if (strcmp(*argv, "bf-cbc") == 0)
        !           731:                        doit[D_CBC_BF] = 1;
        !           732:                else if (strcmp(*argv, "blowfish") == 0)
        !           733:                        doit[D_CBC_BF] = 1;
        !           734:                else if (strcmp(*argv, "bf") == 0)
        !           735:                        doit[D_CBC_BF] = 1;
        !           736:                else
        !           737: #endif
        !           738: #ifndef OPENSSL_NO_CAST
        !           739:                if (strcmp(*argv, "cast-cbc") == 0)
        !           740:                        doit[D_CBC_CAST] = 1;
        !           741:                else if (strcmp(*argv, "cast") == 0)
        !           742:                        doit[D_CBC_CAST] = 1;
        !           743:                else if (strcmp(*argv, "cast5") == 0)
        !           744:                        doit[D_CBC_CAST] = 1;
        !           745:                else
        !           746: #endif
        !           747: #ifndef OPENSSL_NO_DES
        !           748:                if (strcmp(*argv, "des") == 0) {
        !           749:                        doit[D_CBC_DES] = 1;
        !           750:                        doit[D_EDE3_DES] = 1;
        !           751:                } else
        !           752: #endif
        !           753: #ifndef OPENSSL_NO_AES
        !           754:                if (strcmp(*argv, "aes") == 0) {
        !           755:                        doit[D_CBC_128_AES] = 1;
        !           756:                        doit[D_CBC_192_AES] = 1;
        !           757:                        doit[D_CBC_256_AES] = 1;
        !           758:                } else if (strcmp(*argv, "ghash") == 0) {
        !           759:                        doit[D_GHASH] = 1;
        !           760:                } else
        !           761: #endif
        !           762: #ifndef OPENSSL_NO_CAMELLIA
        !           763:                if (strcmp(*argv, "camellia") == 0) {
        !           764:                        doit[D_CBC_128_CML] = 1;
        !           765:                        doit[D_CBC_192_CML] = 1;
        !           766:                        doit[D_CBC_256_CML] = 1;
        !           767:                } else
        !           768: #endif
        !           769:                if (strcmp(*argv, "rsa") == 0) {
        !           770:                        rsa_doit[R_RSA_512] = 1;
        !           771:                        rsa_doit[R_RSA_1024] = 1;
        !           772:                        rsa_doit[R_RSA_2048] = 1;
        !           773:                        rsa_doit[R_RSA_4096] = 1;
        !           774:                } else
        !           775:                if (strcmp(*argv, "dsa") == 0) {
        !           776:                        dsa_doit[R_DSA_512] = 1;
        !           777:                        dsa_doit[R_DSA_1024] = 1;
        !           778:                        dsa_doit[R_DSA_2048] = 1;
        !           779:                } else
        !           780:                if (strcmp(*argv, "ecdsap160") == 0)
        !           781:                        ecdsa_doit[R_EC_P160] = 2;
        !           782:                else if (strcmp(*argv, "ecdsap192") == 0)
        !           783:                        ecdsa_doit[R_EC_P192] = 2;
        !           784:                else if (strcmp(*argv, "ecdsap224") == 0)
        !           785:                        ecdsa_doit[R_EC_P224] = 2;
        !           786:                else if (strcmp(*argv, "ecdsap256") == 0)
        !           787:                        ecdsa_doit[R_EC_P256] = 2;
        !           788:                else if (strcmp(*argv, "ecdsap384") == 0)
        !           789:                        ecdsa_doit[R_EC_P384] = 2;
        !           790:                else if (strcmp(*argv, "ecdsap521") == 0)
        !           791:                        ecdsa_doit[R_EC_P521] = 2;
        !           792:                else if (strcmp(*argv, "ecdsak163") == 0)
        !           793:                        ecdsa_doit[R_EC_K163] = 2;
        !           794:                else if (strcmp(*argv, "ecdsak233") == 0)
        !           795:                        ecdsa_doit[R_EC_K233] = 2;
        !           796:                else if (strcmp(*argv, "ecdsak283") == 0)
        !           797:                        ecdsa_doit[R_EC_K283] = 2;
        !           798:                else if (strcmp(*argv, "ecdsak409") == 0)
        !           799:                        ecdsa_doit[R_EC_K409] = 2;
        !           800:                else if (strcmp(*argv, "ecdsak571") == 0)
        !           801:                        ecdsa_doit[R_EC_K571] = 2;
        !           802:                else if (strcmp(*argv, "ecdsab163") == 0)
        !           803:                        ecdsa_doit[R_EC_B163] = 2;
        !           804:                else if (strcmp(*argv, "ecdsab233") == 0)
        !           805:                        ecdsa_doit[R_EC_B233] = 2;
        !           806:                else if (strcmp(*argv, "ecdsab283") == 0)
        !           807:                        ecdsa_doit[R_EC_B283] = 2;
        !           808:                else if (strcmp(*argv, "ecdsab409") == 0)
        !           809:                        ecdsa_doit[R_EC_B409] = 2;
        !           810:                else if (strcmp(*argv, "ecdsab571") == 0)
        !           811:                        ecdsa_doit[R_EC_B571] = 2;
        !           812:                else if (strcmp(*argv, "ecdsa") == 0) {
        !           813:                        for (i = 0; i < EC_NUM; i++)
        !           814:                                ecdsa_doit[i] = 1;
        !           815:                } else
        !           816:                if (strcmp(*argv, "ecdhp160") == 0)
        !           817:                        ecdh_doit[R_EC_P160] = 2;
        !           818:                else if (strcmp(*argv, "ecdhp192") == 0)
        !           819:                        ecdh_doit[R_EC_P192] = 2;
        !           820:                else if (strcmp(*argv, "ecdhp224") == 0)
        !           821:                        ecdh_doit[R_EC_P224] = 2;
        !           822:                else if (strcmp(*argv, "ecdhp256") == 0)
        !           823:                        ecdh_doit[R_EC_P256] = 2;
        !           824:                else if (strcmp(*argv, "ecdhp384") == 0)
        !           825:                        ecdh_doit[R_EC_P384] = 2;
        !           826:                else if (strcmp(*argv, "ecdhp521") == 0)
        !           827:                        ecdh_doit[R_EC_P521] = 2;
        !           828:                else if (strcmp(*argv, "ecdhk163") == 0)
        !           829:                        ecdh_doit[R_EC_K163] = 2;
        !           830:                else if (strcmp(*argv, "ecdhk233") == 0)
        !           831:                        ecdh_doit[R_EC_K233] = 2;
        !           832:                else if (strcmp(*argv, "ecdhk283") == 0)
        !           833:                        ecdh_doit[R_EC_K283] = 2;
        !           834:                else if (strcmp(*argv, "ecdhk409") == 0)
        !           835:                        ecdh_doit[R_EC_K409] = 2;
        !           836:                else if (strcmp(*argv, "ecdhk571") == 0)
        !           837:                        ecdh_doit[R_EC_K571] = 2;
        !           838:                else if (strcmp(*argv, "ecdhb163") == 0)
        !           839:                        ecdh_doit[R_EC_B163] = 2;
        !           840:                else if (strcmp(*argv, "ecdhb233") == 0)
        !           841:                        ecdh_doit[R_EC_B233] = 2;
        !           842:                else if (strcmp(*argv, "ecdhb283") == 0)
        !           843:                        ecdh_doit[R_EC_B283] = 2;
        !           844:                else if (strcmp(*argv, "ecdhb409") == 0)
        !           845:                        ecdh_doit[R_EC_B409] = 2;
        !           846:                else if (strcmp(*argv, "ecdhb571") == 0)
        !           847:                        ecdh_doit[R_EC_B571] = 2;
        !           848:                else if (strcmp(*argv, "ecdh") == 0) {
        !           849:                        for (i = 0; i < EC_NUM; i++)
        !           850:                                ecdh_doit[i] = 1;
        !           851:                } else
        !           852:                {
        !           853:                        BIO_printf(bio_err, "Error: bad option or value\n");
        !           854:                        BIO_printf(bio_err, "\n");
        !           855:                        BIO_printf(bio_err, "Available values:\n");
        !           856: #ifndef OPENSSL_NO_MDC2
        !           857:                        BIO_printf(bio_err, "mdc2     ");
        !           858: #endif
        !           859: #ifndef OPENSSL_NO_MD4
        !           860:                        BIO_printf(bio_err, "md4      ");
        !           861: #endif
        !           862: #ifndef OPENSSL_NO_MD5
        !           863:                        BIO_printf(bio_err, "md5      ");
        !           864: #ifndef OPENSSL_NO_HMAC
        !           865:                        BIO_printf(bio_err, "hmac     ");
        !           866: #endif
        !           867: #endif
        !           868: #ifndef OPENSSL_NO_SHA1
        !           869:                        BIO_printf(bio_err, "sha1     ");
        !           870: #endif
        !           871: #ifndef OPENSSL_NO_SHA256
        !           872:                        BIO_printf(bio_err, "sha256   ");
        !           873: #endif
        !           874: #ifndef OPENSSL_NO_SHA512
        !           875:                        BIO_printf(bio_err, "sha512   ");
        !           876: #endif
        !           877: #ifndef OPENSSL_NO_WHIRLPOOL
        !           878:                        BIO_printf(bio_err, "whirlpool");
        !           879: #endif
        !           880: #ifndef OPENSSL_NO_RIPEMD160
        !           881:                        BIO_printf(bio_err, "rmd160");
        !           882: #endif
        !           883: #if !defined(OPENSSL_NO_MD2) || !defined(OPENSSL_NO_MDC2) || \
        !           884:     !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \
        !           885:     !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160) || \
        !           886:     !defined(OPENSSL_NO_WHIRLPOOL)
        !           887:                        BIO_printf(bio_err, "\n");
        !           888: #endif
        !           889:
        !           890: #ifndef OPENSSL_NO_IDEA
        !           891:                        BIO_printf(bio_err, "idea-cbc ");
        !           892: #endif
        !           893: #ifndef OPENSSL_NO_RC2
        !           894:                        BIO_printf(bio_err, "rc2-cbc  ");
        !           895: #endif
        !           896: #ifndef OPENSSL_NO_RC5
        !           897:                        BIO_printf(bio_err, "rc5-cbc  ");
        !           898: #endif
        !           899: #ifndef OPENSSL_NO_BF
        !           900:                        BIO_printf(bio_err, "bf-cbc");
        !           901: #endif
        !           902: #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_SEED) || !defined(OPENSSL_NO_RC2) || \
        !           903:     !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_RC5)
        !           904:                        BIO_printf(bio_err, "\n");
        !           905: #endif
        !           906: #ifndef OPENSSL_NO_DES
        !           907:                        BIO_printf(bio_err, "des-cbc  des-ede3 ");
        !           908: #endif
        !           909: #ifndef OPENSSL_NO_AES
        !           910:                        BIO_printf(bio_err, "aes-128-cbc aes-192-cbc aes-256-cbc ");
        !           911:                        BIO_printf(bio_err, "aes-128-ige aes-192-ige aes-256-ige ");
        !           912: #endif
        !           913: #ifndef OPENSSL_NO_CAMELLIA
        !           914:                        BIO_printf(bio_err, "\n");
        !           915:                        BIO_printf(bio_err, "camellia-128-cbc camellia-192-cbc camellia-256-cbc ");
        !           916: #endif
        !           917: #ifndef OPENSSL_NO_RC4
        !           918:                        BIO_printf(bio_err, "rc4");
        !           919: #endif
        !           920:                        BIO_printf(bio_err, "\n");
        !           921:
        !           922:                        BIO_printf(bio_err, "rsa512   rsa1024  rsa2048  rsa4096\n");
        !           923:
        !           924:                        BIO_printf(bio_err, "dsa512   dsa1024  dsa2048\n");
        !           925:                        BIO_printf(bio_err, "ecdsap160 ecdsap192 ecdsap224 ecdsap256 ecdsap384 ecdsap521\n");
        !           926:                        BIO_printf(bio_err, "ecdsak163 ecdsak233 ecdsak283 ecdsak409 ecdsak571\n");
        !           927:                        BIO_printf(bio_err, "ecdsab163 ecdsab233 ecdsab283 ecdsab409 ecdsab571\n");
        !           928:                        BIO_printf(bio_err, "ecdsa\n");
        !           929:                        BIO_printf(bio_err, "ecdhp160  ecdhp192  ecdhp224  ecdhp256  ecdhp384  ecdhp521\n");
        !           930:                        BIO_printf(bio_err, "ecdhk163  ecdhk233  ecdhk283  ecdhk409  ecdhk571\n");
        !           931:                        BIO_printf(bio_err, "ecdhb163  ecdhb233  ecdhb283  ecdhb409  ecdhb571\n");
        !           932:                        BIO_printf(bio_err, "ecdh\n");
        !           933:
        !           934: #ifndef OPENSSL_NO_IDEA
        !           935:                        BIO_printf(bio_err, "idea     ");
        !           936: #endif
        !           937: #ifndef OPENSSL_NO_RC2
        !           938:                        BIO_printf(bio_err, "rc2      ");
        !           939: #endif
        !           940: #ifndef OPENSSL_NO_DES
        !           941:                        BIO_printf(bio_err, "des      ");
        !           942: #endif
        !           943: #ifndef OPENSSL_NO_AES
        !           944:                        BIO_printf(bio_err, "aes      ");
        !           945: #endif
        !           946: #ifndef OPENSSL_NO_CAMELLIA
        !           947:                        BIO_printf(bio_err, "camellia ");
        !           948: #endif
        !           949:                        BIO_printf(bio_err, "rsa      ");
        !           950: #ifndef OPENSSL_NO_BF
        !           951:                        BIO_printf(bio_err, "blowfish");
        !           952: #endif
        !           953: #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_SEED) || \
        !           954:     !defined(OPENSSL_NO_RC2) || !defined(OPENSSL_NO_DES) || \
        !           955:     !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_BF) || \
        !           956:     !defined(OPENSSL_NO_AES) || !defined(OPENSSL_NO_CAMELLIA)
        !           957:                        BIO_printf(bio_err, "\n");
        !           958: #endif
        !           959:
        !           960:                        BIO_printf(bio_err, "\n");
        !           961:                        BIO_printf(bio_err, "Available options:\n");
        !           962: #if defined(TIMES) || defined(USE_TOD)
        !           963:                        BIO_printf(bio_err, "-elapsed        measure time in real time instead of CPU user time.\n");
        !           964: #endif
        !           965: #ifndef OPENSSL_NO_ENGINE
        !           966:                        BIO_printf(bio_err, "-engine e       use engine e, possibly a hardware device.\n");
        !           967: #endif
        !           968:                        BIO_printf(bio_err, "-evp e          use EVP e.\n");
        !           969:                        BIO_printf(bio_err, "-decrypt        time decryption instead of encryption (only EVP).\n");
        !           970:                        BIO_printf(bio_err, "-mr             produce machine readable output.\n");
        !           971:                        BIO_printf(bio_err, "-multi n        run n benchmarks in parallel.\n");
        !           972:                        goto end;
        !           973:                }
        !           974:                argc--;
        !           975:                argv++;
        !           976:                j++;
        !           977:        }
        !           978:
        !           979:        if (multi && do_multi(multi))
        !           980:                goto show_res;
        !           981:
        !           982:        if (j == 0) {
        !           983:                for (i = 0; i < ALGOR_NUM; i++) {
        !           984:                        if (i != D_EVP)
        !           985:                                doit[i] = 1;
        !           986:                }
        !           987:                for (i = 0; i < RSA_NUM; i++)
        !           988:                        rsa_doit[i] = 1;
        !           989:                for (i = 0; i < DSA_NUM; i++)
        !           990:                        dsa_doit[i] = 1;
        !           991:                for (i = 0; i < EC_NUM; i++)
        !           992:                        ecdsa_doit[i] = 1;
        !           993:                for (i = 0; i < EC_NUM; i++)
        !           994:                        ecdh_doit[i] = 1;
        !           995:        }
        !           996:        for (i = 0; i < ALGOR_NUM; i++)
        !           997:                if (doit[i])
        !           998:                        pr_header++;
        !           999:
        !          1000:        if (usertime == 0 && !mr)
        !          1001:                BIO_printf(bio_err, "You have chosen to measure elapsed time instead of user CPU time.\n");
        !          1002:
        !          1003:        for (i = 0; i < RSA_NUM; i++) {
        !          1004:                const unsigned char *p;
        !          1005:
        !          1006:                p = rsa_data[i];
        !          1007:                rsa_key[i] = d2i_RSAPrivateKey(NULL, &p, rsa_data_length[i]);
        !          1008:                if (rsa_key[i] == NULL) {
        !          1009:                        BIO_printf(bio_err, "internal error loading RSA key number %d\n", i);
        !          1010:                        goto end;
        !          1011:                }
        !          1012: #if 0
        !          1013:                else {
        !          1014:                        BIO_printf(bio_err, mr ? "+RK:%d:"
        !          1015:                            : "Loaded RSA key, %d bit modulus and e= 0x",
        !          1016:                            BN_num_bits(rsa_key[i]->n));
        !          1017:                        BN_print(bio_err, rsa_key[i]->e);
        !          1018:                        BIO_printf(bio_err, "\n");
        !          1019:                }
        !          1020: #endif
        !          1021:        }
        !          1022:
        !          1023:        dsa_key[0] = get_dsa512();
        !          1024:        dsa_key[1] = get_dsa1024();
        !          1025:        dsa_key[2] = get_dsa2048();
        !          1026:
        !          1027: #ifndef OPENSSL_NO_DES
        !          1028:        DES_set_key_unchecked(&key, &sch);
        !          1029:        DES_set_key_unchecked(&key2, &sch2);
        !          1030:        DES_set_key_unchecked(&key3, &sch3);
        !          1031: #endif
        !          1032: #ifndef OPENSSL_NO_AES
        !          1033:        AES_set_encrypt_key(key16, 128, &aes_ks1);
        !          1034:        AES_set_encrypt_key(key24, 192, &aes_ks2);
        !          1035:        AES_set_encrypt_key(key32, 256, &aes_ks3);
        !          1036: #endif
        !          1037: #ifndef OPENSSL_NO_CAMELLIA
        !          1038:        Camellia_set_key(key16, 128, &camellia_ks1);
        !          1039:        Camellia_set_key(ckey24, 192, &camellia_ks2);
        !          1040:        Camellia_set_key(ckey32, 256, &camellia_ks3);
        !          1041: #endif
        !          1042: #ifndef OPENSSL_NO_IDEA
        !          1043:        idea_set_encrypt_key(key16, &idea_ks);
        !          1044: #endif
        !          1045: #ifndef OPENSSL_NO_RC4
        !          1046:        RC4_set_key(&rc4_ks, 16, key16);
        !          1047: #endif
        !          1048: #ifndef OPENSSL_NO_RC2
        !          1049:        RC2_set_key(&rc2_ks, 16, key16, 128);
        !          1050: #endif
        !          1051: #ifndef OPENSSL_NO_RC5
        !          1052:        RC5_32_set_key(&rc5_ks, 16, key16, 12);
        !          1053: #endif
        !          1054: #ifndef OPENSSL_NO_BF
        !          1055:        BF_set_key(&bf_ks, 16, key16);
        !          1056: #endif
        !          1057: #ifndef OPENSSL_NO_CAST
        !          1058:        CAST_set_key(&cast_ks, 16, key16);
        !          1059: #endif
        !          1060:        memset(rsa_c, 0, sizeof(rsa_c));
        !          1061: #define COND(c)        (run && count<0x7fffffff)
        !          1062: #define COUNT(d) (count)
        !          1063:        signal(SIGALRM, sig_done);
        !          1064:
        !          1065: #ifndef OPENSSL_NO_MDC2
        !          1066:        if (doit[D_MDC2]) {
        !          1067:                for (j = 0; j < SIZE_NUM; j++) {
        !          1068:                        print_message(names[D_MDC2], c[D_MDC2][j], lengths[j]);
        !          1069:                        Time_F(START);
        !          1070:                        for (count = 0, run = 1; COND(c[D_MDC2][j]); count++)
        !          1071:                                EVP_Digest(buf, (unsigned long) lengths[j], &(mdc2[0]), NULL, EVP_mdc2(), NULL);
        !          1072:                        d = Time_F(STOP);
        !          1073:                        print_result(D_MDC2, j, count, d);
        !          1074:                }
        !          1075:        }
        !          1076: #endif
        !          1077:
        !          1078: #ifndef OPENSSL_NO_MD4
        !          1079:        if (doit[D_MD4]) {
        !          1080:                for (j = 0; j < SIZE_NUM; j++) {
        !          1081:                        print_message(names[D_MD4], c[D_MD4][j], lengths[j]);
        !          1082:                        Time_F(START);
        !          1083:                        for (count = 0, run = 1; COND(c[D_MD4][j]); count++)
        !          1084:                                EVP_Digest(&(buf[0]), (unsigned long) lengths[j], &(md4[0]), NULL, EVP_md4(), NULL);
        !          1085:                        d = Time_F(STOP);
        !          1086:                        print_result(D_MD4, j, count, d);
        !          1087:                }
        !          1088:        }
        !          1089: #endif
        !          1090:
        !          1091: #ifndef OPENSSL_NO_MD5
        !          1092:        if (doit[D_MD5]) {
        !          1093:                for (j = 0; j < SIZE_NUM; j++) {
        !          1094:                        print_message(names[D_MD5], c[D_MD5][j], lengths[j]);
        !          1095:                        Time_F(START);
        !          1096:                        for (count = 0, run = 1; COND(c[D_MD5][j]); count++)
        !          1097:                                EVP_Digest(&(buf[0]), (unsigned long) lengths[j], &(md5[0]), NULL, EVP_get_digestbyname("md5"), NULL);
        !          1098:                        d = Time_F(STOP);
        !          1099:                        print_result(D_MD5, j, count, d);
        !          1100:                }
        !          1101:        }
        !          1102: #endif
        !          1103:
        !          1104: #if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC)
        !          1105:        if (doit[D_HMAC]) {
        !          1106:                HMAC_CTX hctx;
        !          1107:
        !          1108:                HMAC_CTX_init(&hctx);
        !          1109:                HMAC_Init_ex(&hctx, (unsigned char *) "This is a key...",
        !          1110:                    16, EVP_md5(), NULL);
        !          1111:
        !          1112:                for (j = 0; j < SIZE_NUM; j++) {
        !          1113:                        print_message(names[D_HMAC], c[D_HMAC][j], lengths[j]);
        !          1114:                        Time_F(START);
        !          1115:                        for (count = 0, run = 1; COND(c[D_HMAC][j]); count++) {
        !          1116:                                HMAC_Init_ex(&hctx, NULL, 0, NULL, NULL);
        !          1117:                                HMAC_Update(&hctx, buf, lengths[j]);
        !          1118:                                HMAC_Final(&hctx, &(hmac[0]), NULL);
        !          1119:                        }
        !          1120:                        d = Time_F(STOP);
        !          1121:                        print_result(D_HMAC, j, count, d);
        !          1122:                }
        !          1123:                HMAC_CTX_cleanup(&hctx);
        !          1124:        }
        !          1125: #endif
        !          1126: #ifndef OPENSSL_NO_SHA
        !          1127:        if (doit[D_SHA1]) {
        !          1128:                for (j = 0; j < SIZE_NUM; j++) {
        !          1129:                        print_message(names[D_SHA1], c[D_SHA1][j], lengths[j]);
        !          1130:                        Time_F(START);
        !          1131:                        for (count = 0, run = 1; COND(c[D_SHA1][j]); count++)
        !          1132:                                EVP_Digest(buf, (unsigned long) lengths[j], &(sha[0]), NULL, EVP_sha1(), NULL);
        !          1133:                        d = Time_F(STOP);
        !          1134:                        print_result(D_SHA1, j, count, d);
        !          1135:                }
        !          1136:        }
        !          1137: #ifndef OPENSSL_NO_SHA256
        !          1138:        if (doit[D_SHA256]) {
        !          1139:                for (j = 0; j < SIZE_NUM; j++) {
        !          1140:                        print_message(names[D_SHA256], c[D_SHA256][j], lengths[j]);
        !          1141:                        Time_F(START);
        !          1142:                        for (count = 0, run = 1; COND(c[D_SHA256][j]); count++)
        !          1143:                                SHA256(buf, lengths[j], sha256);
        !          1144:                        d = Time_F(STOP);
        !          1145:                        print_result(D_SHA256, j, count, d);
        !          1146:                }
        !          1147:        }
        !          1148: #endif
        !          1149:
        !          1150: #ifndef OPENSSL_NO_SHA512
        !          1151:        if (doit[D_SHA512]) {
        !          1152:                for (j = 0; j < SIZE_NUM; j++) {
        !          1153:                        print_message(names[D_SHA512], c[D_SHA512][j], lengths[j]);
        !          1154:                        Time_F(START);
        !          1155:                        for (count = 0, run = 1; COND(c[D_SHA512][j]); count++)
        !          1156:                                SHA512(buf, lengths[j], sha512);
        !          1157:                        d = Time_F(STOP);
        !          1158:                        print_result(D_SHA512, j, count, d);
        !          1159:                }
        !          1160:        }
        !          1161: #endif
        !          1162: #endif
        !          1163:
        !          1164: #ifndef OPENSSL_NO_WHIRLPOOL
        !          1165:        if (doit[D_WHIRLPOOL]) {
        !          1166:                for (j = 0; j < SIZE_NUM; j++) {
        !          1167:                        print_message(names[D_WHIRLPOOL], c[D_WHIRLPOOL][j], lengths[j]);
        !          1168:                        Time_F(START);
        !          1169:                        for (count = 0, run = 1; COND(c[D_WHIRLPOOL][j]); count++)
        !          1170:                                WHIRLPOOL(buf, lengths[j], whirlpool);
        !          1171:                        d = Time_F(STOP);
        !          1172:                        print_result(D_WHIRLPOOL, j, count, d);
        !          1173:                }
        !          1174:        }
        !          1175: #endif
        !          1176:
        !          1177: #ifndef OPENSSL_NO_RIPEMD
        !          1178:        if (doit[D_RMD160]) {
        !          1179:                for (j = 0; j < SIZE_NUM; j++) {
        !          1180:                        print_message(names[D_RMD160], c[D_RMD160][j], lengths[j]);
        !          1181:                        Time_F(START);
        !          1182:                        for (count = 0, run = 1; COND(c[D_RMD160][j]); count++)
        !          1183:                                EVP_Digest(buf, (unsigned long) lengths[j], &(rmd160[0]), NULL, EVP_ripemd160(), NULL);
        !          1184:                        d = Time_F(STOP);
        !          1185:                        print_result(D_RMD160, j, count, d);
        !          1186:                }
        !          1187:        }
        !          1188: #endif
        !          1189: #ifndef OPENSSL_NO_RC4
        !          1190:        if (doit[D_RC4]) {
        !          1191:                for (j = 0; j < SIZE_NUM; j++) {
        !          1192:                        print_message(names[D_RC4], c[D_RC4][j], lengths[j]);
        !          1193:                        Time_F(START);
        !          1194:                        for (count = 0, run = 1; COND(c[D_RC4][j]); count++)
        !          1195:                                RC4(&rc4_ks, (unsigned int) lengths[j],
        !          1196:                                    buf, buf);
        !          1197:                        d = Time_F(STOP);
        !          1198:                        print_result(D_RC4, j, count, d);
        !          1199:                }
        !          1200:        }
        !          1201: #endif
        !          1202: #ifndef OPENSSL_NO_DES
        !          1203:        if (doit[D_CBC_DES]) {
        !          1204:                for (j = 0; j < SIZE_NUM; j++) {
        !          1205:                        print_message(names[D_CBC_DES], c[D_CBC_DES][j], lengths[j]);
        !          1206:                        Time_F(START);
        !          1207:                        for (count = 0, run = 1; COND(c[D_CBC_DES][j]); count++)
        !          1208:                                DES_ncbc_encrypt(buf, buf, lengths[j], &sch,
        !          1209:                                    &DES_iv, DES_ENCRYPT);
        !          1210:                        d = Time_F(STOP);
        !          1211:                        print_result(D_CBC_DES, j, count, d);
        !          1212:                }
        !          1213:        }
        !          1214:        if (doit[D_EDE3_DES]) {
        !          1215:                for (j = 0; j < SIZE_NUM; j++) {
        !          1216:                        print_message(names[D_EDE3_DES], c[D_EDE3_DES][j], lengths[j]);
        !          1217:                        Time_F(START);
        !          1218:                        for (count = 0, run = 1; COND(c[D_EDE3_DES][j]); count++)
        !          1219:                                DES_ede3_cbc_encrypt(buf, buf, lengths[j],
        !          1220:                                    &sch, &sch2, &sch3,
        !          1221:                                    &DES_iv, DES_ENCRYPT);
        !          1222:                        d = Time_F(STOP);
        !          1223:                        print_result(D_EDE3_DES, j, count, d);
        !          1224:                }
        !          1225:        }
        !          1226: #endif
        !          1227: #ifndef OPENSSL_NO_AES
        !          1228:        if (doit[D_CBC_128_AES]) {
        !          1229:                for (j = 0; j < SIZE_NUM; j++) {
        !          1230:                        print_message(names[D_CBC_128_AES], c[D_CBC_128_AES][j], lengths[j]);
        !          1231:                        Time_F(START);
        !          1232:                        for (count = 0, run = 1; COND(c[D_CBC_128_AES][j]); count++)
        !          1233:                                AES_cbc_encrypt(buf, buf,
        !          1234:                                    (unsigned long) lengths[j], &aes_ks1,
        !          1235:                                    iv, AES_ENCRYPT);
        !          1236:                        d = Time_F(STOP);
        !          1237:                        print_result(D_CBC_128_AES, j, count, d);
        !          1238:                }
        !          1239:        }
        !          1240:        if (doit[D_CBC_192_AES]) {
        !          1241:                for (j = 0; j < SIZE_NUM; j++) {
        !          1242:                        print_message(names[D_CBC_192_AES], c[D_CBC_192_AES][j], lengths[j]);
        !          1243:                        Time_F(START);
        !          1244:                        for (count = 0, run = 1; COND(c[D_CBC_192_AES][j]); count++)
        !          1245:                                AES_cbc_encrypt(buf, buf,
        !          1246:                                    (unsigned long) lengths[j], &aes_ks2,
        !          1247:                                    iv, AES_ENCRYPT);
        !          1248:                        d = Time_F(STOP);
        !          1249:                        print_result(D_CBC_192_AES, j, count, d);
        !          1250:                }
        !          1251:        }
        !          1252:        if (doit[D_CBC_256_AES]) {
        !          1253:                for (j = 0; j < SIZE_NUM; j++) {
        !          1254:                        print_message(names[D_CBC_256_AES], c[D_CBC_256_AES][j], lengths[j]);
        !          1255:                        Time_F(START);
        !          1256:                        for (count = 0, run = 1; COND(c[D_CBC_256_AES][j]); count++)
        !          1257:                                AES_cbc_encrypt(buf, buf,
        !          1258:                                    (unsigned long) lengths[j], &aes_ks3,
        !          1259:                                    iv, AES_ENCRYPT);
        !          1260:                        d = Time_F(STOP);
        !          1261:                        print_result(D_CBC_256_AES, j, count, d);
        !          1262:                }
        !          1263:        }
        !          1264:        if (doit[D_IGE_128_AES]) {
        !          1265:                for (j = 0; j < SIZE_NUM; j++) {
        !          1266:                        print_message(names[D_IGE_128_AES], c[D_IGE_128_AES][j], lengths[j]);
        !          1267:                        Time_F(START);
        !          1268:                        for (count = 0, run = 1; COND(c[D_IGE_128_AES][j]); count++)
        !          1269:                                AES_ige_encrypt(buf, buf2,
        !          1270:                                    (unsigned long) lengths[j], &aes_ks1,
        !          1271:                                    iv, AES_ENCRYPT);
        !          1272:                        d = Time_F(STOP);
        !          1273:                        print_result(D_IGE_128_AES, j, count, d);
        !          1274:                }
        !          1275:        }
        !          1276:        if (doit[D_IGE_192_AES]) {
        !          1277:                for (j = 0; j < SIZE_NUM; j++) {
        !          1278:                        print_message(names[D_IGE_192_AES], c[D_IGE_192_AES][j], lengths[j]);
        !          1279:                        Time_F(START);
        !          1280:                        for (count = 0, run = 1; COND(c[D_IGE_192_AES][j]); count++)
        !          1281:                                AES_ige_encrypt(buf, buf2,
        !          1282:                                    (unsigned long) lengths[j], &aes_ks2,
        !          1283:                                    iv, AES_ENCRYPT);
        !          1284:                        d = Time_F(STOP);
        !          1285:                        print_result(D_IGE_192_AES, j, count, d);
        !          1286:                }
        !          1287:        }
        !          1288:        if (doit[D_IGE_256_AES]) {
        !          1289:                for (j = 0; j < SIZE_NUM; j++) {
        !          1290:                        print_message(names[D_IGE_256_AES], c[D_IGE_256_AES][j], lengths[j]);
        !          1291:                        Time_F(START);
        !          1292:                        for (count = 0, run = 1; COND(c[D_IGE_256_AES][j]); count++)
        !          1293:                                AES_ige_encrypt(buf, buf2,
        !          1294:                                    (unsigned long) lengths[j], &aes_ks3,
        !          1295:                                    iv, AES_ENCRYPT);
        !          1296:                        d = Time_F(STOP);
        !          1297:                        print_result(D_IGE_256_AES, j, count, d);
        !          1298:                }
        !          1299:        }
        !          1300:        if (doit[D_GHASH]) {
        !          1301:                GCM128_CONTEXT *ctx = CRYPTO_gcm128_new(&aes_ks1, (block128_f) AES_encrypt);
        !          1302:                CRYPTO_gcm128_setiv(ctx, (unsigned char *) "0123456789ab", 12);
        !          1303:
        !          1304:                for (j = 0; j < SIZE_NUM; j++) {
        !          1305:                        print_message(names[D_GHASH], c[D_GHASH][j], lengths[j]);
        !          1306:                        Time_F(START);
        !          1307:                        for (count = 0, run = 1; COND(c[D_GHASH][j]); count++)
        !          1308:                                CRYPTO_gcm128_aad(ctx, buf, lengths[j]);
        !          1309:                        d = Time_F(STOP);
        !          1310:                        print_result(D_GHASH, j, count, d);
        !          1311:                }
        !          1312:                CRYPTO_gcm128_release(ctx);
        !          1313:        }
        !          1314: #endif
        !          1315: #ifndef OPENSSL_NO_CAMELLIA
        !          1316:        if (doit[D_CBC_128_CML]) {
        !          1317:                for (j = 0; j < SIZE_NUM; j++) {
        !          1318:                        print_message(names[D_CBC_128_CML], c[D_CBC_128_CML][j], lengths[j]);
        !          1319:                        Time_F(START);
        !          1320:                        for (count = 0, run = 1; COND(c[D_CBC_128_CML][j]); count++)
        !          1321:                                Camellia_cbc_encrypt(buf, buf,
        !          1322:                                    (unsigned long) lengths[j], &camellia_ks1,
        !          1323:                                    iv, CAMELLIA_ENCRYPT);
        !          1324:                        d = Time_F(STOP);
        !          1325:                        print_result(D_CBC_128_CML, j, count, d);
        !          1326:                }
        !          1327:        }
        !          1328:        if (doit[D_CBC_192_CML]) {
        !          1329:                for (j = 0; j < SIZE_NUM; j++) {
        !          1330:                        print_message(names[D_CBC_192_CML], c[D_CBC_192_CML][j], lengths[j]);
        !          1331:                        Time_F(START);
        !          1332:                        for (count = 0, run = 1; COND(c[D_CBC_192_CML][j]); count++)
        !          1333:                                Camellia_cbc_encrypt(buf, buf,
        !          1334:                                    (unsigned long) lengths[j], &camellia_ks2,
        !          1335:                                    iv, CAMELLIA_ENCRYPT);
        !          1336:                        d = Time_F(STOP);
        !          1337:                        print_result(D_CBC_192_CML, j, count, d);
        !          1338:                }
        !          1339:        }
        !          1340:        if (doit[D_CBC_256_CML]) {
        !          1341:                for (j = 0; j < SIZE_NUM; j++) {
        !          1342:                        print_message(names[D_CBC_256_CML], c[D_CBC_256_CML][j], lengths[j]);
        !          1343:                        Time_F(START);
        !          1344:                        for (count = 0, run = 1; COND(c[D_CBC_256_CML][j]); count++)
        !          1345:                                Camellia_cbc_encrypt(buf, buf,
        !          1346:                                    (unsigned long) lengths[j], &camellia_ks3,
        !          1347:                                    iv, CAMELLIA_ENCRYPT);
        !          1348:                        d = Time_F(STOP);
        !          1349:                        print_result(D_CBC_256_CML, j, count, d);
        !          1350:                }
        !          1351:        }
        !          1352: #endif
        !          1353: #ifndef OPENSSL_NO_IDEA
        !          1354:        if (doit[D_CBC_IDEA]) {
        !          1355:                for (j = 0; j < SIZE_NUM; j++) {
        !          1356:                        print_message(names[D_CBC_IDEA], c[D_CBC_IDEA][j], lengths[j]);
        !          1357:                        Time_F(START);
        !          1358:                        for (count = 0, run = 1; COND(c[D_CBC_IDEA][j]); count++)
        !          1359:                                idea_cbc_encrypt(buf, buf,
        !          1360:                                    (unsigned long) lengths[j], &idea_ks,
        !          1361:                                    iv, IDEA_ENCRYPT);
        !          1362:                        d = Time_F(STOP);
        !          1363:                        print_result(D_CBC_IDEA, j, count, d);
        !          1364:                }
        !          1365:        }
        !          1366: #endif
        !          1367: #ifndef OPENSSL_NO_RC2
        !          1368:        if (doit[D_CBC_RC2]) {
        !          1369:                for (j = 0; j < SIZE_NUM; j++) {
        !          1370:                        print_message(names[D_CBC_RC2], c[D_CBC_RC2][j], lengths[j]);
        !          1371:                        Time_F(START);
        !          1372:                        for (count = 0, run = 1; COND(c[D_CBC_RC2][j]); count++)
        !          1373:                                RC2_cbc_encrypt(buf, buf,
        !          1374:                                    (unsigned long) lengths[j], &rc2_ks,
        !          1375:                                    iv, RC2_ENCRYPT);
        !          1376:                        d = Time_F(STOP);
        !          1377:                        print_result(D_CBC_RC2, j, count, d);
        !          1378:                }
        !          1379:        }
        !          1380: #endif
        !          1381: #ifndef OPENSSL_NO_RC5
        !          1382:        if (doit[D_CBC_RC5]) {
        !          1383:                for (j = 0; j < SIZE_NUM; j++) {
        !          1384:                        print_message(names[D_CBC_RC5], c[D_CBC_RC5][j], lengths[j]);
        !          1385:                        Time_F(START);
        !          1386:                        for (count = 0, run = 1; COND(c[D_CBC_RC5][j]); count++)
        !          1387:                                RC5_32_cbc_encrypt(buf, buf,
        !          1388:                                    (unsigned long) lengths[j], &rc5_ks,
        !          1389:                                    iv, RC5_ENCRYPT);
        !          1390:                        d = Time_F(STOP);
        !          1391:                        print_result(D_CBC_RC5, j, count, d);
        !          1392:                }
        !          1393:        }
        !          1394: #endif
        !          1395: #ifndef OPENSSL_NO_BF
        !          1396:        if (doit[D_CBC_BF]) {
        !          1397:                for (j = 0; j < SIZE_NUM; j++) {
        !          1398:                        print_message(names[D_CBC_BF], c[D_CBC_BF][j], lengths[j]);
        !          1399:                        Time_F(START);
        !          1400:                        for (count = 0, run = 1; COND(c[D_CBC_BF][j]); count++)
        !          1401:                                BF_cbc_encrypt(buf, buf,
        !          1402:                                    (unsigned long) lengths[j], &bf_ks,
        !          1403:                                    iv, BF_ENCRYPT);
        !          1404:                        d = Time_F(STOP);
        !          1405:                        print_result(D_CBC_BF, j, count, d);
        !          1406:                }
        !          1407:        }
        !          1408: #endif
        !          1409: #ifndef OPENSSL_NO_CAST
        !          1410:        if (doit[D_CBC_CAST]) {
        !          1411:                for (j = 0; j < SIZE_NUM; j++) {
        !          1412:                        print_message(names[D_CBC_CAST], c[D_CBC_CAST][j], lengths[j]);
        !          1413:                        Time_F(START);
        !          1414:                        for (count = 0, run = 1; COND(c[D_CBC_CAST][j]); count++)
        !          1415:                                CAST_cbc_encrypt(buf, buf,
        !          1416:                                    (unsigned long) lengths[j], &cast_ks,
        !          1417:                                    iv, CAST_ENCRYPT);
        !          1418:                        d = Time_F(STOP);
        !          1419:                        print_result(D_CBC_CAST, j, count, d);
        !          1420:                }
        !          1421:        }
        !          1422: #endif
        !          1423:
        !          1424:        if (doit[D_EVP]) {
        !          1425:                for (j = 0; j < SIZE_NUM; j++) {
        !          1426:                        if (evp_cipher) {
        !          1427:                                EVP_CIPHER_CTX ctx;
        !          1428:                                int outl;
        !          1429:
        !          1430:                                names[D_EVP] = OBJ_nid2ln(evp_cipher->nid);
        !          1431:                                /*
        !          1432:                                 * -O3 -fschedule-insns messes up an
        !          1433:                                 * optimization here!  names[D_EVP] somehow
        !          1434:                                 * becomes NULL
        !          1435:                                 */
        !          1436:                                print_message(names[D_EVP], save_count,
        !          1437:                                    lengths[j]);
        !          1438:
        !          1439:                                EVP_CIPHER_CTX_init(&ctx);
        !          1440:                                if (decrypt)
        !          1441:                                        EVP_DecryptInit_ex(&ctx, evp_cipher, NULL, key16, iv);
        !          1442:                                else
        !          1443:                                        EVP_EncryptInit_ex(&ctx, evp_cipher, NULL, key16, iv);
        !          1444:                                EVP_CIPHER_CTX_set_padding(&ctx, 0);
        !          1445:
        !          1446:                                Time_F(START);
        !          1447:                                if (decrypt)
        !          1448:                                        for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++)
        !          1449:                                                EVP_DecryptUpdate(&ctx, buf, &outl, buf, lengths[j]);
        !          1450:                                else
        !          1451:                                        for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++)
        !          1452:                                                EVP_EncryptUpdate(&ctx, buf, &outl, buf, lengths[j]);
        !          1453:                                if (decrypt)
        !          1454:                                        EVP_DecryptFinal_ex(&ctx, buf, &outl);
        !          1455:                                else
        !          1456:                                        EVP_EncryptFinal_ex(&ctx, buf, &outl);
        !          1457:                                d = Time_F(STOP);
        !          1458:                                EVP_CIPHER_CTX_cleanup(&ctx);
        !          1459:                        }
        !          1460:                        if (evp_md) {
        !          1461:                                names[D_EVP] = OBJ_nid2ln(evp_md->type);
        !          1462:                                print_message(names[D_EVP], save_count,
        !          1463:                                    lengths[j]);
        !          1464:
        !          1465:                                Time_F(START);
        !          1466:                                for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++)
        !          1467:                                        EVP_Digest(buf, lengths[j], &(md[0]), NULL, evp_md, NULL);
        !          1468:
        !          1469:                                d = Time_F(STOP);
        !          1470:                        }
        !          1471:                        print_result(D_EVP, j, count, d);
        !          1472:                }
        !          1473:        }
        !          1474:        RAND_pseudo_bytes(buf, 36);
        !          1475:        for (j = 0; j < RSA_NUM; j++) {
        !          1476:                int ret;
        !          1477:                if (!rsa_doit[j])
        !          1478:                        continue;
        !          1479:                ret = RSA_sign(NID_md5_sha1, buf, 36, buf2, &rsa_num, rsa_key[j]);
        !          1480:                if (ret == 0) {
        !          1481:                        BIO_printf(bio_err, "RSA sign failure.  No RSA sign will be done.\n");
        !          1482:                        ERR_print_errors(bio_err);
        !          1483:                        rsa_count = 1;
        !          1484:                } else {
        !          1485:                        pkey_print_message("private", "rsa",
        !          1486:                            rsa_c[j][0], rsa_bits[j],
        !          1487:                            RSA_SECONDS);
        !          1488: /*                     RSA_blinding_on(rsa_key[j],NULL); */
        !          1489:                        Time_F(START);
        !          1490:                        for (count = 0, run = 1; COND(rsa_c[j][0]); count++) {
        !          1491:                                ret = RSA_sign(NID_md5_sha1, buf, 36, buf2,
        !          1492:                                    &rsa_num, rsa_key[j]);
        !          1493:                                if (ret == 0) {
        !          1494:                                        BIO_printf(bio_err,
        !          1495:                                            "RSA sign failure\n");
        !          1496:                                        ERR_print_errors(bio_err);
        !          1497:                                        count = 1;
        !          1498:                                        break;
        !          1499:                                }
        !          1500:                        }
        !          1501:                        d = Time_F(STOP);
        !          1502:                        BIO_printf(bio_err, mr ? "+R1:%ld:%d:%.2f\n"
        !          1503:                            : "%ld %d bit private RSA's in %.2fs\n",
        !          1504:                            count, rsa_bits[j], d);
        !          1505:                        rsa_results[j][0] = d / (double) count;
        !          1506:                        rsa_count = count;
        !          1507:                }
        !          1508:
        !          1509: #if 1
        !          1510:                ret = RSA_verify(NID_md5_sha1, buf, 36, buf2, rsa_num, rsa_key[j]);
        !          1511:                if (ret <= 0) {
        !          1512:                        BIO_printf(bio_err, "RSA verify failure.  No RSA verify will be done.\n");
        !          1513:                        ERR_print_errors(bio_err);
        !          1514:                        rsa_doit[j] = 0;
        !          1515:                } else {
        !          1516:                        pkey_print_message("public", "rsa",
        !          1517:                            rsa_c[j][1], rsa_bits[j],
        !          1518:                            RSA_SECONDS);
        !          1519:                        Time_F(START);
        !          1520:                        for (count = 0, run = 1; COND(rsa_c[j][1]); count++) {
        !          1521:                                ret = RSA_verify(NID_md5_sha1, buf, 36, buf2,
        !          1522:                                    rsa_num, rsa_key[j]);
        !          1523:                                if (ret <= 0) {
        !          1524:                                        BIO_printf(bio_err,
        !          1525:                                            "RSA verify failure\n");
        !          1526:                                        ERR_print_errors(bio_err);
        !          1527:                                        count = 1;
        !          1528:                                        break;
        !          1529:                                }
        !          1530:                        }
        !          1531:                        d = Time_F(STOP);
        !          1532:                        BIO_printf(bio_err, mr ? "+R2:%ld:%d:%.2f\n"
        !          1533:                            : "%ld %d bit public RSA's in %.2fs\n",
        !          1534:                            count, rsa_bits[j], d);
        !          1535:                        rsa_results[j][1] = d / (double) count;
        !          1536:                }
        !          1537: #endif
        !          1538:
        !          1539:                if (rsa_count <= 1) {
        !          1540:                        /* if longer than 10s, don't do any more */
        !          1541:                        for (j++; j < RSA_NUM; j++)
        !          1542:                                rsa_doit[j] = 0;
        !          1543:                }
        !          1544:        }
        !          1545:
        !          1546:        RAND_pseudo_bytes(buf, 20);
        !          1547:        for (j = 0; j < DSA_NUM; j++) {
        !          1548:                unsigned int kk;
        !          1549:                int ret;
        !          1550:
        !          1551:                if (!dsa_doit[j])
        !          1552:                        continue;
        !          1553: /*             DSA_generate_key(dsa_key[j]); */
        !          1554: /*             DSA_sign_setup(dsa_key[j],NULL); */
        !          1555:                ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2,
        !          1556:                    &kk, dsa_key[j]);
        !          1557:                if (ret == 0) {
        !          1558:                        BIO_printf(bio_err, "DSA sign failure.  No DSA sign will be done.\n");
        !          1559:                        ERR_print_errors(bio_err);
        !          1560:                        rsa_count = 1;
        !          1561:                } else {
        !          1562:                        pkey_print_message("sign", "dsa",
        !          1563:                            dsa_c[j][0], dsa_bits[j],
        !          1564:                            DSA_SECONDS);
        !          1565:                        Time_F(START);
        !          1566:                        for (count = 0, run = 1; COND(dsa_c[j][0]); count++) {
        !          1567:                                ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2,
        !          1568:                                    &kk, dsa_key[j]);
        !          1569:                                if (ret == 0) {
        !          1570:                                        BIO_printf(bio_err,
        !          1571:                                            "DSA sign failure\n");
        !          1572:                                        ERR_print_errors(bio_err);
        !          1573:                                        count = 1;
        !          1574:                                        break;
        !          1575:                                }
        !          1576:                        }
        !          1577:                        d = Time_F(STOP);
        !          1578:                        BIO_printf(bio_err, mr ? "+R3:%ld:%d:%.2f\n"
        !          1579:                            : "%ld %d bit DSA signs in %.2fs\n",
        !          1580:                            count, dsa_bits[j], d);
        !          1581:                        dsa_results[j][0] = d / (double) count;
        !          1582:                        rsa_count = count;
        !          1583:                }
        !          1584:
        !          1585:                ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2,
        !          1586:                    kk, dsa_key[j]);
        !          1587:                if (ret <= 0) {
        !          1588:                        BIO_printf(bio_err, "DSA verify failure.  No DSA verify will be done.\n");
        !          1589:                        ERR_print_errors(bio_err);
        !          1590:                        dsa_doit[j] = 0;
        !          1591:                } else {
        !          1592:                        pkey_print_message("verify", "dsa",
        !          1593:                            dsa_c[j][1], dsa_bits[j],
        !          1594:                            DSA_SECONDS);
        !          1595:                        Time_F(START);
        !          1596:                        for (count = 0, run = 1; COND(dsa_c[j][1]); count++) {
        !          1597:                                ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2,
        !          1598:                                    kk, dsa_key[j]);
        !          1599:                                if (ret <= 0) {
        !          1600:                                        BIO_printf(bio_err,
        !          1601:                                            "DSA verify failure\n");
        !          1602:                                        ERR_print_errors(bio_err);
        !          1603:                                        count = 1;
        !          1604:                                        break;
        !          1605:                                }
        !          1606:                        }
        !          1607:                        d = Time_F(STOP);
        !          1608:                        BIO_printf(bio_err, mr ? "+R4:%ld:%d:%.2f\n"
        !          1609:                            : "%ld %d bit DSA verify in %.2fs\n",
        !          1610:                            count, dsa_bits[j], d);
        !          1611:                        dsa_results[j][1] = d / (double) count;
        !          1612:                }
        !          1613:
        !          1614:                if (rsa_count <= 1) {
        !          1615:                        /* if longer than 10s, don't do any more */
        !          1616:                        for (j++; j < DSA_NUM; j++)
        !          1617:                                dsa_doit[j] = 0;
        !          1618:                }
        !          1619:        }
        !          1620:
        !          1621:        for (j = 0; j < EC_NUM; j++) {
        !          1622:                int ret;
        !          1623:
        !          1624:                if (!ecdsa_doit[j])
        !          1625:                        continue;       /* Ignore Curve */
        !          1626:                ecdsa[j] = EC_KEY_new_by_curve_name(test_curves[j]);
        !          1627:                if (ecdsa[j] == NULL) {
        !          1628:                        BIO_printf(bio_err, "ECDSA failure.\n");
        !          1629:                        ERR_print_errors(bio_err);
        !          1630:                        rsa_count = 1;
        !          1631:                } else {
        !          1632: #if 1
        !          1633:                        EC_KEY_precompute_mult(ecdsa[j], NULL);
        !          1634: #endif
        !          1635:                        /* Perform ECDSA signature test */
        !          1636:                        EC_KEY_generate_key(ecdsa[j]);
        !          1637:                        ret = ECDSA_sign(0, buf, 20, ecdsasig,
        !          1638:                            &ecdsasiglen, ecdsa[j]);
        !          1639:                        if (ret == 0) {
        !          1640:                                BIO_printf(bio_err, "ECDSA sign failure.  No ECDSA sign will be done.\n");
        !          1641:                                ERR_print_errors(bio_err);
        !          1642:                                rsa_count = 1;
        !          1643:                        } else {
        !          1644:                                pkey_print_message("sign", "ecdsa",
        !          1645:                                    ecdsa_c[j][0],
        !          1646:                                    test_curves_bits[j],
        !          1647:                                    ECDSA_SECONDS);
        !          1648:
        !          1649:                                Time_F(START);
        !          1650:                                for (count = 0, run = 1; COND(ecdsa_c[j][0]);
        !          1651:                                    count++) {
        !          1652:                                        ret = ECDSA_sign(0, buf, 20,
        !          1653:                                            ecdsasig, &ecdsasiglen,
        !          1654:                                            ecdsa[j]);
        !          1655:                                        if (ret == 0) {
        !          1656:                                                BIO_printf(bio_err, "ECDSA sign failure\n");
        !          1657:                                                ERR_print_errors(bio_err);
        !          1658:                                                count = 1;
        !          1659:                                                break;
        !          1660:                                        }
        !          1661:                                }
        !          1662:                                d = Time_F(STOP);
        !          1663:
        !          1664:                                BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" :
        !          1665:                                    "%ld %d bit ECDSA signs in %.2fs \n",
        !          1666:                                    count, test_curves_bits[j], d);
        !          1667:                                ecdsa_results[j][0] = d / (double) count;
        !          1668:                                rsa_count = count;
        !          1669:                        }
        !          1670:
        !          1671:                        /* Perform ECDSA verification test */
        !          1672:                        ret = ECDSA_verify(0, buf, 20, ecdsasig,
        !          1673:                            ecdsasiglen, ecdsa[j]);
        !          1674:                        if (ret != 1) {
        !          1675:                                BIO_printf(bio_err, "ECDSA verify failure.  No ECDSA verify will be done.\n");
        !          1676:                                ERR_print_errors(bio_err);
        !          1677:                                ecdsa_doit[j] = 0;
        !          1678:                        } else {
        !          1679:                                pkey_print_message("verify", "ecdsa",
        !          1680:                                    ecdsa_c[j][1],
        !          1681:                                    test_curves_bits[j],
        !          1682:                                    ECDSA_SECONDS);
        !          1683:                                Time_F(START);
        !          1684:                                for (count = 0, run = 1; COND(ecdsa_c[j][1]); count++) {
        !          1685:                                        ret = ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]);
        !          1686:                                        if (ret != 1) {
        !          1687:                                                BIO_printf(bio_err, "ECDSA verify failure\n");
        !          1688:                                                ERR_print_errors(bio_err);
        !          1689:                                                count = 1;
        !          1690:                                                break;
        !          1691:                                        }
        !          1692:                                }
        !          1693:                                d = Time_F(STOP);
        !          1694:                                BIO_printf(bio_err, mr ? "+R6:%ld:%d:%.2f\n"
        !          1695:                                    : "%ld %d bit ECDSA verify in %.2fs\n",
        !          1696:                                    count, test_curves_bits[j], d);
        !          1697:                                ecdsa_results[j][1] = d / (double) count;
        !          1698:                        }
        !          1699:
        !          1700:                        if (rsa_count <= 1) {
        !          1701:                                /* if longer than 10s, don't do any more */
        !          1702:                                for (j++; j < EC_NUM; j++)
        !          1703:                                        ecdsa_doit[j] = 0;
        !          1704:                        }
        !          1705:                }
        !          1706:        }
        !          1707:
        !          1708:        for (j = 0; j < EC_NUM; j++) {
        !          1709:                if (!ecdh_doit[j])
        !          1710:                        continue;
        !          1711:                ecdh_a[j] = EC_KEY_new_by_curve_name(test_curves[j]);
        !          1712:                ecdh_b[j] = EC_KEY_new_by_curve_name(test_curves[j]);
        !          1713:                if ((ecdh_a[j] == NULL) || (ecdh_b[j] == NULL)) {
        !          1714:                        BIO_printf(bio_err, "ECDH failure.\n");
        !          1715:                        ERR_print_errors(bio_err);
        !          1716:                        rsa_count = 1;
        !          1717:                } else {
        !          1718:                        /* generate two ECDH key pairs */
        !          1719:                        if (!EC_KEY_generate_key(ecdh_a[j]) ||
        !          1720:                            !EC_KEY_generate_key(ecdh_b[j])) {
        !          1721:                                BIO_printf(bio_err, "ECDH key generation failure.\n");
        !          1722:                                ERR_print_errors(bio_err);
        !          1723:                                rsa_count = 1;
        !          1724:                        } else {
        !          1725:                                /*
        !          1726:                                 * If field size is not more than 24 octets,
        !          1727:                                 * then use SHA-1 hash of result; otherwise,
        !          1728:                                 * use result (see section 4.8 of
        !          1729:                                 * draft-ietf-tls-ecc-03.txt).
        !          1730:                                 */
        !          1731:                                int field_size, outlen;
        !          1732:                                void *(*kdf) (const void *in, size_t inlen, void *out, size_t * xoutlen);
        !          1733:                                field_size = EC_GROUP_get_degree(EC_KEY_get0_group(ecdh_a[j]));
        !          1734:                                if (field_size <= 24 * 8) {
        !          1735:                                        outlen = KDF1_SHA1_len;
        !          1736:                                        kdf = KDF1_SHA1;
        !          1737:                                } else {
        !          1738:                                        outlen = (field_size + 7) / 8;
        !          1739:                                        kdf = NULL;
        !          1740:                                }
        !          1741:                                secret_size_a = ECDH_compute_key(secret_a, outlen,
        !          1742:                                    EC_KEY_get0_public_key(ecdh_b[j]),
        !          1743:                                    ecdh_a[j], kdf);
        !          1744:                                secret_size_b = ECDH_compute_key(secret_b, outlen,
        !          1745:                                    EC_KEY_get0_public_key(ecdh_a[j]),
        !          1746:                                    ecdh_b[j], kdf);
        !          1747:                                if (secret_size_a != secret_size_b)
        !          1748:                                        ecdh_checks = 0;
        !          1749:                                else
        !          1750:                                        ecdh_checks = 1;
        !          1751:
        !          1752:                                for (secret_idx = 0;
        !          1753:                                    (secret_idx < secret_size_a)
        !          1754:                                    && (ecdh_checks == 1);
        !          1755:                                    secret_idx++) {
        !          1756:                                        if (secret_a[secret_idx] != secret_b[secret_idx])
        !          1757:                                                ecdh_checks = 0;
        !          1758:                                }
        !          1759:
        !          1760:                                if (ecdh_checks == 0) {
        !          1761:                                        BIO_printf(bio_err, "ECDH computations don't match.\n");
        !          1762:                                        ERR_print_errors(bio_err);
        !          1763:                                        rsa_count = 1;
        !          1764:                                }
        !          1765:                                pkey_print_message("", "ecdh",
        !          1766:                                    ecdh_c[j][0],
        !          1767:                                    test_curves_bits[j],
        !          1768:                                    ECDH_SECONDS);
        !          1769:                                Time_F(START);
        !          1770:                                for (count = 0, run = 1; COND(ecdh_c[j][0]); count++) {
        !          1771:                                        ECDH_compute_key(secret_a, outlen,
        !          1772:                                            EC_KEY_get0_public_key(ecdh_b[j]),
        !          1773:                                            ecdh_a[j], kdf);
        !          1774:                                }
        !          1775:                                d = Time_F(STOP);
        !          1776:                                BIO_printf(bio_err, mr ? "+R7:%ld:%d:%.2f\n" : "%ld %d-bit ECDH ops in %.2fs\n",
        !          1777:                                    count, test_curves_bits[j], d);
        !          1778:                                ecdh_results[j][0] = d / (double) count;
        !          1779:                                rsa_count = count;
        !          1780:                        }
        !          1781:                }
        !          1782:
        !          1783:
        !          1784:                if (rsa_count <= 1) {
        !          1785:                        /* if longer than 10s, don't do any more */
        !          1786:                        for (j++; j < EC_NUM; j++)
        !          1787:                                ecdh_doit[j] = 0;
        !          1788:                }
        !          1789:        }
        !          1790: show_res:
        !          1791:        if (!mr) {
        !          1792:                fprintf(stdout, "%s\n", SSLeay_version(SSLEAY_VERSION));
        !          1793:                fprintf(stdout, "%s\n", SSLeay_version(SSLEAY_BUILT_ON));
        !          1794:                printf("options:");
        !          1795:                printf("%s ", BN_options());
        !          1796: #ifndef OPENSSL_NO_RC4
        !          1797:                printf("%s ", RC4_options());
        !          1798: #endif
        !          1799: #ifndef OPENSSL_NO_DES
        !          1800:                printf("%s ", DES_options());
        !          1801: #endif
        !          1802: #ifndef OPENSSL_NO_AES
        !          1803:                printf("%s ", AES_options());
        !          1804: #endif
        !          1805: #ifndef OPENSSL_NO_IDEA
        !          1806:                printf("%s ", idea_options());
        !          1807: #endif
        !          1808: #ifndef OPENSSL_NO_BF
        !          1809:                printf("%s ", BF_options());
        !          1810: #endif
        !          1811:                fprintf(stdout, "\n%s\n", SSLeay_version(SSLEAY_CFLAGS));
        !          1812:        }
        !          1813:        if (pr_header) {
        !          1814:                if (mr)
        !          1815:                        fprintf(stdout, "+H");
        !          1816:                else {
        !          1817:                        fprintf(stdout, "The 'numbers' are in 1000s of bytes per second processed.\n");
        !          1818:                        fprintf(stdout, "type        ");
        !          1819:                }
        !          1820:                for (j = 0; j < SIZE_NUM; j++)
        !          1821:                        fprintf(stdout, mr ? ":%d" : "%7d bytes", lengths[j]);
        !          1822:                fprintf(stdout, "\n");
        !          1823:        }
        !          1824:        for (k = 0; k < ALGOR_NUM; k++) {
        !          1825:                if (!doit[k])
        !          1826:                        continue;
        !          1827:                if (mr)
        !          1828:                        fprintf(stdout, "+F:%d:%s", k, names[k]);
        !          1829:                else
        !          1830:                        fprintf(stdout, "%-13s", names[k]);
        !          1831:                for (j = 0; j < SIZE_NUM; j++) {
        !          1832:                        if (results[k][j] > 10000 && !mr)
        !          1833:                                fprintf(stdout, " %11.2fk", results[k][j] / 1e3);
        !          1834:                        else
        !          1835:                                fprintf(stdout, mr ? ":%.2f" : " %11.2f ", results[k][j]);
        !          1836:                }
        !          1837:                fprintf(stdout, "\n");
        !          1838:        }
        !          1839:        j = 1;
        !          1840:        for (k = 0; k < RSA_NUM; k++) {
        !          1841:                if (!rsa_doit[k])
        !          1842:                        continue;
        !          1843:                if (j && !mr) {
        !          1844:                        printf("%18ssign    verify    sign/s verify/s\n", " ");
        !          1845:                        j = 0;
        !          1846:                }
        !          1847:                if (mr)
        !          1848:                        fprintf(stdout, "+F2:%u:%u:%f:%f\n",
        !          1849:                            k, rsa_bits[k], rsa_results[k][0],
        !          1850:                            rsa_results[k][1]);
        !          1851:                else
        !          1852:                        fprintf(stdout, "rsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
        !          1853:                            rsa_bits[k], rsa_results[k][0], rsa_results[k][1],
        !          1854:                            1.0 / rsa_results[k][0], 1.0 / rsa_results[k][1]);
        !          1855:        }
        !          1856:        j = 1;
        !          1857:        for (k = 0; k < DSA_NUM; k++) {
        !          1858:                if (!dsa_doit[k])
        !          1859:                        continue;
        !          1860:                if (j && !mr) {
        !          1861:                        printf("%18ssign    verify    sign/s verify/s\n", " ");
        !          1862:                        j = 0;
        !          1863:                }
        !          1864:                if (mr)
        !          1865:                        fprintf(stdout, "+F3:%u:%u:%f:%f\n",
        !          1866:                            k, dsa_bits[k], dsa_results[k][0], dsa_results[k][1]);
        !          1867:                else
        !          1868:                        fprintf(stdout, "dsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
        !          1869:                            dsa_bits[k], dsa_results[k][0], dsa_results[k][1],
        !          1870:                            1.0 / dsa_results[k][0], 1.0 / dsa_results[k][1]);
        !          1871:        }
        !          1872:        j = 1;
        !          1873:        for (k = 0; k < EC_NUM; k++) {
        !          1874:                if (!ecdsa_doit[k])
        !          1875:                        continue;
        !          1876:                if (j && !mr) {
        !          1877:                        printf("%30ssign    verify    sign/s verify/s\n", " ");
        !          1878:                        j = 0;
        !          1879:                }
        !          1880:                if (mr)
        !          1881:                        fprintf(stdout, "+F4:%u:%u:%f:%f\n",
        !          1882:                            k, test_curves_bits[k],
        !          1883:                            ecdsa_results[k][0], ecdsa_results[k][1]);
        !          1884:                else
        !          1885:                        fprintf(stdout,
        !          1886:                            "%4u bit ecdsa (%s) %8.4fs %8.4fs %8.1f %8.1f\n",
        !          1887:                            test_curves_bits[k],
        !          1888:                            test_curves_names[k],
        !          1889:                            ecdsa_results[k][0], ecdsa_results[k][1],
        !          1890:                            1.0 / ecdsa_results[k][0], 1.0 / ecdsa_results[k][1]);
        !          1891:        }
        !          1892:
        !          1893:
        !          1894:        j = 1;
        !          1895:        for (k = 0; k < EC_NUM; k++) {
        !          1896:                if (!ecdh_doit[k])
        !          1897:                        continue;
        !          1898:                if (j && !mr) {
        !          1899:                        printf("%30sop      op/s\n", " ");
        !          1900:                        j = 0;
        !          1901:                }
        !          1902:                if (mr)
        !          1903:                        fprintf(stdout, "+F5:%u:%u:%f:%f\n",
        !          1904:                            k, test_curves_bits[k],
        !          1905:                            ecdh_results[k][0], 1.0 / ecdh_results[k][0]);
        !          1906:
        !          1907:                else
        !          1908:                        fprintf(stdout, "%4u bit ecdh (%s) %8.4fs %8.1f\n",
        !          1909:                            test_curves_bits[k],
        !          1910:                            test_curves_names[k],
        !          1911:                            ecdh_results[k][0], 1.0 / ecdh_results[k][0]);
        !          1912:        }
        !          1913:
        !          1914:        mret = 0;
        !          1915:
        !          1916: end:
        !          1917:        ERR_print_errors(bio_err);
        !          1918:        free(buf);
        !          1919:        free(buf2);
        !          1920:        for (i = 0; i < RSA_NUM; i++)
        !          1921:                if (rsa_key[i] != NULL)
        !          1922:                        RSA_free(rsa_key[i]);
        !          1923:        for (i = 0; i < DSA_NUM; i++)
        !          1924:                if (dsa_key[i] != NULL)
        !          1925:                        DSA_free(dsa_key[i]);
        !          1926:
        !          1927:        for (i = 0; i < EC_NUM; i++)
        !          1928:                if (ecdsa[i] != NULL)
        !          1929:                        EC_KEY_free(ecdsa[i]);
        !          1930:        for (i = 0; i < EC_NUM; i++) {
        !          1931:                if (ecdh_a[i] != NULL)
        !          1932:                        EC_KEY_free(ecdh_a[i]);
        !          1933:                if (ecdh_b[i] != NULL)
        !          1934:                        EC_KEY_free(ecdh_b[i]);
        !          1935:        }
        !          1936:
        !          1937:
        !          1938:        return (mret);
        !          1939: }
        !          1940:
        !          1941: static void
        !          1942: print_message(const char *s, long num, int length)
        !          1943: {
        !          1944:        BIO_printf(bio_err, mr ? "+DT:%s:%d:%d\n"
        !          1945:            : "Doing %s for %ds on %d size blocks: ", s, SECONDS, length);
        !          1946:        (void) BIO_flush(bio_err);
        !          1947:        alarm(SECONDS);
        !          1948: }
        !          1949:
        !          1950: static void
        !          1951: pkey_print_message(const char *str, const char *str2, long num,
        !          1952:     int bits, int tm)
        !          1953: {
        !          1954:        BIO_printf(bio_err, mr ? "+DTP:%d:%s:%s:%d\n"
        !          1955:            : "Doing %d bit %s %s's for %ds: ", bits, str, str2, tm);
        !          1956:        (void) BIO_flush(bio_err);
        !          1957:        alarm(tm);
        !          1958: }
        !          1959:
        !          1960: static void
        !          1961: print_result(int alg, int run_no, int count, double time_used)
        !          1962: {
        !          1963:        BIO_printf(bio_err, mr ? "+R:%d:%s:%f\n"
        !          1964:            : "%d %s's in %.2fs\n", count, names[alg], time_used);
        !          1965:        results[alg][run_no] = ((double) count) / time_used * lengths[run_no];
        !          1966: }
        !          1967:
        !          1968: static char *
        !          1969: sstrsep(char **string, const char *delim)
        !          1970: {
        !          1971:        char isdelim[256];
        !          1972:        char *token = *string;
        !          1973:
        !          1974:        if (**string == 0)
        !          1975:                return NULL;
        !          1976:
        !          1977:        memset(isdelim, 0, sizeof isdelim);
        !          1978:        isdelim[0] = 1;
        !          1979:
        !          1980:        while (*delim) {
        !          1981:                isdelim[(unsigned char) (*delim)] = 1;
        !          1982:                delim++;
        !          1983:        }
        !          1984:
        !          1985:        while (!isdelim[(unsigned char) (**string)]) {
        !          1986:                (*string)++;
        !          1987:        }
        !          1988:
        !          1989:        if (**string) {
        !          1990:                **string = 0;
        !          1991:                (*string)++;
        !          1992:        }
        !          1993:        return token;
        !          1994: }
        !          1995:
        !          1996: static int
        !          1997: do_multi(int multi)
        !          1998: {
        !          1999:        int n;
        !          2000:        int fd[2];
        !          2001:        int *fds;
        !          2002:        static char sep[] = ":";
        !          2003:        const char *errstr = NULL;
        !          2004:
        !          2005:        fds = reallocarray(NULL, multi, sizeof *fds);
        !          2006:        for (n = 0; n < multi; ++n) {
        !          2007:                if (pipe(fd) == -1) {
        !          2008:                        fprintf(stderr, "pipe failure\n");
        !          2009:                        exit(1);
        !          2010:                }
        !          2011:                fflush(stdout);
        !          2012:                fflush(stderr);
        !          2013:                if (fork()) {
        !          2014:                        close(fd[1]);
        !          2015:                        fds[n] = fd[0];
        !          2016:                } else {
        !          2017:                        close(fd[0]);
        !          2018:                        close(1);
        !          2019:                        if (dup(fd[1]) == -1) {
        !          2020:                                fprintf(stderr, "dup failed\n");
        !          2021:                                exit(1);
        !          2022:                        }
        !          2023:                        close(fd[1]);
        !          2024:                        mr = 1;
        !          2025:                        usertime = 0;
        !          2026:                        free(fds);
        !          2027:                        return 0;
        !          2028:                }
        !          2029:                printf("Forked child %d\n", n);
        !          2030:        }
        !          2031:
        !          2032:        /* for now, assume the pipe is long enough to take all the output */
        !          2033:        for (n = 0; n < multi; ++n) {
        !          2034:                FILE *f;
        !          2035:                char buf[1024];
        !          2036:                char *p;
        !          2037:
        !          2038:                f = fdopen(fds[n], "r");
        !          2039:                while (fgets(buf, sizeof buf, f)) {
        !          2040:                        p = strchr(buf, '\n');
        !          2041:                        if (p)
        !          2042:                                *p = '\0';
        !          2043:                        if (buf[0] != '+') {
        !          2044:                                fprintf(stderr, "Don't understand line '%s' from child %d\n",
        !          2045:                                    buf, n);
        !          2046:                                continue;
        !          2047:                        }
        !          2048:                        printf("Got: %s from %d\n", buf, n);
        !          2049:                        if (!strncmp(buf, "+F:", 3)) {
        !          2050:                                int alg;
        !          2051:                                int j;
        !          2052:
        !          2053:                                p = buf + 3;
        !          2054:                                alg = strtonum(sstrsep(&p, sep),
        !          2055:                                    0, ALGOR_NUM - 1, &errstr);
        !          2056:                                sstrsep(&p, sep);
        !          2057:                                for (j = 0; j < SIZE_NUM; ++j)
        !          2058:                                        results[alg][j] += atof(sstrsep(&p, sep));
        !          2059:                        } else if (!strncmp(buf, "+F2:", 4)) {
        !          2060:                                int k;
        !          2061:                                double d;
        !          2062:
        !          2063:                                p = buf + 4;
        !          2064:                                k = strtonum(sstrsep(&p, sep),
        !          2065:                                    0, ALGOR_NUM - 1, &errstr);
        !          2066:                                sstrsep(&p, sep);
        !          2067:
        !          2068:                                d = atof(sstrsep(&p, sep));
        !          2069:                                if (n)
        !          2070:                                        rsa_results[k][0] = 1 / (1 / rsa_results[k][0] + 1 / d);
        !          2071:                                else
        !          2072:                                        rsa_results[k][0] = d;
        !          2073:
        !          2074:                                d = atof(sstrsep(&p, sep));
        !          2075:                                if (n)
        !          2076:                                        rsa_results[k][1] = 1 / (1 / rsa_results[k][1] + 1 / d);
        !          2077:                                else
        !          2078:                                        rsa_results[k][1] = d;
        !          2079:                        } else if (!strncmp(buf, "+F2:", 4)) {
        !          2080:                                int k;
        !          2081:                                double d;
        !          2082:
        !          2083:                                p = buf + 4;
        !          2084:                                k = strtonum(sstrsep(&p, sep),
        !          2085:                                    0, ALGOR_NUM - 1, &errstr);
        !          2086:                                sstrsep(&p, sep);
        !          2087:
        !          2088:                                d = atof(sstrsep(&p, sep));
        !          2089:                                if (n)
        !          2090:                                        rsa_results[k][0] = 1 / (1 / rsa_results[k][0] + 1 / d);
        !          2091:                                else
        !          2092:                                        rsa_results[k][0] = d;
        !          2093:
        !          2094:                                d = atof(sstrsep(&p, sep));
        !          2095:                                if (n)
        !          2096:                                        rsa_results[k][1] = 1 / (1 / rsa_results[k][1] + 1 / d);
        !          2097:                                else
        !          2098:                                        rsa_results[k][1] = d;
        !          2099:                        }
        !          2100:                        else if (!strncmp(buf, "+F3:", 4)) {
        !          2101:                                int k;
        !          2102:                                double d;
        !          2103:
        !          2104:                                p = buf + 4;
        !          2105:                                k = strtonum(sstrsep(&p, sep),
        !          2106:                                    0, ALGOR_NUM - 1, &errstr);
        !          2107:                                sstrsep(&p, sep);
        !          2108:
        !          2109:                                d = atof(sstrsep(&p, sep));
        !          2110:                                if (n)
        !          2111:                                        dsa_results[k][0] = 1 / (1 / dsa_results[k][0] + 1 / d);
        !          2112:                                else
        !          2113:                                        dsa_results[k][0] = d;
        !          2114:
        !          2115:                                d = atof(sstrsep(&p, sep));
        !          2116:                                if (n)
        !          2117:                                        dsa_results[k][1] = 1 / (1 / dsa_results[k][1] + 1 / d);
        !          2118:                                else
        !          2119:                                        dsa_results[k][1] = d;
        !          2120:                        }
        !          2121:                        else if (!strncmp(buf, "+F4:", 4)) {
        !          2122:                                int k;
        !          2123:                                double d;
        !          2124:
        !          2125:                                p = buf + 4;
        !          2126:                                k = strtonum(sstrsep(&p, sep),
        !          2127:                                    0, ALGOR_NUM - 1, &errstr);
        !          2128:                                sstrsep(&p, sep);
        !          2129:
        !          2130:                                d = atof(sstrsep(&p, sep));
        !          2131:                                if (n)
        !          2132:                                        ecdsa_results[k][0] = 1 / (1 / ecdsa_results[k][0] + 1 / d);
        !          2133:                                else
        !          2134:                                        ecdsa_results[k][0] = d;
        !          2135:
        !          2136:                                d = atof(sstrsep(&p, sep));
        !          2137:                                if (n)
        !          2138:                                        ecdsa_results[k][1] = 1 / (1 / ecdsa_results[k][1] + 1 / d);
        !          2139:                                else
        !          2140:                                        ecdsa_results[k][1] = d;
        !          2141:                        }
        !          2142:
        !          2143:                        else if (!strncmp(buf, "+F5:", 4)) {
        !          2144:                                int k;
        !          2145:                                double d;
        !          2146:
        !          2147:                                p = buf + 4;
        !          2148:                                k = strtonum(sstrsep(&p, sep),
        !          2149:                                    0, ALGOR_NUM - 1, &errstr);
        !          2150:                                sstrsep(&p, sep);
        !          2151:
        !          2152:                                d = atof(sstrsep(&p, sep));
        !          2153:                                if (n)
        !          2154:                                        ecdh_results[k][0] = 1 / (1 / ecdh_results[k][0] + 1 / d);
        !          2155:                                else
        !          2156:                                        ecdh_results[k][0] = d;
        !          2157:
        !          2158:                        }
        !          2159:
        !          2160:                        else if (!strncmp(buf, "+H:", 3)) {
        !          2161:                        } else
        !          2162:                                fprintf(stderr, "Unknown type '%s' from child %d\n", buf, n);
        !          2163:                }
        !          2164:
        !          2165:                fclose(f);
        !          2166:        }
        !          2167:        free(fds);
        !          2168:        return 1;
        !          2169: }
        !          2170: #endif