diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2018-12-02 19:20:33 +0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2018-12-02 06:20:33 -0500 |
commit | afaa4c65b58e31f36a8162f88ad79829f68d0a86 (patch) | |
tree | 0660c30fe1382a2507c017b0df20c51544462258 /src/cryptography/hazmat/primitives/hmac.py | |
parent | 3531439f8a09dd40102ac0e336cb962e86d8bf57 (diff) | |
download | cryptography-afaa4c65b58e31f36a8162f88ad79829f68d0a86.tar.gz cryptography-afaa4c65b58e31f36a8162f88ad79829f68d0a86.tar.bz2 cryptography-afaa4c65b58e31f36a8162f88ad79829f68d0a86.zip |
centralize our bytes check (#4622)
this will make life a bit easier when we support bytearrays
Diffstat (limited to 'src/cryptography/hazmat/primitives/hmac.py')
-rw-r--r-- | src/cryptography/hazmat/primitives/hmac.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/cryptography/hazmat/primitives/hmac.py b/src/cryptography/hazmat/primitives/hmac.py index 2e9a4e2f..590555d9 100644 --- a/src/cryptography/hazmat/primitives/hmac.py +++ b/src/cryptography/hazmat/primitives/hmac.py @@ -38,8 +38,7 @@ class HMAC(object): def update(self, data): if self._ctx is None: raise AlreadyFinalized("Context was already finalized.") - if not isinstance(data, bytes): - raise TypeError("data must be bytes.") + utils._check_bytes("data", data) self._ctx.update(data) def copy(self): @@ -60,8 +59,7 @@ class HMAC(object): return digest def verify(self, signature): - if not isinstance(signature, bytes): - raise TypeError("signature must be bytes.") + utils._check_bytes("signature", signature) if self._ctx is None: raise AlreadyFinalized("Context was already finalized.") |