diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2019-01-17 09:41:25 -0600 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2019-01-17 10:41:25 -0500 |
commit | 8d9ea52be9e7de1373641d3afaed9b292cb03f43 (patch) | |
tree | 4ac1aba34cc455f4e0b20b8b3a010ef81221a6c8 /src | |
parent | b480d2d4dbc6339f476d49faa0900eae2f4c1d07 (diff) | |
download | cryptography-8d9ea52be9e7de1373641d3afaed9b292cb03f43.tar.gz cryptography-8d9ea52be9e7de1373641d3afaed9b292cb03f43.tar.bz2 cryptography-8d9ea52be9e7de1373641d3afaed9b292cb03f43.zip |
support byteslike in hmac update (#4705)
needed for some KDF keying material
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/hmac.py | 3 | ||||
-rw-r--r-- | src/cryptography/hazmat/primitives/hmac.py | 2 |
2 files changed, 3 insertions, 2 deletions
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): |