diff options
author | Alex Stapleton <alexs@prol.etari.at> | 2013-12-21 21:26:55 +0000 |
---|---|---|
committer | Alex Stapleton <alexs@prol.etari.at> | 2013-12-21 21:32:02 +0000 |
commit | 447d64fb69e19c0059e3ba18ef3b1317a716a7c4 (patch) | |
tree | 39debf1be2daed29df51e240164f4f229caf9c64 /cryptography | |
parent | 9b9318d79ba5927603b120411d13b607938cae56 (diff) | |
download | cryptography-447d64fb69e19c0059e3ba18ef3b1317a716a7c4.tar.gz cryptography-447d64fb69e19c0059e3ba18ef3b1317a716a7c4.tar.bz2 cryptography-447d64fb69e19c0059e3ba18ef3b1317a716a7c4.zip |
Raise UnsupportedAlgorithm when initing HMACs
Diffstat (limited to 'cryptography')
-rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 6 |
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..94826874 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -442,7 +442,11 @@ class _HMACContext(object): ctx = self._backend.ffi.gc(ctx, self._backend.lib.HMAC_CTX_cleanup) 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.Cryptography_HMAC_Init_ex( ctx, key, len(key), evp_md, self._backend.ffi.NULL ) |