summaryrefslogtreecommitdiff
path: root/client/src/leap/soledad
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-03-27 23:57:21 -0300
committerdrebs <drebs@leap.se>2017-04-19 11:37:06 +0200
commit7bfa9951b211806157101804d086eaabe47c6498 (patch)
treed19b0c5edd2738b693cff7fddc7424efe1bdd8e7 /client/src/leap/soledad
parent7acbef762be976ab484889f411382e7bd2b8551d (diff)
[bug] adapt blob size to fake size from #8758
Issue #8758 rounded doc size considering we would add some kind of padding to the document. Since we arent removing the pad, this commit makes the client discover the size from the decrypted amount. Proper padding and strip should be done in the future. - Related: #8758 - Related: #8814
Diffstat (limited to 'client/src/leap/soledad')
-rw-r--r--client/src/leap/soledad/client/_blobs.py3
-rw-r--r--client/src/leap/soledad/client/_crypto.py6
2 files changed, 8 insertions, 1 deletions
diff --git a/client/src/leap/soledad/client/_blobs.py b/client/src/leap/soledad/client/_blobs.py
index 99ed1678..24e2fa65 100644
--- a/client/src/leap/soledad/client/_blobs.py
+++ b/client/src/leap/soledad/client/_blobs.py
@@ -125,7 +125,8 @@ class DecrypterBuffer(object):
self.preamble_pipe.write(data)
def close(self):
- return self.decrypter._end_stream(), self.decrypter.size
+ real_size = self.decrypter.decrypted_content_size
+ return self.decrypter._end_stream(), real_size
class BlobManager(object):
diff --git a/client/src/leap/soledad/client/_crypto.py b/client/src/leap/soledad/client/_crypto.py
index 868fcd0d..7a1d508e 100644
--- a/client/src/leap/soledad/client/_crypto.py
+++ b/client/src/leap/soledad/client/_crypto.py
@@ -360,6 +360,10 @@ class BlobDecryptor(object):
if start_stream:
self._start_stream()
+ @property
+ def decrypted_content_size(self):
+ return self._aes.written
+
def _start_stream(self):
self._producer = FileBodyProducer(self.fd, readSize=2**16)
@@ -485,6 +489,7 @@ class AESWriter(object):
cipher = _get_aes_cipher(key, self.iv, tag, mode)
cipher = cipher.decryptor() if tag else cipher.encryptor()
self.cipher, self.aead = cipher, ''
+ self.written = 0
def authenticate(self, data):
self.aead += data
@@ -495,6 +500,7 @@ class AESWriter(object):
return getattr(self.cipher, 'tag', None)
def write(self, data):
+ self.written += len(data)
self.buffer.write(self.cipher.update(data))
def end(self):