ssl/s3_clnt.c:1816: error: BUFFER_OVERRUN_L3
  Offset: [-1, +oo] Size: 28 by call to `tls1_check_curve`.
Showing all 9 steps of the trace


ssl/s3_clnt.c:1441:1: Parameter `*s->init_msg`
1439.   }
1440.   
1441. > int ssl3_get_key_exchange(SSL *s)
1442.   {
1443.   #ifndef OPENSSL_NO_RSA

ssl/s3_clnt.c:1816:14: Call
1814.            * invalid curve. ECParameters is 3 bytes.
1815.            */
1816.           if (!tls1_check_curve(s, data, 3)) {
                     ^
1817.               SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_WRONG_CURVE);
1818.               goto f_err;

ssl/t1_lib.c:266:1: Array declaration
  264.   
  265.   /* The client's default curves / the server's 'auto' curves. */
  266. > static const unsigned char eccurves_auto[] = {
  267.       /* Prefer P-256 which has the fastest and most secure implementations. */
  268.       0, 23,                      /* secp256r1 (23) */

ssl/t1_lib.c:507:20: Call
  505.       for (i = 0; i < num_curves; i++, curves += 2) {
  506.           if (p[1] == curves[0] && p[2] == curves[1])
  507.               return tls_curve_allowed(s, p + 1, SSL_SECOP_CURVE_CHECK);
                            ^
  508.       }
  509.       return 0;

ssl/t1_lib.c:466:1: <Offset trace>
464.   
465.   /* See if curve is allowed by security callback */
466. > static int tls_curve_allowed(SSL *s, const unsigned char *curve, int op)
467.   {
468.       const tls_curve_info *cinfo;

ssl/t1_lib.c:466:1: Parameter `*curve`
    464.   
    465.   /* See if curve is allowed by security callback */
    466. > static int tls_curve_allowed(SSL *s, const unsigned char *curve, int op)
    467.   {
    468.       const tls_curve_info *cinfo;

ssl/t1_lib.c:228:1: <Length trace>
226.   # define TLS_CURVE_PRIME         0x0
227.   
228. > static const tls_curve_info nid_list[] = {
229.       {NID_sect163k1, 80, TLS_CURVE_CHAR2}, /* sect163k1 (1) */
230.       {NID_sect163r1, 80, TLS_CURVE_CHAR2}, /* sect163r1 (2) */

ssl/t1_lib.c:228:1: Array declaration
    226.   # define TLS_CURVE_PRIME         0x0
    227.   
    228. > static const tls_curve_info nid_list[] = {
    229.       {NID_sect163k1, 80, TLS_CURVE_CHAR2}, /* sect163k1 (1) */
    230.       {NID_sect163r1, 80, TLS_CURVE_CHAR2}, /* sect163r1 (2) */

ssl/t1_lib.c:473:5: Array access: Offset: [-1, +oo] Size: 28 by call to `tls1_check_curve` 
    471.       if ((curve[1] < 1) || ((size_t)curve[1] > OSSL_NELEM(nid_list)))
    472.           return 0;
    473.       cinfo = &nid_list[curve[1] - 1];
               ^
    474.   # ifdef OPENSSL_NO_EC2M
    475.       if (cinfo->flags & TLS_CURVE_CHAR2)

static int tls_curve_allowed(SSL *s, const unsigned char *curve, int op)
{
    const tls_curve_info *cinfo;
    if (curve[0])
        return 1;
    if ((curve[1] < 1) || ((size_t)curve[1] > OSSL_NELEM(nid_list)))
        return 0;
    cinfo = &nid_list[curve[1] - 1];
# ifdef OPENSSL_NO_EC2M
    if (cinfo->flags & TLS_CURVE_CHAR2)
        return 0;
# endif
    return ssl_security(s, op, cinfo->secbits, cinfo->nid, (void *)curve);
}
['int ssl3_get_key_exchange(SSL *s)\n{\n#ifndef OPENSSL_NO_RSA\n    unsigned char *q, md_buf[EVP_MAX_MD_SIZE * 2];\n#endif\n    EVP_MD_CTX md_ctx;\n    int al, j, verify_ret, ok;\n    unsigned int i;\n    long n, alg_k, alg_a;\n    EVP_PKEY *pkey = NULL;\n    const EVP_MD *md = NULL;\n#ifndef OPENSSL_NO_RSA\n    RSA *rsa = NULL;\n#endif\n#ifndef OPENSSL_NO_DH\n    DH *dh = NULL;\n#endif\n#ifndef OPENSSL_NO_EC\n    EC_KEY *ecdh = NULL;\n    BN_CTX *bn_ctx = NULL;\n    EC_POINT *srvr_ecpoint = NULL;\n    int curve_nid = 0;\n    unsigned int encoded_pt_len = 0;\n#endif\n    PACKET pkt;\n    unsigned char *data, *param;\n    size_t startparam, endparam;\n    EVP_MD_CTX_init(&md_ctx);\n    n = s->method->ssl_get_message(s,\n                                   SSL3_ST_CR_KEY_EXCH_A,\n                                   SSL3_ST_CR_KEY_EXCH_B,\n                                   -1, s->max_cert_list, &ok);\n    if (!ok)\n        return ((int)n);\n    alg_k = s->s3->tmp.new_cipher->algorithm_mkey;\n    if (s->s3->tmp.message_type != SSL3_MT_SERVER_KEY_EXCHANGE) {\n        if (alg_k & (SSL_kDHE | SSL_kECDHE | SSL_kDHEPSK | SSL_kECDHEPSK)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE);\n            al = SSL_AD_UNEXPECTED_MESSAGE;\n            goto f_err;\n        }\n        s->s3->tmp.reuse_message = 1;\n        return (1);\n    }\n    if (!PACKET_buf_init(&pkt, s->init_msg, n)\n            || !PACKET_get_bookmark(&pkt, &startparam)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n            al = SSL_AD_INTERNAL_ERROR;\n            goto f_err;\n    }\n#ifndef OPENSSL_NO_RSA\n    RSA_free(s->s3->peer_rsa_tmp);\n    s->s3->peer_rsa_tmp = NULL;\n#endif\n#ifndef OPENSSL_NO_DH\n    DH_free(s->s3->peer_dh_tmp);\n    s->s3->peer_dh_tmp = NULL;\n#endif\n#ifndef OPENSSL_NO_EC\n    EC_KEY_free(s->s3->peer_ecdh_tmp);\n    s->s3->peer_ecdh_tmp = NULL;\n#endif\n    alg_a = s->s3->tmp.new_cipher->algorithm_auth;\n    al = SSL_AD_DECODE_ERROR;\n#ifndef OPENSSL_NO_PSK\n    if (alg_k & SSL_PSK) {\n        if (!PACKET_get_net_2(&pkt, &i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (i > PSK_MAX_IDENTITY_LEN) {\n            al = SSL_AD_HANDSHAKE_FAILURE;\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_DATA_LENGTH_TOO_LONG);\n            goto f_err;\n        }\n        if (PACKET_remaining(&pkt) < i) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,\n                   SSL_R_BAD_PSK_IDENTITY_HINT_LENGTH);\n            goto f_err;\n        }\n        OPENSSL_free(s->session->psk_identity_hint);\n        if (i != 0) {\n            unsigned char *hint = NULL;\n            if (!PACKET_get_bytes(&pkt, &hint, i)) {\n                SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_MISMATCH);\n                goto f_err;\n            }\n            s->session->psk_identity_hint = BUF_strndup((char *)hint, i);\n            if (s->session->psk_identity_hint == NULL) {\n                al = SSL_AD_HANDSHAKE_FAILURE;\n                SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE);\n                goto f_err;\n            }\n        } else {\n            s->session->psk_identity_hint = NULL;\n        }\n    }\n    if (alg_k & (SSL_kPSK | SSL_kRSAPSK)) {\n    } else\n#endif\n#ifndef OPENSSL_NO_SRP\n    if (alg_k & SSL_kSRP) {\n        if (!PACKET_get_net_2(&pkt, &i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (!PACKET_get_bytes(&pkt, &data, i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SRP_N_LENGTH);\n            goto f_err;\n        }\n        if ((s->srp_ctx.N = BN_bin2bn(data, i, NULL)) == NULL) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);\n            goto err;\n        }\n        if (!PACKET_get_net_2(&pkt, &i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (!PACKET_get_bytes(&pkt, &data, i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SRP_G_LENGTH);\n            goto f_err;\n        }\n        if ((s->srp_ctx.g = BN_bin2bn(data, i, NULL)) == NULL) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);\n            goto err;\n        }\n        if (!PACKET_get_1(&pkt, &i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (!PACKET_get_bytes(&pkt, &data, i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SRP_S_LENGTH);\n            goto f_err;\n        }\n        if ((s->srp_ctx.s = BN_bin2bn(data, i, NULL)) == NULL) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);\n            goto err;\n        }\n        if (!PACKET_get_net_2(&pkt, &i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (!PACKET_get_bytes(&pkt, &data, i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SRP_B_LENGTH);\n            goto f_err;\n        }\n        if ((s->srp_ctx.B = BN_bin2bn(data, i, NULL)) == NULL) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);\n            goto err;\n        }\n        if (!srp_verify_server_param(s, &al)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SRP_PARAMETERS);\n            goto f_err;\n        }\n        if (alg_a & (SSL_aRSA|SSL_aDSS))\n            pkey = X509_get_pubkey(s->session->peer);\n    } else\n#endif\n#ifndef OPENSSL_NO_RSA\n    if (alg_k & SSL_kRSA) {\n        if (!SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)) {\n            al = SSL_AD_UNEXPECTED_MESSAGE;\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE);\n            goto f_err;\n        }\n        if ((rsa = RSA_new()) == NULL) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        if (!PACKET_get_net_2(&pkt, &i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (!PACKET_get_bytes(&pkt, &data, i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_RSA_MODULUS_LENGTH);\n            goto f_err;\n        }\n        if ((rsa->n = BN_bin2bn(data, i, rsa->n)) == NULL) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);\n            goto err;\n        }\n        if (!PACKET_get_net_2(&pkt, &i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (!PACKET_get_bytes(&pkt, &data, i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_RSA_E_LENGTH);\n            goto f_err;\n        }\n        if ((rsa->e = BN_bin2bn(data, i, rsa->e)) == NULL) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);\n            goto err;\n        }\n        if (alg_a & SSL_aRSA)\n            pkey = X509_get_pubkey(s->session->peer);\n        else {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n        if (EVP_PKEY_bits(pkey) <= SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) {\n            al = SSL_AD_UNEXPECTED_MESSAGE;\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE);\n            goto f_err;\n        }\n        s->s3->peer_rsa_tmp = rsa;\n        rsa = NULL;\n    }\n#else\n    if (0) ;\n#endif\n#ifndef OPENSSL_NO_DH\n    else if (alg_k & (SSL_kDHE | SSL_kDHEPSK)) {\n        if ((dh = DH_new()) == NULL) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_DH_LIB);\n            goto err;\n        }\n        if (!PACKET_get_net_2(&pkt, &i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (!PACKET_get_bytes(&pkt, &data, i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_P_LENGTH);\n            goto f_err;\n        }\n        if ((dh->p = BN_bin2bn(data, i, NULL)) == NULL) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);\n            goto err;\n        }\n        if (BN_is_zero(dh->p)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_P_VALUE);\n            goto f_err;\n        }\n        if (!PACKET_get_net_2(&pkt, &i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (!PACKET_get_bytes(&pkt, &data, i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_G_LENGTH);\n            goto f_err;\n        }\n        if ((dh->g = BN_bin2bn(data, i, NULL)) == NULL) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);\n            goto err;\n        }\n        if (BN_is_zero(dh->g)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_G_VALUE);\n            goto f_err;\n        }\n        if (!PACKET_get_net_2(&pkt, &i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (!PACKET_get_bytes(&pkt, &data, i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_PUB_KEY_LENGTH);\n            goto f_err;\n        }\n        if ((dh->pub_key = BN_bin2bn(data, i, NULL)) == NULL) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);\n            goto err;\n        }\n        if (BN_is_zero(dh->pub_key)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_PUB_KEY_VALUE);\n            goto f_err;\n        }\n        if (!ssl_security(s, SSL_SECOP_TMP_DH, DH_security_bits(dh), 0, dh)) {\n            al = SSL_AD_HANDSHAKE_FAILURE;\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_DH_KEY_TOO_SMALL);\n            goto f_err;\n        }\n        if (alg_a & (SSL_aRSA|SSL_aDSS))\n            pkey = X509_get_pubkey(s->session->peer);\n        s->s3->peer_dh_tmp = dh;\n        dh = NULL;\n    }\n#endif\n#ifndef OPENSSL_NO_EC\n    else if (alg_k & (SSL_kECDHE | SSL_kECDHEPSK)) {\n        EC_GROUP *ngroup;\n        const EC_GROUP *group;\n        if ((ecdh = EC_KEY_new()) == NULL) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        if (!PACKET_get_bytes(&pkt, &data, 3)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (!tls1_check_curve(s, data, 3)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_WRONG_CURVE);\n            goto f_err;\n        }\n        if ((curve_nid = tls1_ec_curve_id2nid(*(data + 2))) == 0) {\n            al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,\n                   SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS);\n            goto f_err;\n        }\n        ngroup = EC_GROUP_new_by_curve_name(curve_nid);\n        if (ngroup == NULL) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_EC_LIB);\n            goto err;\n        }\n        if (EC_KEY_set_group(ecdh, ngroup) == 0) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_EC_LIB);\n            goto err;\n        }\n        EC_GROUP_free(ngroup);\n        group = EC_KEY_get0_group(ecdh);\n        if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) &&\n            (EC_GROUP_get_degree(group) > 163)) {\n            al = SSL_AD_EXPORT_RESTRICTION;\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,\n                   SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER);\n            goto f_err;\n        }\n        if (((srvr_ecpoint = EC_POINT_new(group)) == NULL) ||\n            ((bn_ctx = BN_CTX_new()) == NULL)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        if (!PACKET_get_1(&pkt, &encoded_pt_len)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (!PACKET_get_bytes(&pkt, &data, encoded_pt_len) ||\n            (EC_POINT_oct2point(group, srvr_ecpoint,\n                                data, encoded_pt_len, bn_ctx) == 0)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_ECPOINT);\n            goto f_err;\n        }\n        if (0) ;\n# ifndef OPENSSL_NO_RSA\n        else if (alg_a & SSL_aRSA)\n            pkey = X509_get_pubkey(s->session->peer);\n# endif\n# ifndef OPENSSL_NO_EC\n        else if (alg_a & SSL_aECDSA)\n            pkey = X509_get_pubkey(s->session->peer);\n# endif\n        EC_KEY_set_public_key(ecdh, srvr_ecpoint);\n        s->s3->peer_ecdh_tmp = ecdh;\n        ecdh = NULL;\n        BN_CTX_free(bn_ctx);\n        bn_ctx = NULL;\n        EC_POINT_free(srvr_ecpoint);\n        srvr_ecpoint = NULL;\n    } else if (alg_k) {\n        al = SSL_AD_UNEXPECTED_MESSAGE;\n        SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_UNEXPECTED_MESSAGE);\n        goto f_err;\n    }\n#endif\n    if (!PACKET_get_bookmark(&pkt, &endparam)) {\n        SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n        goto f_err;\n    }\n    if (pkey != NULL) {\n        if (SSL_USE_SIGALGS(s)) {\n            int rv;\n            if (!PACKET_get_bytes(&pkt, &data, 2)) {\n                SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n                goto f_err;\n            }\n            rv = tls12_check_peer_sigalg(&md, s, data, pkey);\n            if (rv == -1)\n                goto err;\n            else if (rv == 0) {\n                goto f_err;\n            }\n#ifdef SSL_DEBUG\n            fprintf(stderr, "USING TLSv1.2 HASH %s\\n", EVP_MD_name(md));\n#endif\n        } else\n            md = EVP_sha1();\n        if (!PACKET_get_net_2(&pkt, &i)) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        j = EVP_PKEY_size(pkey);\n        if (j < 0) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n            goto f_err;\n        }\n        if (i > (unsigned int)j\n                || !PACKET_get_bytes(&pkt, &data, i)\n                || PACKET_remaining(&pkt) != 0) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_WRONG_SIGNATURE_LENGTH);\n            goto f_err;\n        }\n        if (!PACKET_goto_bookmark(&pkt, startparam)\n                || !PACKET_get_bytes(&pkt, &param, endparam - startparam)) {\n            al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n            goto f_err;\n        }\n#ifndef OPENSSL_NO_RSA\n        if (pkey->type == EVP_PKEY_RSA && !SSL_USE_SIGALGS(s)) {\n            int num;\n            unsigned int size;\n            j = 0;\n            q = md_buf;\n            for (num = 2; num > 0; num--) {\n                EVP_MD_CTX_set_flags(&md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);\n                EVP_DigestInit_ex(&md_ctx, (num == 2)\n                                  ? s->ctx->md5 : s->ctx->sha1, NULL);\n                EVP_DigestUpdate(&md_ctx, &(s->s3->client_random[0]),\n                                 SSL3_RANDOM_SIZE);\n                EVP_DigestUpdate(&md_ctx, &(s->s3->server_random[0]),\n                                 SSL3_RANDOM_SIZE);\n                EVP_DigestUpdate(&md_ctx, param, endparam - startparam);\n                EVP_DigestFinal_ex(&md_ctx, q, &size);\n                q += size;\n                j += size;\n            }\n            verify_ret =\n                RSA_verify(NID_md5_sha1, md_buf, j, data, i, pkey->pkey.rsa);\n            if (verify_ret < 0) {\n                al = SSL_AD_DECRYPT_ERROR;\n                SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_RSA_DECRYPT);\n                goto f_err;\n            }\n            if (verify_ret == 0) {\n                al = SSL_AD_DECRYPT_ERROR;\n                SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SIGNATURE);\n                goto f_err;\n            }\n        } else\n#endif\n        {\n            EVP_VerifyInit_ex(&md_ctx, md, NULL);\n            EVP_VerifyUpdate(&md_ctx, &(s->s3->client_random[0]),\n                             SSL3_RANDOM_SIZE);\n            EVP_VerifyUpdate(&md_ctx, &(s->s3->server_random[0]),\n                             SSL3_RANDOM_SIZE);\n            EVP_VerifyUpdate(&md_ctx, param, endparam - startparam);\n            if (EVP_VerifyFinal(&md_ctx, data, (int)i, pkey) <= 0) {\n                al = SSL_AD_DECRYPT_ERROR;\n                SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_SIGNATURE);\n                goto f_err;\n            }\n        }\n    } else {\n        if (!(alg_a & (SSL_aNULL | SSL_aSRP)) && !(alg_k & SSL_PSK)) {\n            if (ssl3_check_cert_and_algorithm(s))\n                SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n        if (PACKET_remaining(&pkt) != 0) {\n            SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_EXTRA_DATA_IN_MESSAGE);\n            goto f_err;\n        }\n    }\n    EVP_PKEY_free(pkey);\n    EVP_MD_CTX_cleanup(&md_ctx);\n    return (1);\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n err:\n    EVP_PKEY_free(pkey);\n#ifndef OPENSSL_NO_RSA\n    RSA_free(rsa);\n#endif\n#ifndef OPENSSL_NO_DH\n    DH_free(dh);\n#endif\n#ifndef OPENSSL_NO_EC\n    BN_CTX_free(bn_ctx);\n    EC_POINT_free(srvr_ecpoint);\n    EC_KEY_free(ecdh);\n#endif\n    EVP_MD_CTX_cleanup(&md_ctx);\n    s->state = SSL_ST_ERR;\n    return (-1);\n}', 'int tls1_check_curve(SSL *s, const unsigned char *p, size_t len)\n{\n    const unsigned char *curves;\n    size_t num_curves, i;\n    unsigned int suiteb_flags = tls1_suiteb(s);\n    if (len != 3 || p[0] != NAMED_CURVE_TYPE)\n        return 0;\n    if (suiteb_flags) {\n        unsigned long cid = s->s3->tmp.new_cipher->id;\n        if (p[1])\n            return 0;\n        if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256) {\n            if (p[2] != TLSEXT_curve_P_256)\n                return 0;\n        } else if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384) {\n            if (p[2] != TLSEXT_curve_P_384)\n                return 0;\n        } else\n            return 0;\n    }\n    if (!tls1_get_curvelist(s, 0, &curves, &num_curves))\n        return 0;\n    for (i = 0; i < num_curves; i++, curves += 2) {\n        if (p[1] == curves[0] && p[2] == curves[1])\n            return tls_curve_allowed(s, p + 1, SSL_SECOP_CURVE_CHECK);\n    }\n    return 0;\n}', 'static int tls_curve_allowed(SSL *s, const unsigned char *curve, int op)\n{\n    const tls_curve_info *cinfo;\n    if (curve[0])\n        return 1;\n    if ((curve[1] < 1) || ((size_t)curve[1] > OSSL_NELEM(nid_list)))\n        return 0;\n    cinfo = &nid_list[curve[1] - 1];\n# ifdef OPENSSL_NO_EC2M\n    if (cinfo->flags & TLS_CURVE_CHAR2)\n        return 0;\n# endif\n    return ssl_security(s, op, cinfo->secbits, cinfo->nid, (void *)curve);\n}']