summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-12-14 14:29:14 -0300
committerVictor Shyba <victor1984@riseup.net>2017-12-22 13:51:27 -0300
commitb7ed3cbb22c9896c8491b88b2cfdea5d92787323 (patch)
treed1329e7b6af387a0ba6581c90e586fb119d825ff
parentfcdcd5968ef6e9426925eb03412c6306c6fe4e17 (diff)
[feature] get_unarmored_ciphertext_size on client
-rw-r--r--src/leap/soledad/client/_crypto.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/leap/soledad/client/_crypto.py b/src/leap/soledad/client/_crypto.py
index 873b82a8..90cfe45b 100644
--- a/src/leap/soledad/client/_crypto.py
+++ b/src/leap/soledad/client/_crypto.py
@@ -538,3 +538,13 @@ def _ceiling(size):
step = 2 ** i
if size < step:
return step
+
+
+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
+ return cleartext_size + size