From e68cdc11086c6d475fa3806cb27b9a9f2103e916 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Tue, 16 Oct 2018 11:46:09 +0200 Subject: [PATCH] Try to handle binary signature --- envelope.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/envelope.py b/envelope.py index a3f6e4e..338437c 100644 --- a/envelope.py +++ b/envelope.py @@ -72,6 +72,7 @@ def check(msg, GNUPG_DIRECTORY, accept_public_key=True, beta=False): from archive import _guess_mime # Looking for signed content + lpart = None for part in msg.walk(): payload = part.get_payload() if payload is not None and not part.is_multipart() and part.get_payload(decode=True).find(b"-----BEGIN PGP SIGNED MESSAGE-----") >= 0: @@ -100,3 +101,9 @@ def check(msg, GNUPG_DIRECTORY, accept_public_key=True, beta=False): yield MailTest("Public key file discovered, but content-type mismatched: got %s instead of application/pgp-keys." % part.get_content_type(), 2) yield from import_pubkey(part.get_payload(decode=True), GNUPG_DIRECTORY) return + + elif lpart is not None and part.get_filename() is not None and lpart.get_filename() is not None and part.get_filename()[:len(lpart.get_filename())] == lpart.get_filename(): + yield MailTest("Standalone non-armored signature file discovered. Avoid using binary signature over SMTP (see RFC2015 #2. PGP data formats).", 2) + yield (lpart.get_payload(decode=True), part.get_payload(decode=True)) + + lpart = part