aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/hazmat/backends/openssl/backend.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
index 18238e1c..cf0300e0 100644
--- a/src/cryptography/hazmat/backends/openssl/backend.py
+++ b/src/cryptography/hazmat/backends/openssl/backend.py
@@ -662,6 +662,14 @@ class Backend(object):
if not isinstance(algorithm, hashes.HashAlgorithm):
raise TypeError('Algorithm must be a registered hash algorithm.')
+ if (
+ isinstance(algorithm, hashes.MD5) and not
+ isinstance(private_key, rsa.RSAPrivateKey)
+ ):
+ raise ValueError(
+ "MD5 is not a supported hash algorithm for EC/DSA CSRs"
+ )
+
# Resolve the signature algorithm.
evp_md = self._lib.EVP_get_digestbyname(
algorithm.name.encode('ascii')
@@ -731,6 +739,14 @@ class Backend(object):
if not isinstance(algorithm, hashes.HashAlgorithm):
raise TypeError('Algorithm must be a registered hash algorithm.')
+ if (
+ isinstance(algorithm, hashes.MD5) and not
+ isinstance(private_key, rsa.RSAPrivateKey)
+ ):
+ raise ValueError(
+ "MD5 is not a supported hash algorithm for EC/DSA certificates"
+ )
+
# Resolve the signature algorithm.
evp_md = self._lib.EVP_get_digestbyname(
algorithm.name.encode('ascii')
@@ -828,6 +844,14 @@ class Backend(object):
if not isinstance(algorithm, hashes.HashAlgorithm):
raise TypeError('Algorithm must be a registered hash algorithm.')
+ if (
+ isinstance(algorithm, hashes.MD5) and not
+ isinstance(private_key, rsa.RSAPrivateKey)
+ ):
+ raise ValueError(
+ "MD5 is not a supported hash algorithm for EC/DSA CRLs"
+ )
+
evp_md = self._lib.EVP_get_digestbyname(
algorithm.name.encode('ascii')
)