Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B853C433F5 for ; Sat, 13 Nov 2021 12:43:19 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B1926113B for ; Sat, 13 Nov 2021 12:43:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4B1926113B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8CC7783112; Sat, 13 Nov 2021 13:43:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="BUtvHEWo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8529F83110; Sat, 13 Nov 2021 12:52:21 +0100 (CET) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DA5CF83102 for ; Sat, 13 Nov 2021 12:52:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1636804317; bh=hRQumYlxu02iqwp2Jw+PhV0LY1Q8Meop8L7A+LtI2eA=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=BUtvHEWosqEx0CCwyywTzRXKgSal2wZOV1+09Ub0jtueYA/0sLw/kF6In4WVRPgg4 nv4hP26NQuBGulokfl6JrFyYNFBjd1kHHQsINLqtNjUtGO++emL+x3qCo5mUfaynbi 7FITi58brZoM9sQZmlbsLraLqHd5eBOYoAucSLqo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.35] ([88.152.144.157]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N7R1T-1mdo6z3vwb-017isL; Sat, 13 Nov 2021 12:51:57 +0100 Message-ID: Date: Sat, 13 Nov 2021 12:51:52 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH 00/16] tools: Add support for signing devicetree blobs Content-Language: en-US To: Simon Glass Cc: AKASHI Takahiro , Alexandru Gagniuc , Artem Lapkin , Bill Mills , "Chan, Donald" , Chris Packham , Hannu Lounento , Heiko Schocher , Ilies CHERGUI , Jessica Clarke , Joe Hershberger , Joel Stanley , John Keeping , Marc Kleine-Budde , Marek Vasut , Martyn Welch , Ming Liu , =?UTF-8?Q?Pali_Roh=c3=a1r?= , Philippe Reynes , Rob Herring , Sean Anderson , Sebastian Reichel , Stefan Roese , Stefano Babic , Sven Roederer , Thomas Hebb , =?UTF-8?Q?Fran=c3=a7ois_Ozog?= , Thomas Perrot , Tom Rini , Tyler Hicks , U-Boot Mailing List , Vagrant Cascadian , Yann Dirson References: <20211112192817.199075-1-sjg@chromium.org> From: Heinrich Schuchardt In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:yKiUki0afPwalfoGy6fB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hK141n7D6xYsm04+gGHmgHFu0wmim0XHBT89HjxjDHzeQeD6Z/he1o3 P0C2VPKS5IxMjIAxrKl5haUSJWlvgVV6rjw4JWtx+ewTaU0iu5CMorDoaJ+LgdwCXS1hAsUnE jVSOH6v/VGp0efuK6Sri0gqlXAi2Ty9CVuuoS7244IhFb6MyrRwDRSwTFE17Ho5Nmtd/iW0UP NHijOkXKoafn4cUwOMrcVQM8DRfZ7x9hea6bDsEsoCgzgML+bgySxoYCPycI1asToG2QCmKXa 4hLHoor9o7R9Ac= X-Mailman-Approved-At: Sat, 13 Nov 2021 13:43:01 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.35 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 11/13/21 04:30, Simon Glass wrote: > Hi Heinrich, > > On Fri, 12 Nov 2021 at 17:02, Heinrich Schuchardt w= rote: >> >> >> >> On 11/12/21 20:49, Fran=C3=A7ois Ozog wrote: >>> Hi Simon >>> >>> Le ven. 12 nov. 2021 =C3=A0 20:36, Simon Glass >> > a =C3=A9crit : >>> >>> At present mkimage supports signing FITs, the standard U-Boot ima= ge >>> type. >>> >>> Various people are opposed to using FIT since: >>> >>> just to be sure: I am not one of those. >>> >>> >>> a) it requires adding support for FIT into other bootloaders, not= ably >>> UEFI >>> >>> whatever happens to FIT is entirely orthogonal to U-Boot UEFI subsyste= m. >>> FIT can evolve, U-Boot UEFI does not have to change. >> >> We already can create signed FIT images containing a UEFI binary and a >> devcie-tree and launch the FIT image with the bootm command. >> >> Cf. >> CONFIG_BOOTM_EFI >> test/py/tests/test_efi_fit.py >> doc/usage/bootefi.rst >> >> Simon, what are you missing? > > Some people don't want to use FIT. The problem with FIT is that other firmware like EDK II does not support i= t. Why do you expect those people to like your new tool better? > >> >>> >>> >>> b) it requires packaging a kernel in this standard U-Boot format, >>> meaning >>> that distros must run 'mkimage' and deal with the kernel and = initrd >>> being inside a FIT >> >> U-Boot tools are contained in distros like Debian and Ubuntu. >> Package flash-kernel uses a script in /etc/initramfs/post-update.d/ for >> a similar purpose. The same hook directory can be used to create a FIT >> image with a simple bash script. >> >> Why do we need a new tool for signing device-trees? >> >> The real problem to solve is the protection of the private key used for >> signing any file containing an initrd. > > Well FIT already solves that one. Either FIT is not being used, in > which case this series is useful, or it is being used, in which case > the initrd problem is solved. The question was: How do you protect the private key used by Linux to sign the FIT image with the updated initrd generated by intramfs-tools? Best regards Heinrich > >> >>> >>> The kernel and initrd can be dealt with in other ways. But withou= t FIT, >> >> How can the initrd be checked without FIT? > > I don't know. Please check with the EFI people. > >> >>> we have no standard way of signing and grouping FDT files. Instea= d >>> we must >>> include them in the distro as separate files. >>> >>> In particular, some sort of mechanism for verifying FDT files is = needed. >>> One option would be to tack a signature on before or after the fi= le, >>> processing it accordingly. But due to the nature of the FDT binar= y >>> format, >>> it is possible to embed a signature inside the FDT itself, which = is very >>> convenient. >>> >>> This series provides a tool, fdt_sign, which can add a signature = to an >>> FDT. The signature can be checked later, preventing any change to >>> the FDT, >>> other than in permitted nodes (e.g. /chosen). >> >> I am not aware of any standard defining which nodes may be changed in >> the FDT fixup and which may not be changed. >> >> How can we discover which nodes were excluded from the signature after >> the signature? > > There is no way at present. I decided against adding a list of signed > nodes. We can of course add whatever is useful here. > >> >>> >>> This series also provides a fdt_check_sign tool, used to check >>> signatures. >>> >>> Both of these tools are stand-alone do not require mkimage or FIT= . >>> >>> As with FIT signing, multiple signatures are possible, but in thi= s case >>> that requires that fit_sign be called once for each signature. To >>> make the >>> check fail if a signature does not match, it should be marked as >>> 'required' using the -r flag to fdt_sign. >>> >>> Run-time support for checking FDT signatures could be added to U-= Boot >>> fairly easily, but needs further discussion as the correct plumbi= ng >>> needs >>> to be determined. >>> >>> For now there is absolutely no configurability in the signature >>> mechanism. >> >> I would have expected a description of what a signature looks like. I >> don't wont to reverse engineer your patches. >> >> Please, describe this in doc/develop/ and in this cover-letter. > > It is the same format as the FIT signature, an RSA signature. See here: > > https://github.com/u-boot/u-boot/blob/master/doc/uImage.FIT/signature.tx= t#L162 > >> >> This series should have been sent as RFC. > > The last time I did that it disappeared without trace. You can of > course make comments on any series I send. > > Regards, > Simon > >> >> Best regards >> >> Heinrich >> >>> It would of course be possible to adjust which nodes are signed, = as is >>> done for FIT, but that needs further discussion also. The omissio= n >>> of the >>> /chosen node is implemented in h_exclude_nodes() like this: >>> >>> if (type =3D=3D FDT_IS_NODE) { >>> /* Ignore the chosen node as well as /signature and subnod= es */ >>> if (!strcmp("/chosen", data) || !strncmp("/signature", dat= a, 10)) >>> return 0; >>> } >>> >>> Man pages are provided with example usage of the tools. Use this = to view >>> them: >>> >>> man -l doc/fdt_check_sign.1 >>> >>> This series also includes various clean-ups noticed along the way= , >>> as well >>> as refactoring to avoid code duplication with the new tools. The >>> last four >>> patches are the new code. >>> >>> This series is available at u-boot-dm/fdt-sign-working : >>> >>> https://source.denx.de/u-boot/custodians/u-boot-dm/-/tree/fdt-sig= n-working >>> >>> >>> >>> Simon Glass (16): >>> rsa: Add debugging for failure cases >>> fit_check_sign: Update help to mention the key is in a dtb >>> tools: Move copyfile() into a common file >>> tools: Avoid leaving extra data at the end of copied files >>> tools: Improve comments in signing functions >>> tools: Drop unused name in image-host >>> tools: Avoid confusion between keys and signatures >>> tools: Tidy up argument order in fit_config_check_sig() >>> tools: Pass the key blob around >>> image: Return destination node for add_verify_data() method >>> tools: Pass public-key node through to caller >>> tools: mkimage: Show where signatures/keys are written >>> tools: Add a new tool to sign FDT blobs >>> tools: Add a new tool to check FDT-blob signatures >>> test: Add a test for FDT signing >>> tools: Add man pages for fdt_sign and fdt_check_sign >>> >>> MAINTAINERS | 7 + >>> boot/image-fit-sig.c | 151 +++++++++---- >>> boot/image-fit.c | 12 +- >>> common/spl/spl_fit.c | 3 +- >>> doc/fdt_check_sign.1 | 74 +++++++ >>> doc/fdt_sign.1 | 111 ++++++++++ >>> include/image.h | 80 ++++++- >>> include/u-boot/ecdsa.h | 5 +- >>> include/u-boot/rsa.h | 5 +- >>> lib/ecdsa/ecdsa-libcrypto.c | 4 +- >>> lib/rsa/rsa-sign.c | 5 +- >>> lib/rsa/rsa-verify.c | 13 +- >>> test/py/tests/test_fdt_sign.py | 83 ++++++++ >>> test/py/tests/test_vboot.py | 21 +- >>> test/py/tests/vboot/sign-fdt.dts | 23 ++ >>> test/py/tests/vboot_comm.py | 22 ++ >>> tools/Makefile | 10 +- >>> tools/fdt-host.c | 353 ++++++++++++++++++++++++= +++++++ >>> tools/fdt_check_sign.c | 85 ++++++++ >>> tools/fdt_host.h | 46 ++++ >>> tools/fdt_sign.c | 210 ++++++++++++++++++ >>> tools/fit_check_sign.c | 4 +- >>> tools/fit_common.c | 69 ++++++ >>> tools/fit_common.h | 23 ++ >>> tools/fit_image.c | 59 +----- >>> tools/image-fdt-sig.c | 254 ++++++++++++++++++++++ >>> tools/image-host.c | 155 +++++++++++--- >>> tools/imagetool.h | 4 + >>> tools/mkimage.c | 4 + >>> 29 files changed, 1714 insertions(+), 181 deletions(-) >>> create mode 100644 doc/fdt_check_sign.1 >>> create mode 100644 doc/fdt_sign.1 >>> create mode 100644 test/py/tests/test_fdt_sign.py >>> create mode 100644 test/py/tests/vboot/sign-fdt.dts >>> create mode 100644 test/py/tests/vboot_comm.py >>> create mode 100644 tools/fdt-host.c >>> create mode 100644 tools/fdt_check_sign.c >>> create mode 100644 tools/fdt_sign.c >>> create mode 100644 tools/image-fdt-sig.c >>> >>> -- >>> 2.34.0.rc1.387.gb447b232ab-goog >>> >>> -- >>> >>> Fran=C3=A7ois-Fr=C3=A9d=C3=A9ric Ozog | /Director Business Development= / >>> T: +33.67221.6485 >>> francois.ozog@linaro.org | Skype: ff= ozog >>> >>>