aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography/hazmat/primitives/cmac.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-10-30 11:03:20 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2014-10-30 11:03:20 -0700
commit9172ea9d34cc3f2b162f56a143f1398fbba2dd20 (patch)
tree523c72842d6931a230691e59cc42b20c0bb7e5cb /cryptography/hazmat/primitives/cmac.py
parent90d08975edf01b2a5e4dd127d56799a185cd646b (diff)
downloadcryptography-9172ea9d34cc3f2b162f56a143f1398fbba2dd20.tar.gz
cryptography-9172ea9d34cc3f2b162f56a143f1398fbba2dd20.tar.bz2
cryptography-9172ea9d34cc3f2b162f56a143f1398fbba2dd20.zip
Remove duplicate code, now the verify method isn't special
Diffstat (limited to 'cryptography/hazmat/primitives/cmac.py')
-rw-r--r--cryptography/hazmat/primitives/cmac.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/cryptography/hazmat/primitives/cmac.py b/cryptography/hazmat/primitives/cmac.py
index 7ae5c118..d5e26a57 100644
--- a/cryptography/hazmat/primitives/cmac.py
+++ b/cryptography/hazmat/primitives/cmac.py
@@ -59,9 +59,11 @@ class CMAC(object):
def verify(self, signature):
if not isinstance(signature, bytes):
raise TypeError("signature must be bytes.")
- digest = self.finalize()
- if not constant_time.bytes_eq(digest, signature):
- raise InvalidSignature("Signature did not match digest.")
+ if self._ctx is None:
+ raise AlreadyFinalized("Context was already finalized.")
+
+ ctx, self._ctx = self._ctx, None
+ ctx.verify(signature)
def copy(self):
if self._ctx is None: