aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/pgp/keygen.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman_pgp/pgp/keygen.py')
-rw-r--r--src/mailman_pgp/pgp/keygen.py36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/mailman_pgp/pgp/keygen.py b/src/mailman_pgp/pgp/keygen.py
index 684b81a..57a94d7 100644
--- a/src/mailman_pgp/pgp/keygen.py
+++ b/src/mailman_pgp/pgp/keygen.py
@@ -25,22 +25,32 @@ from pgpy import PGPKey, PGPUID
from pgpy.constants import (
CompressionAlgorithm, HashAlgorithm, KeyFlags, SymmetricKeyAlgorithm)
+from mailman_pgp.config import config
+from mailman_pgp.utils.pgp import key_from_file
+
class ListKeyGenerator(mp.Process):
"""A multiprocessing list key generator."""
- def __init__(self, primary_args, subkey_args, display_name,
- posting_address,
- request_address, key_path):
+ def __init__(self, pgp_list):
super().__init__(
- target=self.generate,
- args=(primary_args, subkey_args, display_name, posting_address,
- request_address, key_path),
+ target=self._run,
+ args=(config.pgp.primary_key_args, config.pgp.sub_key_args,
+ pgp_list.mlist.display_name,
+ pgp_list.mlist.posting_address,
+ pgp_list.mlist.request_address,
+ pgp_list.key_path),
daemon=True)
+ self._pgp_list = pgp_list
+
+ def generate(self, block=False):
+ self.start()
+ if block:
+ self.join()
+ return key_from_file(self._pgp_list.key_path)
- def generate(self, primary_args, subkey_args, display_name,
- posting_address,
- request_address, key_path):
+ def _run(self, primary_args, subkey_args, display_name, posting_address,
+ request_address, key_path):
"""
Generate the list keypair and save it.
@@ -51,11 +61,11 @@ class ListKeyGenerator(mp.Process):
:param request_address:
:param key_path:
"""
- key = self._create(primary_args, subkey_args, display_name,
- posting_address,
- request_address)
+ self.key = self._create(primary_args, subkey_args, display_name,
+ posting_address,
+ request_address)
with Lock(key_path + '.lock'):
- self._save(key, key_path)
+ self._save(self.key, key_path)
def _create(self, primary_args, subkey_args, display_name, posting_address,
request_address):