crypto/kdf/tls1_prf.c:256: error: NULL_DEREFERENCE
  pointer `mdname` last assigned on line 244 could be null and is dereferenced by call to `strlen()` at line 256, column 50.
Showing all 62 steps of the trace


crypto/kdf/tls1_prf.c:231:1: start of procedure tls1_prf_P_hash()
229.    *     A(i) = HMAC_<hash>(secret, A(i-1))
230.    */
231. > static int tls1_prf_P_hash(const EVP_MD *md,
232.                              const unsigned char *sec, size_t sec_len,
233.                              const unsigned char *seed, size_t seed_len,

crypto/kdf/tls1_prf.c:237:5: 
235.   {
236.       size_t chunk;
237. >     EVP_MAC *mac = NULL;
238.       EVP_MAC_CTX *ctx = NULL, *ctx_Ai = NULL, *ctx_init = NULL;
239.       unsigned char Ai[EVP_MAX_MD_SIZE];

crypto/kdf/tls1_prf.c:238:5: 
236.       size_t chunk;
237.       EVP_MAC *mac = NULL;
238. >     EVP_MAC_CTX *ctx = NULL, *ctx_Ai = NULL, *ctx_init = NULL;
239.       unsigned char Ai[EVP_MAX_MD_SIZE];
240.       size_t Ai_len;

crypto/kdf/tls1_prf.c:241:5: 
239.       unsigned char Ai[EVP_MAX_MD_SIZE];
240.       size_t Ai_len;
241. >     int ret = 0;
242.       OSSL_PARAM params[4];
243.       int mac_flags;

crypto/kdf/tls1_prf.c:244:5: 
242.       OSSL_PARAM params[4];
243.       int mac_flags;
244. >     const char *mdname = EVP_MD_name(md);
245.   
246.       mac = EVP_MAC_fetch(NULL, OSSL_MAC_NAME_HMAC, NULL); /* Implicit fetch */

crypto/evp/evp_lib.c:460:1: start of procedure EVP_MD_name()
  458.   }
  459.   
  460. > const char *EVP_MD_name(const EVP_MD *md)
  461.   {
  462.       if (md->prov != NULL)

crypto/evp/evp_lib.c:462:9: Taking false branch
  460.   const char *EVP_MD_name(const EVP_MD *md)
  461.   {
  462.       if (md->prov != NULL)
                 ^
  463.           return md->name;
  464.   #ifndef FIPS_MODE

crypto/evp/evp_lib.c:467:5: 
  465.       return OBJ_nid2sn(EVP_MD_nid(md));
  466.   #else
  467. >     return NULL;
  468.   #endif
  469.   }

crypto/evp/evp_lib.c:469:1: return from a call to EVP_MD_name
  467.       return NULL;
  468.   #endif
  469. > }
  470.   
  471.   const OSSL_PROVIDER *EVP_MD_provider(const EVP_MD *md)

crypto/kdf/tls1_prf.c:246:5: 
244.       const char *mdname = EVP_MD_name(md);
245.   
246. >     mac = EVP_MAC_fetch(NULL, OSSL_MAC_NAME_HMAC, NULL); /* Implicit fetch */
247.       ctx_init = EVP_MAC_CTX_new(mac);
248.       if (ctx_init == NULL)

crypto/evp/mac_meth.c:153:1: start of procedure EVP_MAC_fetch()
  151.   }
  152.   
  153. > EVP_MAC *EVP_MAC_fetch(OPENSSL_CTX *libctx, const char *algorithm,
  154.                          const char *properties)
  155.   {

crypto/evp/mac_meth.c:156:5: 
  154.                          const char *properties)
  155.   {
  156. >     return evp_generic_fetch(libctx, OSSL_OP_MAC, algorithm, properties,
  157.                                evp_mac_from_dispatch, NULL, evp_mac_up_ref,
  158.                                evp_mac_free);

crypto/evp/evp_fetch.c:157:1: start of procedure evp_generic_fetch()
    155.   }
    156.   
    157. > void *evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id,
    158.                           const char *name, const char *properties,
    159.                           void *(*new_method)(const char *name,

crypto/evp/evp_fetch.c:167:5: 
    165.                           void (*free_method)(void *))
    166.   {
    167. >     OSSL_METHOD_STORE *store = get_default_method_store(libctx);
    168.       OSSL_NAMEMAP *namemap = ossl_namemap_stored(libctx);
    169.       int nameid = 0;

crypto/evp/evp_fetch.c:64:1: start of procedure get_default_method_store()
      62.   }
      63.   
      64. > static OSSL_METHOD_STORE *get_default_method_store(OPENSSL_CTX *libctx)
      65.   {
      66.       return openssl_ctx_get_data(libctx, OPENSSL_CTX_DEFAULT_METHOD_STORE_INDEX,

crypto/evp/evp_fetch.c:66:5: 
      64.   static OSSL_METHOD_STORE *get_default_method_store(OPENSSL_CTX *libctx)
      65.   {
      66. >     return openssl_ctx_get_data(libctx, OPENSSL_CTX_DEFAULT_METHOD_STORE_INDEX,
      67.                                   &default_method_store_method);
      68.   }

crypto/context.c:207:1: start of procedure openssl_ctx_get_data()
        205.   }
        206.   
        207. > void *openssl_ctx_get_data(OPENSSL_CTX *ctx, int index,
        208.                              const OPENSSL_CTX_METHOD *meth)
        209.   {

crypto/context.c:210:5: 
        208.                              const OPENSSL_CTX_METHOD *meth)
        209.   {
        210. >     void *data = NULL;
        211.       int dynidx;
        212.   

crypto/context.c:213:5: 
        211.       int dynidx;
        212.   
        213. >     ctx = openssl_ctx_get_concrete(ctx);
        214.       if (ctx == NULL)
        215.           return NULL;

crypto/context.c:155:1: start of procedure openssl_ctx_get_concrete()
          153.   }
          154.   
          155. > OPENSSL_CTX *openssl_ctx_get_concrete(OPENSSL_CTX *ctx)
          156.   {
          157.   #ifndef FIPS_MODE

crypto/context.c:164:5: 
          162.       }
          163.   #endif
          164. >     return ctx;
          165.   }
          166.   

