aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorAlex Stapleton <alexs@prol.etari.at>2013-12-21 15:16:57 +0000
committerAlex Stapleton <alexs@prol.etari.at>2013-12-21 17:12:05 +0000
commit1b1327cfe537b9e7bdc271239d1025c2479239c3 (patch)
tree8a27a12313c0ba6ab6b62757d1332e18bac2df9c /cryptography
parent9b9318d79ba5927603b120411d13b607938cae56 (diff)
downloadcryptography-1b1327cfe537b9e7bdc271239d1025c2479239c3.tar.gz
cryptography-1b1327cfe537b9e7bdc271239d1025c2479239c3.tar.bz2
cryptography-1b1327cfe537b9e7bdc271239d1025c2479239c3.zip
Raise UnsupportedAlgorithm when initing Hash()
Instead of just an AssertionError.
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