ssl/statem/statem_clnt.c:2857: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_malloc()` at line 2809, column 11 is not reachable after line 2857, column 5.
Showing all 68 steps of the trace


ssl/statem/statem_clnt.c:2784:1: start of procedure tls_construct_cke_rsa()
2782.   }
2783.   
2784. > static int tls_construct_cke_rsa(SSL *s, WPACKET *pkt, int *al)
2785.   {
2786.   #ifndef OPENSSL_NO_RSA

ssl/statem/statem_clnt.c:2787:5: 
2785.   {
2786.   #ifndef OPENSSL_NO_RSA
2787. >     unsigned char *encdata = NULL;
2788.       EVP_PKEY *pkey = NULL;
2789.       EVP_PKEY_CTX *pctx = NULL;

ssl/statem/statem_clnt.c:2788:5: 
2786.   #ifndef OPENSSL_NO_RSA
2787.       unsigned char *encdata = NULL;
2788. >     EVP_PKEY *pkey = NULL;
2789.       EVP_PKEY_CTX *pctx = NULL;
2790.       size_t enclen;

ssl/statem/statem_clnt.c:2789:5: 
2787.       unsigned char *encdata = NULL;
2788.       EVP_PKEY *pkey = NULL;
2789. >     EVP_PKEY_CTX *pctx = NULL;
2790.       size_t enclen;
2791.       unsigned char *pms = NULL;

ssl/statem/statem_clnt.c:2791:5: 
2789.       EVP_PKEY_CTX *pctx = NULL;
2790.       size_t enclen;
2791. >     unsigned char *pms = NULL;
2792.       size_t pmslen = 0;
2793.   

ssl/statem/statem_clnt.c:2792:5: 
2790.       size_t enclen;
2791.       unsigned char *pms = NULL;
2792. >     size_t pmslen = 0;
2793.   
2794.       if (s->session->peer == NULL) {

ssl/statem/statem_clnt.c:2794:9: Taking false branch
2792.       size_t pmslen = 0;
2793.   
2794.       if (s->session->peer == NULL) {
                ^
2795.           /*
2796.            * We should always have a server certificate with SSL_kRSA.

ssl/statem/statem_clnt.c:2802:5: 
2800.       }
2801.   
2802. >     pkey = X509_get0_pubkey(s->session->peer);
2803.       if (EVP_PKEY_get0_RSA(pkey) == NULL) {
2804.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);

crypto/x509/x509_cmp.c:265:1: start of procedure X509_get0_pubkey()
  263.   }
  264.   
  265. > EVP_PKEY *X509_get0_pubkey(const X509 *x)
  266.   {
  267.       if (x == NULL)

crypto/x509/x509_cmp.c:267:9: Taking false branch
  265.   EVP_PKEY *X509_get0_pubkey(const X509 *x)
  266.   {
  267.       if (x == NULL)
                 ^
  268.           return NULL;
  269.       return X509_PUBKEY_get0(x->cert_info.key);

crypto/x509/x509_cmp.c:269:5: 
  267.       if (x == NULL)
  268.           return NULL;
  269. >     return X509_PUBKEY_get0(x->cert_info.key);
  270.   }
  271.   

crypto/x509/x_pubkey.c:140:1: start of procedure X509_PUBKEY_get0()
    138.   }
    139.   
    140. > EVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key)
    141.   {
    142.       EVP_PKEY *ret = NULL;

crypto/x509/x_pubkey.c:142:5: 
    140.   EVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key)
    141.   {
    142. >     EVP_PKEY *ret = NULL;
    143.   
    144.       if (key == NULL || key->public_key == NULL)

crypto/x509/x_pubkey.c:144:9: Taking false branch
    142.       EVP_PKEY *ret = NULL;
    143.   
    144.       if (key == NULL || key->public_key == NULL)
                   ^
    145.           return NULL;
    146.   

crypto/x509/x_pubkey.c:144:24: Taking false branch
    142.       EVP_PKEY *ret = NULL;
    143.   
    144.       if (key == NULL || key->public_key == NULL)
                                  ^
    145.           return NULL;
    146.   

crypto/x509/x_pubkey.c:147:9: Taking true branch
    145.           return NULL;
    146.   
    147.       if (key->pkey != NULL)
                   ^
    148.           return key->pkey;
    149.   

crypto/x509/x_pubkey.c:148:9: 
    146.   
    147.       if (key->pkey != NULL)
    148. >         return key->pkey;
    149.   
    150.       /*

crypto/x509/x_pubkey.c:166:1: return from a call to X509_PUBKEY_get0
    164.   
    165.       return NULL;
    166. > }
    167.   
    168.   EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)

crypto/x509/x509_cmp.c:270:1: return from a call to X509_get0_pubkey
  268.           return NULL;
  269.       return X509_PUBKEY_get0(x->cert_info.key);
  270. > }
  271.   
  272.   EVP_PKEY *X509_get_pubkey(X509 *x)

ssl/statem/statem_clnt.c:2803:9: 
2801.   
2802.       pkey = X509_get0_pubkey(s->session->peer);
2803. >     if (EVP_PKEY_get0_RSA(pkey) == NULL) {
2804.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);
2805.           return 0;

crypto/evp/p_lib.c:290:1: start of procedure EVP_PKEY_get0_RSA()
  288.   }
  289.   
  290. > RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
  291.   {
  292.       if (pkey->type != EVP_PKEY_RSA) {

crypto/evp/p_lib.c:292:9: Taking false branch
  290.   RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
  291.   {
  292.       if (pkey->type != EVP_PKEY_RSA) {
                 ^
  293.           EVPerr(EVP_F_EVP_PKEY_GET0_RSA, EVP_R_EXPECTING_AN_RSA_KEY);
  294.           return NULL;

crypto/evp/p_lib.c:296:5: 
  294.           return NULL;
  295.       }
  296. >     return pkey->pkey.rsa;
  297.   }
  298.   

crypto/evp/p_lib.c:297:1: return from a call to EVP_PKEY_get0_RSA
  295.       }
  296.       return pkey->pkey.rsa;
  297. > }
  298.   
  299.   RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey)

ssl/statem/statem_clnt.c:2803:9: Taking false branch
2801.   
2802.       pkey = X509_get0_pubkey(s->session->peer);
2803.       if (EVP_PKEY_get0_RSA(pkey) == NULL) {
                ^
2804.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);
2805.           return 0;

ssl/statem/statem_clnt.c:2808:5: 
2806.       }
2807.   
2808. >     pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2809.       pms = OPENSSL_malloc(pmslen);
2810.       if (pms == NULL) {

ssl/statem/statem_clnt.c:2809:5: 
2807.   
2808.       pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2809. >     pms = OPENSSL_malloc(pmslen);
2810.       if (pms == NULL) {
2811.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_MALLOC_FAILURE);

crypto/mem.c:169:1: start of procedure CRYPTO_malloc()
  167.   #endif
  168.   
  169. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  170.   {
  171.       void *ret = NULL;

crypto/mem.c:171:5: 
  169.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  170.   {
  171. >     void *ret = NULL;
  172.   
  173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:173:9: Taking false branch
  171.       void *ret = NULL;
  172.   
  173.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  174.           return malloc_impl(num, file, line);
  175.   

crypto/mem.c:176:9: Taking false branch
  174.           return malloc_impl(num, file, line);
  175.   
  176.       if (num == 0)
                 ^
  177.           return NULL;
  178.   

crypto/mem.c:180:5: 
  178.   
  179.       FAILTEST();
  180. >     allow_customize = 0;
  181.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  182.       if (call_malloc_debug) {

crypto/mem.c:190:5: 
  188.       }
  189.   #else
  190. >     osslargused(file); osslargused(line);
  191.       ret = malloc(num);
  192.   #endif

crypto/mem.c:190:24: 
  188.       }
  189.   #else
  190. >     osslargused(file); osslargused(line);
  191.       ret = malloc(num);
  192.   #endif

crypto/mem.c:191:5: 
  189.   #else
  190.       osslargused(file); osslargused(line);
  191. >     ret = malloc(num);
  192.   #endif
  193.   

crypto/mem.c:194:5: 
  192.   #endif
  193.   
  194. >     return ret;
  195.   }
  196.   

crypto/mem.c:195:1: return from a call to CRYPTO_malloc
  193.   
  194.       return ret;
  195. > }
  196.   
  197.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

ssl/statem/statem_clnt.c:2810:9: Taking false branch
2808.       pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2809.       pms = OPENSSL_malloc(pmslen);
2810.       if (pms == NULL) {
                ^
2811.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_MALLOC_FAILURE);
2812.           *al = SSL_AD_INTERNAL_ERROR;

ssl/statem/statem_clnt.c:2816:5: 
2814.       }
2815.   
2816. >     pms[0] = s->client_version >> 8;
2817.       pms[1] = s->client_version & 0xff;
2818.       /* TODO(size_t): Convert this function */

ssl/statem/statem_clnt.c:2817:5: 
2815.   
2816.       pms[0] = s->client_version >> 8;
2817. >     pms[1] = s->client_version & 0xff;
2818.       /* TODO(size_t): Convert this function */
2819.       if (ssl_randbytes(s, pms + 2, (int)(pmslen - 2)) <= 0) {

ssl/statem/statem_clnt.c:2819:9: 
2817.       pms[1] = s->client_version & 0xff;
2818.       /* TODO(size_t): Convert this function */
2819. >     if (ssl_randbytes(s, pms + 2, (int)(pmslen - 2)) <= 0) {
2820.           goto err;
2821.       }

ssl/ssl_lib.c:5097:1: start of procedure ssl_randbytes()
  5095.   }
  5096.   
  5097. > int ssl_randbytes(SSL *s, unsigned char *rnd, size_t size)
  5098.   {
  5099.       if (s->drbg != NULL)

ssl/ssl_lib.c:5099:9: Taking true branch
  5097.   int ssl_randbytes(SSL *s, unsigned char *rnd, size_t size)
  5098.   {
  5099.       if (s->drbg != NULL)
                  ^
  5100.           return RAND_DRBG_generate(s->drbg, rnd, size, 0, NULL, 0);
  5101.       return RAND_bytes(rnd, (int)size);

ssl/ssl_lib.c:5100:9: 
  5098.   {
  5099.       if (s->drbg != NULL)
  5100. >         return RAND_DRBG_generate(s->drbg, rnd, size, 0, NULL, 0);
  5101.       return RAND_bytes(rnd, (int)size);
  5102.   }

crypto/rand/drbg_lib.c:248:1: start of procedure RAND_DRBG_generate()
    246.    * sent in |adin| and |adinlen|.
    247.    */
    248. > int RAND_DRBG_generate(RAND_DRBG *drbg, unsigned char *out, size_t outlen,
    249.                          int prediction_resistance,
    250.                          const unsigned char *adin, size_t adinlen)

crypto/rand/drbg_lib.c:252:9: Taking false branch
    250.                          const unsigned char *adin, size_t adinlen)
    251.   {
    252.       if (drbg->state == DRBG_ERROR) {
                   ^
    253.           RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_IN_ERROR_STATE);
    254.           return 0;

crypto/rand/drbg_lib.c:256:9: Taking false branch
    254.           return 0;
    255.       }
    256.       if (drbg->state == DRBG_UNINITIALISED) {
                   ^
    257.           RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_NOT_INSTANTIATED);
    258.           return 0;

crypto/rand/drbg_lib.c:260:9: Taking false branch
    258.           return 0;
    259.       }
    260.       if (outlen > drbg->max_request) {
                   ^
    261.           RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_REQUEST_TOO_LARGE_FOR_DRBG);
    262.           return 0;

crypto/rand/drbg_lib.c:264:9: Taking true branch
    262.           return 0;
    263.       }
    264.       if (adinlen > drbg->max_adin) {
                   ^
    265.           RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_ADDITIONAL_INPUT_TOO_LONG);
    266.           return 0;

crypto/rand/drbg_lib.c:265:9: Skipping ERR_put_error(): empty list of specs
    263.       }
    264.       if (adinlen > drbg->max_adin) {
    265.           RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_ADDITIONAL_INPUT_TOO_LONG);
                   ^
    266.           return 0;
    267.       }

crypto/rand/drbg_lib.c:266:9: 
    264.       if (adinlen > drbg->max_adin) {
    265.           RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_ADDITIONAL_INPUT_TOO_LONG);
    266. >         return 0;
    267.       }
    268.   

crypto/rand/drbg_lib.c:292:1: return from a call to RAND_DRBG_generate
    290.           drbg->reseed_counter++;
    291.       return 1;
    292. > }
    293.   
    294.   /*

ssl/ssl_lib.c:5102:1: return from a call to ssl_randbytes
  5100.           return RAND_DRBG_generate(s->drbg, rnd, size, 0, NULL, 0);
  5101.       return RAND_bytes(rnd, (int)size);
  5102. > }

ssl/statem/statem_clnt.c:2819:9: Taking true branch
2817.       pms[1] = s->client_version & 0xff;
2818.       /* TODO(size_t): Convert this function */
2819.       if (ssl_randbytes(s, pms + 2, (int)(pmslen - 2)) <= 0) {
                ^
2820.           goto err;
2821.       }

ssl/statem/statem_clnt.c:2856:2: 
2854.   
2855.       return 1;
2856. >  err:
2857.       OPENSSL_clear_free(pms, pmslen);
2858.       EVP_PKEY_CTX_free(pctx);

ssl/statem/statem_clnt.c:2857:5: 
2855.       return 1;
2856.    err:
2857. >     OPENSSL_clear_free(pms, pmslen);
2858.       EVP_PKEY_CTX_free(pctx);
2859.   

crypto/mem.c:284:1: start of procedure CRYPTO_clear_free()
  282.   }
  283.   
  284. > void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)
  285.   {
  286.       if (str == NULL)

crypto/mem.c:286:9: Taking false branch
  284.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)
  285.   {
  286.       if (str == NULL)
                 ^
  287.           return;
  288.       if (num)

crypto/mem.c:288:9: Taking true branch
  286.       if (str == NULL)
  287.           return;
  288.       if (num)
                 ^
  289.           OPENSSL_cleanse(str, num);
  290.       CRYPTO_free(str, file, line);

crypto/mem.c:289:9: Skipping OPENSSL_cleanse(): method has no implementation
  287.           return;
  288.       if (num)
  289.           OPENSSL_cleanse(str, num);
                 ^
  290.       CRYPTO_free(str, file, line);
  291.   }

crypto/mem.c:290:5: 
  288.       if (num)
  289.           OPENSSL_cleanse(str, num);
  290. >     CRYPTO_free(str, file, line);
  291.   }

crypto/mem.c:264:1: start of procedure CRYPTO_free()
    262.   }
    263.   
    264. > void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:266:9: Taking true branch
    264.   void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    267.           free_impl(str, file, line);
    268.           return;

crypto/mem.c:266:30: Taking true branch
    264.   void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    267.           free_impl(str, file, line);
    268.           return;

crypto/mem.c:267:9: Skipping __function_pointer__(): unresolved function pointer
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    267.           free_impl(str, file, line);
                   ^
    268.           return;
    269.       }

crypto/mem.c:268:9: 
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    267.           free_impl(str, file, line);
    268. >         return;
    269.       }
    270.   

crypto/mem.c:282:1: return from a call to CRYPTO_free
    280.       free(str);
    281.   #endif
    282. > }
    283.   
    284.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/mem.c:291:1: return from a call to CRYPTO_clear_free
  289.           OPENSSL_cleanse(str, num);
  290.       CRYPTO_free(str, file, line);
  291. > }

static int tls_construct_cke_rsa(SSL *s, WPACKET *pkt, int *al)
{
#ifndef OPENSSL_NO_RSA
    unsigned char *encdata = NULL;
    EVP_PKEY *pkey = NULL;
    EVP_PKEY_CTX *pctx = NULL;
    size_t enclen;
    unsigned char *pms = NULL;
    size_t pmslen = 0;
    if (s->session->peer == NULL) {
        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);
        return 0;
    }
    pkey = X509_get0_pubkey(s->session->peer);
    if (EVP_PKEY_get0_RSA(pkey) == NULL) {
        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);
        return 0;
    }
    pmslen = SSL_MAX_MASTER_KEY_LENGTH;
    pms = OPENSSL_malloc(pmslen);
    if (pms == NULL) {
        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_MALLOC_FAILURE);
        *al = SSL_AD_INTERNAL_ERROR;
        return 0;
    }
    pms[0] = s->client_version >> 8;
    pms[1] = s->client_version & 0xff;
    if (ssl_randbytes(s, pms + 2, (int)(pmslen - 2)) <= 0) {
        goto err;
    }
    if (s->version > SSL3_VERSION && !WPACKET_start_sub_packet_u16(pkt)) {
        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);
        goto err;
    }
    pctx = EVP_PKEY_CTX_new(pkey, NULL);
    if (pctx == NULL || EVP_PKEY_encrypt_init(pctx) <= 0
        || EVP_PKEY_encrypt(pctx, NULL, &enclen, pms, pmslen) <= 0) {
        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_EVP_LIB);
        goto err;
    }
    if (!WPACKET_allocate_bytes(pkt, enclen, &encdata)
            || EVP_PKEY_encrypt(pctx, encdata, &enclen, pms, pmslen) <= 0) {
        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, SSL_R_BAD_RSA_ENCRYPT);
        goto err;
    }
    EVP_PKEY_CTX_free(pctx);
    pctx = NULL;
    if (s->version > SSL3_VERSION && !WPACKET_close(pkt)) {
        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);
        goto err;
    }
    if (!ssl_log_rsa_client_key_exchange(s, encdata, enclen, pms, pmslen))
        goto err;
    s->s3->tmp.pms = pms;
    s->s3->tmp.pmslen = pmslen;
    return 1;
 err:
    OPENSSL_clear_free(pms, pmslen);
    EVP_PKEY_CTX_free(pctx);
    return 0;
#else
    SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);
    *al = SSL_AD_INTERNAL_ERROR;
    return 0;
#endif
}
['static int tls_construct_cke_rsa(SSL *s, WPACKET *pkt, int *al)\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        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, 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        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, 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        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_MALLOC_FAILURE);\n        *al = SSL_AD_INTERNAL_ERROR;\n        return 0;\n    }\n    pms[0] = s->client_version >> 8;\n    pms[1] = s->client_version & 0xff;\n    if (ssl_randbytes(s, pms + 2, (int)(pmslen - 2)) <= 0) {\n        goto err;\n    }\n    if (s->version > SSL3_VERSION && !WPACKET_start_sub_packet_u16(pkt)) {\n        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, 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        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, 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        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, 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        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, 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    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    SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);\n    *al = SSL_AD_INTERNAL_ERROR;\n    return 0;\n#endif\n}', 'EVP_PKEY *X509_get0_pubkey(const X509 *x)\n{\n    if (x == NULL)\n        return NULL;\n    return X509_PUBKEY_get0(x->cert_info.key);\n}', 'EVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key)\n{\n    EVP_PKEY *ret = NULL;\n    if (key == NULL || key->public_key == NULL)\n        return NULL;\n    if (key->pkey != NULL)\n        return key->pkey;\n    x509_pubkey_decode(&ret, key);\n    if (ret != NULL) {\n        X509err(X509_F_X509_PUBKEY_GET0, ERR_R_INTERNAL_ERROR);\n        EVP_PKEY_free(ret);\n    }\n    return NULL;\n}', 'RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey)\n{\n    if (pkey->type != EVP_PKEY_RSA) {\n        EVPerr(EVP_F_EVP_PKEY_GET0_RSA, EVP_R_EXPECTING_AN_RSA_KEY);\n        return NULL;\n    }\n    return pkey->pkey.rsa;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\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    allow_customize = 0;\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    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'int ssl_randbytes(SSL *s, unsigned char *rnd, size_t size)\n{\n    if (s->drbg != NULL)\n        return RAND_DRBG_generate(s->drbg, rnd, size, 0, NULL, 0);\n    return RAND_bytes(rnd, (int)size);\n}', 'int RAND_DRBG_generate(RAND_DRBG *drbg, unsigned char *out, size_t outlen,\n                       int prediction_resistance,\n                       const unsigned char *adin, size_t adinlen)\n{\n    if (drbg->state == DRBG_ERROR) {\n        RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_IN_ERROR_STATE);\n        return 0;\n    }\n    if (drbg->state == DRBG_UNINITIALISED) {\n        RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_NOT_INSTANTIATED);\n        return 0;\n    }\n    if (outlen > drbg->max_request) {\n        RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_REQUEST_TOO_LARGE_FOR_DRBG);\n        return 0;\n    }\n    if (adinlen > drbg->max_adin) {\n        RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_ADDITIONAL_INPUT_TOO_LONG);\n        return 0;\n    }\n    if (drbg->reseed_counter >= drbg->reseed_interval)\n        drbg->state = DRBG_RESEED;\n    if (drbg->state == DRBG_RESEED || prediction_resistance) {\n        if (!RAND_DRBG_reseed(drbg, adin, adinlen)) {\n            RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_RESEED_ERROR);\n            return 0;\n        }\n        adin = NULL;\n        adinlen = 0;\n    }\n    if (!ctr_generate(drbg, out, outlen, adin, adinlen)) {\n        drbg->state = DRBG_ERROR;\n        RANDerr(RAND_F_RAND_DRBG_GENERATE, RAND_R_GENERATE_ERROR);\n        return 0;\n    }\n    if (drbg->reseed_counter >= drbg->reseed_interval)\n        drbg->state = DRBG_RESEED;\n    else\n        drbg->reseed_counter++;\n    return 1;\n}', 'void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)\n{\n    if (str == NULL)\n        return;\n    if (num)\n        OPENSSL_cleanse(str, num);\n    CRYPTO_free(str, file, line);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']