void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size)
{
    size_t i;
    if (in) {
        out += size - 1;
        for (i = 0; i < size; i++)
            *out-- = *in++;
    } else {
        unsigned char *q;
        char c;
        q = out + size - 1;
        for (i = 0; i < size / 2; i++) {
            c = *q;
            *q-- = *out;
            *out++ = c;
        }
    }
}
['MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt)\n{\n    EVP_PKEY *pkey = NULL;\n    const unsigned char *data;\n#ifndef OPENSSL_NO_GOST\n    unsigned char *gost_data = NULL;\n#endif\n    int al = SSL_AD_INTERNAL_ERROR, ret = MSG_PROCESS_ERROR;\n    int type = 0, j;\n    unsigned int len;\n    X509 *peer;\n    const EVP_MD *md = NULL;\n    size_t hdatalen = 0;\n    void *hdata;\n    unsigned char tls13tbs[TLS13_TBS_PREAMBLE_SIZE + EVP_MAX_MD_SIZE];\n    EVP_MD_CTX *mctx = EVP_MD_CTX_new();\n    EVP_PKEY_CTX *pctx = NULL;\n    if (mctx == NULL) {\n        SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_MALLOC_FAILURE);\n        goto f_err;\n    }\n    peer = s->session->peer;\n    pkey = X509_get0_pubkey(peer);\n    if (pkey == NULL)\n        goto f_err;\n    type = X509_certificate_type(peer, pkey);\n    if (!(type & EVP_PKT_SIGN)) {\n        SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY,\n               SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE);\n        al = SSL_AD_ILLEGAL_PARAMETER;\n        goto f_err;\n    }\n    if (SSL_USE_SIGALGS(s)) {\n        int rv;\n        unsigned int sigalg;\n        if (!PACKET_get_net_2(pkt, &sigalg)) {\n            al = SSL_AD_DECODE_ERROR;\n            goto f_err;\n        }\n        rv = tls12_check_peer_sigalg(s, sigalg, pkey);\n        if (rv == -1) {\n            goto f_err;\n        } else if (rv == 0) {\n            al = SSL_AD_DECODE_ERROR;\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 if (!tls1_set_peer_legacy_sigalg(s, pkey)) {\n            al = SSL_AD_INTERNAL_ERROR;\n            goto f_err;\n    }\n    md = ssl_md(s->s3->tmp.peer_sigalg->hash_idx);\n#ifndef OPENSSL_NO_GOST\n    if (!SSL_USE_SIGALGS(s)\n        && ((PACKET_remaining(pkt) == 64\n             && (EVP_PKEY_id(pkey) == NID_id_GostR3410_2001\n                 || EVP_PKEY_id(pkey) == NID_id_GostR3410_2012_256))\n            || (PACKET_remaining(pkt) == 128\n                && EVP_PKEY_id(pkey) == NID_id_GostR3410_2012_512))) {\n        len = PACKET_remaining(pkt);\n    } else\n#endif\n    if (!PACKET_get_net_2(pkt, &len)) {\n        SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_LENGTH_MISMATCH);\n        al = SSL_AD_DECODE_ERROR;\n        goto f_err;\n    }\n    j = EVP_PKEY_size(pkey);\n    if (((int)len > j) || ((int)PACKET_remaining(pkt) > j)\n        || (PACKET_remaining(pkt) == 0)) {\n        SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_WRONG_SIGNATURE_SIZE);\n        al = SSL_AD_DECODE_ERROR;\n        goto f_err;\n    }\n    if (!PACKET_get_bytes(pkt, &data, len)) {\n        SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_LENGTH_MISMATCH);\n        al = SSL_AD_DECODE_ERROR;\n        goto f_err;\n    }\n    if (!get_cert_verify_tbs_data(s, tls13tbs, &hdata, &hdatalen)) {\n        SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_INTERNAL_ERROR);\n        goto f_err;\n    }\n#ifdef SSL_DEBUG\n    fprintf(stderr, "Using client verify alg %s\\n", EVP_MD_name(md));\n#endif\n    if (EVP_DigestVerifyInit(mctx, &pctx, md, NULL, pkey) <= 0) {\n        SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_EVP_LIB);\n        goto f_err;\n    }\n#ifndef OPENSSL_NO_GOST\n    {\n        int pktype = EVP_PKEY_id(pkey);\n        if (pktype == NID_id_GostR3410_2001\n            || pktype == NID_id_GostR3410_2012_256\n            || pktype == NID_id_GostR3410_2012_512) {\n            if ((gost_data = OPENSSL_malloc(len)) == NULL) {\n                SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_MALLOC_FAILURE);\n                goto f_err;\n            }\n            BUF_reverse(gost_data, data, len);\n            data = gost_data;\n        }\n    }\n#endif\n    if (SSL_USE_PSS(s)) {\n        if (EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING) <= 0\n            || EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx,\n                                                RSA_PSS_SALTLEN_DIGEST) <= 0) {\n            SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_EVP_LIB);\n            goto f_err;\n        }\n    }\n    if (s->version == SSL3_VERSION) {\n        if (EVP_DigestVerifyUpdate(mctx, hdata, hdatalen) <= 0\n                || !EVP_MD_CTX_ctrl(mctx, EVP_CTRL_SSL3_MASTER_SECRET,\n                                    (int)s->session->master_key_length,\n                                    s->session->master_key)) {\n            SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_EVP_LIB);\n            goto f_err;\n        }\n        if (EVP_DigestVerifyFinal(mctx, data, len) <= 0) {\n            al = SSL_AD_DECRYPT_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_BAD_SIGNATURE);\n            goto f_err;\n        }\n    } else {\n        j = EVP_DigestVerify(mctx, data, len, hdata, hdatalen);\n        if (j < 0) {\n            SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_EVP_LIB);\n            goto f_err;\n        } else if (j == 0) {\n            al = SSL_AD_DECRYPT_ERROR;\n            SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, SSL_R_BAD_SIGNATURE);\n            goto f_err;\n        }\n    }\n    ret = MSG_PROCESS_CONTINUE_READING;\n    if (0) {\n f_err:\n        ssl3_send_alert(s, SSL3_AL_FATAL, al);\n        ossl_statem_set_error(s);\n    }\n    BIO_free(s->s3->handshake_buffer);\n    s->s3->handshake_buffer = NULL;\n    EVP_MD_CTX_free(mctx);\n#ifndef OPENSSL_NO_GOST\n    OPENSSL_free(gost_data);\n#endif\n    return ret;\n}', 'int EVP_PKEY_size(EVP_PKEY *pkey)\n{\n    if (pkey && pkey->ameth && pkey->ameth->pkey_size)\n        return pkey->ameth->pkey_size(pkey);\n    return 0;\n}', 'void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size)\n{\n    size_t i;\n    if (in) {\n        out += size - 1;\n        for (i = 0; i < size; i++)\n            *out-- = *in++;\n    } else {\n        unsigned char *q;\n        char c;\n        q = out + size - 1;\n        for (i = 0; i < size / 2; i++) {\n            c = *q;\n            *q-- = *out;\n            *out++ = c;\n        }\n    }\n}']