crypto/context.c:165:1: return from a call to openssl_ctx_get_concrete
          163.   #endif
          164.       return ctx;
          165. > }
          166.   
          167.   static void openssl_ctx_generic_new(void *parent_ign, void *ptr_ign,

crypto/context.c:214:9: Taking true branch
        212.   
        213.       ctx = openssl_ctx_get_concrete(ctx);
        214.       if (ctx == NULL)
                       ^
        215.           return NULL;
        216.   

crypto/context.c:215:9: 
        213.       ctx = openssl_ctx_get_concrete(ctx);
        214.       if (ctx == NULL)
        215. >         return NULL;
        216.   
        217.       CRYPTO_THREAD_read_lock(ctx->lock);

crypto/context.c:255:1: return from a call to openssl_ctx_get_data
        253.   
        254.       return data;
        255. > }
        256.   
        257.   OSSL_EX_DATA_GLOBAL *openssl_ctx_get_ex_data_global(OPENSSL_CTX *ctx)

crypto/evp/evp_fetch.c:68:1: return from a call to get_default_method_store
      66.       return openssl_ctx_get_data(libctx, OPENSSL_CTX_DEFAULT_METHOD_STORE_INDEX,
      67.                                   &default_method_store_method);
      68. > }
      69.   
      70.   /*

crypto/evp/evp_fetch.c:168:5: 
    166.   {
    167.       OSSL_METHOD_STORE *store = get_default_method_store(libctx);
    168. >     OSSL_NAMEMAP *namemap = ossl_namemap_stored(libctx);
    169.       int nameid = 0;
    170.       uint32_t methid = 0;

crypto/core_namemap.c:90:1: start of procedure ossl_namemap_stored()
      88.    */
      89.   
      90. > OSSL_NAMEMAP *ossl_namemap_stored(OPENSSL_CTX *libctx)
      91.   {
      92.       return openssl_ctx_get_data(libctx, OPENSSL_CTX_NAMEMAP_INDEX,

crypto/core_namemap.c:92:5: 
      90.   OSSL_NAMEMAP *ossl_namemap_stored(OPENSSL_CTX *libctx)
      91.   {
      92. >     return openssl_ctx_get_data(libctx, OPENSSL_CTX_NAMEMAP_INDEX,
      93.                                   &stored_namemap_method);
      94.   }

crypto/context.c:207:1: start of procedure openssl_ctx_get_data()
        205.   }
        206.   
        207. > void *openssl_ctx_get_data(OPENSSL_CTX *ctx, int index,
        208.                              const OPENSSL_CTX_METHOD *meth)
        209.   {

crypto/context.c:210:5: 
        208.                              const OPENSSL_CTX_METHOD *meth)
        209.   {
        210. >     void *data = NULL;
        211.       int dynidx;
        212.   

crypto/context.c:213:5: 
        211.       int dynidx;
        212.   
        213. >     ctx = openssl_ctx_get_concrete(ctx);
        214.       if (ctx == NULL)
        215.           return NULL;

crypto/context.c:155:1: start of procedure openssl_ctx_get_concrete()
          153.   }
          154.   
          155. > OPENSSL_CTX *openssl_ctx_get_concrete(OPENSSL_CTX *ctx)
          156.   {
          157.   #ifndef FIPS_MODE

crypto/context.c:164:5: 
          162.       }
          163.   #endif
          164. >     return ctx;
          165.   }
          166.   

