Verified Commit c5b7da7d authored by Victor's avatar Victor
Browse files

[refactor] move preamble constant to its module

parent a3d267e0
......@@ -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
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment