From b480d2d4dbc6339f476d49faa0900eae2f4c1d07 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Wed, 16 Jan 2019 22:07:17 -0600 Subject: support byteslike in hash updates (#4702) This is needed to handle keying material in some of the KDFs --- tests/hazmat/primitives/test_hashes.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') 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" + ) -- cgit v1.2.3