diff options
author | Matt Caswell <matt@openssl.org> | 2020-09-18 09:55:16 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2020-09-25 11:13:53 +0100 |
commit | ce64d3eee06a64e78ea5be7e8f0dd7172aa78259 (patch) | |
tree | f78916571d0e41b39c47879bc96ca7dcf4d9c088 /providers/common | |
parent | 7a032be7f293bd80e3fe18c5568cf382b0b79543 (diff) |
Move SM2 asymmetric encryption to be available in the default provider
Fixes #12908
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12913)
Diffstat (limited to 'providers/common')
-rw-r--r-- | providers/common/include/prov/provider_util.h | 8 | ||||
-rw-r--r-- | providers/common/provider_util.c | 12 |
2 files changed, 18 insertions, 2 deletions
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) |