diff options
author | Victor Shyba <victor1984@riseup.net> | 2017-12-14 14:29:14 -0300 |
---|---|---|
committer | Victor Shyba <victor1984@riseup.net> | 2017-12-22 13:51:27 -0300 |
commit | b7ed3cbb22c9896c8491b88b2cfdea5d92787323 (patch) | |
tree | d1329e7b6af387a0ba6581c90e586fb119d825ff /src/leap | |
parent | fcdcd5968ef6e9426925eb03412c6306c6fe4e17 (diff) |
[feature] get_unarmored_ciphertext_size on client
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/soledad/client/_crypto.py | 10 |
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 |