This commit is contained in:
Mark Qvist 2022-06-08 12:52:42 +02:00
parent 76f86f782a
commit 7a596882a8
2 changed files with 7 additions and 4 deletions

View File

@ -28,6 +28,9 @@ from RNS.Cryptography import PKCS7
from RNS.Cryptography.AES import AES_128_CBC from RNS.Cryptography.AES import AES_128_CBC
class Fernet(): class Fernet():
FERNET_VERSION = 0x80
FERNET_OVERHEAD = 57 # In bytes
OPTIMISED_FERNET_OVERHEAD = 54 # In bytes
@staticmethod @staticmethod
def generate_key(): def generate_key():
@ -71,7 +74,7 @@ class Fernet():
) )
signed_parts = b"\x80"+current_time.to_bytes(length=8, byteorder="big")+iv+ciphertext 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() return signed_parts + HMAC.new(self._signing_key, signed_parts).digest()

View File

@ -56,9 +56,9 @@ class Identity:
""" """
# Non-configurable constants # Non-configurable constants
FERNET_VERSION = 0x80 FERNET_VERSION = RNS.Cryptography.Fernet.FERNET_VERSION
FERNET_OVERHEAD = 57 # In bytes FERNET_OVERHEAD = RNS.Cryptography.Fernet.FERNET_OVERHEAD
OPTIMISED_FERNET_OVERHEAD = 54 # In bytes OPTIMISED_FERNET_OVERHEAD = RNS.Cryptography.Fernet.OPTIMISED_FERNET_OVERHEAD
AES128_BLOCKSIZE = 16 # In bytes AES128_BLOCKSIZE = 16 # In bytes
HASHLENGTH = 256 # In bits HASHLENGTH = 256 # In bits
SIGLENGTH = KEYSIZE # In bits SIGLENGTH = KEYSIZE # In bits