summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-12-24 20:20:06 -0300
committerVictor Shyba <victor1984@riseup.net>2017-12-24 20:20:06 -0300
commitc5b7da7d7898f18b620927657875845ca31dbf36 (patch)
treef815ab9cd4b11dbd0fe24947d7c07577dd2584ab
parenta3d267e087c6b268f64f32f5f6e65e89b0c577df (diff)
[refactor] move preamble constant to its module
-rw-r--r--src/leap/soledad/client/_crypto.py9
-rw-r--r--src/leap/soledad/common/blobs/preamble.py1
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):