crypto/context.c:165:1: return from a call to openssl_ctx_get_concrete
          163.   #endif
          164.       return ctx;
          165. > }
          166.   
          167.   static void openssl_ctx_generic_new(void *parent_ign, void *ptr_ign,

crypto/context.c:214:9: Taking true branch
        212.   
        213.       ctx = openssl_ctx_get_concrete(ctx);
        214.       if (ctx == NULL)
                       ^
        215.           return NULL;
        216.   

crypto/context.c:215:9: 
        213.       ctx = openssl_ctx_get_concrete(ctx);
        214.       if (ctx == NULL)
        215. >         return NULL;
        216.   
        217.       CRYPTO_THREAD_read_lock(ctx->lock);

crypto/context.c:255:1: return from a call to openssl_ctx_get_data
        253.   
        254.       return data;
        255. > }
        256.   
        257.   OSSL_EX_DATA_GLOBAL *openssl_ctx_get_ex_data_global(OPENSSL_CTX *ctx)

crypto/core_namemap.c:94:1: return from a call to ossl_namemap_stored
      92.       return openssl_ctx_get_data(libctx, OPENSSL_CTX_NAMEMAP_INDEX,
      93.                                   &stored_namemap_method);
      94. > }
      95.   
      96.   OSSL_NAMEMAP *ossl_namemap_new(void)

crypto/evp/evp_fetch.c:169:5: 
    167.       OSSL_METHOD_STORE *store = get_default_method_store(libctx);
    168.       OSSL_NAMEMAP *namemap = ossl_namemap_stored(libctx);
    169. >     int nameid = 0;
    170.       uint32_t methid = 0;
    171.       void *method = NULL;

crypto/evp/evp_fetch.c:170:5: 
    168.       OSSL_NAMEMAP *namemap = ossl_namemap_stored(libctx);
    169.       int nameid = 0;
    170. >     uint32_t methid = 0;
    171.       void *method = NULL;
    172.   

crypto/evp/evp_fetch.c:171:5: 
    169.       int nameid = 0;
    170.       uint32_t methid = 0;
    171. >     void *method = NULL;
    172.   
    173.       if (store == NULL || namemap == NULL)

crypto/evp/evp_fetch.c:173:9: Taking true branch
    171.       void *method = NULL;
    172.   
    173.       if (store == NULL || namemap == NULL)
                   ^
    174.           return NULL;
    175.   

crypto/evp/evp_fetch.c:174:9: 
    172.   
    173.       if (store == NULL || namemap == NULL)
    174. >         return NULL;
    175.   
    176.       /*

crypto/evp/evp_fetch.c:231:1: return from a call to evp_generic_fetch
    229.   
    230.       return method;
    231. > }
    232.   
    233.   int EVP_set_default_properties(OPENSSL_CTX *libctx, const char *propq)

crypto/evp/mac_meth.c:159:1: return from a call to EVP_MAC_fetch
  157.                                evp_mac_from_dispatch, NULL, evp_mac_up_ref,
  158.                                evp_mac_free);
  159. > }
  160.   
  161.   int EVP_MAC_up_ref(EVP_MAC *mac)

crypto/kdf/tls1_prf.c:247:5: Skipping EVP_MAC_CTX_new(): empty list of specs
245.   
246.       mac = EVP_MAC_fetch(NULL, OSSL_MAC_NAME_HMAC, NULL); /* Implicit fetch */
247.       ctx_init = EVP_MAC_CTX_new(mac);
           ^
