aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/commands/eml_key.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman_pgp/commands/eml_key.py')
-rw-r--r--src/mailman_pgp/commands/eml_key.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mailman_pgp/commands/eml_key.py b/src/mailman_pgp/commands/eml_key.py
index be0af44..1f39888 100644
--- a/src/mailman_pgp/commands/eml_key.py
+++ b/src/mailman_pgp/commands/eml_key.py
@@ -23,6 +23,7 @@ from mailman.interfaces.command import ContinueProcessing, IEmailCommand
from mailman.interfaces.pending import IPendings
from mailman.interfaces.subscriptions import ISubscriptionManager
from mailman.interfaces.usermanager import IUserManager
+from pgpy.constants import KeyFlags
from public import public
from zope.component import getUtility
from zope.interface import implementer
@@ -74,6 +75,14 @@ def _cmd_set(pgp_list, mlist, msg, msgdata, arguments, results):
file=results)
return ContinueProcessing.no
+ usage_flags = key.usage_flags()
+ for subkey in key.subkeys.values():
+ usage_flags |= subkey.usage_flags()
+ if KeyFlags.EncryptCommunications not in usage_flags:
+ print('Need a key which can be used to encrypt communications.',
+ file=results)
+ return ContinueProcessing.no
+
email = get_email(msg)
if not email:
print('No email to subscribe with.', file=results)
@@ -219,6 +228,14 @@ def _cmd_change(pgp_list, mlist, msg, msgdata, arguments, results):
file=results)
return ContinueProcessing.no
+ usage_flags = key.usage_flags()
+ for subkey in key.subkeys.values():
+ usage_flags |= subkey.usage_flags()
+ if KeyFlags.EncryptCommunications not in usage_flags:
+ print('Need a key which can be used to encrypt communications.',
+ file=results)
+ return ContinueProcessing.no
+
workflow = KeyChangeWorkflow(mlist, pgp_address, key)
list(workflow)
print('Key change request received.', file=results)