diff options
Diffstat (limited to 'tests/hazmat/primitives/test_hmac.py')
-rw-r--r-- | tests/hazmat/primitives/test_hmac.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/hazmat/primitives/test_hmac.py b/tests/hazmat/primitives/test_hmac.py index 6d8cc27b..c216dd4d 100644 --- a/tests/hazmat/primitives/test_hmac.py +++ b/tests/hazmat/primitives/test_hmac.py @@ -13,6 +13,8 @@ from __future__ import absolute_import, division, print_function +import binascii + import pretend import pytest @@ -23,8 +25,6 @@ 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): @@ -33,11 +33,16 @@ class UnsupportedDummyHash(object): @pytest.mark.hmac class TestHMAC(object): - test_copy = generate_base_hmac_test( - hashes.MD5(), + @pytest.mark.supported( only_if=lambda backend: backend.hmac_supported(hashes.MD5), skip_message="Does not support MD5", ) + def test_hmac_copy(self, backend): + key = b"ab" + h = hmac.HMAC(binascii.unhexlify(key), hashes.MD5(), backend=backend) + h_copy = h.copy() + assert h != h_copy + assert h._ctx != h_copy._ctx def test_hmac_reject_unicode(self, backend): h = hmac.HMAC(b"mykey", hashes.SHA1(), backend=backend) |