diff options
author | drebs <drebs@leap.se> | 2013-01-28 11:48:32 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-01-28 11:48:32 -0200 |
commit | 3101a2edd3ade3945965829b4e7e1eb624133aec (patch) | |
tree | 4c855f418522e0a4815db25109db1991f468f8d0 /backends/leap_backend.py | |
parent | 0a4548d55b22b21d5d54e88a0cd1e5b118b867f7 (diff) |
LeapSyncTarget checks whether document has been correctly encrypted.
Diffstat (limited to 'backends/leap_backend.py')
-rw-r--r-- | backends/leap_backend.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/backends/leap_backend.py b/backends/leap_backend.py index ec26dca4..f73698f2 100644 --- a/backends/leap_backend.py +++ b/backends/leap_backend.py @@ -20,6 +20,10 @@ class NoSoledadInstance(Exception): pass +class DocumentEncryptionFailed(Exception): + pass + + class LeapDocument(Document): """ LEAP Documents are standard u1db documents with cabability of returning an @@ -181,9 +185,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]) |