From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 1xJzBLExq16yTAAA0tVLHw (envelope-from ) for ; Thu, 30 Apr 2020 20:14:41 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id SC4qKLoxq14FMAAAbx9fmQ (envelope-from ) for ; Thu, 30 Apr 2020 20:14:50 +0000 Received: from arlo.cworth.org (arlo.cworth.org [50.126.95.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 01962943301 for ; Thu, 30 Apr 2020 20:14:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id EC1FD6DE13CE; Thu, 30 Apr 2020 13:14:39 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RSVQ73Pj3Nwu; Thu, 30 Apr 2020 13:14:39 -0700 (PDT) Received: from arlo.cworth.org (localhost [IPv6:::1]) by arlo.cworth.org (Postfix) with ESMTP id 6977E6DE13F3; Thu, 30 Apr 2020 13:14:21 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id BEA816DE13DA for ; Thu, 30 Apr 2020 13:14:19 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5qA0r5FVTbs9 for ; Thu, 30 Apr 2020 13:14:18 -0700 (PDT) Received: from che.mayfirst.org (unknown [162.247.75.117]) by arlo.cworth.org (Postfix) with ESMTPS id 40E146DE13C8 for ; Thu, 30 Apr 2020 13:14:18 -0700 (PDT) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/simple; d=fifthhorseman.net; i=@fifthhorseman.net; q=dns/txt; s=2019; t=1588277655; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=aBIg3+NsyQvczlXu7sOOcmkBwPCN4fr7Uh6qedfVaAo=; b=QhuimJoJn2r8Zo1iOkGGf1cTKF6V0xfTZQ66vxNGnUBki0aC72aiXkd5hgtCtxPexekxZ tQ5EDXqvpCXDKPUBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fifthhorseman.net; i=@fifthhorseman.net; q=dns/txt; s=2019rsa; t=1588277655; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=aBIg3+NsyQvczlXu7sOOcmkBwPCN4fr7Uh6qedfVaAo=; b=uXxaqVP6g0Mrl1ZfEZKtsSad9LGBiK3P3S54tZjHc42WtJ8UsspLIYP7kOxb47/+/Uz2C 9KKFvrlM7qitDYZdlPCv8sQNTklxcv4ajK6ioK6wU7gMhXYeOPty6XZre4KNPg/qzvlaVta QQQS8fDlwYvdc2yaaHaQXkn51PP37Aro9HDIOiTWMFEXYeQqN/8Rgfo56gT2Kgzs9OalTRr qmTu6x8bhLNDHxj97F5U4D2iXANsL+uj6w1xFfwMJn9jyHjHkQ6Rr4Z3/y2k+owEfIGbjY8 3+16OBnlpVQZqaUSF8SLgo4hDWO9KB8uqVaeA8gCk1D7HC+343Dx5tBeTJHg== Received: from fifthhorseman.net (unknown [108.58.6.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by che.mayfirst.org (Postfix) with ESMTPSA id 53B24F9A5 for ; Thu, 30 Apr 2020 16:14:15 -0400 (EDT) Received: by fifthhorseman.net (Postfix, from userid 1000) id 49D4B21014; Thu, 30 Apr 2020 16:13:35 -0400 (EDT) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH 8/9] smime: Pass PKCS#7 envelopedData to node_decrypt_and_verify Date: Thu, 30 Apr 2020 16:13:27 -0400 Message-Id: <20200430201328.725651-9-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200430201328.725651-1-dkg@fifthhorseman.net> References: <20200430201328.725651-1-dkg@fifthhorseman.net> MIME-Version: 1.0 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: notmuch-bounces@notmuchmail.org Sender: "notmuch" X-Scanner: scn0 X-Spam-Score: 1.09 Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=fifthhorseman.net header.s=2019 header.b=QhuimJoJ; dkim=fail (body hash did not verify) header.d=fifthhorseman.net header.s=2019rsa header.b=uXxaqVP6; dmarc=fail reason="SPF not aligned (relaxed)" header.from=fifthhorseman.net (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 50.126.95.6 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Scan-Result: default: False [1.09 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.46702959604437]; DWL_DNSWL_BLOCKED(0.00)[50.126.95.6:from]; R_SPF_ALLOW(-0.20)[+a:c]; R_DKIM_REJECT(1.00)[fifthhorseman.net:s=2019,fifthhorseman.net:s=2019rsa]; IP_REPUTATION_HAM(0.00)[asn: 27017(-0.18), country: US(-0.00), ip: 50.126.95.6(-0.47)]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[fifthhorseman.net:-]; MX_GOOD(-0.50)[cached: notmuchmail.org]; MAILLIST(-0.20)[mailman]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:27017, ipnet:50.126.64.0/18, country:US]; FROM_NEQ_ENVFROM(0.00)[dkg@fifthhorseman.net,notmuch-bounces@notmuchmail.org]; ARC_NA(0.00)[]; URIBL_BLOCKED(0.00)[fifthhorseman.net:email,notmuchmail.org:email]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[notmuch@notmuchmail.org]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; DNSWL_BLOCKED(0.00)[50.126.95.6:from]; MID_CONTAINS_FROM(1.00)[]; RCVD_COUNT_SEVEN(0.00)[8]; FORGED_SENDER_MAILLIST(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[fifthhorseman.net : SPF not aligned (relaxed),none] X-TUID: bKlOmOLAlKCo This change means we can support "notmuch show --decrypt=true" for S/MIME encrypted messages, resolving several outstanding broken tests, including all the remaining S/MIME protected header examples. We do not yet handle indexing the cleartext of S/MIME encrypted messages, though. Signed-off-by: Daniel Kahn Gillmor --- mime-node.c | 6 ++++++ test/T355-smime.sh | 2 -- test/T356-protected-headers.sh | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mime-node.c b/mime-node.c index c2ee858d..f552e03a 100644 --- a/mime-node.c +++ b/mime-node.c @@ -390,6 +390,12 @@ _mime_node_set_up_part (mime_node_t *node, GMimeObject *part, int numchild) * to just unwrap (instead of verifying), but * https://github.com/jstedfast/gmime/issues/67 */ node_verify (node, part); + } else if (GMIME_IS_APPLICATION_PKCS7_MIME (part) && + GMIME_SECURE_MIME_TYPE_ENVELOPED_DATA == g_mime_application_pkcs7_mime_get_smime_type (GMIME_APPLICATION_PKCS7_MIME (part)) && + (node->ctx->crypto->decrypt != NOTMUCH_DECRYPT_FALSE)) { + node_decrypt_and_verify (node, part); + if (node->unwrapped_child && node->nchildren == 0) + node->nchildren = 1; } else { if (_notmuch_message_crypto_potential_payload (node->ctx->msg_crypto, part, node->parent ? node->parent->part : NULL, numchild) && node->ctx->msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_FULL) { diff --git a/test/T355-smime.sh b/test/T355-smime.sh index 4b67a559..0d32a7d5 100755 --- a/test/T355-smime.sh +++ b/test/T355-smime.sh @@ -80,7 +80,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "Decryption (notmuch CLI)" -test_subtest_known_broken notmuch show --decrypt=true subject:"test encrypted message 001" |\ grep "^This is a" > OUTPUT cat < EXPECTED @@ -89,7 +88,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "Cryptographic message status (encrypted+signed)" -test_subtest_known_broken output=$(notmuch show --format=json --decrypt=true subject:"test encrypted message 001") test_json_nodes <<<"$output" \ 'crypto_encrypted:[0][0][0]["crypto"]["decrypted"]["status"]="full"' \ diff --git a/test/T356-protected-headers.sh b/test/T356-protected-headers.sh index bca50e29..547b0c9a 100755 --- a/test/T356-protected-headers.sh +++ b/test/T356-protected-headers.sh @@ -168,7 +168,6 @@ done for variant in sign+enc sign+enc+legacy-disp; do test_begin_subtest "confirm signed and encrypted PKCS#7 subject ($variant)" - test_subtest_known_broken output=$(notmuch show --decrypt=true --format=json "id:smime-${variant}@protected-headers.example") test_json_nodes <<<"$output" \ 'signed_subject:[0][0][0]["crypto"]["signed"]["headers"]=["Subject"]' \ @@ -179,7 +178,6 @@ for variant in sign+enc sign+enc+legacy-disp; do done test_begin_subtest "confirm encryption-protected PKCS#7 subject (enc+legacy-disp)" -test_subtest_known_broken output=$(notmuch show --decrypt=true --format=json "id:smime-enc+legacy-disp@protected-headers.example") test_json_nodes <<<"$output" \ 'encrypted:[0][0][0]["crypto"]["decrypted"]={"status":"full","header-mask":{"Subject":"..."}}' \ -- 2.26.2