From b7ed3cbb22c9896c8491b88b2cfdea5d92787323 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 14 Dec 2017 14:29:14 -0300 Subject: [feature] get_unarmored_ciphertext_size on client --- src/leap/soledad/client/_crypto.py | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 -- cgit v1.2.3