From badee1b5faf9c6bcc099aee0c6c1d9d29af8b7c7 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 14 Dec 2013 08:43:51 -0800 Subject: Reduce duplication --- cryptography/fernet.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cryptography/fernet.py b/cryptography/fernet.py index 3fcd187c..3cab5479 100644 --- a/cryptography/fernet.py +++ b/cryptography/fernet.py @@ -85,13 +85,13 @@ class Fernet(object): raise InvalidToken assert six.indexbytes(data, 0) == 0x80 - timestamp = data[1:9] + timestamp = struct.unpack(">Q", data[1:9])[0] iv = data[9:25] ciphertext = data[25:-32] if ttl is not None: - if struct.unpack(">Q", timestamp)[0] + ttl < current_time: + if timestamp + ttl < current_time: raise InvalidToken - if current_time + _MAX_CLOCK_SKEW < struct.unpack(">Q", timestamp)[0]: + if current_time + _MAX_CLOCK_SKEW < timestamp: raise InvalidToken h = HMAC(self.signing_key, hashes.SHA256(), self.backend) h.update(data[:-32]) -- cgit v1.2.3