summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman_pgp/commands/eml_key.py5
-rw-r--r--src/mailman_pgp/utils/pgp.py5
2 files changed, 5 insertions, 5 deletions
diff --git a/src/mailman_pgp/commands/eml_key.py b/src/mailman_pgp/commands/eml_key.py
index e182451..b958b93 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
@@ -77,7 +78,7 @@ def _cmd_set(pgp_list, mlist, msg, msgdata, arguments, results):
file=results)
return ContinueProcessing.no
- if not key_usable(key):
+ if not key_usable(key, {KeyFlags.EncryptCommunications, KeyFlags.Sign}):
print('Need a key which can be used to encrypt communications.',
file=results)
return ContinueProcessing.no
@@ -228,7 +229,7 @@ def _cmd_change(pgp_list, mlist, msg, msgdata, arguments, results):
file=results)
return ContinueProcessing.no
- if not key_usable(key):
+ if not key_usable(key, {KeyFlags.EncryptCommunications, KeyFlags.Sign}):
print('Need a key which can be used to encrypt communications.',
file=results)
return ContinueProcessing.no
diff --git a/src/mailman_pgp/utils/pgp.py b/src/mailman_pgp/utils/pgp.py
index 1dfdc5e..416e643 100644
--- a/src/mailman_pgp/utils/pgp.py
+++ b/src/mailman_pgp/utils/pgp.py
@@ -107,6 +107,7 @@ def key_usable(key, flags_required):
:param key:
:type key: pgpy.PGPKey
:param flags_required:
+ :type flags_required: set
:return:
:rtype: bool
"""
@@ -125,6 +126,4 @@ def key_usable(key, flags_required):
for subkey in key.subkeys.values():
usage_flags |= subkey.usage_flags()
- if flags_required not in usage_flags:
- return False
- return True
+ return flags_required.issubset(usage_flags)