diff options
author | Richard Levitte <levitte@openssl.org> | 2019-04-18 12:23:21 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-04-19 10:23:59 +0200 |
commit | e019da7b6ff54822e307daf804f7fe78ec352457 (patch) | |
tree | 77647f0e5688085e808cf67c6ac6ce71f9ba7668 | |
parent | 4f29f3a29b8b416a501c7166dbbca5284b198f81 (diff) |
Fix the generic EVP algorithm fetch to actually cache them
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)
-rw-r--r-- | crypto/evp/evp_fetch.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/evp/evp_fetch.c b/crypto/evp/evp_fetch.c index 012383f098..c054f31158 100644 --- a/crypto/evp/evp_fetch.c +++ b/crypto/evp/evp_fetch.c @@ -173,11 +173,15 @@ void *evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id, 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; + if (store == NULL) + return NULL; + if (nid == NID_undef - || !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, @@ -198,7 +202,9 @@ void *evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id, 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); } return method; |