diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-12-21 14:34:21 -0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-12-21 14:34:21 -0800 |
commit | 9b7624e3cd4d19cae38bc8f05eea7b6164445453 (patch) | |
tree | 16b8ecff0fd839b221c596642a118dee9acb05d1 /tests | |
parent | 4447e5a72c6c5d4f3f8fc27711e094540d66ef67 (diff) | |
parent | 447d64fb69e19c0059e3ba18ef3b1317a716a7c4 (diff) | |
download | cryptography-9b7624e3cd4d19cae38bc8f05eea7b6164445453.tar.gz cryptography-9b7624e3cd4d19cae38bc8f05eea7b6164445453.tar.bz2 cryptography-9b7624e3cd4d19cae38bc8f05eea7b6164445453.zip |
Merge pull request #326 from public/unsupported-hmac-hash
Raise UnsupportedAlgorithm when initing HMACs
Diffstat (limited to 'tests')
-rw-r--r-- | tests/hazmat/primitives/test_hmac.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/hazmat/primitives/test_hmac.py b/tests/hazmat/primitives/test_hmac.py index 992bcb1a..124c4377 100644 --- a/tests/hazmat/primitives/test_hmac.py +++ b/tests/hazmat/primitives/test_hmac.py @@ -19,12 +19,18 @@ import pytest import six -from cryptography.exceptions import AlreadyFinalized -from cryptography.hazmat.primitives import hashes, hmac +from cryptography import utils +from cryptography.exceptions import AlreadyFinalized, UnsupportedAlgorithm +from cryptography.hazmat.primitives import hashes, hmac, interfaces from .utils import generate_base_hmac_test +@utils.register_interface(interfaces.HashAlgorithm) +class UnsupportedDummyHash(object): + name = "unsupported-dummy-hash" + + class TestHMAC(object): test_copy = generate_base_hmac_test( hashes.MD5(), @@ -63,3 +69,7 @@ class TestHMAC(object): with pytest.raises(AlreadyFinalized): h.finalize() + + def test_unsupported_hash(self, backend): + with pytest.raises(UnsupportedAlgorithm): + hmac.HMAC(b"key", UnsupportedDummyHash(), backend) |