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


ssl/statem/statem_clnt.c:2575:1: start of procedure tls_construct_cke_rsa()
2573.   }
2574.   
2575. > static int tls_construct_cke_rsa(SSL *s, WPACKET *pkt, int *al)
2576.   {
2577.   #ifndef OPENSSL_NO_RSA

ssl/statem/statem_clnt.c:2578:5: 
2576.   {
2577.   #ifndef OPENSSL_NO_RSA
2578. >     unsigned char *encdata = NULL;
2579.       EVP_PKEY *pkey = NULL;
2580.       EVP_PKEY_CTX *pctx = NULL;

ssl/statem/statem_clnt.c:2579:5: 
2577.   #ifndef OPENSSL_NO_RSA
2578.       unsigned char *encdata = NULL;
2579. >     EVP_PKEY *pkey = NULL;
2580.       EVP_PKEY_CTX *pctx = NULL;
2581.       size_t enclen;

ssl/statem/statem_clnt.c:2580:5: 
2578.       unsigned char *encdata = NULL;
2579.       EVP_PKEY *pkey = NULL;
2580. >     EVP_PKEY_CTX *pctx = NULL;
2581.       size_t enclen;
2582.       unsigned char *pms = NULL;

ssl/statem/statem_clnt.c:2582:5: 
2580.       EVP_PKEY_CTX *pctx = NULL;
2581.       size_t enclen;
2582. >     unsigned char *pms = NULL;
2583.       size_t pmslen = 0;
2584.   

ssl/statem/statem_clnt.c:2583:5: 
2581.       size_t enclen;
2582.       unsigned char *pms = NULL;
2583. >     size_t pmslen = 0;
2584.   
2585.       if (s->session->peer == NULL) {

ssl/statem/statem_clnt.c:2585:9: Taking false branch
2583.       size_t pmslen = 0;
2584.   
2585.       if (s->session->peer == NULL) {
                ^
2586.           /*
2587.            * We should always have a server certificate with SSL_kRSA.

ssl/statem/statem_clnt.c:2593:5: 
2591.       }
2592.   
2593. >     pkey = X509_get0_pubkey(s->session->peer);
2594.       if (EVP_PKEY_get0_RSA(pkey) == NULL) {
2595.           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:2594:9: 
2592.   
2593.       pkey = X509_get0_pubkey(s->session->peer);
2594. >     if (EVP_PKEY_get0_RSA(pkey) == NULL) {
2595.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);
2596.           return 0;

crypto/evp/p_lib.c:275:1: start of procedure EVP_PKEY_get0_RSA()
  273.   }
  274.   
  275. > RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
  276.   {
  277.       if (pkey->type != EVP_PKEY_RSA) {

crypto/evp/p_lib.c:277:9: Taking false branch
  275.   RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
  276.   {
  277.       if (pkey->type != EVP_PKEY_RSA) {
                 ^
  278.           EVPerr(EVP_F_EVP_PKEY_GET0_RSA, EVP_R_EXPECTING_AN_RSA_KEY);
  279.           return NULL;

crypto/evp/p_lib.c:281:5: 
  279.           return NULL;
  280.       }
  281. >     return pkey->pkey.rsa;
  282.   }
  283.   

crypto/evp/p_lib.c:282:1: return from a call to EVP_PKEY_get0_RSA
  280.       }
  281.       return pkey->pkey.rsa;
  282. > }
  283.   
  284.   RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey)

ssl/statem/statem_clnt.c:2594:9: Taking false branch
2592.   
2593.       pkey = X509_get0_pubkey(s->session->peer);
2594.       if (EVP_PKEY_get0_RSA(pkey) == NULL) {
                ^
2595.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);
2596.           return 0;

ssl/statem/statem_clnt.c:2599:5: 
2597.       }
2598.   
2599. >     pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2600.       pms = OPENSSL_malloc(pmslen);
2601.       if (pms == NULL) {

ssl/statem/statem_clnt.c:2600:5: 
2598.   
2599.       pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2600. >     pms = OPENSSL_malloc(pmslen);
2601.       if (pms == NULL) {
2602.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_MALLOC_FAILURE);

crypto/mem.c:158:1: start of procedure CRYPTO_malloc()
  156.   #endif
  157.   
  158. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  159.   {
  160.       void *ret = NULL;

crypto/mem.c:160:5: 
  158.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  159.   {
  160. >     void *ret = NULL;
  161.   
  162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:162:9: Taking false branch
  160.       void *ret = NULL;
  161.   
  162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  163.           return malloc_impl(num, file, line);
  164.   

crypto/mem.c:165:9: Taking false branch
  163.           return malloc_impl(num, file, line);
  164.   
  165.       if (num <= 0)
                 ^
  166.           return NULL;
  167.   

crypto/mem.c:169:5: 
  167.   
  168.       FAILTEST();
  169. >     allow_customize = 0;
  170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
  177.       }
  178.   #else
  179. >     osslargused(file); osslargused(line);
  180.       ret = malloc(num);
  181.   #endif

crypto/mem.c:179:24: 
  177.       }
  178.   #else
  179. >     osslargused(file); osslargused(line);
  180.       ret = malloc(num);
  181.   #endif

crypto/mem.c:180:5: 
  178.   #else
  179.       osslargused(file); osslargused(line);
  180. >     ret = malloc(num);
  181.   #endif
  182.   

crypto/mem.c:183:5: 
  181.   #endif
  182.   
  183. >     return ret;
  184.   }
  185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
  182.   
  183.       return ret;
  184. > }
  185.   
  186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

ssl/statem/statem_clnt.c:2601:9: Taking false branch
2599.       pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2600.       pms = OPENSSL_malloc(pmslen);
2601.       if (pms == NULL) {
                ^
2602.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_MALLOC_FAILURE);
2603.           *al = SSL_AD_INTERNAL_ERROR;

ssl/statem/statem_clnt.c:2607:5: 
2605.       }
2606.   
2607. >     pms[0] = s->client_version >> 8;
2608.       pms[1] = s->client_version & 0xff;
2609.       /* TODO(size_t): Convert this function */

ssl/statem/statem_clnt.c:2608:5: 
2606.   
2607.       pms[0] = s->client_version >> 8;
2608. >     pms[1] = s->client_version & 0xff;
2609.       /* TODO(size_t): Convert this function */
2610.       if (RAND_bytes(pms + 2, (int)(pmslen - 2)) <= 0) {

ssl/statem/statem_clnt.c:2610:9: 
2608.       pms[1] = s->client_version & 0xff;
2609.       /* TODO(size_t): Convert this function */
2610. >     if (RAND_bytes(pms + 2, (int)(pmslen - 2)) <= 0) {
2611.           goto err;
2612.       }

crypto/rand/rand_lib.c:102:1: start of procedure RAND_bytes()
  100.   }
  101.   
  102. > int RAND_bytes(unsigned char *buf, int num)
  103.   {
  104.       const RAND_METHOD *meth = RAND_get_rand_method();

crypto/rand/rand_lib.c:104:5: 
  102.   int RAND_bytes(unsigned char *buf, int num)
  103.   {
  104. >     const RAND_METHOD *meth = RAND_get_rand_method();
  105.       if (meth && meth->bytes)
  106.           return meth->bytes(buf, num);

crypto/rand/rand_lib.c:39:1: start of procedure RAND_get_rand_method()
    37.   }
    38.   
    39. > const RAND_METHOD *RAND_get_rand_method(void)
    40.   {
    41.       if (!default_RAND_meth) {

crypto/rand/rand_lib.c:41:10: Taking false branch
    39.   const RAND_METHOD *RAND_get_rand_method(void)
    40.   {
    41.       if (!default_RAND_meth) {
                   ^
    42.   #ifndef OPENSSL_NO_ENGINE
    43.           ENGINE *e = ENGINE_get_default_RAND();

crypto/rand/rand_lib.c:57:5: 
    55.               default_RAND_meth = RAND_OpenSSL();
    56.       }
    57. >     return default_RAND_meth;
    58.   }
    59.   

crypto/rand/rand_lib.c:58:1: return from a call to RAND_get_rand_method
    56.       }
    57.       return default_RAND_meth;
    58. > }
    59.   
    60.   #ifndef OPENSSL_NO_ENGINE

crypto/rand/rand_lib.c:105:9: Taking true branch
  103.   {
  104.       const RAND_METHOD *meth = RAND_get_rand_method();
  105.       if (meth && meth->bytes)
                 ^
  106.           return meth->bytes(buf, num);
  107.       return (-1);

crypto/rand/rand_lib.c:105:17: Taking false branch
  103.   {
  104.       const RAND_METHOD *meth = RAND_get_rand_method();
  105.       if (meth && meth->bytes)
                         ^
  106.           return meth->bytes(buf, num);
  107.       return (-1);

crypto/rand/rand_lib.c:107:5: 
  105.       if (meth && meth->bytes)
  106.           return meth->bytes(buf, num);
  107. >     return (-1);
  108.   }
  109.   

crypto/rand/rand_lib.c:108:1: return from a call to RAND_bytes
  106.           return meth->bytes(buf, num);
  107.       return (-1);
  108. > }
  109.   
  110.   #if OPENSSL_API_COMPAT < 0x10100000L

ssl/statem/statem_clnt.c:2610:9: Taking true branch
2608.       pms[1] = s->client_version & 0xff;
2609.       /* TODO(size_t): Convert this function */
2610.       if (RAND_bytes(pms + 2, (int)(pmslen - 2)) <= 0) {
                ^
2611.           goto err;
2612.       }

ssl/statem/statem_clnt.c:2653:2: 
2651.   
2652.       return 1;
2653. >  err:
2654.       OPENSSL_clear_free(pms, pmslen);
2655.       EVP_PKEY_CTX_free(pctx);

ssl/statem/statem_clnt.c:2654:5: 
2652.       return 1;
2653.    err:
2654. >     OPENSSL_clear_free(pms, pmslen);
2655.       EVP_PKEY_CTX_free(pctx);
2656.   

crypto/mem.c:273:1: start of procedure CRYPTO_clear_free()
  271.   }
  272.   
  273. > void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)
  274.   {
  275.       if (str == NULL)

crypto/mem.c:275:9: Taking false branch
  273.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)
  274.   {
  275.       if (str == NULL)
                 ^
  276.           return;
  277.       if (num)

crypto/mem.c:277:9: Taking true branch
  275.       if (str == NULL)
  276.           return;
  277.       if (num)
                 ^
  278.           OPENSSL_cleanse(str, num);
  279.       CRYPTO_free(str, file, line);

crypto/mem.c:278:9: Skipping OPENSSL_cleanse(): method has no implementation
  276.           return;
  277.       if (num)
  278.           OPENSSL_cleanse(str, num);
                 ^
  279.       CRYPTO_free(str, file, line);
  280.   }

crypto/mem.c:279:5: 
  277.       if (num)
  278.           OPENSSL_cleanse(str, num);
  279. >     CRYPTO_free(str, file, line);
  280.   }

crypto/mem.c:253:1: start of procedure CRYPTO_free()
    251.   }
    252.   
    253. > void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:255:9: Taking true branch
    253.   void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    256.           free_impl(str, file, line);
    257.           return;

crypto/mem.c:255:30: Taking true branch
    253.   void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    256.           free_impl(str, file, line);
    257.           return;

crypto/mem.c:256:9: Skipping __function_pointer__(): unresolved function pointer
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    256.           free_impl(str, file, line);
                   ^
    257.           return;
    258.       }

