diff options
| author | J08nY | 2017-08-02 20:59:26 +0200 |
|---|---|---|
| committer | J08nY | 2017-08-02 20:59:26 +0200 |
| commit | 7a4b76f64fc08d667ac48f432a726061998bd81f (patch) | |
| tree | 8dee2b1a044c2a6ddfc84ba5a63ab6867d042273 | |
| parent | ffafcc3d57eba95095b64dbaad78bb6785266dc2 (diff) | |
| download | mailman-pgp-7a4b76f64fc08d667ac48f432a726061998bd81f.tar.gz mailman-pgp-7a4b76f64fc08d667ac48f432a726061998bd81f.tar.zst mailman-pgp-7a4b76f64fc08d667ac48f432a726061998bd81f.zip | |
| -rw-r--r-- | src/mailman_pgp/commands/eml_key.py | 5 | ||||
| -rw-r--r-- | src/mailman_pgp/utils/pgp.py | 5 |
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) |
