From ce64d3eee06a64e78ea5be7e8f0dd7172aa78259 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Fri, 18 Sep 2020 09:55:16 +0100 Subject: Move SM2 asymmetric encryption to be available in the default provider Fixes #12908 Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/12913) --- providers/common/include/prov/provider_util.h | 8 ++++++++ providers/common/provider_util.c | 12 ++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'providers/common') diff --git a/providers/common/include/prov/provider_util.h b/providers/common/include/prov/provider_util.h index d964f832ad..83f6d63ed7 100644 --- a/providers/common/include/prov/provider_util.h +++ b/providers/common/include/prov/provider_util.h @@ -58,6 +58,14 @@ const EVP_CIPHER *ossl_prov_cipher_cipher(const PROV_CIPHER *pc); ENGINE *ossl_prov_cipher_engine(const PROV_CIPHER *pc); /* Digest functions */ + +/* + * Fetch a digest from the specified libctx using the provided mdname and + * propquery. Store the result in the PROV_DIGEST and return the fetched md. + */ +const EVP_MD *ossl_prov_digest_fetch(PROV_DIGEST *pd, OPENSSL_CTX *libctx, + const char *mdname, const char *propquery); + /* * Load a digest from the specified parameters with the specified context. * The params "properties", "engine" and "digest" are used to determine the diff --git a/providers/common/provider_util.c b/providers/common/provider_util.c index 4259d7167a..2e9fe8d5da 100644 --- a/providers/common/provider_util.c +++ b/providers/common/provider_util.c @@ -124,6 +124,15 @@ int ossl_prov_digest_copy(PROV_DIGEST *dst, const PROV_DIGEST *src) return 1; } +const EVP_MD *ossl_prov_digest_fetch(PROV_DIGEST *pd, OPENSSL_CTX *libctx, + const char *mdname, const char *propquery) +{ + EVP_MD_free(pd->alloc_md); + pd->md = pd->alloc_md = EVP_MD_fetch(libctx, mdname, propquery); + + return pd->md; +} + int ossl_prov_digest_load_from_params(PROV_DIGEST *pd, const OSSL_PARAM params[], OPENSSL_CTX *ctx) @@ -141,9 +150,8 @@ int ossl_prov_digest_load_from_params(PROV_DIGEST *pd, if (p->data_type != OSSL_PARAM_UTF8_STRING) return 0; - EVP_MD_free(pd->alloc_md); ERR_set_mark(); - pd->md = pd->alloc_md = EVP_MD_fetch(ctx, p->data, propquery); + ossl_prov_digest_fetch(pd, ctx, p->data, propquery); /* TODO legacy stuff, to be removed */ #ifndef FIPS_MODULE /* Inside the FIPS module, we don't support legacy digests */ if (pd->md == NULL) -- cgit v1.2.3