summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-02-16 17:18:06 -0300
committerVictor Shyba <victor1984@riseup.net>2017-02-16 17:32:30 -0300
commitac6d87e83f91ed61b160e7cdd968f4a6f3d68f34 (patch)
treec58ac408e71cdca560132f32b3e77c43a4007324
parentd2ef605af73a592ea21c5bae005f53f483e310a6 (diff)
[style] add deprecation warning on legacy decoder
-rw-r--r--client/src/leap/soledad/client/_crypto.py5
-rw-r--r--testing/tests/client/test_crypto.py3
2 files changed, 8 insertions, 0 deletions
diff --git a/client/src/leap/soledad/client/_crypto.py b/client/src/leap/soledad/client/_crypto.py
index c4c6d336..f91084a4 100644
--- a/client/src/leap/soledad/client/_crypto.py
+++ b/client/src/leap/soledad/client/_crypto.py
@@ -22,6 +22,7 @@ Cryptographic operations for the soledad client
import binascii
import base64
import hashlib
+import warnings
import hmac
import os
import re
@@ -278,6 +279,10 @@ class BlobDecryptor(object):
try:
if len(preamble) == LEGACY_PACMAN.size:
+ warnings.warn("Decrypting a legacy document without size. " +
+ "This will be deprecated in 0.12. Doc was: " +
+ "doc_id: %s rev: %s" % (self.doc_id, self.rev),
+ Warning)
unpacked_data = LEGACY_PACMAN.unpack(preamble)
magic, sch, meth, ts, iv, doc_id, rev = unpacked_data
elif len(preamble) == PACMAN.size:
diff --git a/testing/tests/client/test_crypto.py b/testing/tests/client/test_crypto.py
index 2d4d827b..399fdc99 100644
--- a/testing/tests/client/test_crypto.py
+++ b/testing/tests/client/test_crypto.py
@@ -292,6 +292,9 @@ class PreambleTestCase(unittest.TestCase):
self.doc_info, BytesIO(ciphertext),
secret='A' * 96).decrypt()
assert cleartext == self.cleartext.getvalue()
+ warnings = self.flushWarnings()
+ assert len(warnings) == 1
+ assert 'legacy document without size' in warnings[0]['message']
def _aes_encrypt(key, iv, data, aead=''):