From 00baf58a71ccd0842e483ac034a0658e8945f887 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 6 Feb 2023 11:35:43 +0100 Subject: [PATCH] [crypto,x509] simplify retrieval of default signature digest --- libfreerdp/crypto/x509_utils.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libfreerdp/crypto/x509_utils.c b/libfreerdp/crypto/x509_utils.c index 37676724f..edf09bd27 100644 --- a/libfreerdp/crypto/x509_utils.c +++ b/libfreerdp/crypto/x509_utils.c @@ -718,13 +718,15 @@ WINPR_MD_TYPE x509_utils_get_signature_alg(const X509* xcert) { WINPR_ASSERT(xcert); - const int nid = X509_get_signature_nid(xcert); + EVP_PKEY* evp = X509_get0_pubkey(xcert); + WINPR_ASSERT(evp); - int hash_nid = 0; - if (OBJ_find_sigid_algs(nid, &hash_nid, NULL) != 1) + int nid = 0; + const int res = EVP_PKEY_get_default_digest_nid(evp, &nid); + if (res <= 0) return WINPR_MD_NONE; - switch (hash_nid) + switch (nid) { case NID_md2: return WINPR_MD_MD2;