summaryrefslogtreecommitdiff
path: root/src/leap/keymanager/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/keymanager/__init__.py')
-rw-r--r--src/leap/keymanager/__init__.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/leap/keymanager/__init__.py b/src/leap/keymanager/__init__.py
index 61213d38..dbc54891 100644
--- a/src/leap/keymanager/__init__.py
+++ b/src/leap/keymanager/__init__.py
@@ -495,6 +495,48 @@ class KeyManager(object):
return self._wrapper_map[pubkey.__class__].verify(
data, pubkey, detached_sig=detached_sig)
+ def parse_openpgp_ascii_key(self, key_data):
+ """
+ Parses an ascii armored key (or key pair) data and returns
+ the OpenPGPKey keys.
+
+ :param key_data: the key data to be parsed.
+ :type key_data: str or unicode
+
+ :returns: the public key and private key (if applies) for that data.
+ :rtype: (public, private) -> tuple(OpenPGPKey, OpenPGPKey)
+ the tuple may have one or both components None
+ """
+ return self._wrapper_map[OpenPGPKey].parse_ascii_key(key_data)
+
+ def delete_key(self, key):
+ """
+ Remove C{key} from storage.
+
+ May raise:
+ openpgp.errors.KeyNotFound
+ openpgp.errors.KeyAttributesDiffer
+
+ :param key: The key to be removed.
+ :type key: EncryptionKey
+ """
+ try:
+ self._wrapper_map[type(key)].delete_key(key)
+ except IndexError as e:
+ leap_assert(False, "Unsupported key type. Error {0!r}".format(e))
+
+ def put_key(self, key):
+ """
+ Put C{key} in local storage.
+
+ :param key: The key to be stored.
+ :type key: OpenPGPKey
+ """
+ try:
+ self._wrapper_map[type(key)].put_key(key)
+ except IndexError as e:
+ leap_assert(False, "Unsupported key type. Error {0!r}".format(e))
+
from ._version import get_versions
__version__ = get_versions()['version']
del get_versions