From 8d9ea52be9e7de1373641d3afaed9b292cb03f43 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 17 Jan 2019 09:41:25 -0600 Subject: support byteslike in hmac update (#4705) needed for some KDF keying material --- src/cryptography/hazmat/backends/openssl/hmac.py | 3 ++- src/cryptography/hazmat/primitives/hmac.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/cryptography/hazmat/backends/openssl/hmac.py b/src/cryptography/hazmat/backends/openssl/hmac.py index b606e111..b23ac649 100644 --- a/src/cryptography/hazmat/backends/openssl/hmac.py +++ b/src/cryptography/hazmat/backends/openssl/hmac.py @@ -56,7 +56,8 @@ class _HMACContext(object): ) def update(self, data): - res = self._backend._lib.HMAC_Update(self._ctx, data, len(data)) + data_ptr = self._backend._ffi.from_buffer(data) + res = self._backend._lib.HMAC_Update(self._ctx, data_ptr, len(data)) self._backend.openssl_assert(res != 0) def finalize(self): diff --git a/src/cryptography/hazmat/primitives/hmac.py b/src/cryptography/hazmat/primitives/hmac.py index 590555d9..f7f401d2 100644 --- a/src/cryptography/hazmat/primitives/hmac.py +++ b/src/cryptography/hazmat/primitives/hmac.py @@ -38,7 +38,7 @@ class HMAC(object): def update(self, data): if self._ctx is None: raise AlreadyFinalized("Context was already finalized.") - utils._check_bytes("data", data) + utils._check_byteslike("data", data) self._ctx.update(data) def copy(self): -- cgit v1.2.3