248.       if (ctx_init == NULL)
249.           goto err;

crypto/kdf/tls1_prf.c:248:9: Taking false branch
246.       mac = EVP_MAC_fetch(NULL, OSSL_MAC_NAME_HMAC, NULL); /* Implicit fetch */
247.       ctx_init = EVP_MAC_CTX_new(mac);
248.       if (ctx_init == NULL)
               ^
249.           goto err;
250.   

crypto/kdf/tls1_prf.c:252:5: 
250.   
251.       /* TODO(3.0) rethink "flags", also see hmac.c in providers */
252. >     mac_flags = EVP_MD_CTX_FLAG_NON_FIPS_ALLOW;
253.       params[0] = OSSL_PARAM_construct_int(OSSL_MAC_PARAM_FLAGS, &mac_flags);
254.       params[1] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST,

crypto/kdf/tls1_prf.c:253:5: 
251.       /* TODO(3.0) rethink "flags", also see hmac.c in providers */
252.       mac_flags = EVP_MD_CTX_FLAG_NON_FIPS_ALLOW;
253. >     params[0] = OSSL_PARAM_construct_int(OSSL_MAC_PARAM_FLAGS, &mac_flags);
254.       params[1] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST,
255.                                                    (char *)mdname,

crypto/params.c:65:1: start of procedure OSSL_PARAM_construct_int()
  63.   }
  64.   
  65. > OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf)
  66.   {
  67.       return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int));

crypto/params.c:67:5: 
  65.   OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf)
  66.   {
  67. >     return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int));
  68.   }
  69.   

crypto/params.c:30:1: start of procedure ossl_param_construct()
    28.   }
    29.   
    30. > static OSSL_PARAM ossl_param_construct(const char *key, unsigned int data_type,
    31.                                          void *data, size_t data_size)
    32.   {

crypto/params.c:35:5: 
    33.       OSSL_PARAM res;
    34.   
    35. >     res.key = key;
    36.       res.data_type = data_type;
    37.       res.data = data;

crypto/params.c:36:5: 
    34.   
    35.       res.key = key;
    36. >     res.data_type = data_type;
    37.       res.data = data;
    38.       res.data_size = data_size;

crypto/params.c:37:5: 
    35.       res.key = key;
    36.       res.data_type = data_type;
    37. >     res.data = data;
    38.       res.data_size = data_size;
    39.       res.return_size = 0;

crypto/params.c:38:5: 
    36.       res.data_type = data_type;
    37.       res.data = data;
    38. >     res.data_size = data_size;
    39.       res.return_size = 0;
    40.       return res;

crypto/params.c:39:5: 
    37.       res.data = data;
    38.       res.data_size = data_size;
    39. >     res.return_size = 0;
    40.       return res;
    41.   }

crypto/params.c:40:5: 
    38.       res.data_size = data_size;
    39.       res.return_size = 0;
    40. >     return res;
    41.   }
    42.   

crypto/params.c:41:1: return from a call to ossl_param_construct
    39.       res.return_size = 0;
    40.       return res;
    41. > }
    42.   
    43.   int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val)

crypto/params.c:68:1: return from a call to OSSL_PARAM_construct_int
  66.   {
  67.       return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int));
  68. > }
  69.   
  70.   int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val)

crypto/kdf/tls1_prf.c:254:5: 
252.       mac_flags = EVP_MD_CTX_FLAG_NON_FIPS_ALLOW;
253.       params[0] = OSSL_PARAM_construct_int(OSSL_MAC_PARAM_FLAGS, &mac_flags);
254. >     params[1] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST,
255.                                                    (char *)mdname,
256.                                                    strlen(mdname) + 1);

