static int nss_keylog_int(const char *prefix,
                          SSL *ssl,
                          const uint8_t *parameter_1,
                          size_t parameter_1_len,
                          const uint8_t *parameter_2,
                          size_t parameter_2_len)
{
    char *out = NULL;
    char *cursor = NULL;
    size_t out_len = 0;
    size_t i;
    size_t prefix_len;
    if (ssl->ctx->keylog_callback == NULL)
        return 1;
    prefix_len = strlen(prefix);
    out_len = prefix_len + (2 * parameter_1_len) + (2 * parameter_2_len) + 3;
    if ((out = cursor = OPENSSL_malloc(out_len)) == NULL) {
        SSLfatal(ssl, SSL_AD_INTERNAL_ERROR, SSL_F_NSS_KEYLOG_INT,
                 ERR_R_MALLOC_FAILURE);
        return 0;
    }
    strcpy(cursor, prefix);
    cursor += prefix_len;
    *cursor++ = ' ';
    for (i = 0; i < parameter_1_len; i++) {
        sprintf(cursor, "%02x", parameter_1[i]);
        cursor += 2;
    }
    *cursor++ = ' ';
    for (i = 0; i < parameter_2_len; i++) {
        sprintf(cursor, "%02x", parameter_2[i]);
        cursor += 2;
    }
    *cursor = '\0';
    ssl->ctx->keylog_callback(ssl, (const char *)out);
    OPENSSL_clear_free(out, out_len);
    return 1;
}
['static int tls_construct_cke_rsa(SSL *s, WPACKET *pkt)\n{\n#ifndef OPENSSL_NO_RSA\n    unsigned char *encdata = NULL;\n    EVP_PKEY *pkey = NULL;\n    EVP_PKEY_CTX *pctx = NULL;\n    size_t enclen;\n    unsigned char *pms = NULL;\n    size_t pmslen = 0;\n    if (s->session->peer == NULL) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,\n                 ERR_R_INTERNAL_ERROR);\n        return 0;\n    }\n    pkey = X509_get0_pubkey(s->session->peer);\n    if (EVP_PKEY_get0_RSA(pkey) == NULL) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,\n                 ERR_R_INTERNAL_ERROR);\n        return 0;\n    }\n    pmslen = SSL_MAX_MASTER_KEY_LENGTH;\n    pms = OPENSSL_malloc(pmslen);\n    if (pms == NULL) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,\n                 ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    pms[0] = s->client_version >> 8;\n    pms[1] = s->client_version & 0xff;\n    if (RAND_bytes(pms + 2, (int)(pmslen - 2)) <= 0) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,\n                 ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (s->version > SSL3_VERSION && !WPACKET_start_sub_packet_u16(pkt)) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,\n                 ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    pctx = EVP_PKEY_CTX_new(pkey, NULL);\n    if (pctx == NULL || EVP_PKEY_encrypt_init(pctx) <= 0\n        || EVP_PKEY_encrypt(pctx, NULL, &enclen, pms, pmslen) <= 0) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,\n                 ERR_R_EVP_LIB);\n        goto err;\n    }\n    if (!WPACKET_allocate_bytes(pkt, enclen, &encdata)\n            || EVP_PKEY_encrypt(pctx, encdata, &enclen, pms, pmslen) <= 0) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,\n                 SSL_R_BAD_RSA_ENCRYPT);\n        goto err;\n    }\n    EVP_PKEY_CTX_free(pctx);\n    pctx = NULL;\n    if (s->version > SSL3_VERSION && !WPACKET_close(pkt)) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,\n                 ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    if (!ssl_log_rsa_client_key_exchange(s, encdata, enclen, pms, pmslen)) {\n        goto err;\n    }\n    s->s3->tmp.pms = pms;\n    s->s3->tmp.pmslen = pmslen;\n    return 1;\n err:\n    OPENSSL_clear_free(pms, pmslen);\n    EVP_PKEY_CTX_free(pctx);\n    return 0;\n#else\n    SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,\n             ERR_R_INTERNAL_ERROR);\n    return 0;\n#endif\n}', 'int ssl_log_rsa_client_key_exchange(SSL *ssl,\n                                    const uint8_t *encrypted_premaster,\n                                    size_t encrypted_premaster_len,\n                                    const uint8_t *premaster,\n                                    size_t premaster_len)\n{\n    if (encrypted_premaster_len < 8) {\n        SSLfatal(ssl, SSL_AD_INTERNAL_ERROR,\n                 SSL_F_SSL_LOG_RSA_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n        return 0;\n    }\n    return nss_keylog_int("RSA",\n                          ssl,\n                          encrypted_premaster,\n                          8,\n                          premaster,\n                          premaster_len);\n}', 'static int nss_keylog_int(const char *prefix,\n                          SSL *ssl,\n                          const uint8_t *parameter_1,\n                          size_t parameter_1_len,\n                          const uint8_t *parameter_2,\n                          size_t parameter_2_len)\n{\n    char *out = NULL;\n    char *cursor = NULL;\n    size_t out_len = 0;\n    size_t i;\n    size_t prefix_len;\n    if (ssl->ctx->keylog_callback == NULL)\n        return 1;\n    prefix_len = strlen(prefix);\n    out_len = prefix_len + (2 * parameter_1_len) + (2 * parameter_2_len) + 3;\n    if ((out = cursor = OPENSSL_malloc(out_len)) == NULL) {\n        SSLfatal(ssl, SSL_AD_INTERNAL_ERROR, SSL_F_NSS_KEYLOG_INT,\n                 ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    strcpy(cursor, prefix);\n    cursor += prefix_len;\n    *cursor++ = \' \';\n    for (i = 0; i < parameter_1_len; i++) {\n        sprintf(cursor, "%02x", parameter_1[i]);\n        cursor += 2;\n    }\n    *cursor++ = \' \';\n    for (i = 0; i < parameter_2_len; i++) {\n        sprintf(cursor, "%02x", parameter_2[i]);\n        cursor += 2;\n    }\n    *cursor = \'\\0\';\n    ssl->ctx->keylog_callback(ssl, (const char *)out);\n    OPENSSL_clear_free(out, out_len);\n    return 1;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    if (allow_customize) {\n        allow_customize = 0;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}']