summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2012-12-24 12:42:56 -0200
committerdrebs <drebs@leap.se>2012-12-24 12:42:56 -0200
commit34fc48331fb036c723d75acce203be3b988dc5e9 (patch)
tree8aba3fe1a41607b5f01d34d6e67b29d2e4da79be /src
parent15a5b15cf1a03cc3fbb68bfccf4cd32af8479f2a (diff)
GPGWrapper now extends gnupg.GPG
Diffstat (limited to 'src')
-rw-r--r--src/leap/soledad/util.py30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/leap/soledad/util.py b/src/leap/soledad/util.py
index 41fd4548..5d1e263e 100644
--- a/src/leap/soledad/util.py
+++ b/src/leap/soledad/util.py
@@ -2,7 +2,7 @@ import os
import gnupg
import re
-class GPGWrapper():
+class GPGWrapper(gnupg.GPG):
"""
This is a temporary class for handling GPG requests, and should be
replaced by a more general class used throughout the project.
@@ -12,13 +12,13 @@ class GPGWrapper():
GNUPG_BINARY = "/usr/bin/gpg" # this has to be changed based on OS
def __init__(self, gpghome=GNUPG_HOME, gpgbinary=GNUPG_BINARY):
- self.gpg = gnupg.GPG(gnupghome=gpghome, gpgbinary=gpgbinary)
+ super(GPGWrapper, self).__init__(gnupghome=gpghome, gpgbinary=gpgbinary)
def find_key(self, email):
"""
Find user's key based on their email.
"""
- for key in self.gpg.list_keys():
+ for key in self.list_keys():
for uid in key['uids']:
if re.search(email, uid):
return key
@@ -26,23 +26,17 @@ class GPGWrapper():
def encrypt(self, data, recipient, sign=None, always_trust=True,
passphrase=None, symmetric=False):
- return self.gpg.encrypt(data, recipient, sign=sign,
- always_trust=always_trust,
- passphrase=passphrase, symmetric=symmetric)
+ # TODO: devise a way so we don't need to "always trust".
+ return super(GPGWrapper, self).encrypt(data, recipient, sign=sign,
+ always_trust=always_trust,
+ passphrase=passphrase,
+ symmetric=symmetric)
def decrypt(self, data, always_trust=True, passphrase=None):
- result = self.gpg.decrypt(data, always_trust=always_trust,
- passphrase=passphrase)
- return result
-
- def import_keys(self, data):
- return self.gpg.import_keys(data)
-
- def gen_key_input(self, **kwargs):
- return self.gpg.gen_key_input(**kwargs)
-
- def gen_key(self, input):
- return self.gpg.gen_key(input)
+ # TODO: devise a way so we don't need to "always trust".
+ return super(GPGWrapper, self).decrypt(data,
+ always_trust=always_trust,
+ passphrase=passphrase)
#----------------------------------------------------------------------------