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] >
                           sizeof(nid_list) / sizeof(nid_list[0])))
        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 tls1_shared_curve(SSL *s, int nmatch)\n{\n    const unsigned char *pref, *supp;\n    size_t num_pref, num_supp, i, j;\n    int k;\n    if (s->server == 0)\n        return -1;\n    if (nmatch == -2) {\n        if (tls1_suiteb(s)) {\n            unsigned long cid = s->s3->tmp.new_cipher->id;\n            if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256)\n                return NID_X9_62_prime256v1;\n            if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384)\n                return NID_secp384r1;\n            return NID_undef;\n        }\n        nmatch = 0;\n    }\n    if (!tls1_get_curvelist\n        (s, (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE) != 0, &supp,\n         &num_supp))\n        return nmatch == -1 ? 0 : NID_undef;\n    if (!tls1_get_curvelist\n        (s, !(s->options & SSL_OP_CIPHER_SERVER_PREFERENCE), &pref,\n         &num_pref))\n        return nmatch == -1 ? 0 : NID_undef;\n    k = 0;\n    for (i = 0; i < num_pref; i++, pref += 2) {\n        const unsigned char *tsupp = supp;\n        for (j = 0; j < num_supp; j++, tsupp += 2) {\n            if (pref[0] == tsupp[0] && pref[1] == tsupp[1]) {\n                if (!tls_curve_allowed(s, pref, SSL_SECOP_CURVE_SHARED))\n                    continue;\n                if (nmatch == k) {\n                    int id = (pref[0] << 8) | pref[1];\n                    return tls1_ec_curve_id2nid(id);\n                }\n                k++;\n            }\n        }\n    }\n    if (nmatch == -1)\n        return k;\n    return NID_undef;\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] >\n                           sizeof(nid_list) / sizeof(nid_list[0])))\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}']