From 7a596882a83989709dd666bdc6330f0fb1ceedbe Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Wed, 8 Jun 2022 12:52:42 +0200 Subject: [PATCH] Cleanup --- RNS/Cryptography/Fernet.py | 5 ++++- RNS/Identity.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/RNS/Cryptography/Fernet.py b/RNS/Cryptography/Fernet.py index 790747b..7227b90 100644 --- a/RNS/Cryptography/Fernet.py +++ b/RNS/Cryptography/Fernet.py @@ -28,6 +28,9 @@ from RNS.Cryptography import PKCS7 from RNS.Cryptography.AES import AES_128_CBC class Fernet(): + FERNET_VERSION = 0x80 + FERNET_OVERHEAD = 57 # In bytes + OPTIMISED_FERNET_OVERHEAD = 54 # In bytes @staticmethod def generate_key(): @@ -71,7 +74,7 @@ class Fernet(): ) signed_parts = b"\x80"+current_time.to_bytes(length=8, byteorder="big")+iv+ciphertext - + return signed_parts + HMAC.new(self._signing_key, signed_parts).digest() diff --git a/RNS/Identity.py b/RNS/Identity.py index 4a29596..cf7d575 100644 --- a/RNS/Identity.py +++ b/RNS/Identity.py @@ -56,9 +56,9 @@ class Identity: """ # Non-configurable constants - FERNET_VERSION = 0x80 - FERNET_OVERHEAD = 57 # In bytes - OPTIMISED_FERNET_OVERHEAD = 54 # In bytes + FERNET_VERSION = RNS.Cryptography.Fernet.FERNET_VERSION + FERNET_OVERHEAD = RNS.Cryptography.Fernet.FERNET_OVERHEAD + OPTIMISED_FERNET_OVERHEAD = RNS.Cryptography.Fernet.OPTIMISED_FERNET_OVERHEAD AES128_BLOCKSIZE = 16 # In bytes HASHLENGTH = 256 # In bits SIGLENGTH = KEYSIZE # In bits