summaryrefslogtreecommitdiff
path: root/testing/tests/client
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-03-15 20:25:35 -0300
committerdrebs <drebs@leap.se>2017-04-04 18:27:33 +0200
commit26bdafe0445cdd5c1b1174dedfd9292847e47758 (patch)
tree0e510238cbd7f1855dba36521a650c1c8b544e41 /testing/tests/client
parent02cd9d60641cd40cfc6c7b8216d5861f40f92494 (diff)
[feature] incremental decrypter
Diffstat (limited to 'testing/tests/client')
-rw-r--r--testing/tests/client/test_crypto.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/testing/tests/client/test_crypto.py b/testing/tests/client/test_crypto.py
index 44e1b2a5..11384ad7 100644
--- a/testing/tests/client/test_crypto.py
+++ b/testing/tests/client/test_crypto.py
@@ -143,6 +143,35 @@ class BlobTestCase(unittest.TestCase):
assert str(decrypted) == snowden1
@defer.inlineCallbacks
+ def test_init_with_preamble_alone(self):
+ ciphertext = yield self.blob.encrypt()
+ preamble = ciphertext.getvalue().split()[0]
+ decryptor = _crypto.BlobDecryptor(
+ self.doc_info, BytesIO(preamble),
+ start_stream=False,
+ secret='A' * 96)
+ assert decryptor._consume_preamble()
+
+ @defer.inlineCallbacks
+ def test_incremental_blob_decryptor(self):
+ ciphertext = yield self.blob.encrypt()
+ preamble, ciphertext = ciphertext.getvalue().split()
+ ciphertext = base64.urlsafe_b64decode(ciphertext)
+
+ decryptor = _crypto.BlobDecryptor(
+ self.doc_info, BytesIO(preamble),
+ start_stream=False,
+ secret='A' * 96,
+ tag=ciphertext[-16:])
+ ciphertext = BytesIO(ciphertext[:-16])
+ chunk = ciphertext.read(10)
+ while chunk:
+ decryptor.write(chunk)
+ chunk = ciphertext.read(10)
+ decrypted = decryptor._end_stream()
+ assert decrypted.getvalue() == snowden1
+
+ @defer.inlineCallbacks
def test_blob_decryptor(self):
ciphertext = yield self.blob.encrypt()