ossl_method_store_cache_get() and ossl_method_store_cache_set() were
called with a NULL argument for store, which means no caching is
done. Give them a real store instead.
Also, increment the refcount when we do get a method out of the cache.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8781)
void (*free_method)(void *),
int (*nid_method)(void *))
{
void (*free_method)(void *),
int (*nid_method)(void *))
{
+ OSSL_METHOD_STORE *store = get_default_method_store(libctx);
int nid = OBJ_sn2nid(algorithm);
void *method = NULL;
int nid = OBJ_sn2nid(algorithm);
void *method = NULL;
+ if (store == NULL)
+ return NULL;
+
- || !ossl_method_store_cache_get(NULL, nid, properties, &method)) {
+ || !ossl_method_store_cache_get(store, nid, properties, &method)) {
OSSL_METHOD_CONSTRUCT_METHOD mcm = {
alloc_tmp_method_store,
dealloc_tmp_method_store,
OSSL_METHOD_CONSTRUCT_METHOD mcm = {
alloc_tmp_method_store,
dealloc_tmp_method_store,
method = ossl_method_construct(libctx, operation_id, algorithm,
properties, 0 /* !force_cache */,
&mcm, &mcmdata);
method = ossl_method_construct(libctx, operation_id, algorithm,
properties, 0 /* !force_cache */,
&mcm, &mcmdata);
- ossl_method_store_cache_set(NULL, nid, properties, method);
+ ossl_method_store_cache_set(store, nid, properties, method);
+ } else {
+ upref_method(method);