apps/speed.c:1794: error: BUFFER_OVERRUN_L2
  Offset: [-oo, 8257] Size: 8257 by call to `DSA_sign`.
Showing all 21 steps of the trace


apps/speed.c:831:18: Call
829.               break;
830.           case OPT_MISALIGN:
831.               if (!opt_int(opt_arg(), &misalign))
                        ^
832.                   goto end;
833.               if (misalign > MISALIGN) {

apps/opt.c:359:10: Call
  357.       long l;
  358.   
  359.       if (!opt_long(value, &l))
                  ^
  360.           return 0;
  361.       *result = (int)l;

apps/opt.c:371:1: Parameter `*result`
    369.   
    370.   /* Parse a long, put it into *result; return 0 on failure, else 1. */
    371. > int opt_long(const char *value, long *result)
    372.   {
    373.       int oerrno = errno;

apps/speed.c:839:13: Assignment
837.               }
838.               buf = buf_malloc + misalign;
839.               buf2 = buf2_malloc + misalign;
                   ^
840.               break;
841.           case OPT_MR:

apps/speed.c:1794:14: Call
1792.           /* DSA_generate_key(dsa_key[j]); */
1793.           /* DSA_sign_setup(dsa_key[j],NULL); */
1794.           st = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2, &kk, dsa_key[j]);
                     ^
1795.           if (st == 0) {
1796.               BIO_printf(bio_err,

crypto/dsa/dsa_asn1.c:149:1: Parameter `*sig`
  147.   }
  148.   
  149. > int DSA_sign(int type, const unsigned char *dgst, int dlen,
  150.                unsigned char *sig, unsigned int *siglen, DSA *dsa)
  151.   {

crypto/dsa/dsa_asn1.c:159:15: Call
  157.           return (0);
  158.       }
  159.       *siglen = i2d_DSA_SIG(s, &sig);
                       ^
  160.       DSA_SIG_free(s);
  161.       return (1);

crypto/dsa/dsa_asn1.c:91:1: Parameter `**out`
    89.   } static_ASN1_SEQUENCE_END_cb(DSA_SIG, DSA_SIG)
    90.   
    91. > IMPLEMENT_ASN1_FUNCTIONS_const(DSA_SIG)
    92.   
    93.   /* Override the default free and new methods */

crypto/dsa/dsa_asn1.c:91:1: Call
    89.   } static_ASN1_SEQUENCE_END_cb(DSA_SIG, DSA_SIG)
    90.   
    91. > IMPLEMENT_ASN1_FUNCTIONS_const(DSA_SIG)
    92.   
    93.   /* Override the default free and new methods */

crypto/asn1/tasn_enc.c:92:1: Parameter `**out`
      90.   }
      91.   
      92. > int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
      93.   {
      94.       return asn1_item_flags_i2d(val, out, it, 0);

crypto/asn1/tasn_enc.c:94:12: Call
      92.   int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
      93.   {
      94.       return asn1_item_flags_i2d(val, out, it, 0);
                       ^
      95.   }
      96.   

crypto/asn1/tasn_enc.c:104:1: Parameter `**out`
        102.    */
        103.   
        104. > static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,
        105.                                  const ASN1_ITEM *it, int flags)
        106.   {

crypto/asn1/tasn_enc.c:122:12: Call
        120.       }
        121.   
        122.       return ASN1_item_ex_i2d(&val, out, it, -1, flags);
                          ^
        123.   }
        124.   

