diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2019-01-16 19:10:48 -0600 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2019-01-16 20:10:48 -0500 |
commit | bfc6fae472457c37abafb3818b44f0bd639be6cc (patch) | |
tree | 6670cd7d3ee34e8af308f4fe27af6dcb5a89d9b5 /tests/hazmat/primitives/test_cmac.py | |
parent | c6656af81d3b4440d0d1032fd82e64d717541d62 (diff) | |
download | cryptography-bfc6fae472457c37abafb3818b44f0bd639be6cc.tar.gz cryptography-bfc6fae472457c37abafb3818b44f0bd639be6cc.tar.bz2 cryptography-bfc6fae472457c37abafb3818b44f0bd639be6cc.zip |
support bytes-like keys in CMAC and HMAC contexts (#4701)
Diffstat (limited to 'tests/hazmat/primitives/test_cmac.py')
-rw-r--r-- | tests/hazmat/primitives/test_cmac.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_cmac.py b/tests/hazmat/primitives/test_cmac.py index 2ca05d6d..e319396d 100644 --- a/tests/hazmat/primitives/test_cmac.py +++ b/tests/hazmat/primitives/test_cmac.py @@ -183,6 +183,19 @@ class TestCMAC(object): copy_cmac = cmac.copy() assert cmac.finalize() == copy_cmac.finalize() + @pytest.mark.supported( + only_if=lambda backend: backend.cmac_algorithm_supported( + AES(fake_key)), + skip_message="Does not support CMAC." + ) + def test_buffer_protocol(self, backend): + key = bytearray(b"2b7e151628aed2a6abf7158809cf4f3c") + cmac = CMAC(AES(key), backend) + cmac.update(b"6bc1bee22e409f96e93d7e117393172a") + assert cmac.finalize() == binascii.unhexlify( + b"a21e6e647bfeaf5ca0a5e1bcd957dfad" + ) + def test_invalid_backend(): key = b"2b7e151628aed2a6abf7158809cf4f3c" |