crypto/mem.c:257:9: 
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    256.           free_impl(str, file, line);
    257. >         return;
    258.       }
    259.   

crypto/mem.c:271:1: return from a call to CRYPTO_free
    269.       free(str);
    270.   #endif
    271. > }
    272.   
    273.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

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

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 (RAND_bytes(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;
# ifdef PKCS1_CHECK
    if (s->options & SSL_OP_PKCS1_CHECK_1)
        (*p)[1]++;
    if (s->options & SSL_OP_PKCS1_CHECK_2)
        tmp_buf[0] = 0x70;
# endif
    if (s->version > SSL3_VERSION && !WPACKET_close(pkt)) {
        SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);
        goto err;
    }
    s->s3->tmp.pms = pms;
    s->s3->tmp.pmslen = pmslen;
    if (!ssl_log_rsa_client_key_exchange(s, encdata, enclen, pms, pmslen))
        goto err;
    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 (RAND_bytes(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# ifdef PKCS1_CHECK\n    if (s->options & SSL_OP_PKCS1_CHECK_1)\n        (*p)[1]++;\n    if (s->options & SSL_OP_PKCS1_CHECK_2)\n        tmp_buf[0] = 0x70;\n# endif\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    s->s3->tmp.pms = pms;\n    s->s3->tmp.pmslen = pmslen;\n    if (!ssl_log_rsa_client_key_exchange(s, encdata, enclen, pms, pmslen))\n        goto err;\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 RAND_bytes(unsigned char *buf, int num)\n{\n    const RAND_METHOD *meth = RAND_get_rand_method();\n    if (meth && meth->bytes)\n        return meth->bytes(buf, num);\n    return (-1);\n}', 'const RAND_METHOD *RAND_get_rand_method(void)\n{\n    if (!default_RAND_meth) {\n#ifndef OPENSSL_NO_ENGINE\n        ENGINE *e = ENGINE_get_default_RAND();\n        if (e) {\n            default_RAND_meth = ENGINE_get_RAND(e);\n            if (default_RAND_meth == NULL) {\n                ENGINE_finish(e);\n                e = NULL;\n            }\n        }\n        if (e)\n            funct_ref = e;\n        else\n#endif\n            default_RAND_meth = RAND_OpenSSL();\n    }\n    return default_RAND_meth;\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}']