diff options
Diffstat (limited to 'src/mailman_pgp/pgp/keygen.py')
| -rw-r--r-- | src/mailman_pgp/pgp/keygen.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mailman_pgp/pgp/keygen.py b/src/mailman_pgp/pgp/keygen.py new file mode 100644 index 0000000..b15dbf6 --- /dev/null +++ b/src/mailman_pgp/pgp/keygen.py @@ -0,0 +1,29 @@ +"""""" + +import threading + +from mailman_pgp.config import config + + +class KeyGenerator(threading.Thread): + def __init__(self, name, email, comment=None): + super().__init__(daemon=True) + self._name = name + self._comment = comment + self._email = email + self.key_fingerprint = None + + def run(self): + default_config = config.gpg.keypair_config + key_config = dict(default_config) + key_config.update(dict(name_real=self._name, + name_email=self._email)) + if self._comment is not None: + key_config['name_comment'] = self._comment + key_input = config.gpg.gen_key_input(**key_config) + key = config.gpg.gen_key(key_input) + self.key_fingerprint = key.fingerprint + + @property + def has_key(self): + return self.key_fingerprint is not None |
