diff options
author | drebs <drebs@leap.se> | 2013-02-09 22:27:22 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-02-09 22:27:22 -0200 |
commit | 46a3373295a683db9b66c233b07a7a948b8147bc (patch) | |
tree | 410a47871bfd8654ddabbb53f3c29a89c1550e71 /src/leap/soledad/backends/leap_backend.py | |
parent | e726f3df7c7efbe4069846468ffdbed6829ccfc4 (diff) | |
parent | b376948ccd59aa02022123102eaae359a536e4e6 (diff) |
Merge branch 'develop' into feature/soledad-api
Diffstat (limited to 'src/leap/soledad/backends/leap_backend.py')
-rw-r--r-- | src/leap/soledad/backends/leap_backend.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/leap/soledad/backends/leap_backend.py b/src/leap/soledad/backends/leap_backend.py index c0a22feb..c3c52ee6 100644 --- a/src/leap/soledad/backends/leap_backend.py +++ b/src/leap/soledad/backends/leap_backend.py @@ -20,6 +20,10 @@ class NoSoledadInstance(Exception): pass +class DocumentEncryptionFailed(Exception): + pass + + class LeapDocument(Document): """ Encryptable and syncable document. @@ -164,9 +168,17 @@ class LeapSyncTarget(HTTPSyncTarget): comma = ',' for doc, gen, trans_id in docs_by_generations: if doc.syncable: - # encrypt before sending to server. + # encrypt and verify before sending to server. + doc_content = doc.get_encrypted_json() + if doc_content == doc.get_json(): + raise DocumentEncryptionFailed + enc_doc = LeapDocument(doc.doc_id, doc.rev, + encrypted_json=doc_content, + soledad=self._soledad) + if doc.get_json() != enc_doc.get_json(): + raise DocumentEncryptionFailed size += prepare(id=doc.doc_id, rev=doc.rev, - content=doc.get_encrypted_json(), + content=doc_content, gen=gen, trans_id=trans_id) entries.append('\r\n]') size += len(entries[-1]) |