summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2017-12-26 08:48:18 -0200
committerdrebs <drebs@leap.se>2017-12-26 08:48:22 -0200
commit0cf535b26c8989a60df646f64dfcb14b59de1a86 (patch)
tree9548a11644fc90e8e1560852382f0026d86943f4
parent5087e93eea322a62f991f92bd942472f76eb5396 (diff)
[doc] improve documentation of ciphertext size estimation function
-rw-r--r--src/leap/soledad/client/_crypto.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/leap/soledad/client/_crypto.py b/src/leap/soledad/client/_crypto.py
index ce166c94..ab5fe881 100644
--- a/src/leap/soledad/client/_crypto.py
+++ b/src/leap/soledad/client/_crypto.py
@@ -541,9 +541,17 @@ 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)
+ """
+ Get the (unarmored) ciphertext size from the cleartext size.
+
+ In some cases (when streaming uploads, for example) we need to tell the
+ server how much data we are sending before starting to encrypt the stream.
+ This function returns the final size of what will be streamed from the
+ total size of the cleartext.
+ """
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
+ # without considering the preamble and tag, the ciphertext size is equal to
+ # the cleartext size.
return cleartext_size + size