crypto/asn1/tasn_enc.c:130:1: Parameter `**out`
          128.    */
          129.   
          130. > int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
          131.                        const ASN1_ITEM *it, int tag, int aclass)
          132.   {

crypto/asn1/tasn_enc.c:154:16: Call
          152.   
          153.       case ASN1_ITYPE_MSTRING:
          154.           return asn1_i2d_ex_primitive(pval, out, it, -1, aclass);
                                ^
          155.   
          156.       case ASN1_ITYPE_CHOICE:

crypto/asn1/tasn_enc.c:472:1: Parameter `**out`
            470.   }
            471.   
            472. > static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
            473.                                    const ASN1_ITEM *it, int tag, int aclass)
            474.   {

crypto/asn1/tasn_enc.c:517:13: Call
            515.       if (out) {
            516.           if (usetag)
            517.               ASN1_put_object(out, ndef, len, tag, aclass);
                               ^
            518.           asn1_ex_i2c(pval, *out, &utype, it);
            519.           if (ndef)

crypto/asn1/asn1_lib.c:196:1: <Length trace>
194.    * class 0 is constructed constructed == 2 for indefinite length constructed
195.    */
196. > void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
197.                        int xclass)
198.   {

crypto/asn1/asn1_lib.c:196:1: Parameter `**pp`
              194.    * class 0 is constructed constructed == 2 for indefinite length constructed
              195.    */
              196. > void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
              197.                        int xclass)
              198.   {

crypto/asn1/asn1_lib.c:199:5: Assignment
              197.                        int xclass)
              198.   {
              199.       unsigned char *p = *pp;
                         ^
              200.       int i, ttag;
              201.   

crypto/asn1/asn1_lib.c:205:9: Array access: Offset: [-oo, 8257] Size: 8257 by call to `DSA_sign` 
              203.       i |= (xclass & V_ASN1_PRIVATE);
              204.       if (tag < 31)
              205.           *(p++) = i | (tag & V_ASN1_PRIMITIVE_TAG);
                             ^
              206.       else {
              207.           *(p++) = i | V_ASN1_PRIMITIVE_TAG;

void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,
                     int xclass)
{
    unsigned char *p = *pp;
    int i, ttag;
    i = (constructed) ? V_ASN1_CONSTRUCTED : 0;
    i |= (xclass & V_ASN1_PRIVATE);
    if (tag < 31)
        *(p++) = i | (tag & V_ASN1_PRIMITIVE_TAG);
    else {
        *(p++) = i | V_ASN1_PRIMITIVE_TAG;
        for (i = 0, ttag = tag; ttag > 0; i++)
            ttag >>= 7;
        ttag = i;
        while (i-- > 0) {
            p[i] = tag & 0x7f;
            if (i != (ttag - 1))
                p[i] |= 0x80;
            tag >>= 7;
        }
        p += ttag;
    }
    if (constructed == 2)
        *(p++) = 0x80;
    else
        asn1_put_length(&p, length);
    *pp = p;
}
['int speed_main(int argc, char **argv)\n{\n    char *prog;\n    const EVP_CIPHER *evp_cipher = NULL;\n    const EVP_MD *evp_md = NULL;\n    double d = 0.0;\n    OPTION_CHOICE o;\n    int decrypt = 0, multiblock = 0, doit[ALGOR_NUM], pr_header = 0;\n    int dsa_doit[DSA_NUM], rsa_doit[RSA_NUM];\n    int ret = 1, i, j, k, misalign = MAX_MISALIGNMENT + 1;\n    long c[ALGOR_NUM][SIZE_NUM], count = 0, save_count = 0;\n    unsigned char *buf_malloc = NULL, *buf2_malloc = NULL;\n    unsigned char *buf = NULL, *buf2 = NULL;\n    unsigned char md[EVP_MAX_MD_SIZE];\n#ifndef NO_FORK\n    int multi = 0;\n#endif\n#if !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_DSA)\n    long rsa_count;\n#endif\n#ifndef OPENSSL_NO_MD2\n    unsigned char md2[MD2_DIGEST_LENGTH];\n#endif\n#ifndef OPENSSL_NO_MDC2\n    unsigned char mdc2[MDC2_DIGEST_LENGTH];\n#endif\n#ifndef OPENSSL_NO_MD4\n    unsigned char md4[MD4_DIGEST_LENGTH];\n#endif\n#ifndef OPENSSL_NO_MD5\n    unsigned char md5[MD5_DIGEST_LENGTH];\n    unsigned char hmac[MD5_DIGEST_LENGTH];\n#endif\n    unsigned char sha[SHA_DIGEST_LENGTH];\n    unsigned char sha256[SHA256_DIGEST_LENGTH];\n    unsigned char sha512[SHA512_DIGEST_LENGTH];\n#ifndef OPENSSL_NO_WHIRLPOOL\n    unsigned char whirlpool[WHIRLPOOL_DIGEST_LENGTH];\n#endif\n#ifndef OPENSSL_NO_RMD160\n    unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];\n#endif\n#ifndef OPENSSL_NO_RC4\n    RC4_KEY rc4_ks;\n#endif\n#ifndef OPENSSL_NO_RC5\n    RC5_32_KEY rc5_ks;\n#endif\n#ifndef OPENSSL_NO_RC2\n    RC2_KEY rc2_ks;\n#endif\n#ifndef OPENSSL_NO_IDEA\n    IDEA_KEY_SCHEDULE idea_ks;\n#endif\n#ifndef OPENSSL_NO_SEED\n    SEED_KEY_SCHEDULE seed_ks;\n#endif\n#ifndef OPENSSL_NO_BF\n    BF_KEY bf_ks;\n#endif\n#ifndef OPENSSL_NO_CAST\n    CAST_KEY cast_ks;\n#endif\n    static const unsigned char key16[16] = {\n        0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,\n        0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12\n    };\n#ifndef OPENSSL_NO_AES\n    static const unsigned char key24[24] = {\n        0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,\n        0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,\n        0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34\n    };\n    static const unsigned char key32[32] = {\n        0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,\n        0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,\n        0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,\n        0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56\n    };\n#endif\n#ifndef OPENSSL_NO_CAMELLIA\n    static const unsigned char ckey24[24] = {\n        0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,\n        0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,\n        0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34\n    };\n    static const unsigned char ckey32[32] = {\n        0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,\n        0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12,\n        0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34,\n        0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56\n    };\n    CAMELLIA_KEY camellia_ks1, camellia_ks2, camellia_ks3;\n#endif\n#ifndef OPENSSL_NO_AES\n# define MAX_BLOCK_SIZE 128\n#else\n# define MAX_BLOCK_SIZE 64\n#endif\n    unsigned char DES_iv[8];\n    unsigned char iv[2 * MAX_BLOCK_SIZE / 8];\n#ifndef OPENSSL_NO_DES\n    static DES_cblock key = {\n        0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0\n    };\n    static DES_cblock key2 = {\n        0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12\n    };\n    static DES_cblock key3 = {\n        0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34\n    };\n    DES_key_schedule sch;\n    DES_key_schedule sch2;\n    DES_key_schedule sch3;\n#endif\n#ifndef OPENSSL_NO_AES\n    AES_KEY aes_ks1, aes_ks2, aes_ks3;\n#endif\n#ifndef OPENSSL_NO_RSA\n    unsigned rsa_num;\n    RSA *rsa_key[RSA_NUM];\n    long rsa_c[RSA_NUM][2];\n    static unsigned int rsa_bits[RSA_NUM] = {\n        512, 1024, 2048, 3072, 4096, 7680, 15360\n    };\n    static unsigned char *rsa_data[RSA_NUM] = {\n        test512, test1024, test2048, test3072, test4096, test7680, test15360\n    };\n    static int rsa_data_length[RSA_NUM] = {\n        sizeof(test512), sizeof(test1024),\n        sizeof(test2048), sizeof(test3072),\n        sizeof(test4096), sizeof(test7680),\n        sizeof(test15360)\n    };\n#endif\n#ifndef OPENSSL_NO_DSA\n    DSA *dsa_key[DSA_NUM];\n    long dsa_c[DSA_NUM][2];\n    static unsigned int dsa_bits[DSA_NUM] = { 512, 1024, 2048 };\n#endif\n#ifndef OPENSSL_NO_EC\n    static unsigned int test_curves[EC_NUM] = {\n        NID_secp160r1, NID_X9_62_prime192v1, NID_secp224r1,\n        NID_X9_62_prime256v1, NID_secp384r1, NID_secp521r1,\n        NID_sect163k1, NID_sect233k1, NID_sect283k1,\n        NID_sect409k1, NID_sect571k1, NID_sect163r2,\n        NID_sect233r1, NID_sect283r1, NID_sect409r1,\n        NID_sect571r1\n    };\n    static const char *test_curves_names[EC_NUM] = {\n        "secp160r1", "nistp192", "nistp224",\n        "nistp256", "nistp384", "nistp521",\n        "nistk163", "nistk233", "nistk283",\n        "nistk409", "nistk571", "nistb163",\n        "nistb233", "nistb283", "nistb409",\n        "nistb571"\n    };\n    static int test_curves_bits[EC_NUM] = {\n        160, 192, 224,\n        256, 384, 521,\n        163, 233, 283,\n        409, 571, 163,\n        233, 283, 409,\n        571\n    };\n#endif\n#ifndef OPENSSL_NO_EC\n    unsigned char ecdsasig[256];\n    unsigned int ecdsasiglen;\n    EC_KEY *ecdsa[EC_NUM];\n    long ecdsa_c[EC_NUM][2];\n    int ecdsa_doit[EC_NUM];\n    EC_KEY *ecdh_a[EC_NUM], *ecdh_b[EC_NUM];\n    unsigned char secret_a[MAX_ECDH_SIZE], secret_b[MAX_ECDH_SIZE];\n    int secret_size_a, secret_size_b;\n    int ecdh_checks = 0;\n    int secret_idx = 0;\n    long ecdh_c[EC_NUM][2];\n    int ecdh_doit[EC_NUM];\n#endif\n    memset(results, 0, sizeof(results));\n#ifndef OPENSSL_NO_DSA\n    memset(dsa_key, 0, sizeof(dsa_key));\n#endif\n#ifndef OPENSSL_NO_EC\n    for (i = 0; i < EC_NUM; i++)\n        ecdsa[i] = NULL;\n    for (i = 0; i < EC_NUM; i++)\n        ecdh_a[i] = ecdh_b[i] = NULL;\n#endif\n#ifndef OPENSSL_NO_RSA\n    memset(rsa_key, 0, sizeof(rsa_key));\n    for (i = 0; i < RSA_NUM; i++)\n        rsa_key[i] = NULL;\n#endif\n    memset(c, 0, sizeof(c));\n    memset(DES_iv, 0, sizeof(DES_iv));\n    memset(iv, 0, sizeof(iv));\n    for (i = 0; i < ALGOR_NUM; i++)\n        doit[i] = 0;\n    for (i = 0; i < RSA_NUM; i++)\n        rsa_doit[i] = 0;\n    for (i = 0; i < DSA_NUM; i++)\n        dsa_doit[i] = 0;\n#ifndef OPENSSL_NO_EC\n    for (i = 0; i < EC_NUM; i++)\n        ecdsa_doit[i] = 0;\n    for (i = 0; i < EC_NUM; i++)\n        ecdh_doit[i] = 0;\n#endif\n    buf = buf_malloc = app_malloc((int)BUFSIZE + misalign, "input buffer");\n    buf2 = buf2_malloc = app_malloc((int)BUFSIZE + misalign, "output buffer");\n    misalign = 0;\n    prog = opt_init(argc, argv, speed_options);\n    while ((o = opt_next()) != OPT_EOF) {\n        switch (o) {\n        case OPT_EOF:\n        case OPT_ERR:\n opterr:\n            BIO_printf(bio_err, "%s: Use -help for summary.\\n", prog);\n            goto end;\n        case OPT_HELP:\n            opt_help(speed_options);\n            ret = 0;\n            goto end;\n        case OPT_ELAPSED:\n            usertime = 0;\n            break;\n        case OPT_EVP:\n            evp_cipher = EVP_get_cipherbyname(opt_arg());\n            if (evp_cipher == NULL)\n                evp_md = EVP_get_digestbyname(opt_arg());\n            if (evp_cipher == NULL && evp_md == NULL) {\n                BIO_printf(bio_err,\n                           "%s: %s  an unknown cipher or digest\\n",\n                           prog, opt_arg());\n                goto end;\n            }\n            doit[D_EVP] = 1;\n            break;\n        case OPT_DECRYPT:\n            decrypt = 1;\n            break;\n        case OPT_ENGINE:\n            (void)setup_engine(opt_arg(), 0);\n            break;\n        case OPT_MULTI:\n#ifndef NO_FORK\n            multi = atoi(opt_arg());\n#endif\n            break;\n        case OPT_MISALIGN:\n            if (!opt_int(opt_arg(), &misalign))\n                goto end;\n            if (misalign > MISALIGN) {\n                BIO_printf(bio_err,\n                           "%s: Maximum offset is %d\\n", prog, MISALIGN);\n                goto opterr;\n            }\n            buf = buf_malloc + misalign;\n            buf2 = buf2_malloc + misalign;\n            break;\n        case OPT_MR:\n            mr = 1;\n            break;\n        case OPT_MB:\n            multiblock = 1;\n            break;\n        }\n    }\n    argc = opt_num_rest();\n    argv = opt_rest();\n    for ( ; *argv; argv++) {\n        if (found(*argv, doit_choices, &i)) {\n            doit[i] = 1;\n            continue;\n        }\n#ifndef OPENSSL_NO_DES\n        if (strcmp(*argv, "des") == 0) {\n            doit[D_CBC_DES] = doit[D_EDE3_DES] = 1;\n            continue;\n        }\n#endif\n        if (strcmp(*argv, "sha") == 0) {\n            doit[D_SHA1] = doit[D_SHA256] = doit[D_SHA512] = 1;\n            continue;\n        }\n#ifndef OPENSSL_NO_RSA\n# ifndef RSA_NULL\n        if (strcmp(*argv, "openssl") == 0) {\n            RSA_set_default_method(RSA_PKCS1_OpenSSL());\n            continue;\n        }\n# endif\n        if (strcmp(*argv, "rsa") == 0) {\n            rsa_doit[R_RSA_512] = rsa_doit[R_RSA_1024] =\n                rsa_doit[R_RSA_2048] = rsa_doit[R_RSA_3072] =\n                rsa_doit[R_RSA_4096] = rsa_doit[R_RSA_7680] =\n                rsa_doit[R_RSA_15360] = 1;\n            continue;\n        }\n        if (found(*argv, rsa_choices, &i)) {\n            rsa_doit[i] = 1;\n            continue;\n        }\n#endif\n#ifndef OPENSSL_NO_DSA\n        if (strcmp(*argv, "dsa") == 0) {\n            dsa_doit[R_DSA_512] = dsa_doit[R_DSA_1024] =\n                dsa_doit[R_DSA_2048] = 1;\n            continue;\n        }\n        if (found(*argv, dsa_choices, &i)) {\n            dsa_doit[i] = 2;\n            continue;\n        }\n#endif\n#ifndef OPENSSL_NO_AES\n        if (strcmp(*argv, "aes") == 0) {\n            doit[D_CBC_128_AES] = doit[D_CBC_192_AES] =\n                doit[D_CBC_256_AES] = 1;\n            continue;\n        }\n#endif\n#ifndef OPENSSL_NO_CAMELLIA\n        if (strcmp(*argv, "camellia") == 0) {\n            doit[D_CBC_128_CML] = doit[D_CBC_192_CML] =\n                doit[D_CBC_256_CML] = 1;\n            continue;\n        }\n#endif\n#ifndef OPENSSL_NO_EC\n        if (strcmp(*argv, "ecdsa") == 0) {\n            for (i = 0; i < EC_NUM; i++)\n                ecdsa_doit[i] = 1;\n            continue;\n        }\n        if (found(*argv, ecdsa_choices, &i)) {\n            ecdsa_doit[i] = 2;\n            continue;\n        }\n        if (strcmp(*argv, "ecdh") == 0) {\n            for (i = 0; i < EC_NUM; i++)\n                ecdh_doit[i] = 1;\n            continue;\n        }\n        if (found(*argv, ecdh_choices, &i)) {\n            ecdh_doit[i] = 2;\n            continue;\n        }\n#endif\n        BIO_printf(bio_err, "%s: Unknown algorithm %s\\n", prog, *argv);\n        goto end;\n    }\n#ifndef NO_FORK\n    if (multi && do_multi(multi))\n        goto show_res;\n#endif\n    if ((argc == 0) && !doit[D_EVP]) {\n        for (i = 0; i < ALGOR_NUM; i++)\n            if (i != D_EVP)\n                doit[i] = 1;\n        for (i = 0; i < RSA_NUM; i++)\n            rsa_doit[i] = 1;\n        for (i = 0; i < DSA_NUM; i++)\n            dsa_doit[i] = 1;\n#ifndef OPENSSL_NO_EC\n        for (i = 0; i < EC_NUM; i++)\n            ecdsa_doit[i] = 1;\n        for (i = 0; i < EC_NUM; i++)\n            ecdh_doit[i] = 1;\n#endif\n    }\n    for (i = 0; i < ALGOR_NUM; i++)\n        if (doit[i])\n            pr_header++;\n    if (usertime == 0 && !mr)\n        BIO_printf(bio_err,\n                   "You have chosen to measure elapsed time "\n                   "instead of user CPU time.\\n");\n#ifndef OPENSSL_NO_RSA\n    for (i = 0; i < RSA_NUM; i++) {\n        const unsigned char *p;\n        p = rsa_data[i];\n        rsa_key[i] = d2i_RSAPrivateKey(NULL, &p, rsa_data_length[i]);\n        if (rsa_key[i] == NULL) {\n            BIO_printf(bio_err, "internal error loading RSA key number %d\\n",\n                       i);\n            goto end;\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_DSA\n    dsa_key[0] = get_dsa512();\n    dsa_key[1] = get_dsa1024();\n    dsa_key[2] = get_dsa2048();\n#endif\n#ifndef OPENSSL_NO_DES\n    DES_set_key_unchecked(&key, &sch);\n    DES_set_key_unchecked(&key2, &sch2);\n    DES_set_key_unchecked(&key3, &sch3);\n#endif\n#ifndef OPENSSL_NO_AES\n    AES_set_encrypt_key(key16, 128, &aes_ks1);\n    AES_set_encrypt_key(key24, 192, &aes_ks2);\n    AES_set_encrypt_key(key32, 256, &aes_ks3);\n#endif\n#ifndef OPENSSL_NO_CAMELLIA\n    Camellia_set_key(key16, 128, &camellia_ks1);\n    Camellia_set_key(ckey24, 192, &camellia_ks2);\n    Camellia_set_key(ckey32, 256, &camellia_ks3);\n#endif\n#ifndef OPENSSL_NO_IDEA\n    idea_set_encrypt_key(key16, &idea_ks);\n#endif\n#ifndef OPENSSL_NO_SEED\n    SEED_set_key(key16, &seed_ks);\n#endif\n#ifndef OPENSSL_NO_RC4\n    RC4_set_key(&rc4_ks, 16, key16);\n#endif\n#ifndef OPENSSL_NO_RC2\n    RC2_set_key(&rc2_ks, 16, key16, 128);\n#endif\n#ifndef OPENSSL_NO_RC5\n    RC5_32_set_key(&rc5_ks, 16, key16, 12);\n#endif\n#ifndef OPENSSL_NO_BF\n    BF_set_key(&bf_ks, 16, key16);\n#endif\n#ifndef OPENSSL_NO_CAST\n    CAST_set_key(&cast_ks, 16, key16);\n#endif\n#ifndef OPENSSL_NO_RSA\n    memset(rsa_c, 0, sizeof(rsa_c));\n#endif\n#ifndef SIGALRM\n# ifndef OPENSSL_NO_DES\n    BIO_printf(bio_err, "First we calculate the approximate speed ...\\n");\n    count = 10;\n    do {\n        long it;\n        count *= 2;\n        Time_F(START);\n        for (it = count; it; it--)\n            DES_ecb_encrypt((DES_cblock *)buf,\n                            (DES_cblock *)buf, &sch, DES_ENCRYPT);\n        d = Time_F(STOP);\n    } while (d < 3);\n    save_count = count;\n    c[D_MD2][0] = count / 10;\n    c[D_MDC2][0] = count / 10;\n    c[D_MD4][0] = count;\n    c[D_MD5][0] = count;\n    c[D_HMAC][0] = count;\n    c[D_SHA1][0] = count;\n    c[D_RMD160][0] = count;\n    c[D_RC4][0] = count * 5;\n    c[D_CBC_DES][0] = count;\n    c[D_EDE3_DES][0] = count / 3;\n    c[D_CBC_IDEA][0] = count;\n    c[D_CBC_SEED][0] = count;\n    c[D_CBC_RC2][0] = count;\n    c[D_CBC_RC5][0] = count;\n    c[D_CBC_BF][0] = count;\n    c[D_CBC_CAST][0] = count;\n    c[D_CBC_128_AES][0] = count;\n    c[D_CBC_192_AES][0] = count;\n    c[D_CBC_256_AES][0] = count;\n    c[D_CBC_128_CML][0] = count;\n    c[D_CBC_192_CML][0] = count;\n    c[D_CBC_256_CML][0] = count;\n    c[D_SHA256][0] = count;\n    c[D_SHA512][0] = count;\n    c[D_WHIRLPOOL][0] = count;\n    c[D_IGE_128_AES][0] = count;\n    c[D_IGE_192_AES][0] = count;\n    c[D_IGE_256_AES][0] = count;\n    c[D_GHASH][0] = count;\n    for (i = 1; i < SIZE_NUM; i++) {\n        long l0, l1;\n        l0 = (long)lengths[0];\n        l1 = (long)lengths[i];\n        c[D_MD2][i] = c[D_MD2][0] * 4 * l0 / l1;\n        c[D_MDC2][i] = c[D_MDC2][0] * 4 * l0 / l1;\n        c[D_MD4][i] = c[D_MD4][0] * 4 * l0 / l1;\n        c[D_MD5][i] = c[D_MD5][0] * 4 * l0 / l1;\n        c[D_HMAC][i] = c[D_HMAC][0] * 4 * l0 / l1;\n        c[D_SHA1][i] = c[D_SHA1][0] * 4 * l0 / l1;\n        c[D_RMD160][i] = c[D_RMD160][0] * 4 * l0 / l1;\n        c[D_SHA256][i] = c[D_SHA256][0] * 4 * l0 / l1;\n        c[D_SHA512][i] = c[D_SHA512][0] * 4 * l0 / l1;\n        c[D_WHIRLPOOL][i] = c[D_WHIRLPOOL][0] * 4 * l0 / l1;\n        l0 = (long)lengths[i - 1];\n        c[D_RC4][i] = c[D_RC4][i - 1] * l0 / l1;\n        c[D_CBC_DES][i] = c[D_CBC_DES][i - 1] * l0 / l1;\n        c[D_EDE3_DES][i] = c[D_EDE3_DES][i - 1] * l0 / l1;\n        c[D_CBC_IDEA][i] = c[D_CBC_IDEA][i - 1] * l0 / l1;\n        c[D_CBC_SEED][i] = c[D_CBC_SEED][i - 1] * l0 / l1;\n        c[D_CBC_RC2][i] = c[D_CBC_RC2][i - 1] * l0 / l1;\n        c[D_CBC_RC5][i] = c[D_CBC_RC5][i - 1] * l0 / l1;\n        c[D_CBC_BF][i] = c[D_CBC_BF][i - 1] * l0 / l1;\n        c[D_CBC_CAST][i] = c[D_CBC_CAST][i - 1] * l0 / l1;\n        c[D_CBC_128_AES][i] = c[D_CBC_128_AES][i - 1] * l0 / l1;\n        c[D_CBC_192_AES][i] = c[D_CBC_192_AES][i - 1] * l0 / l1;\n        c[D_CBC_256_AES][i] = c[D_CBC_256_AES][i - 1] * l0 / l1;\n        c[D_CBC_128_CML][i] = c[D_CBC_128_CML][i - 1] * l0 / l1;\n        c[D_CBC_192_CML][i] = c[D_CBC_192_CML][i - 1] * l0 / l1;\n        c[D_CBC_256_CML][i] = c[D_CBC_256_CML][i - 1] * l0 / l1;\n        c[D_IGE_128_AES][i] = c[D_IGE_128_AES][i - 1] * l0 / l1;\n        c[D_IGE_192_AES][i] = c[D_IGE_192_AES][i - 1] * l0 / l1;\n        c[D_IGE_256_AES][i] = c[D_IGE_256_AES][i - 1] * l0 / l1;\n    }\n#  ifndef OPENSSL_NO_RSA\n    rsa_c[R_RSA_512][0] = count / 2000;\n    rsa_c[R_RSA_512][1] = count / 400;\n    for (i = 1; i < RSA_NUM; i++) {\n        rsa_c[i][0] = rsa_c[i - 1][0] / 8;\n        rsa_c[i][1] = rsa_c[i - 1][1] / 4;\n        if ((rsa_doit[i] <= 1) && (rsa_c[i][0] == 0))\n            rsa_doit[i] = 0;\n        else {\n            if (rsa_c[i][0] == 0) {\n                rsa_c[i][0] = 1;\n                rsa_c[i][1] = 20;\n            }\n        }\n    }\n#  endif\n#  ifndef OPENSSL_NO_DSA\n    dsa_c[R_DSA_512][0] = count / 1000;\n    dsa_c[R_DSA_512][1] = count / 1000 / 2;\n    for (i = 1; i < DSA_NUM; i++) {\n        dsa_c[i][0] = dsa_c[i - 1][0] / 4;\n        dsa_c[i][1] = dsa_c[i - 1][1] / 4;\n        if ((dsa_doit[i] <= 1) && (dsa_c[i][0] == 0))\n            dsa_doit[i] = 0;\n        else {\n            if (dsa_c[i] == 0) {\n                dsa_c[i][0] = 1;\n                dsa_c[i][1] = 1;\n            }\n        }\n    }\n#  endif\n#  ifndef OPENSSL_NO_EC\n    ecdsa_c[R_EC_P160][0] = count / 1000;\n    ecdsa_c[R_EC_P160][1] = count / 1000 / 2;\n    for (i = R_EC_P192; i <= R_EC_P521; i++) {\n        ecdsa_c[i][0] = ecdsa_c[i - 1][0] / 2;\n        ecdsa_c[i][1] = ecdsa_c[i - 1][1] / 2;\n        if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))\n            ecdsa_doit[i] = 0;\n        else {\n            if (ecdsa_c[i] == 0) {\n                ecdsa_c[i][0] = 1;\n                ecdsa_c[i][1] = 1;\n            }\n        }\n    }\n    ecdsa_c[R_EC_K163][0] = count / 1000;\n    ecdsa_c[R_EC_K163][1] = count / 1000 / 2;\n    for (i = R_EC_K233; i <= R_EC_K571; i++) {\n        ecdsa_c[i][0] = ecdsa_c[i - 1][0] / 2;\n        ecdsa_c[i][1] = ecdsa_c[i - 1][1] / 2;\n        if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))\n            ecdsa_doit[i] = 0;\n        else {\n            if (ecdsa_c[i] == 0) {\n                ecdsa_c[i][0] = 1;\n                ecdsa_c[i][1] = 1;\n            }\n        }\n    }\n    ecdsa_c[R_EC_B163][0] = count / 1000;\n    ecdsa_c[R_EC_B163][1] = count / 1000 / 2;\n    for (i = R_EC_B233; i <= R_EC_B571; i++) {\n        ecdsa_c[i][0] = ecdsa_c[i - 1][0] / 2;\n        ecdsa_c[i][1] = ecdsa_c[i - 1][1] / 2;\n        if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))\n            ecdsa_doit[i] = 0;\n        else {\n            if (ecdsa_c[i] == 0) {\n                ecdsa_c[i][0] = 1;\n                ecdsa_c[i][1] = 1;\n            }\n        }\n    }\n    ecdh_c[R_EC_P160][0] = count / 1000;\n    ecdh_c[R_EC_P160][1] = count / 1000;\n    for (i = R_EC_P192; i <= R_EC_P521; i++) {\n        ecdh_c[i][0] = ecdh_c[i - 1][0] / 2;\n        ecdh_c[i][1] = ecdh_c[i - 1][1] / 2;\n        if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))\n            ecdh_doit[i] = 0;\n        else {\n            if (ecdh_c[i] == 0) {\n                ecdh_c[i][0] = 1;\n                ecdh_c[i][1] = 1;\n            }\n        }\n    }\n    ecdh_c[R_EC_K163][0] = count / 1000;\n    ecdh_c[R_EC_K163][1] = count / 1000;\n    for (i = R_EC_K233; i <= R_EC_K571; i++) {\n        ecdh_c[i][0] = ecdh_c[i - 1][0] / 2;\n        ecdh_c[i][1] = ecdh_c[i - 1][1] / 2;\n        if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))\n            ecdh_doit[i] = 0;\n        else {\n            if (ecdh_c[i] == 0) {\n                ecdh_c[i][0] = 1;\n                ecdh_c[i][1] = 1;\n            }\n        }\n    }\n    ecdh_c[R_EC_B163][0] = count / 1000;\n    ecdh_c[R_EC_B163][1] = count / 1000;\n    for (i = R_EC_B233; i <= R_EC_B571; i++) {\n        ecdh_c[i][0] = ecdh_c[i - 1][0] / 2;\n        ecdh_c[i][1] = ecdh_c[i - 1][1] / 2;\n        if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))\n            ecdh_doit[i] = 0;\n        else {\n            if (ecdh_c[i] == 0) {\n                ecdh_c[i][0] = 1;\n                ecdh_c[i][1] = 1;\n            }\n        }\n    }\n#  endif\n#  define COND(d) (count < (d))\n#  define COUNT(d) (d)\n# else\n#  error "You cannot disable DES on systems without SIGALRM."\n# endif\n#else\n# define COND(c) (run && count<0x7fffffff)\n# define COUNT(d) (count)\n# ifndef _WIN32\n    signal(SIGALRM, sig_done);\n# endif\n#endif\n#ifndef OPENSSL_NO_MD2\n    if (doit[D_MD2]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_MD2], c[D_MD2][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_MD2][j]); count++)\n                EVP_Digest(buf, (unsigned long)lengths[j], &(md2[0]), NULL,\n                           EVP_md2(), NULL);\n            d = Time_F(STOP);\n            print_result(D_MD2, j, count, d);\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_MDC2\n    if (doit[D_MDC2]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_MDC2], c[D_MDC2][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_MDC2][j]); count++)\n                EVP_Digest(buf, (unsigned long)lengths[j], &(mdc2[0]), NULL,\n                           EVP_mdc2(), NULL);\n            d = Time_F(STOP);\n            print_result(D_MDC2, j, count, d);\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_MD4\n    if (doit[D_MD4]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_MD4], c[D_MD4][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_MD4][j]); count++)\n                EVP_Digest(&(buf[0]), (unsigned long)lengths[j], &(md4[0]),\n                           NULL, EVP_md4(), NULL);\n            d = Time_F(STOP);\n            print_result(D_MD4, j, count, d);\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_MD5\n    if (doit[D_MD5]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_MD5], c[D_MD5][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_MD5][j]); count++)\n                MD5(buf, lengths[j], md5);\n            d = Time_F(STOP);\n            print_result(D_MD5, j, count, d);\n        }\n    }\n#endif\n#if !defined(OPENSSL_NO_MD5)\n    if (doit[D_HMAC]) {\n        HMAC_CTX *hctx = NULL;\n        hctx = HMAC_CTX_new();\n        if (hctx == NULL) {\n            BIO_printf(bio_err, "HMAC malloc failure, exiting...");\n            exit(1);\n        }\n        HMAC_Init_ex(hctx, (unsigned char *)"This is a key...",\n                     16, EVP_md5(), NULL);\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_HMAC], c[D_HMAC][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_HMAC][j]); count++) {\n                HMAC_Init_ex(hctx, NULL, 0, NULL, NULL);\n                HMAC_Update(hctx, buf, lengths[j]);\n                HMAC_Final(hctx, &(hmac[0]), NULL);\n            }\n            d = Time_F(STOP);\n            print_result(D_HMAC, j, count, d);\n        }\n        HMAC_CTX_free(hctx);\n    }\n#endif\n    if (doit[D_SHA1]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_SHA1], c[D_SHA1][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_SHA1][j]); count++)\n                SHA1(buf, lengths[j], sha);\n            d = Time_F(STOP);\n            print_result(D_SHA1, j, count, d);\n        }\n    }\n    if (doit[D_SHA256]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_SHA256], c[D_SHA256][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_SHA256][j]); count++)\n                SHA256(buf, lengths[j], sha256);\n            d = Time_F(STOP);\n            print_result(D_SHA256, j, count, d);\n        }\n    }\n    if (doit[D_SHA512]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_SHA512], c[D_SHA512][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_SHA512][j]); count++)\n                SHA512(buf, lengths[j], sha512);\n            d = Time_F(STOP);\n            print_result(D_SHA512, j, count, d);\n        }\n    }\n#ifndef OPENSSL_NO_WHIRLPOOL\n    if (doit[D_WHIRLPOOL]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_WHIRLPOOL], c[D_WHIRLPOOL][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_WHIRLPOOL][j]); count++)\n                WHIRLPOOL(buf, lengths[j], whirlpool);\n            d = Time_F(STOP);\n            print_result(D_WHIRLPOOL, j, count, d);\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_RMD160\n    if (doit[D_RMD160]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_RMD160], c[D_RMD160][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_RMD160][j]); count++)\n                EVP_Digest(buf, (unsigned long)lengths[j], &(rmd160[0]), NULL,\n                           EVP_ripemd160(), NULL);\n            d = Time_F(STOP);\n            print_result(D_RMD160, j, count, d);\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_RC4\n    if (doit[D_RC4]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_RC4], c[D_RC4][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_RC4][j]); count++)\n                RC4(&rc4_ks, (unsigned int)lengths[j], buf, buf);\n            d = Time_F(STOP);\n            print_result(D_RC4, j, count, d);\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_DES\n    if (doit[D_CBC_DES]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_CBC_DES], c[D_CBC_DES][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_CBC_DES][j]); count++)\n                DES_ncbc_encrypt(buf, buf, lengths[j], &sch,\n                                 &DES_iv, DES_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_CBC_DES, j, count, d);\n        }\n    }\n    if (doit[D_EDE3_DES]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_EDE3_DES], c[D_EDE3_DES][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_EDE3_DES][j]); count++)\n                DES_ede3_cbc_encrypt(buf, buf, lengths[j],\n                                     &sch, &sch2, &sch3,\n                                     &DES_iv, DES_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_EDE3_DES, j, count, d);\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_AES\n    if (doit[D_CBC_128_AES]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_CBC_128_AES], c[D_CBC_128_AES][j],\n                          lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_CBC_128_AES][j]); count++)\n                AES_cbc_encrypt(buf, buf,\n                                (unsigned long)lengths[j], &aes_ks1,\n                                iv, AES_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_CBC_128_AES, j, count, d);\n        }\n    }\n    if (doit[D_CBC_192_AES]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_CBC_192_AES], c[D_CBC_192_AES][j],\n                          lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_CBC_192_AES][j]); count++)\n                AES_cbc_encrypt(buf, buf,\n                                (unsigned long)lengths[j], &aes_ks2,\n                                iv, AES_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_CBC_192_AES, j, count, d);\n        }\n    }\n    if (doit[D_CBC_256_AES]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_CBC_256_AES], c[D_CBC_256_AES][j],\n                          lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_CBC_256_AES][j]); count++)\n                AES_cbc_encrypt(buf, buf,\n                                (unsigned long)lengths[j], &aes_ks3,\n                                iv, AES_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_CBC_256_AES, j, count, d);\n        }\n    }\n    if (doit[D_IGE_128_AES]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_IGE_128_AES], c[D_IGE_128_AES][j],\n                          lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_IGE_128_AES][j]); count++)\n                AES_ige_encrypt(buf, buf2,\n                                (unsigned long)lengths[j], &aes_ks1,\n                                iv, AES_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_IGE_128_AES, j, count, d);\n        }\n    }\n    if (doit[D_IGE_192_AES]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_IGE_192_AES], c[D_IGE_192_AES][j],\n                          lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_IGE_192_AES][j]); count++)\n                AES_ige_encrypt(buf, buf2,\n                                (unsigned long)lengths[j], &aes_ks2,\n                                iv, AES_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_IGE_192_AES, j, count, d);\n        }\n    }\n    if (doit[D_IGE_256_AES]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_IGE_256_AES], c[D_IGE_256_AES][j],\n                          lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_IGE_256_AES][j]); count++)\n                AES_ige_encrypt(buf, buf2,\n                                (unsigned long)lengths[j], &aes_ks3,\n                                iv, AES_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_IGE_256_AES, j, count, d);\n        }\n    }\n    if (doit[D_GHASH]) {\n        GCM128_CONTEXT *ctx =\n            CRYPTO_gcm128_new(&aes_ks1, (block128_f) AES_encrypt);\n        CRYPTO_gcm128_setiv(ctx, (unsigned char *)"0123456789ab", 12);\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_GHASH], c[D_GHASH][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_GHASH][j]); count++)\n                CRYPTO_gcm128_aad(ctx, buf, lengths[j]);\n            d = Time_F(STOP);\n            print_result(D_GHASH, j, count, d);\n        }\n        CRYPTO_gcm128_release(ctx);\n    }\n#endif\n#ifndef OPENSSL_NO_CAMELLIA\n    if (doit[D_CBC_128_CML]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_CBC_128_CML], c[D_CBC_128_CML][j],\n                          lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_CBC_128_CML][j]); count++)\n                Camellia_cbc_encrypt(buf, buf,\n                                     (unsigned long)lengths[j], &camellia_ks1,\n                                     iv, CAMELLIA_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_CBC_128_CML, j, count, d);\n        }\n    }\n    if (doit[D_CBC_192_CML]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_CBC_192_CML], c[D_CBC_192_CML][j],\n                          lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_CBC_192_CML][j]); count++)\n                Camellia_cbc_encrypt(buf, buf,\n                                     (unsigned long)lengths[j], &camellia_ks2,\n                                     iv, CAMELLIA_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_CBC_192_CML, j, count, d);\n        }\n    }\n    if (doit[D_CBC_256_CML]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_CBC_256_CML], c[D_CBC_256_CML][j],\n                          lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_CBC_256_CML][j]); count++)\n                Camellia_cbc_encrypt(buf, buf,\n                                     (unsigned long)lengths[j], &camellia_ks3,\n                                     iv, CAMELLIA_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_CBC_256_CML, j, count, d);\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_IDEA\n    if (doit[D_CBC_IDEA]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_CBC_IDEA], c[D_CBC_IDEA][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_CBC_IDEA][j]); count++)\n                idea_cbc_encrypt(buf, buf,\n                                 (unsigned long)lengths[j], &idea_ks,\n                                 iv, IDEA_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_CBC_IDEA, j, count, d);\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_SEED\n    if (doit[D_CBC_SEED]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_CBC_SEED], c[D_CBC_SEED][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_CBC_SEED][j]); count++)\n                SEED_cbc_encrypt(buf, buf,\n                                 (unsigned long)lengths[j], &seed_ks, iv, 1);\n            d = Time_F(STOP);\n            print_result(D_CBC_SEED, j, count, d);\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_RC2\n    if (doit[D_CBC_RC2]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_CBC_RC2], c[D_CBC_RC2][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_CBC_RC2][j]); count++)\n                RC2_cbc_encrypt(buf, buf,\n                                (unsigned long)lengths[j], &rc2_ks,\n                                iv, RC2_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_CBC_RC2, j, count, d);\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_RC5\n    if (doit[D_CBC_RC5]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_CBC_RC5], c[D_CBC_RC5][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_CBC_RC5][j]); count++)\n                RC5_32_cbc_encrypt(buf, buf,\n                                   (unsigned long)lengths[j], &rc5_ks,\n                                   iv, RC5_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_CBC_RC5, j, count, d);\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_BF\n    if (doit[D_CBC_BF]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_CBC_BF], c[D_CBC_BF][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_CBC_BF][j]); count++)\n                BF_cbc_encrypt(buf, buf,\n                               (unsigned long)lengths[j], &bf_ks,\n                               iv, BF_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_CBC_BF, j, count, d);\n        }\n    }\n#endif\n#ifndef OPENSSL_NO_CAST\n    if (doit[D_CBC_CAST]) {\n        for (j = 0; j < SIZE_NUM; j++) {\n            print_message(names[D_CBC_CAST], c[D_CBC_CAST][j], lengths[j]);\n            Time_F(START);\n            for (count = 0, run = 1; COND(c[D_CBC_CAST][j]); count++)\n                CAST_cbc_encrypt(buf, buf,\n                                 (unsigned long)lengths[j], &cast_ks,\n                                 iv, CAST_ENCRYPT);\n            d = Time_F(STOP);\n            print_result(D_CBC_CAST, j, count, d);\n        }\n    }\n#endif\n    if (doit[D_EVP]) {\n#ifdef EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK\n        if (multiblock && evp_cipher) {\n            if (!\n                (EVP_CIPHER_flags(evp_cipher) &\n                 EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK)) {\n                BIO_printf(bio_err, "%s is not multi-block capable\\n",\n                        OBJ_nid2ln(evp_cipher->nid));\n                goto end;\n            }\n            multiblock_speed(evp_cipher);\n            ret = 0;\n            goto end;\n        }\n#endif\n        for (j = 0; j < SIZE_NUM; j++) {\n            if (evp_cipher) {\n                EVP_CIPHER_CTX *ctx;\n                int outl;\n                names[D_EVP] = OBJ_nid2ln(evp_cipher->nid);\n                print_message(names[D_EVP], save_count, lengths[j]);\n                ctx = EVP_CIPHER_CTX_new();\n                if (decrypt)\n                    EVP_DecryptInit_ex(ctx, evp_cipher, NULL, key16, iv);\n                else\n                    EVP_EncryptInit_ex(ctx, evp_cipher, NULL, key16, iv);\n                EVP_CIPHER_CTX_set_padding(ctx, 0);\n                Time_F(START);\n                if (decrypt)\n                    for (count = 0, run = 1;\n                         COND(save_count * 4 * lengths[0] / lengths[j]);\n                         count++)\n                        EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[j]);\n                else\n                    for (count = 0, run = 1;\n                         COND(save_count * 4 * lengths[0] / lengths[j]);\n                         count++)\n                        EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[j]);\n                if (decrypt)\n                    EVP_DecryptFinal_ex(ctx, buf, &outl);\n                else\n                    EVP_EncryptFinal_ex(ctx, buf, &outl);\n                d = Time_F(STOP);\n                EVP_CIPHER_CTX_free(ctx);\n            }\n            if (evp_md) {\n                names[D_EVP] = OBJ_nid2ln(EVP_MD_type(evp_md));\n                print_message(names[D_EVP], save_count, lengths[j]);\n                Time_F(START);\n                for (count = 0, run = 1;\n                     COND(save_count * 4 * lengths[0] / lengths[j]); count++)\n                    EVP_Digest(buf, lengths[j], &(md[0]), NULL, evp_md, NULL);\n                d = Time_F(STOP);\n            }\n            print_result(D_EVP, j, count, d);\n        }\n    }\n    RAND_bytes(buf, 36);\n#ifndef OPENSSL_NO_RSA\n    for (j = 0; j < RSA_NUM; j++) {\n        int st;\n        if (!rsa_doit[j])\n            continue;\n        st = RSA_sign(NID_md5_sha1, buf, 36, buf2, &rsa_num, rsa_key[j]);\n        if (st == 0) {\n            BIO_printf(bio_err,\n                       "RSA sign failure.  No RSA sign will be done.\\n");\n            ERR_print_errors(bio_err);\n            rsa_count = 1;\n        } else {\n            pkey_print_message("private", "rsa",\n                               rsa_c[j][0], rsa_bits[j], RSA_SECONDS);\n            Time_F(START);\n            for (count = 0, run = 1; COND(rsa_c[j][0]); count++) {\n                st = RSA_sign(NID_md5_sha1, buf, 36, buf2,\n                              &rsa_num, rsa_key[j]);\n                if (st == 0) {\n                    BIO_printf(bio_err, "RSA sign failure\\n");\n                    ERR_print_errors(bio_err);\n                    count = 1;\n                    break;\n                }\n            }\n            d = Time_F(STOP);\n            BIO_printf(bio_err,\n                       mr ? "+R1:%ld:%d:%.2f\\n"\n                       : "%ld %d bit private RSA\'s in %.2fs\\n",\n                       count, rsa_bits[j], d);\n            rsa_results[j][0] = d / (double)count;\n            rsa_count = count;\n        }\n        st = RSA_verify(NID_md5_sha1, buf, 36, buf2, rsa_num, rsa_key[j]);\n        if (st <= 0) {\n            BIO_printf(bio_err,\n                       "RSA verify failure.  No RSA verify will be done.\\n");\n            ERR_print_errors(bio_err);\n            rsa_doit[j] = 0;\n        } else {\n            pkey_print_message("public", "rsa",\n                               rsa_c[j][1], rsa_bits[j], RSA_SECONDS);\n            Time_F(START);\n            for (count = 0, run = 1; COND(rsa_c[j][1]); count++) {\n                st = RSA_verify(NID_md5_sha1, buf, 36, buf2,\n                                rsa_num, rsa_key[j]);\n                if (st <= 0) {\n                    BIO_printf(bio_err, "RSA verify failure\\n");\n                    ERR_print_errors(bio_err);\n                    count = 1;\n                    break;\n                }\n            }\n            d = Time_F(STOP);\n            BIO_printf(bio_err,\n                       mr ? "+R2:%ld:%d:%.2f\\n"\n                       : "%ld %d bit public RSA\'s in %.2fs\\n",\n                       count, rsa_bits[j], d);\n            rsa_results[j][1] = d / (double)count;\n        }\n        if (rsa_count <= 1) {\n            for (j++; j < RSA_NUM; j++)\n                rsa_doit[j] = 0;\n        }\n    }\n#endif\n    RAND_bytes(buf, 20);\n#ifndef OPENSSL_NO_DSA\n    if (RAND_status() != 1) {\n        RAND_seed(rnd_seed, sizeof rnd_seed);\n        rnd_fake = 1;\n    }\n    for (j = 0; j < DSA_NUM; j++) {\n        unsigned int kk;\n        int st;\n        if (!dsa_doit[j])\n            continue;\n        st = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2, &kk, dsa_key[j]);\n        if (st == 0) {\n            BIO_printf(bio_err,\n                       "DSA sign failure.  No DSA sign will be done.\\n");\n            ERR_print_errors(bio_err);\n            rsa_count = 1;\n        } else {\n            pkey_print_message("sign", "dsa",\n                               dsa_c[j][0], dsa_bits[j], DSA_SECONDS);\n            Time_F(START);\n            for (count = 0, run = 1; COND(dsa_c[j][0]); count++) {\n                st = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2, &kk, dsa_key[j]);\n                if (st == 0) {\n                    BIO_printf(bio_err, "DSA sign failure\\n");\n                    ERR_print_errors(bio_err);\n                    count = 1;\n                    break;\n                }\n            }\n            d = Time_F(STOP);\n            BIO_printf(bio_err,\n                       mr ? "+R3:%ld:%d:%.2f\\n"\n                       : "%ld %d bit DSA signs in %.2fs\\n",\n                       count, dsa_bits[j], d);\n            dsa_results[j][0] = d / (double)count;\n            rsa_count = count;\n        }\n        st = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2, kk, dsa_key[j]);\n        if (st <= 0) {\n            BIO_printf(bio_err,\n                       "DSA verify failure.  No DSA verify will be done.\\n");\n            ERR_print_errors(bio_err);\n            dsa_doit[j] = 0;\n        } else {\n            pkey_print_message("verify", "dsa",\n                               dsa_c[j][1], dsa_bits[j], DSA_SECONDS);\n            Time_F(START);\n            for (count = 0, run = 1; COND(dsa_c[j][1]); count++) {\n                st = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2, kk, dsa_key[j]);\n                if (st <= 0) {\n                    BIO_printf(bio_err, "DSA verify failure\\n");\n                    ERR_print_errors(bio_err);\n                    count = 1;\n                    break;\n                }\n            }\n            d = Time_F(STOP);\n            BIO_printf(bio_err,\n                       mr ? "+R4:%ld:%d:%.2f\\n"\n                       : "%ld %d bit DSA verify in %.2fs\\n",\n                       count, dsa_bits[j], d);\n            dsa_results[j][1] = d / (double)count;\n        }\n        if (rsa_count <= 1) {\n            for (j++; j < DSA_NUM; j++)\n                dsa_doit[j] = 0;\n        }\n    }\n    if (rnd_fake)\n        RAND_cleanup();\n#endif\n#ifndef OPENSSL_NO_EC\n    if (RAND_status() != 1) {\n        RAND_seed(rnd_seed, sizeof rnd_seed);\n        rnd_fake = 1;\n    }\n    for (j = 0; j < EC_NUM; j++) {\n        int st;\n        if (!ecdsa_doit[j])\n            continue;\n        ecdsa[j] = EC_KEY_new_by_curve_name(test_curves[j]);\n        if (ecdsa[j] == NULL) {\n            BIO_printf(bio_err, "ECDSA failure.\\n");\n            ERR_print_errors(bio_err);\n            rsa_count = 1;\n        } else {\n            EC_KEY_precompute_mult(ecdsa[j], NULL);\n            EC_KEY_generate_key(ecdsa[j]);\n            st = ECDSA_sign(0, buf, 20, ecdsasig, &ecdsasiglen, ecdsa[j]);\n            if (st == 0) {\n                BIO_printf(bio_err,\n                           "ECDSA sign failure.  No ECDSA sign will be done.\\n");\n                ERR_print_errors(bio_err);\n                rsa_count = 1;\n            } else {\n                pkey_print_message("sign", "ecdsa",\n                                   ecdsa_c[j][0],\n                                   test_curves_bits[j], ECDSA_SECONDS);\n                Time_F(START);\n                for (count = 0, run = 1; COND(ecdsa_c[j][0]); count++) {\n                    st = ECDSA_sign(0, buf, 20,\n                                    ecdsasig, &ecdsasiglen, ecdsa[j]);\n                    if (st == 0) {\n                        BIO_printf(bio_err, "ECDSA sign failure\\n");\n                        ERR_print_errors(bio_err);\n                        count = 1;\n                        break;\n                    }\n                }\n                d = Time_F(STOP);\n                BIO_printf(bio_err,\n                           mr ? "+R5:%ld:%d:%.2f\\n" :\n                           "%ld %d bit ECDSA signs in %.2fs \\n",\n                           count, test_curves_bits[j], d);\n                ecdsa_results[j][0] = d / (double)count;\n                rsa_count = count;\n            }\n            st = ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]);\n            if (st != 1) {\n                BIO_printf(bio_err,\n                           "ECDSA verify failure.  No ECDSA verify will be done.\\n");\n                ERR_print_errors(bio_err);\n                ecdsa_doit[j] = 0;\n            } else {\n                pkey_print_message("verify", "ecdsa",\n                                   ecdsa_c[j][1],\n                                   test_curves_bits[j], ECDSA_SECONDS);\n                Time_F(START);\n                for (count = 0, run = 1; COND(ecdsa_c[j][1]); count++) {\n                    st = ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen,\n                                      ecdsa[j]);\n                    if (st != 1) {\n                        BIO_printf(bio_err, "ECDSA verify failure\\n");\n                        ERR_print_errors(bio_err);\n                        count = 1;\n                        break;\n                    }\n                }\n                d = Time_F(STOP);\n                BIO_printf(bio_err,\n                           mr ? "+R6:%ld:%d:%.2f\\n"\n                           : "%ld %d bit ECDSA verify in %.2fs\\n",\n                           count, test_curves_bits[j], d);\n                ecdsa_results[j][1] = d / (double)count;\n            }\n            if (rsa_count <= 1) {\n                for (j++; j < EC_NUM; j++)\n                    ecdsa_doit[j] = 0;\n            }\n        }\n    }\n    if (rnd_fake)\n        RAND_cleanup();\n#endif\n#ifndef OPENSSL_NO_EC\n    if (RAND_status() != 1) {\n        RAND_seed(rnd_seed, sizeof rnd_seed);\n        rnd_fake = 1;\n    }\n    for (j = 0; j < EC_NUM; j++) {\n        if (!ecdh_doit[j])\n            continue;\n        ecdh_a[j] = EC_KEY_new_by_curve_name(test_curves[j]);\n        ecdh_b[j] = EC_KEY_new_by_curve_name(test_curves[j]);\n        if ((ecdh_a[j] == NULL) || (ecdh_b[j] == NULL)) {\n            BIO_printf(bio_err, "ECDH failure.\\n");\n            ERR_print_errors(bio_err);\n            rsa_count = 1;\n        } else {\n            if (!EC_KEY_generate_key(ecdh_a[j]) ||\n                !EC_KEY_generate_key(ecdh_b[j])) {\n                BIO_printf(bio_err, "ECDH key generation failure.\\n");\n                ERR_print_errors(bio_err);\n                rsa_count = 1;\n            } else {\n                int field_size, outlen;\n                void *(*kdf) (const void *in, size_t inlen, void *out,\n                              size_t *xoutlen);\n                field_size =\n                    EC_GROUP_get_degree(EC_KEY_get0_group(ecdh_a[j]));\n                if (field_size <= 24 * 8) {\n                    outlen = KDF1_SHA1_len;\n                    kdf = KDF1_SHA1;\n                } else {\n                    outlen = (field_size + 7) / 8;\n                    kdf = NULL;\n                }\n                secret_size_a =\n                    ECDH_compute_key(secret_a, outlen,\n                                     EC_KEY_get0_public_key(ecdh_b[j]),\n                                     ecdh_a[j], kdf);\n                secret_size_b =\n                    ECDH_compute_key(secret_b, outlen,\n                                     EC_KEY_get0_public_key(ecdh_a[j]),\n                                     ecdh_b[j], kdf);\n                if (secret_size_a != secret_size_b)\n                    ecdh_checks = 0;\n                else\n                    ecdh_checks = 1;\n                for (secret_idx = 0; (secret_idx < secret_size_a)\n                     && (ecdh_checks == 1); secret_idx++) {\n                    if (secret_a[secret_idx] != secret_b[secret_idx])\n                        ecdh_checks = 0;\n                }\n                if (ecdh_checks == 0) {\n                    BIO_printf(bio_err, "ECDH computations don\'t match.\\n");\n                    ERR_print_errors(bio_err);\n                    rsa_count = 1;\n                }\n                pkey_print_message("", "ecdh",\n                                   ecdh_c[j][0],\n                                   test_curves_bits[j], ECDH_SECONDS);\n                Time_F(START);\n                for (count = 0, run = 1; COND(ecdh_c[j][0]); count++) {\n                    ECDH_compute_key(secret_a, outlen,\n                                     EC_KEY_get0_public_key(ecdh_b[j]),\n                                     ecdh_a[j], kdf);\n                }\n                d = Time_F(STOP);\n                BIO_printf(bio_err,\n                           mr ? "+R7:%ld:%d:%.2f\\n" :\n                           "%ld %d-bit ECDH ops in %.2fs\\n", count,\n                           test_curves_bits[j], d);\n                ecdh_results[j][0] = d / (double)count;\n                rsa_count = count;\n            }\n        }\n        if (rsa_count <= 1) {\n            for (j++; j < EC_NUM; j++)\n                ecdh_doit[j] = 0;\n        }\n    }\n    if (rnd_fake)\n        RAND_cleanup();\n#endif\n#ifndef NO_FORK\n show_res:\n#endif\n    if (!mr) {\n        printf("%s\\n", OpenSSL_version(OPENSSL_VERSION));\n        printf("%s\\n", OpenSSL_version(OPENSSL_BUILT_ON));\n        printf("options:");\n        printf("%s ", BN_options());\n#ifndef OPENSSL_NO_MD2\n        printf("%s ", MD2_options());\n#endif\n#ifndef OPENSSL_NO_RC4\n        printf("%s ", RC4_options());\n#endif\n#ifndef OPENSSL_NO_DES\n        printf("%s ", DES_options());\n#endif\n#ifndef OPENSSL_NO_AES\n        printf("%s ", AES_options());\n#endif\n#ifndef OPENSSL_NO_IDEA\n        printf("%s ", idea_options());\n#endif\n#ifndef OPENSSL_NO_BF\n        printf("%s ", BF_options());\n#endif\n        printf("\\n%s\\n", OpenSSL_version(OPENSSL_CFLAGS));\n    }\n    if (pr_header) {\n        if (mr)\n            printf("+H");\n        else {\n            printf\n                ("The \'numbers\' are in 1000s of bytes per second processed.\\n");\n            printf("type        ");\n        }\n        for (j = 0; j < SIZE_NUM; j++)\n            printf(mr ? ":%d" : "%7d bytes", lengths[j]);\n        printf("\\n");\n    }\n    for (k = 0; k < ALGOR_NUM; k++) {\n        if (!doit[k])\n            continue;\n        if (mr)\n            printf("+F:%d:%s", k, names[k]);\n        else\n            printf("%-13s", names[k]);\n        for (j = 0; j < SIZE_NUM; j++) {\n            if (results[k][j] > 10000 && !mr)\n                printf(" %11.2fk", results[k][j] / 1e3);\n            else\n                printf(mr ? ":%.2f" : " %11.2f ", results[k][j]);\n        }\n        printf("\\n");\n    }\n#ifndef OPENSSL_NO_RSA\n    j = 1;\n    for (k = 0; k < RSA_NUM; k++) {\n        if (!rsa_doit[k])\n            continue;\n        if (j && !mr) {\n            printf("%18ssign    verify    sign/s verify/s\\n", " ");\n            j = 0;\n        }\n        if (mr)\n            printf("+F2:%u:%u:%f:%f\\n",\n                   k, rsa_bits[k], rsa_results[k][0], rsa_results[k][1]);\n        else\n            printf("rsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\\n",\n                   rsa_bits[k], rsa_results[k][0], rsa_results[k][1],\n                   1.0 / rsa_results[k][0], 1.0 / rsa_results[k][1]);\n    }\n#endif\n#ifndef OPENSSL_NO_DSA\n    j = 1;\n    for (k = 0; k < DSA_NUM; k++) {\n        if (!dsa_doit[k])\n            continue;\n        if (j && !mr) {\n            printf("%18ssign    verify    sign/s verify/s\\n", " ");\n            j = 0;\n        }\n        if (mr)\n            printf("+F3:%u:%u:%f:%f\\n",\n                   k, dsa_bits[k], dsa_results[k][0], dsa_results[k][1]);\n        else\n            printf("dsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\\n",\n                   dsa_bits[k], dsa_results[k][0], dsa_results[k][1],\n                   1.0 / dsa_results[k][0], 1.0 / dsa_results[k][1]);\n    }\n#endif\n#ifndef OPENSSL_NO_EC\n    j = 1;\n    for (k = 0; k < EC_NUM; k++) {\n        if (!ecdsa_doit[k])\n            continue;\n        if (j && !mr) {\n            printf("%30ssign    verify    sign/s verify/s\\n", " ");\n            j = 0;\n        }\n        if (mr)\n            printf("+F4:%u:%u:%f:%f\\n",\n                   k, test_curves_bits[k],\n                   ecdsa_results[k][0], ecdsa_results[k][1]);\n        else\n            printf("%4u bit ecdsa (%s) %8.4fs %8.4fs %8.1f %8.1f\\n",\n                   test_curves_bits[k],\n                   test_curves_names[k],\n                   ecdsa_results[k][0], ecdsa_results[k][1],\n                   1.0 / ecdsa_results[k][0], 1.0 / ecdsa_results[k][1]);\n    }\n#endif\n#ifndef OPENSSL_NO_EC\n    j = 1;\n    for (k = 0; k < EC_NUM; k++) {\n        if (!ecdh_doit[k])\n            continue;\n        if (j && !mr) {\n            printf("%30sop      op/s\\n", " ");\n            j = 0;\n        }\n        if (mr)\n            printf("+F5:%u:%u:%f:%f\\n",\n                   k, test_curves_bits[k],\n                   ecdh_results[k][0], 1.0 / ecdh_results[k][0]);\n        else\n            printf("%4u bit ecdh (%s) %8.4fs %8.1f\\n",\n                   test_curves_bits[k],\n                   test_curves_names[k],\n                   ecdh_results[k][0], 1.0 / ecdh_results[k][0]);\n    }\n#endif\n    ret = 0;\n end:\n    ERR_print_errors(bio_err);\n    OPENSSL_free(buf_malloc);\n    OPENSSL_free(buf2_malloc);\n#ifndef OPENSSL_NO_RSA\n    for (i = 0; i < RSA_NUM; i++)\n        RSA_free(rsa_key[i]);\n#endif\n#ifndef OPENSSL_NO_DSA\n    for (i = 0; i < DSA_NUM; i++)\n        DSA_free(dsa_key[i]);\n#endif\n#ifndef OPENSSL_NO_EC\n    for (i = 0; i < EC_NUM; i++) {\n        EC_KEY_free(ecdsa[i]);\n        EC_KEY_free(ecdh_a[i]);\n        EC_KEY_free(ecdh_b[i]);\n    }\n#endif\n    return (ret);\n}', 'int opt_int(const char *value, int *result)\n{\n    long l;\n    if (!opt_long(value, &l))\n        return 0;\n    *result = (int)l;\n    if (*result != l) {\n        BIO_printf(bio_err, "%s: Value \\"%s\\" outside integer range\\n",\n                   prog, value);\n        return 0;\n    }\n    return 1;\n}', 'int opt_long(const char *value, long *result)\n{\n    int oerrno = errno;\n    long l;\n    char *endp;\n    l = strtol(value, &endp, 0);\n    if (*endp\n            || endp == value\n            || ((l == LONG_MAX || l == LONG_MIN) && errno == ERANGE)\n            || (l == 0 && errno != 0)) {\n        BIO_printf(bio_err, "%s: Can\'t parse \\"%s\\" as a number\\n",\n                   prog, value);\n        errno = oerrno;\n        return 0;\n    }\n    *result = l;\n    errno = oerrno;\n    return 1;\n}', 'int DSA_sign(int type, const unsigned char *dgst, int dlen,\n             unsigned char *sig, unsigned int *siglen, DSA *dsa)\n{\n    DSA_SIG *s;\n    RAND_seed(dgst, dlen);\n    s = DSA_do_sign(dgst, dlen, dsa);\n    if (s == NULL) {\n        *siglen = 0;\n        return (0);\n    }\n    *siglen = i2d_DSA_SIG(s, &sig);\n    DSA_SIG_free(s);\n    return (1);\n}', 'IMPLEMENT_ASN1_FUNCTIONS_const(DSA_SIG)', 'int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)\n{\n    return asn1_item_flags_i2d(val, out, it, 0);\n}', 'static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,\n                               const ASN1_ITEM *it, int flags)\n{\n    if (out && !*out) {\n        unsigned char *p, *buf;\n        int len;\n        len = ASN1_item_ex_i2d(&val, NULL, it, -1, flags);\n        if (len <= 0)\n            return len;\n        buf = OPENSSL_malloc(len);\n        if (buf == NULL)\n            return -1;\n        p = buf;\n        ASN1_item_ex_i2d(&val, &p, it, -1, flags);\n        *out = buf;\n        return len;\n    }\n    return ASN1_item_ex_i2d(&val, out, it, -1, flags);\n}', 'int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,\n                     const ASN1_ITEM *it, int tag, int aclass)\n{\n    const ASN1_TEMPLATE *tt = NULL;\n    int i, seqcontlen, seqlen, ndef = 1;\n    const ASN1_EXTERN_FUNCS *ef;\n    const ASN1_AUX *aux = it->funcs;\n    ASN1_aux_cb *asn1_cb = 0;\n    if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval)\n        return 0;\n    if (aux && aux->asn1_cb)\n        asn1_cb = aux->asn1_cb;\n    switch (it->itype) {\n    case ASN1_ITYPE_PRIMITIVE:\n        if (it->templates)\n            return asn1_template_ex_i2d(pval, out, it->templates,\n                                        tag, aclass);\n        return asn1_i2d_ex_primitive(pval, out, it, tag, aclass);\n    case ASN1_ITYPE_MSTRING:\n        return asn1_i2d_ex_primitive(pval, out, it, -1, aclass);\n    case ASN1_ITYPE_CHOICE:\n        if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))\n            return 0;\n        i = asn1_get_choice_selector(pval, it);\n        if ((i >= 0) && (i < it->tcount)) {\n            ASN1_VALUE **pchval;\n            const ASN1_TEMPLATE *chtt;\n            chtt = it->templates + i;\n            pchval = asn1_get_field_ptr(pval, chtt);\n            return asn1_template_ex_i2d(pchval, out, chtt, -1, aclass);\n        }\n        if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))\n            return 0;\n        break;\n    case ASN1_ITYPE_EXTERN:\n        ef = it->funcs;\n        return ef->asn1_ex_i2d(pval, out, it, tag, aclass);\n    case ASN1_ITYPE_NDEF_SEQUENCE:\n        if (aclass & ASN1_TFLG_NDEF)\n            ndef = 2;\n    case ASN1_ITYPE_SEQUENCE:\n        i = asn1_enc_restore(&seqcontlen, out, pval, it);\n        if (i < 0)\n            return 0;\n        if (i > 0)\n            return seqcontlen;\n        seqcontlen = 0;\n        if (tag == -1) {\n            tag = V_ASN1_SEQUENCE;\n            aclass = (aclass & ~ASN1_TFLG_TAG_CLASS)\n                | V_ASN1_UNIVERSAL;\n        }\n        if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))\n            return 0;\n        for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {\n            const ASN1_TEMPLATE *seqtt;\n            ASN1_VALUE **pseqval;\n            seqtt = asn1_do_adb(pval, tt, 1);\n            if (!seqtt)\n                return 0;\n            pseqval = asn1_get_field_ptr(pval, seqtt);\n            seqcontlen += asn1_template_ex_i2d(pseqval, NULL, seqtt,\n                                               -1, aclass);\n        }\n        seqlen = ASN1_object_size(ndef, seqcontlen, tag);\n        if (!out)\n            return seqlen;\n        ASN1_put_object(out, ndef, seqcontlen, tag, aclass);\n        for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {\n            const ASN1_TEMPLATE *seqtt;\n            ASN1_VALUE **pseqval;\n            seqtt = asn1_do_adb(pval, tt, 1);\n            if (!seqtt)\n                return 0;\n            pseqval = asn1_get_field_ptr(pval, seqtt);\n            asn1_template_ex_i2d(pseqval, out, seqtt, -1, aclass);\n        }\n        if (ndef == 2)\n            ASN1_put_eoc(out);\n        if (asn1_cb && !asn1_cb(ASN1_OP_I2D_POST, pval, it, NULL))\n            return 0;\n        return seqlen;\n    default:\n        return 0;\n    }\n    return 0;\n}', 'static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,\n                                 const ASN1_ITEM *it, int tag, int aclass)\n{\n    int len;\n    int utype;\n    int usetag;\n    int ndef = 0;\n    utype = it->utype;\n    len = asn1_ex_i2c(pval, NULL, &utype, it);\n    if ((utype == V_ASN1_SEQUENCE) || (utype == V_ASN1_SET) ||\n        (utype == V_ASN1_OTHER))\n        usetag = 0;\n    else\n        usetag = 1;\n    if (len == -1)\n        return 0;\n    if (len == -2) {\n        ndef = 2;\n        len = 0;\n    }\n    if (tag == -1)\n        tag = utype;\n    if (out) {\n        if (usetag)\n            ASN1_put_object(out, ndef, len, tag, aclass);\n        asn1_ex_i2c(pval, *out, &utype, it);\n        if (ndef)\n            ASN1_put_eoc(out);\n        else\n            *out += len;\n    }\n    if (usetag)\n        return ASN1_object_size(ndef, len, tag);\n    return len;\n}', 'void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag,\n                     int xclass)\n{\n    unsigned char *p = *pp;\n    int i, ttag;\n    i = (constructed) ? V_ASN1_CONSTRUCTED : 0;\n    i |= (xclass & V_ASN1_PRIVATE);\n    if (tag < 31)\n        *(p++) = i | (tag & V_ASN1_PRIMITIVE_TAG);\n    else {\n        *(p++) = i | V_ASN1_PRIMITIVE_TAG;\n        for (i = 0, ttag = tag; ttag > 0; i++)\n            ttag >>= 7;\n        ttag = i;\n        while (i-- > 0) {\n            p[i] = tag & 0x7f;\n            if (i != (ttag - 1))\n                p[i] |= 0x80;\n            tag >>= 7;\n        }\n        p += ttag;\n    }\n    if (constructed == 2)\n        *(p++) = 0x80;\n    else\n        asn1_put_length(&p, length);\n    *pp = p;\n}']