aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2019-01-16 22:07:17 -0600
committerAlex Gaynor <alex.gaynor@gmail.com>2019-01-16 23:07:17 -0500
commitb480d2d4dbc6339f476d49faa0900eae2f4c1d07 (patch)
tree6e2345d51feefdec0abbdc878b44b84bdb859628 /tests/hazmat
parentbfc6fae472457c37abafb3818b44f0bd639be6cc (diff)
downloadcryptography-b480d2d4dbc6339f476d49faa0900eae2f4c1d07.tar.gz
cryptography-b480d2d4dbc6339f476d49faa0900eae2f4c1d07.tar.bz2
cryptography-b480d2d4dbc6339f476d49faa0900eae2f4c1d07.zip
support byteslike in hash updates (#4702)
This is needed to handle keying material in some of the KDFs
Diffstat (limited to 'tests/hazmat')
-rw-r--r--tests/hazmat/primitives/test_hashes.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_hashes.py b/tests/hazmat/primitives/test_hashes.py
index c2b866f7..6cba84b5 100644
--- a/tests/hazmat/primitives/test_hashes.py
+++ b/tests/hazmat/primitives/test_hashes.py
@@ -4,6 +4,8 @@
from __future__ import absolute_import, division, print_function
+import binascii
+
import pytest
from cryptography.exceptions import AlreadyFinalized, _Reasons
@@ -167,3 +169,13 @@ def test_invalid_backend():
with raises_unsupported_algorithm(_Reasons.BACKEND_MISSING_INTERFACE):
hashes.Hash(hashes.SHA1(), pretend_backend)
+
+
+@pytest.mark.requires_backend_interface(interface=HashBackend)
+def test_buffer_protocol_hash(backend):
+ data = binascii.unhexlify(b"b4190e")
+ h = hashes.Hash(hashes.SHA256(), backend)
+ h.update(bytearray(data))
+ assert h.finalize() == binascii.unhexlify(
+ b"dff2e73091f6c05e528896c4c831b9448653dc2ff043528f6769437bc7b975c2"
+ )