aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_hmac.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hazmat/primitives/test_hmac.py')
-rw-r--r--tests/hazmat/primitives/test_hmac.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_hmac.py b/tests/hazmat/primitives/test_hmac.py
index 50aa9cc2..b6d18ff1 100644
--- a/tests/hazmat/primitives/test_hmac.py
+++ b/tests/hazmat/primitives/test_hmac.py
@@ -4,6 +4,8 @@
from __future__ import absolute_import, division, print_function
+import binascii
+
import pytest
from cryptography.exceptions import (
@@ -79,6 +81,14 @@ class TestHMAC(object):
with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_HASH):
hmac.HMAC(b"key", DummyHashAlgorithm(), backend)
+ def test_buffer_protocol(self, backend):
+ key = bytearray(b"2b7e151628aed2a6abf7158809cf4f3c")
+ h = hmac.HMAC(key, hashes.SHA256(), backend)
+ h.update(b"6bc1bee22e409f96e93d7e117393172a")
+ assert h.finalize() == binascii.unhexlify(
+ b"a1bf7169c56a501c6585190ff4f07cad6e492a3ee187c0372614fb444b9fc3f0"
+ )
+
def test_invalid_backend():
pretend_backend = object()