aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/pgp/inline.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman_pgp/pgp/inline.py')
-rw-r--r--src/mailman_pgp/pgp/inline.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/mailman_pgp/pgp/inline.py b/src/mailman_pgp/pgp/inline.py
index a8e8004..94091cc 100644
--- a/src/mailman_pgp/pgp/inline.py
+++ b/src/mailman_pgp/pgp/inline.py
@@ -41,6 +41,22 @@ class InlineWrapper:
def _as_string(self):
return str(self.msg.get_payload())
+ def _has_signature(self):
+ try:
+ msg = PGPMessage.from_blob(self._as_string())
+ return msg.is_signed
+ except:
+ pass
+ return False
+
+ def _has_message(self):
+ try:
+ msg = PGPMessage.from_blob(self._as_string())
+ return msg.is_encrypted
+ except:
+ pass
+ return False
+
def _has_armor(self, block_type):
try:
dearm = Armorable.ascii_unarmor(self._as_string())
@@ -57,8 +73,7 @@ class InlineWrapper:
:return: If the message is inline signed.
:rtype: bool
"""
- # XXX: This doesnt handle non-cleartext signatures (gpg -s -a)
- return self._is_inline() and self._has_armor('SIGNATURE')
+ return self._is_inline() and self._has_signature()
def is_encrypted(self):
"""
@@ -67,8 +82,7 @@ class InlineWrapper:
:return: If the message is inline encrypted.
:rtype: bool
"""
- # XXX: This mistakes non-cleartext signature as encrypted.
- return self._is_inline() and self._has_armor('MESSAGE')
+ return self._is_inline() and self._has_message()
def has_keys(self):
"""