aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-12-21 10:38:58 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2013-12-21 10:38:58 -0800
commit4447e5a72c6c5d4f3f8fc27711e094540d66ef67 (patch)
treee83aaec9dac1c1cdcf8a0798d1eeac5f78f1e875 /cryptography
parent72d3b80eeb5c31fb487f56f38f283b6416301ad9 (diff)
parent1b1327cfe537b9e7bdc271239d1025c2479239c3 (diff)
downloadcryptography-4447e5a72c6c5d4f3f8fc27711e094540d66ef67.tar.gz
cryptography-4447e5a72c6c5d4f3f8fc27711e094540d66ef67.tar.bz2
cryptography-4447e5a72c6c5d4f3f8fc27711e094540d66ef67.zip
Merge pull request #324 from public/unsupported-hash
Raise UnsupportedAlgorithm when initing Hash()
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/hazmat/backends/openssl/backend.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py
index 588a4273..5b7cb3de 100644
--- a/cryptography/hazmat/backends/openssl/backend.py
+++ b/cryptography/hazmat/backends/openssl/backend.py
@@ -400,7 +400,11 @@ class _HashContext(object):
self._backend.lib.EVP_MD_CTX_destroy)
evp_md = self._backend.lib.EVP_get_digestbyname(
algorithm.name.encode("ascii"))
- assert evp_md != self._backend.ffi.NULL
+ if evp_md == self._backend.ffi.NULL:
+ raise UnsupportedAlgorithm(
+ "{0} is not a supported hash on this backend".format(
+ algorithm.name)
+ )
res = self._backend.lib.EVP_DigestInit_ex(ctx, evp_md,
self._backend.ffi.NULL)
assert res != 0