From c3f78a30bb73b28fdf6b1e95e5083adfc9e7f29c Mon Sep 17 00:00:00 2001 From: J08nY Date: Mon, 19 Jun 2017 19:53:07 +0200 Subject: Fix PGPMIMEWrapper to adhere to RFC3156. --- src/mailman_pgp/pgp/mime.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mailman_pgp/pgp/mime.py b/src/mailman_pgp/pgp/mime.py index 08bd111..5617c19 100644 --- a/src/mailman_pgp/pgp/mime.py +++ b/src/mailman_pgp/pgp/mime.py @@ -18,9 +18,13 @@ class PGPMIMEWrapper: Whether the whole message is MIME signed as per RFC3156 section 5. :return: """ + if not self._is_mime(): + return False + second_type = self.msg.get_payload(1).get_content_type() protocol_param = collapse_rfc2231_value(self.msg.get_param('protocol')) content_subtype = self.msg.get_content_subtype() - return self._is_mime() and \ + + return second_type == 'application/pgp-signature' and \ content_subtype == 'signed' and \ protocol_param == 'application/pgp-signature' @@ -29,9 +33,14 @@ class PGPMIMEWrapper: Whether the whole message is MIME encrypted as per RFC3156 section 4. :return: """ + if not self._is_mime(): + return False + first_type = self.msg.get_payload(0).get_content_type() + second_type = self.msg.get_payload(1).get_content_type() content_subtype = self.msg.get_content_subtype() protocol_param = collapse_rfc2231_value(self.msg.get_param('protocol')) - return self._is_mime() and \ + return first_type == 'application/pgp-encrypted' and \ + second_type == 'application/octet-stream' and \ content_subtype == 'encrypted' and \ protocol_param == 'application/pgp-encrypted' -- cgit v1.2.3-70-g09d2