From e9fe0f7e9df7e0909ca52a024b889e48616a29d9 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Fri, 7 May 2021 17:44:26 +0200 Subject: Replace EVP_PKEY_supports_digest_nid The EVP_PKEY_supports_digest_nid() is renamed to EVP_PKEY_digestsign_supports_digest() and implemented via EVP_DigestSignInit_ex(). Fixes #14343 Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/15198) --- crypto/evp/p_lib.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'crypto') diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index d997ae80e1..6a8dc9bbbb 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -1335,22 +1335,21 @@ int EVP_PKEY_get_group_name(const EVP_PKEY *pkey, char *gname, size_t gname_sz, gname, gname_sz, gname_len); } -int EVP_PKEY_supports_digest_nid(EVP_PKEY *pkey, int nid) +int EVP_PKEY_digestsign_supports_digest(EVP_PKEY *pkey, OSSL_LIB_CTX *libctx, + const char *name, const char *propq) { - int rv = -2, default_nid; + int rv; + EVP_MD_CTX *ctx = NULL; - if (rv == -2) { - /* - * If there is a mandatory default digest and this isn't it, then - * the answer is 'no'. - */ - rv = EVP_PKEY_get_default_digest_nid(pkey, &default_nid); - if (rv == 2) - return (nid == default_nid); - /* zero is an error from EVP_PKEY_get_default_digest_nid() */ - if (rv == 0) - return -1; - } + if ((ctx = EVP_MD_CTX_new()) == NULL) + return -1; + + ERR_set_mark(); + rv = EVP_DigestSignInit_ex(ctx, NULL, name, libctx, + propq, pkey, NULL); + ERR_pop_to_mark(); + + EVP_MD_CTX_free(ctx); return rv; } -- cgit v1.2.3