From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E88E6C63777 for ; Fri, 20 Nov 2020 21:27:57 +0000 (UTC) Received: by mail.kernel.org (Postfix) id C6B252240B; Fri, 20 Nov 2020 21:27:57 +0000 (UTC) Received: from [192.168.1.64] (unknown [89.36.78.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6E53B2240A; Fri, 20 Nov 2020 21:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1605907677; bh=ez5tyHOLOzBapQuCb0KIJF2P+I3mM2c6fTVoTqdTSgc=; h=From:List-Id:To:Cc:Subject:Date:In-Reply-To:References:From; b=tUSkpjh1aoEkkvoTH21QuZSgyklGxZBwNy4ccrYWZIs4+S9ir1zlhUyGR8saMSnJn C7+y3yxDU9g2yccGgZzAlYosriURxlvKAGndof6vEFuTgvM/qG6/4toekUoes7vBGH 5AWJFlhXsba2M16cOVclQgF3F7b73HNuNg9SEflg= From: Konstantin Ryabitsev List-Id: To: signatures@kernel.org Cc: Konstantin Ryabitsev Subject: [PATCH 4/4] Fix in-header attestation code Date: Fri, 20 Nov 2020 16:27:31 -0500 Message-Id: <20201120212731.1645654-5-konstantin@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201120212731.1645654-1-konstantin@linuxfoundation.org> References: <20201120212731.1645654-1-konstantin@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patch-Hashes: v=1; h=sha256; g=03872348abe6561a219e8511d1795f5ce4ee965b; i=5gWyfu5JoaTAO9zRyE37Ma+n5CjLwk1AXz6idYEisrE=; m=eYnPWWm0FEQbm8Sk6uW5+GyBbBn/62+ePJIN8lQivQg=; p=kC6unoEV5YBkl2ykQRzy5BXCEl2VyMPMoibHpX3ZXLw= X-Patch-Sig: m=pgp; i=konstantin@linuxfoundation.org; s=0xB6C41CE35664996C; b=iHUEABYIAB0WIQR2vl2yUnHhSB5njDW2xBzjVmSZbAUCX7g03AAKCRC2xBzjVmSZbG6YAP9VExI qlAJC/Utg3aE9Xlr5NduvzCcHowtqeDyI8g1lgQEA+9tYYVMHPEhAhSURoZI/MaO1MEWrLqsx37dg UynaiQw= We've moved some constant declarations around, so fix the code to look for them in the right places. Signed-off-by: Konstantin Ryabitsev --- b4/attest.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/b4/attest.py b/b4/attest.py index a4012d7..1b464d0 100644 --- a/b4/attest.py +++ b/b4/attest.py @@ -19,12 +19,12 @@ logger = b4.logger def in_header_attest(lmsg: b4.LoreMessage, mode: str = 'pgp', replace: bool = False) -> None: - if lmsg.msg.get(lmsg.attestation.hashes_header_name): + if lmsg.msg.get(b4.HDR_PATCH_HASHES): if not replace: logger.info(' attest: message already attested') return - del lmsg.msg[lmsg.attestation.hashes_header_name] - del lmsg.msg[lmsg.attestation.sig_header_name] + del lmsg.msg[b4.HDR_PATCH_HASHES] + del lmsg.msg[b4.HDR_PATCH_SIG] logger.info(' attest: generating attestation hashes') if not lmsg.attestation: @@ -39,7 +39,7 @@ def in_header_attest(lmsg: b4.LoreMessage, mode: str = 'pgp', replace: bool = Fa f'm={lmsg.attestation.mb}', f'p={lmsg.attestation.pb}', ] - hhname, hhval = b4.dkim_canonicalize_header(lmsg.attestation.hashes_header_name, '; '.join(hparts)) + hhname, hhval = b4.dkim_canonicalize_header(b4.HDR_PATCH_HASHES, '; '.join(hparts)) headers.append(f'{hhname}:{hhval}') logger.debug('Signing with mode=%s', mode) @@ -59,7 +59,7 @@ def in_header_attest(lmsg: b4.LoreMessage, mode: str = 'pgp', replace: bool = Fa 'b=', ] - shname, shval = b4.dkim_canonicalize_header(lmsg.attestation.sig_header_name, '; '.join(hparts)) + shname, shval = b4.dkim_canonicalize_header(b4.HDR_PATCH_SIG, '; '.join(hparts)) headers.append(f'{shname}:{shval}') payload = '\r\n'.join(headers).encode() ecode, out, err = b4.gpg_run_command(gpgargs, payload) @@ -74,8 +74,8 @@ def in_header_attest(lmsg: b4.LoreMessage, mode: str = 'pgp', replace: bool = Fa hhdr = email.header.make_header([(hhval.encode(), 'us-ascii')], maxlinelen=78) shdr = email.header.make_header([(shval.encode(), 'us-ascii')], maxlinelen=78) - lmsg.msg[lmsg.attestation.hashes_header_name] = hhdr - lmsg.msg[lmsg.attestation.sig_header_name] = shdr + lmsg.msg[b4.HDR_PATCH_HASHES] = hhdr + lmsg.msg[b4.HDR_PATCH_SIG] = shdr def header_splitter(longstr: str, limit: int = 77) -> str: -- 2.26.2