summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/keymanager
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/keymanager')
-rw-r--r--src/leap/bitmask/keymanager/__init__.py8
-rw-r--r--src/leap/bitmask/keymanager/openpgp.py27
-rw-r--r--src/leap/bitmask/keymanager/wrapper.py18
3 files changed, 28 insertions, 25 deletions
diff --git a/src/leap/bitmask/keymanager/__init__.py b/src/leap/bitmask/keymanager/__init__.py
index 3798ce0..27c9853 100644
--- a/src/leap/bitmask/keymanager/__init__.py
+++ b/src/leap/bitmask/keymanager/__init__.py
@@ -98,11 +98,11 @@ class KeyManager(object):
self.uid = uid
self._openpgp = OpenPGPScheme(soledad, gpgbinary=gpgbinary)
create = self._create_combined_bundle_file
- try:
+ try:
self._combined_ca_bundle = combined_ca_bundle or create()
- except Exception:
- logger.warn('error while creating combined ca bundle')
- self._combined_ca_bundle = ''
+ except Exception:
+ logger.warn('error while creating combined ca bundle')
+ self._combined_ca_bundle = ''
self._async_client = HTTPClient(self._combined_ca_bundle)
self._async_client_pinned = HTTPClient(self._ca_cert_path)
diff --git a/src/leap/bitmask/keymanager/openpgp.py b/src/leap/bitmask/keymanager/openpgp.py
index 5c97794..02b5456 100644
--- a/src/leap/bitmask/keymanager/openpgp.py
+++ b/src/leap/bitmask/keymanager/openpgp.py
@@ -63,11 +63,14 @@ try:
GNUPG_NG = True
except ImportError:
GNUPG_NG = False
+
class GPGUtilities(object):
+
def __init__(self, gpg):
- self.gpg = gpg
- def is_encrypted_asym(self, raw_data):
- result = self._gpg.list_packets(raw_data)
+ self.gpg = gpg
+
+ def is_encrypted_asym(self, raw_data):
+ result = self._gpg.list_packets(raw_data)
return bool(result.key)
@@ -586,10 +589,10 @@ class OpenPGPScheme(object):
passphrase=passphrase, symmetric=False,
cipher_algo=cipher_algo)
if not GNUPG_NG:
- kw.pop('cipher_algo')
- kw.pop('default_key')
- kw.update(passphrase='')
- kw.update(always_trust=True)
+ kw.pop('cipher_algo')
+ kw.pop('default_key')
+ kw.update(passphrase='')
+ kw.update(always_trust=True)
result = yield from_thread(
gpg.encrypt,
data, pubkey.fingerprint, **kw)
@@ -692,12 +695,12 @@ class OpenPGPScheme(object):
# result.fingerprint - contains the fingerprint of the key used to
# sign.
with TempGPGWrapper(privkey, self._gpgbinary) as gpg:
- kw = dict(default_key=privkey.fingerprint,
- digest_algo=digest_algo, clearsign=clearsign,
- detach=detach, binary=binary)
+ kw = dict(default_key=privkey.fingerprint,
+ digest_algo=digest_algo, clearsign=clearsign,
+ detach=detach, binary=binary)
if not GNUPG_NG:
- kw.pop('digest_algo')
- kw.pop('default_key')
+ kw.pop('digest_algo')
+ kw.pop('default_key')
result = gpg.sign(data, **kw)
rfprint = privkey.fingerprint
privkey = gpg.list_keys(secret=True).pop()
diff --git a/src/leap/bitmask/keymanager/wrapper.py b/src/leap/bitmask/keymanager/wrapper.py
index 1fd4429..ef8e664 100644
--- a/src/leap/bitmask/keymanager/wrapper.py
+++ b/src/leap/bitmask/keymanager/wrapper.py
@@ -105,11 +105,11 @@ class TempGPGWrapper(object):
self._gpg = GPG(binary=self._gpgbinary,
homedir=tempfile.mkdtemp())
except TypeError:
- # compat-mode with python-gnupg until windows
- # support is fixed in gnupg-ng
+ # compat-mode with python-gnupg until windows
+ # support is fixed in gnupg-ng
self._gpg = GPG(gpgbinary=self._gpgbinary,
gnupghome=tempfile.mkdtemp(),
- options=[])
+ options=[])
leap_assert(len(listkeys()) is 0, 'Keyring not empty.')
@@ -150,16 +150,16 @@ class TempGPGWrapper(object):
raise
finally:
- try:
- homedir = self._gpg.homedir
+ try:
+ homedir = self._gpg.homedir
except AttributeError:
- homedir = self._gpg.gnupghome
+ homedir = self._gpg.gnupghome
leap_assert(homedir != os.path.expanduser('~/.gnupg'),
"watch out! Tried to remove default gnupg home!")
# TODO some windows debug ....
- homedir = os.path.normpath(homedir).replace("\\", "/")
- homedir = str(homedir.replace("c:/", "c://"))
+ homedir = os.path.normpath(homedir).replace("\\", "/")
+ homedir = str(homedir.replace("c:/", "c://"))
if platform.system() == "Windows":
- logger.error("BUG! Not erasing folder in Windows")
+ logger.error("BUG! Not erasing folder in Windows")
return
shutil.rmtree(homedir)