[crypto,x509] simplify retrieval of default signature digest

This commit is contained in:
akallabeth 2023-02-06 11:35:43 +01:00 committed by akallabeth
parent e43b4bc091
commit 00baf58a71

View File

@ -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;