From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 7TdyKA+nVWIz8gAAgWs5BA (envelope-from ) for ; Tue, 12 Apr 2022 18:21:35 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id aGXMHw+nVWJOyQAAG6o9tA (envelope-from ) for ; Tue, 12 Apr 2022 18:21:35 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C9258B585 for ; Tue, 12 Apr 2022 18:21:34 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 4FD2F5F70E; Tue, 12 Apr 2022 16:21:32 +0000 (UTC) Received: from smtprelay08.ispgateway.de (smtprelay08.ispgateway.de [134.119.228.98]) by mail.notmuchmail.org (Postfix) with ESMTPS id E7AF45F5E3 for ; Tue, 12 Apr 2022 16:21:29 +0000 (UTC) Received: from [46.244.216.128] (helo=condition-alpha.com) by smtprelay08.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1neJGt-0006NN-12; Tue, 12 Apr 2022 18:21:39 +0200 Message-Id: <68e03382493db20b12786d19f79edfaf@condition-alpha.com> From: Alexander Adolf To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH] emacs/smime: render decrypted MIME entities in notmuch-show In-Reply-To: <87tuazb3ag.fsf@tethera.net> References: <9cc1c3dc135b5126efd210ee97b88d6b@condition-alpha.com> <87pmm43nig.fsf@tethera.net> <90f50b09c047913abad928c461b08412@condition-alpha.com> <877d819j1o.fsf@tethera.net> <874k359em5.fsf@tethera.net> <1e3b5d3c782206a10c600d0ccdc53c03@condition-alpha.com> <87tuazb3ag.fsf@tethera.net> Date: Tue, 12 Apr 2022 18:21:27 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Df-Sender: YWxleGFuZGVyLmFkb2xmQGNvbmRpdGlvbi1hbHBoYS5jb20= Message-ID-Hash: LMP7NS2WFAMWGVU7CV2DZXA6OTNTKVEY X-Message-ID-Hash: LMP7NS2WFAMWGVU7CV2DZXA6OTNTKVEY X-MailFrom: alexander.adolf@condition-alpha.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1649780494; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=GDFZbujzJ4hMn7kFZ36j1XE2gxDRo4RRrbif0+rDypY=; b=qZz5Azad2jfPn6f+f86WL92aDnuMagTdH4Q0GHuff+ehV9cNTPI7kLmrU1xVJLqmmewqAz iC1HBD5at78vsuDmsuidRyxIXsQ4wbz0FARkrvC8Bq4Icgb5+k6tWs0ym+cZZaXklzrVFr g3PIDyVDa/jgD3B4tS3fkC5fDP9PrTaa/x0oxeKThuvstZue/Hk5KXK7Ut6OgWoYCw4XYa VgKWrpxQbJTPi21A+5Pummbu6PNPW68CDpEdgeavkKVXTUiB3j9qcMsxaGU9qnJJSnOofM 29FLewfVsEFECpCw5mntNLMeoyQUhROhPsaAiwqK9JWqwV80N6ZYZnGrTBBCXQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1649780494; a=rsa-sha256; cv=none; b=u/0c84zZrNOgs8okBW51eD69aCjLV92UgYAzWQKDm6fZiedo8n0f+xR7iAJuiOkf9n4eQa 7emnwphljWPBybf04cmDZkgxoUEwim6j2/+J0rCeizmCPpNyIhOf0kxhi28aCy0XLCwvrV 1PkB3FsGhQ/notxiczpmbXsF2IOO3c5sxWd9loARI36JSLb2I9fttmGmp2D3FQLyI8JxqR U7l2F35x7fOZxCccsIqrioLHpHxOGe1YAn+aAu4jzFSupoc3pNQWpHnruVG0ZWLKEGTToo uZlBlp3sL/ZopiMMpEPk5J3Hh/+TGZuFDGmU3t32ohbsxPfFfp3tt/hLxjQRWw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.70 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: C9258B585 X-Spam-Score: -1.70 X-Migadu-Scanner: scn1.migadu.com X-TUID: VdStBuvziwzY --=-=-= Content-Type: text/plain Hello David, David Bremner writes: > [...] > I'm not sure it's less effort, > [...] Neither am I... ;-)) It might perhaps seem easier to run the tests I have added to the attached, updated patch in your complete environment? --alexander --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-emacs-smime-render-decrypted-MIME-entities-in-notmuc.patch >From ba6f00bbd1803f5cccfafdb262f17b79b6c95252 Mon Sep 17 00:00:00 2001 From: Alexander Adolf Date: Fri, 25 Mar 2022 14:13:28 +0100 Subject: [PATCH] emacs/smime: render decrypted MIME entities in notmuch-show When processing encrypted S/MIME messages, after decryption the "last resort" handler notmuch-show-insert-part-*/* was called, because there was no application/pkcs7-mime handler, resulting in the decrypted contents not being displayed. This commit adds a new function notmuch-show-insert-part-application/pkcs7-mime (and an alias notmuch-show-insert-part-application/x-pkcs7-mime for the legacy MIME type) to render the S/MIME protected part after decryption. --- emacs/notmuch-show.el | 17 +++++++ test/T450-emacs-show.sh | 11 +++- .../crypto/smime-encrypted-signed-multipart | 51 +++++++++++++++++++ ...much-show-smime-encrypted-signed-multipart | 15 ++++++ 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 test/corpora/crypto/smime-encrypted-signed-multipart create mode 100644 test/emacs-show.expected-output/notmuch-show-smime-encrypted-signed-multipart diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 7c1f02c9..b7edfc98 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -712,6 +712,23 @@ will return nil if the CID is unknown or cannot be retrieved." (defun notmuch-show-insert-part-application/pgp-encrypted (_msg _part _content-type _nth _depth _button) t) +(defun notmuch-show-insert-part-application/pkcs7-mime (msg part _content-type _nth depth _button) + "Render S/MIME protected content after decryption. + +An alias for this function is also defined to handle entities +using the legacy application/x-pkcs7-mime MIME type." + (let* ((encstatus (car (plist-get part :encstatus))) + (inner-part (car (plist-get part :content)))) + ;; Insert a button detailing the encryption status. + (notmuch-crypto-insert-encstatus-button encstatus) + (if (not (string= (plist-get encstatus :status) "bad")) + ;; Show all decrypted parts. + (notmuch-show-insert-bodypart msg inner-part depth)))) + +;; Support for the legacy "x-" type. +(fset 'notmuch-show-insert-part-application/x-pkcs7-mime + 'notmuch-show-insert-part-application/pkcs7-mime) + (defun notmuch-show-insert-part-multipart/* (msg part _content-type _nth depth _button) (let ((inner-parts (plist-get part :content)) (start (point))) diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh index 057ad37e..5c4bdd7e 100755 --- a/test/T450-emacs-show.sh +++ b/test/T450-emacs-show.sh @@ -49,7 +49,7 @@ test_emacs '(let ((notmuch-crypto-process-mime nil)) (test-visible-output))' test_expect_equal_file $EXPECTED/notmuch-show-process-crypto-mime-parts-off OUTPUT -test_begin_subtest "process cryptographic MIME parts" +test_begin_subtest "process cryptographic MIME parts (PGP)" test_emacs '(let ((notmuch-crypto-process-mime t)) (notmuch-show "id:20091117203301.GV3165@dottiness.seas.harvard.edu") (test-visible-output))' @@ -245,4 +245,13 @@ test_emacs "(test-log-error (notmuch-show \"$tid\")))" test_expect_equal "$(cat MESSAGES)" "COMPLETE" +# more crypto tests, using S/MIME from here on: +add_gpgsm_home + +test_begin_subtest "process cryptographic MIME parts (S/MIME)" +test_emacs '(let ((notmuch-crypto-process-mime t)) + (notmuch-show "id:575ddaaf0b234fd85e077cfb4d44d467@notmuchmail.org") + (test-visible-output))' +test_expect_equal_file $EXPECTED/notmuch-show-smime-encrypted-signed-multipart OUTPUT + test_done diff --git a/test/corpora/crypto/smime-encrypted-signed-multipart b/test/corpora/crypto/smime-encrypted-signed-multipart new file mode 100644 index 00000000..f0bd6c51 --- /dev/null +++ b/test/corpora/crypto/smime-encrypted-signed-multipart @@ -0,0 +1,51 @@ +Message-Id: <575ddaaf0b234fd85e077cfb4d44d467@notmuchmail.org> +From: test_suite@notmuchmail.org +To: test_suite@notmuchmail.org +Subject: notmuch-show S/MIME test +Date: Tue, 12 Apr 2022 16:57:30 +0200 +MIME-Version: 1.0 +Content-Type: application/pkcs7-mime; + smime-type=enveloped-data; + name=smime.p7m +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename=smime.p7m + +MIAGCSqGSIb3DQEHA6CAMIACAQAxggFFMIIBQQIBADApMB0xGzAZBgNVBAMTEk5vdG11Y2ggVGVz +dCBTdWl0ZQIIb3SMlL0MZ6kwDQYJKoZIhvcNAQEBBQAEggEAeCEItxJpxL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GtfOVUnVJ8Ag0g8GfcG8IBgVa7sQHsj +xHI/e1BVTAK4j0GVKYLRURRJgFpBkMBaAzFm211t/YiOInwQZe+n80EWHioTDtmAC6dbj2iR/w9I +mkinAQBgNWFXrXJ6wNnixgw5kAPmR81TGv7CHMxKOHXGy9y5++7AvkUcMB8mY14y5iYOWh+BiBWv +4iDGZiFt73Ur9ur7rz+t+EDXWuHXKuexOu5qH/izf0/hwY5c3jrl7Sg2ZFuRI58oua5Wn3JAtkQS +75frVr67OG9EmUAu9Whv2oqjtyEwujwtddBM2IRbY49dtdenA6u6C+XsZn4v/fgIR46Dl+nC9oyZ +3JrwLmu+l4e79glr+r4B/uB6fbC5gcMk8zlZDZeTVN3ZgJCpWSywpABE2GIPSH4kgiiBH8RHD4hV +7kPAQqc9AXrvvXXN9Gzouy2FmWTOvnb3d63OjG01ZDIgVwaE6dfCZRgKN3P3Jx+/mQboJzhiQJbw +M/cFlSwo/GuUjt1fhTq7Vtr8PLXnAORvTrXYTbpB2ozPxdVDHLfKYpta98s+61vVuoRO4yaLk+oP +IuSI/j9wgPJkUOuN6oGjZ7fr2y/alw2F8JbmG/0eZxRE3JuvnUfwTRJeijMvaKS1Vk8BUoLAADys +JLSbQhXdzvZGk5avYwv7IAkXASMRwODE3AQQzThdv7ONbleBxDPXMpAvRQAAAAAAAAAAAAA= \ No newline at end of file diff --git a/test/emacs-show.expected-output/notmuch-show-smime-encrypted-signed-multipart b/test/emacs-show.expected-output/notmuch-show-smime-encrypted-signed-multipart new file mode 100644 index 00000000..556bd937 --- /dev/null +++ b/test/emacs-show.expected-output/notmuch-show-smime-encrypted-signed-multipart @@ -0,0 +1,15 @@ +test_suite@notmuchmail.org (0 mins. ago) (encrypted inbox) +Subject: notmuch-show S/MIME test +To: test_suite@notmuchmail.org +Date: Tue, 12 Apr 2022 16:57:30 +0200 + +[ smime.p7m: application/pkcs7-mime ] +[ Decryption successful ] +[ multipart/signed ] +[ Good signature by: ] +[ multipart/mixed ] +[ multipart/mixed ] +[ text/plain ] +The password is "12345678". But don't tell anyone! +[ test.dtd: application/octet-stream ] +[ smime.p7s: application/pkcs7-signature ] -- 2.35.1 --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --=-=-=--