aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2018-10-22 18:49:54 +0100
committerNicola Tuveri <nic.tuv@gmail.com>2018-11-10 03:23:14 +0200
commitecbb2fca9301ef22b15beb30c4c0303b29846935 (patch)
tree28568a5d29802e457a3ca4285f5945ed2508069a /crypto/evp
parent2d263a4a73f852005b16359873475d48755999ad (diff)
downloadopenssl-ecbb2fca9301ef22b15beb30c4c0303b29846935.tar.gz
Add EVP_PKEY_supports_digest_nid()
Rather than relying only on mandatory default digests, add a way for the EVP_PKEY to individually report whether each digest algorithm is supported. Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7408)
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/p_lib.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c
index 154ef788e8..c8f3264408 100644
--- a/crypto/evp/p_lib.c
+++ b/crypto/evp/p_lib.c
@@ -667,6 +667,26 @@ int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid)
return evp_pkey_asn1_ctrl(pkey, ASN1_PKEY_CTRL_DEFAULT_MD_NID, 0, pnid);
}
+int EVP_PKEY_supports_digest_nid(EVP_PKEY *pkey, int nid)
+{
+ int rv, default_nid;
+
+ rv = evp_pkey_asn1_ctrl(pkey, ASN1_PKEY_CTRL_SUPPORTS_MD_NID, nid, 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;
+ }
+ return rv;
+}
+
int EVP_PKEY_set1_tls_encodedpoint(EVP_PKEY *pkey,
const unsigned char *pt, size_t ptlen)
{