static int tls1_prf_P_hash(const EVP_MD *md,
                           const unsigned char *sec, size_t sec_len,
                           const unsigned char *seed, size_t seed_len,
                           unsigned char *out, size_t olen)
{
    size_t chunk;
    EVP_MAC *mac = NULL;
    EVP_MAC_CTX *ctx = NULL, *ctx_Ai = NULL, *ctx_init = NULL;
    unsigned char Ai[EVP_MAX_MD_SIZE];
    size_t Ai_len;
    int ret = 0;
    OSSL_PARAM params[4];
    int mac_flags;
    const char *mdname = EVP_MD_name(md);
    mac = EVP_MAC_fetch(NULL, OSSL_MAC_NAME_HMAC, NULL);
    ctx_init = EVP_MAC_CTX_new(mac);
    if (ctx_init == NULL)
        goto err;
    mac_flags = EVP_MD_CTX_FLAG_NON_FIPS_ALLOW;
    params[0] = OSSL_PARAM_construct_int(OSSL_MAC_PARAM_FLAGS, &mac_flags);
    params[1] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST,
                                                 (char *)mdname,
                                                 strlen(mdname) + 1);
    params[2] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,
                                                  (void *)sec, sec_len);
    params[3] = OSSL_PARAM_construct_end();
    if (!EVP_MAC_CTX_set_params(ctx_init, params))
        goto err;
    if (!EVP_MAC_init(ctx_init))
        goto err;
    chunk = EVP_MAC_size(ctx_init);
    if (chunk == 0)
        goto err;
    ctx_Ai = EVP_MAC_CTX_dup(ctx_init);
    if (ctx_Ai == NULL)
        goto err;
    if (seed != NULL && !EVP_MAC_update(ctx_Ai, seed, seed_len))
        goto err;
    for (;;) {
        if (!EVP_MAC_final(ctx_Ai, Ai, &Ai_len, sizeof(Ai)))
            goto err;
        EVP_MAC_CTX_free(ctx_Ai);
        ctx_Ai = NULL;
        ctx = EVP_MAC_CTX_dup(ctx_init);
        if (ctx == NULL)
            goto err;
        if (!EVP_MAC_update(ctx, Ai, Ai_len))
            goto err;
        if (olen > chunk) {
            ctx_Ai = EVP_MAC_CTX_dup(ctx);
            if (ctx_Ai == NULL)
                goto err;
        }
        if (seed != NULL && !EVP_MAC_update(ctx, seed, seed_len))
            goto err;
        if (olen <= chunk) {
            if (!EVP_MAC_final(ctx, Ai, &Ai_len, sizeof(Ai)))
                goto err;
            memcpy(out, Ai, olen);
            break;
        }
        if (!EVP_MAC_final(ctx, out, NULL, olen))
            goto err;
        EVP_MAC_CTX_free(ctx);
        ctx = NULL;
        out += chunk;
        olen -= chunk;
    }
    ret = 1;
 err:
    EVP_MAC_CTX_free(ctx);
    EVP_MAC_CTX_free(ctx_Ai);
    EVP_MAC_CTX_free(ctx_init);
    EVP_MAC_free(mac);
    OPENSSL_cleanse(Ai, sizeof(Ai));
    return ret;
}
['static int tls1_prf_P_hash(const EVP_MD *md,\n                           const unsigned char *sec, size_t sec_len,\n                           const unsigned char *seed, size_t seed_len,\n                           unsigned char *out, size_t olen)\n{\n    size_t chunk;\n    EVP_MAC *mac = NULL;\n    EVP_MAC_CTX *ctx = NULL, *ctx_Ai = NULL, *ctx_init = NULL;\n    unsigned char Ai[EVP_MAX_MD_SIZE];\n    size_t Ai_len;\n    int ret = 0;\n    OSSL_PARAM params[4];\n    int mac_flags;\n    const char *mdname = EVP_MD_name(md);\n    mac = EVP_MAC_fetch(NULL, OSSL_MAC_NAME_HMAC, NULL);\n    ctx_init = EVP_MAC_CTX_new(mac);\n    if (ctx_init == NULL)\n        goto err;\n    mac_flags = EVP_MD_CTX_FLAG_NON_FIPS_ALLOW;\n    params[0] = OSSL_PARAM_construct_int(OSSL_MAC_PARAM_FLAGS, &mac_flags);\n    params[1] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST,\n                                                 (char *)mdname,\n                                                 strlen(mdname) + 1);\n    params[2] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,\n                                                  (void *)sec, sec_len);\n    params[3] = OSSL_PARAM_construct_end();\n    if (!EVP_MAC_CTX_set_params(ctx_init, params))\n        goto err;\n    if (!EVP_MAC_init(ctx_init))\n        goto err;\n    chunk = EVP_MAC_size(ctx_init);\n    if (chunk == 0)\n        goto err;\n    ctx_Ai = EVP_MAC_CTX_dup(ctx_init);\n    if (ctx_Ai == NULL)\n        goto err;\n    if (seed != NULL && !EVP_MAC_update(ctx_Ai, seed, seed_len))\n        goto err;\n    for (;;) {\n        if (!EVP_MAC_final(ctx_Ai, Ai, &Ai_len, sizeof(Ai)))\n            goto err;\n        EVP_MAC_CTX_free(ctx_Ai);\n        ctx_Ai = NULL;\n        ctx = EVP_MAC_CTX_dup(ctx_init);\n        if (ctx == NULL)\n            goto err;\n        if (!EVP_MAC_update(ctx, Ai, Ai_len))\n            goto err;\n        if (olen > chunk) {\n            ctx_Ai = EVP_MAC_CTX_dup(ctx);\n            if (ctx_Ai == NULL)\n                goto err;\n        }\n        if (seed != NULL && !EVP_MAC_update(ctx, seed, seed_len))\n            goto err;\n        if (olen <= chunk) {\n            if (!EVP_MAC_final(ctx, Ai, &Ai_len, sizeof(Ai)))\n                goto err;\n            memcpy(out, Ai, olen);\n            break;\n        }\n        if (!EVP_MAC_final(ctx, out, NULL, olen))\n            goto err;\n        EVP_MAC_CTX_free(ctx);\n        ctx = NULL;\n        out += chunk;\n        olen -= chunk;\n    }\n    ret = 1;\n err:\n    EVP_MAC_CTX_free(ctx);\n    EVP_MAC_CTX_free(ctx_Ai);\n    EVP_MAC_CTX_free(ctx_init);\n    EVP_MAC_free(mac);\n    OPENSSL_cleanse(Ai, sizeof(Ai));\n    return ret;\n}', 'const char *EVP_MD_name(const EVP_MD *md)\n{\n    if (md->prov != NULL)\n        return md->name;\n#ifndef FIPS_MODE\n    return OBJ_nid2sn(EVP_MD_nid(md));\n#else\n    return NULL;\n#endif\n}', 'EVP_MAC *EVP_MAC_fetch(OPENSSL_CTX *libctx, const char *algorithm,\n                       const char *properties)\n{\n    return evp_generic_fetch(libctx, OSSL_OP_MAC, algorithm, properties,\n                             evp_mac_from_dispatch, NULL, evp_mac_up_ref,\n                             evp_mac_free);\n}', 'void *evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id,\n                        const char *name, const char *properties,\n                        void *(*new_method)(const char *name,\n                                            const OSSL_DISPATCH *fns,\n                                            OSSL_PROVIDER *prov,\n                                            void *method_data),\n                        void *method_data,\n                        int (*up_ref_method)(void *),\n                        void (*free_method)(void *))\n{\n    OSSL_METHOD_STORE *store = get_default_method_store(libctx);\n    OSSL_NAMEMAP *namemap = ossl_namemap_stored(libctx);\n    int nameid = 0;\n    uint32_t methid = 0;\n    void *method = NULL;\n    if (store == NULL || namemap == NULL)\n        return NULL;\n    if (!ossl_assert(operation_id > 0))\n        return NULL;\n    if ((nameid = ossl_namemap_name2num(namemap, name)) != 0\n        && (methid = method_id(operation_id, nameid)) == 0)\n        return NULL;\n    if (nameid == 0\n        || !ossl_method_store_cache_get(store, methid, properties,\n                                        &method)) {\n        OSSL_METHOD_CONSTRUCT_METHOD mcm = {\n            alloc_tmp_method_store,\n            dealloc_tmp_method_store,\n            get_method_from_store,\n            put_method_in_store,\n            construct_method,\n            destruct_method\n        };\n        struct method_data_st mcmdata;\n        mcmdata.mcm = &mcm;\n        mcmdata.libctx = libctx;\n        mcmdata.name = name;\n        mcmdata.method_from_dispatch = new_method;\n        mcmdata.destruct_method = free_method;\n        mcmdata.refcnt_up_method = up_ref_method;\n        mcmdata.destruct_method = free_method;\n        mcmdata.method_data = method_data;\n        if ((method = ossl_method_construct(libctx, operation_id, name,\n                                            properties, 0  ,\n                                            &mcm, &mcmdata)) != NULL) {\n            nameid = ossl_namemap_name2num(namemap, name);\n            methid = method_id(operation_id, nameid);\n            ossl_method_store_cache_set(store, methid, properties, method);\n        }\n    } else {\n        up_ref_method(method);\n    }\n    return method;\n}', 'static OSSL_METHOD_STORE *get_default_method_store(OPENSSL_CTX *libctx)\n{\n    return openssl_ctx_get_data(libctx, OPENSSL_CTX_DEFAULT_METHOD_STORE_INDEX,\n                                &default_method_store_method);\n}', 'void *openssl_ctx_get_data(OPENSSL_CTX *ctx, int index,\n                           const OPENSSL_CTX_METHOD *meth)\n{\n    void *data = NULL;\n    int dynidx;\n    ctx = openssl_ctx_get_concrete(ctx);\n    if (ctx == NULL)\n        return NULL;\n    CRYPTO_THREAD_read_lock(ctx->lock);\n    dynidx = ctx->dyn_indexes[index];\n    CRYPTO_THREAD_unlock(ctx->lock);\n    if (dynidx != -1) {\n        CRYPTO_THREAD_read_lock(ctx->index_locks[index]);\n        data = CRYPTO_get_ex_data(&ctx->data, dynidx);\n        CRYPTO_THREAD_unlock(ctx->index_locks[index]);\n        return data;\n    }\n    CRYPTO_THREAD_write_lock(ctx->index_locks[index]);\n    CRYPTO_THREAD_write_lock(ctx->lock);\n    dynidx = ctx->dyn_indexes[index];\n    if (dynidx != -1) {\n        CRYPTO_THREAD_unlock(ctx->lock);\n        data = CRYPTO_get_ex_data(&ctx->data, dynidx);\n        CRYPTO_THREAD_unlock(ctx->index_locks[index]);\n        return data;\n    }\n    if (!openssl_ctx_init_index(ctx, index, meth)) {\n        CRYPTO_THREAD_unlock(ctx->lock);\n        CRYPTO_THREAD_unlock(ctx->index_locks[index]);\n        return NULL;\n    }\n    CRYPTO_THREAD_unlock(ctx->lock);\n    if (CRYPTO_alloc_ex_data(CRYPTO_EX_INDEX_OPENSSL_CTX, NULL,\n                             &ctx->data, ctx->dyn_indexes[index]))\n        data = CRYPTO_get_ex_data(&ctx->data, ctx->dyn_indexes[index]);\n    CRYPTO_THREAD_unlock(ctx->index_locks[index]);\n    return data;\n}', 'OPENSSL_CTX *openssl_ctx_get_concrete(OPENSSL_CTX *ctx)\n{\n#ifndef FIPS_MODE\n    if (ctx == NULL) {\n        if (!RUN_ONCE(&default_context_init, do_default_context_init))\n            return 0;\n        return default_context;\n    }\n#endif\n    return ctx;\n}', 'OSSL_NAMEMAP *ossl_namemap_stored(OPENSSL_CTX *libctx)\n{\n    return openssl_ctx_get_data(libctx, OPENSSL_CTX_NAMEMAP_INDEX,\n                                &stored_namemap_method);\n}', 'OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf)\n{\n    return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int));\n}', 'static OSSL_PARAM ossl_param_construct(const char *key, unsigned int data_type,\n                                       void *data, size_t data_size)\n{\n    OSSL_PARAM res;\n    res.key = key;\n    res.data_type = data_type;\n    res.data = data;\n    res.data_size = data_size;\n    res.return_size = 0;\n    return res;\n}']