From c5b7da7d7898f18b620927657875845ca31dbf36 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Sun, 24 Dec 2017 20:20:06 -0300 Subject: [refactor] move preamble constant to its module --- src/leap/soledad/client/_crypto.py | 9 ++++----- src/leap/soledad/common/blobs/preamble.py | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/leap/soledad/client/_crypto.py b/src/leap/soledad/client/_crypto.py index 90cfe45b..ce166c94 100644 --- a/src/leap/soledad/client/_crypto.py +++ b/src/leap/soledad/client/_crypto.py @@ -90,7 +90,7 @@ from leap.soledad.common.blobs.preamble import InvalidPreambleException from leap.soledad.common.blobs.preamble import decode_preamble from leap.soledad.common.blobs.preamble import Preamble from leap.soledad.common.blobs.preamble import ENC_SCHEME, ENC_METHOD -from leap.soledad.common.blobs.preamble import MAGIC +from leap.soledad.common.blobs.preamble import MAGIC, PREAMBLE_SIZE SECRET_LENGTH = 64 @@ -543,8 +543,7 @@ def _ceiling(size): def get_unarmored_ciphertext_size(cleartext_size): # used for blobs stream up (so we can tell the server how much data we are # sending before starting to encrypt the stream) - PREAMBLE_SIZE = 736 # 552 urlsafe base64 encoded (it's always armored) - TAG_SIZE = 16 - SEPARATOR_SIZE = 1 - size = TAG_SIZE + PREAMBLE_SIZE + SEPARATOR_SIZE + tag_size = 16 # AES-GCM 16-byte tag appended to ciphertext + separator_size = 1 # space separating content from preamble + size = tag_size + PREAMBLE_SIZE + separator_size return cleartext_size + size diff --git a/src/leap/soledad/common/blobs/preamble.py b/src/leap/soledad/common/blobs/preamble.py index c84ec0fa..b27c9f3b 100644 --- a/src/leap/soledad/common/blobs/preamble.py +++ b/src/leap/soledad/common/blobs/preamble.py @@ -36,6 +36,7 @@ LEGACY_PACMAN = struct.Struct('2sbbQ16s255p255p') # DEPRECATED MAGIC = '\x13\x37' ENC_SCHEME = namedtuple('SCHEME', 'symkey external')(1, 2) ENC_METHOD = namedtuple('METHOD', 'aes_256_ctr aes_256_gcm pgp')(1, 2, 3) +PREAMBLE_SIZE = 736 # 552 urlsafe base64 encoded (it's always armored) class InvalidPreambleException(Exception): -- cgit v1.2.3