diff options
author | Alex Stapleton <alexs@prol.etari.at> | 2014-05-17 15:16:51 +0100 |
---|---|---|
committer | Alex Stapleton <alexs@prol.etari.at> | 2014-05-17 15:16:51 +0100 |
commit | a741aad3bd7d6347b9816025cb4905558c2c71c6 (patch) | |
tree | 6fdc0df70cd1bbecd56049208899111a8edcd202 /cryptography/hazmat/primitives/hmac.py | |
parent | 60437c370d079d55db2c284e2f241ecde3b61cbf (diff) | |
parent | 00eff9ca7fece942670429824cb77dd532190c96 (diff) | |
download | cryptography-a741aad3bd7d6347b9816025cb4905558c2c71c6.tar.gz cryptography-a741aad3bd7d6347b9816025cb4905558c2c71c6.tar.bz2 cryptography-a741aad3bd7d6347b9816025cb4905558c2c71c6.zip |
Merge pull request #1048 from Ayrx/change-unicode-check
Fixed TypeError and added documentation
Diffstat (limited to 'cryptography/hazmat/primitives/hmac.py')
-rw-r--r-- | cryptography/hazmat/primitives/hmac.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/cryptography/hazmat/primitives/hmac.py b/cryptography/hazmat/primitives/hmac.py index afbb2f75..5d7bad59 100644 --- a/cryptography/hazmat/primitives/hmac.py +++ b/cryptography/hazmat/primitives/hmac.py @@ -46,8 +46,8 @@ class HMAC(object): def update(self, msg): if self._ctx is None: raise AlreadyFinalized("Context was already finalized") - if isinstance(msg, six.text_type): - raise TypeError("Unicode-objects must be encoded before hashing") + if not isinstance(msg, six.binary_type): + raise TypeError("msg must be bytes") self._ctx.update(msg) def copy(self): @@ -68,8 +68,8 @@ class HMAC(object): return digest def verify(self, signature): - if isinstance(signature, six.text_type): - raise TypeError("Unicode-objects must be encoded before verifying") + if not isinstance(signature, six.binary_type): + raise TypeError("signature must be bytes") digest = self.finalize() if not constant_time.bytes_eq(digest, signature): raise InvalidSignature("Signature did not match digest.") |