aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-12-14 08:43:51 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2013-12-14 08:43:51 -0800
commitbadee1b5faf9c6bcc099aee0c6c1d9d29af8b7c7 (patch)
treea51ad68d91f8e7156fb4882f0cb928b7af8bcf69 /cryptography
parent022bc3afd8b8901b940a6bf0aa4f863914557c7e (diff)
downloadcryptography-badee1b5faf9c6bcc099aee0c6c1d9d29af8b7c7.tar.gz
cryptography-badee1b5faf9c6bcc099aee0c6c1d9d29af8b7c7.tar.bz2
cryptography-badee1b5faf9c6bcc099aee0c6c1d9d29af8b7c7.zip
Reduce duplication
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/fernet.py6
1 files 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])