summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2012-12-03 10:32:54 -0200
committerdrebs <drebs@leap.se>2012-12-03 10:32:54 -0200
commit8febf0c6f71395bbc8a24440beb28dfb719ba01c (patch)
treee9429a787e94c387027cdb79e78a6e65fb64f5ce /src/leap
parent3d912f8d1767202d3ad9fbfa0a36496413ddfead (diff)
Add LeapDocument methods for encrypting/decrypting
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/soledad/__init__.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/leap/soledad/__init__.py b/src/leap/soledad/__init__.py
index 3d685635..94286370 100644
--- a/src/leap/soledad/__init__.py
+++ b/src/leap/soledad/__init__.py
@@ -16,6 +16,7 @@ from u1db import (
)
from swiftclient import client
+import base64
class OpenStackDatabase(CommonBackend):
@@ -148,10 +149,20 @@ class OpenStackDatabase(CommonBackend):
class LeapDocument(Document):
def get_content_encrypted(self):
- raise NotImplementedError(self.get_content_encrypted)
+ """
+ Returns document's json serialization encrypted with user's public key.
+ """
+ # TODO: replace for openpgp encryption with users's pub key.
+ return base64.b64encode(self.get_json())
def set_content_encrypted(self):
- raise NotImplementedError(self.set_content_encrypted)
+ """
+ Set document's content based on encrypted version of json string.
+ """
+ # TODO:
+ # - replace for openpgp decryption using user's priv key.
+ # - raise error if unsuccessful.
+ return self.set_json(base64.b64decode(self.get_json()))
class OpenStackSyncTarget(CommonSyncTarget):