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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 CF5D2C48BE6 for ; Wed, 16 Jun 2021 16:08:16 +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 02C3A610A0 for ; Wed, 16 Jun 2021 16:08:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 02C3A610A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 46C918295B; Wed, 16 Jun 2021 18:08:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com 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; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="lZku8+FM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DC1D78297B; Wed, 16 Jun 2021 18:08:11 +0200 (CEST) Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B43E782024 for ; Wed, 16 Jun 2021 18:08:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x833.google.com with SMTP id d9so2239428qtp.11 for ; Wed, 16 Jun 2021 09:08:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=+HsnD6TJ2bP/0wiCLI6OkoGybLwx4LUTD4OKgsQVQIQ=; b=lZku8+FMS69VCOYUZbrrciLkvUfSaluBNOWTYZ++f5lw0Zmy3+52OpipN31zdGnBYc Pr//juNnu277IPx7jQqVB9Eum1ClbbdBsxBgi/xRdSdQFR4MovNgwPn8mR3nXFqsG79U eO0Nyis1s5jqH+tfbUZQI/ER0p4/aweCGjKMU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=+HsnD6TJ2bP/0wiCLI6OkoGybLwx4LUTD4OKgsQVQIQ=; b=IRsMED/Y5sQfiS4pIri9+0ub/f0TGOH5DTtFfd7IdxICYYYSLVBZn8dtpsNwogSyWb Sf5ITGq10xCVEhG6+3v6FfwS1pUyKfu3jf9F17ZkzSuoQX0EnK+rglsvRDdDyCWuAtJ7 t6VI3B6/1r/mOtRGPtM2f0DK0q3OjF34BuRL6JDPZOXdN6N6FtDMBMBLWmQNqjZXL/HJ krdFmAYF/ZOKBtwd5OgASLFUdJVU8j/XlsbGZa33fAYeBVV+gWbqVCQ0P3YJun7Y7MPg p6c+YPuFR0ywqdGoky/4N3REhdHznmpr5Tzz9+X1ue2v8+DWsQ/WW331+rLIOg7PQ+5Z rKUQ== X-Gm-Message-State: AOAM530JwQnRH4RRF901rtek0zfcLv9BmbUqMAj3I7tDJzJOjaYwqG57 vR27HhVz/M6nWGWLJ9WH/bkH3g== X-Google-Smtp-Source: ABdhPJx1PhefkY5es80Ze+/7riFLBfVg75EQrp7rhAFxbqA/yWIljXwbdMC7IaYSbV3lsGEhYnQ2sg== X-Received: by 2002:ac8:7f91:: with SMTP id z17mr572152qtj.167.1623859683249; Wed, 16 Jun 2021 09:08:03 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-cbda-507d-0469-e510-a4e0.res6.spectrum.com. [2603:6081:7b01:cbda:507d:469:e510:a4e0]) by smtp.gmail.com with ESMTPSA id o2sm1422815qtv.47.2021.06.16.09.08.02 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Jun 2021 09:08:02 -0700 (PDT) Date: Wed, 16 Jun 2021 12:08:00 -0400 From: Tom Rini To: "Alex G." Cc: AKASHI Takahiro , u-boot@lists.denx.de, sjg@chromium.org Subject: Re: [PATCH] tools: Use a single target-independent config to enable OpenSSL Message-ID: <20210616160800.GV9516@bill-the-cat> References: <20210524202317.1492578-1-mr.nuke.me@gmail.com> <20210615233409.GA39672@laputa> <78405a8c-e5c1-53fd-5a85-450809d91919@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="fh9ZBaUqcBlFuagd" Content-Disposition: inline In-Reply-To: <78405a8c-e5c1-53fd-5a85-450809d91919@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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 --fh9ZBaUqcBlFuagd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 16, 2021 at 09:34:27AM -0500, Alex G. wrote: > On 6/15/21 6:34 PM, AKASHI Takahiro wrote: > > A gentle ping. > > What is the current review status? > > Who will take care of this patch? >=20 > Patchwork automatically delegates this to a maintainer [1], but anyone is > welcome to comment and review. Note that it's not automatic, I typically do it for anything that hasn't been picked up by a custodian already. I think the patch in question is fine, and since I think the series it depends on is also fine with Simon, I'll be picking it up either for next or after release. >=20 > Alex >=20 > [1] https://patchwork.ozlabs.org/project/uboot/patch/20210524202317.14925= 78-1-mr.nuke.me@gmail.com/ >=20 > > -Takahiro Akashi > >=20 > > On Mon, May 24, 2021 at 03:23:17PM -0500, Alexandru Gagniuc wrote: > > > Host tool features, such as mkimage's ability to sign FIT images were > > > enabled or disabled based on the target configuration. However, this > > > misses the point of a target-agnostic host tool. > > >=20 > > > A target's ability to verify FIT signatures is independent of > > > mkimage's ability to create those signatures. In fact, u-boot's build > > > system doesn't sign images. The target code can be successfully built > > > without relying on any ability to sign such code. > > >=20 > > > Conversely, mkimage's ability to sign images does not require that > > > those images will only work on targets which support FIT verification. > > > Linking mkimage cryptographic features to target support for FIT > > > verification is misguided. > > >=20 > > > Without loss of generality, we can say that host features are and > > > should be independent of target features. > > >=20 > > > While we prefer that a host tool always supports the same feature set, > > > we recognize the following > > > - some users prefer to build u-boot without a dependency on OpenSS= L. > > > - some distros prefer to ship mkimage without linking to OpenSSL > > >=20 > > > To allow these use cases, introduce a host-only Kconfig which is used > > > to select or deselect libcrypto support. Some mkimage features or some > > > host tools might not be available, but this shouldn't affect the > > > u-boot build. > > >=20 > > > I also considered setting the default of this config based on > > > FIT_SIGNATURE. While it would preserve the old behaviour it's also > > > contrary to the goals of this change. I decided to enable it by > > > default, so that the default build yields the most feature-complete > > > mkimage. > > >=20 > > > Signed-off-by: Alexandru Gagniuc > > > --- > > >=20 > > > This patch is designed to apply on top of > > > [PATCH v2 00/18] image: Reduce #ifdef abuse in image code > > >=20 > > >=20 > > >=20 > > > tools/Kconfig | 11 +++++++++++ > > > tools/Makefile | 46 ++++++++++++++++++++++++++++++---------------- > > > 2 files changed, 41 insertions(+), 16 deletions(-) > > >=20 > > > diff --git a/tools/Kconfig b/tools/Kconfig > > > index b2f5012240..214932ae30 100644 > > > --- a/tools/Kconfig > > > +++ b/tools/Kconfig > > > @@ -9,4 +9,15 @@ config MKIMAGE_DTC_PATH > > > some cases the system dtc may not support all required features > > > and the path to a different version should be given here. > > > +config TOOLS_USE_LIBCRYPTO > > > + bool "Use OpenSSL's libcrypto library for host tools" > > > + default y > > > + help > > > + Cryptographic signature, verification, and encryption of images is > > > + provided by host tools using OpenSSL's libcrypto. Select 'n' here= if > > > + you wish to build host tools without OpenSSL. mkimage will not ha= ve > > > + the ability to sign images. > > > + This selection does not affect target features, such as runtime F= IT > > > + signature verification. > > > + > > > endmenu > > > diff --git a/tools/Makefile b/tools/Makefile > > > index 722355e984..1f30a06cce 100644 > > > --- a/tools/Makefile > > > +++ b/tools/Makefile > > > @@ -3,6 +3,25 @@ > > > # (C) Copyright 2000-2006 > > > # Wolfgang Denk, DENX Software Engineering, wd@denx.de. > > > +# A note on target vs host configuration: > > > +# > > > +# Host tools can be used across multiple targets, or different confi= gurations > > > +# of the same target. Thus, host tools must be able to handle any co= mbination > > > +# of target configurations. To prevent having different variations o= f the same > > > +# tool, the tool build options may not depend on target configuratio= n. > > > +# > > > +# Some linux distributions package these utilities as u-boot-tools, = and it > > > +# would be unmaintainable to have a different tool variation for each > > > +# arch or configuration. > > > +# > > > +# A couple of simple rules: > > > +# > > > +# 1) Do not use target CONFIG_* options to enable or disable feature= s in host > > > +# tools. Only use the configs from tools/Kconfig > > > +# 2) It's okay to use target configs to disable building specific to= ols. > > > +# That's as long as the features of those tools aren't modified. > > > +# > > > + > > > # Enable all the config-independent tools > > > ifneq ($(HOST_TOOLS_ALL),) > > > CONFIG_ARCH_KIRKWOOD =3D y > > > @@ -53,30 +72,30 @@ hostprogs-y +=3D mkenvimage > > > mkenvimage-objs :=3D mkenvimage.o os_support.o lib/crc32.o > > > hostprogs-y +=3D dumpimage mkimage > > > -hostprogs-$(CONFIG_FIT_SIGNATURE) +=3D fit_info fit_check_sign > > > +hostprogs-$(CONFIG_TOOLS_USE_LIBCRYPTO) +=3D fit_info fit_check_sign > > > hostprogs-$(CONFIG_CMD_BOOTEFI_SELFTEST) +=3D file2include > > > FIT_OBJS-$(CONFIG_FIT) :=3D fit_common.o fit_image.o image-host.o c= ommon/image-fit.o > > > -FIT_SIG_OBJS-$(CONFIG_FIT_SIGNATURE) :=3D image-sig-host.o common/im= age-fit-sig.o > > > -FIT_CIPHER_OBJS-$(CONFIG_FIT_CIPHER) :=3D common/image-cipher.o > > > +FIT_SIG_OBJS-$(CONFIG_TOOLS_USE_LIBCRYPTO) :=3D image-sig-host.o com= mon/image-fit-sig.o > > > +FIT_CIPHER_OBJS-$(CONFIG_TOOLS_USE_LIBCRYPTO) :=3D common/image-ciph= er.o > > > # The following files are synced with upstream DTC. > > > # Use synced versions from scripts/dtc/libfdt/. > > > LIBFDT_OBJS :=3D $(addprefix libfdt/, fdt.o fdt_ro.o fdt_wip.o fdt_= sw.o fdt_rw.o \ > > > fdt_strerror.o fdt_empty_tree.o fdt_addresses.o fdt_overlay.o) > > > -RSA_OBJS-$(CONFIG_FIT_SIGNATURE) :=3D $(addprefix lib/rsa/, \ > > > +RSA_OBJS-$(CONFIG_TOOLS_USE_LIBCRYPTO) :=3D $(addprefix lib/rsa/, \ > > > rsa-sign.o rsa-verify.o \ > > > rsa-mod-exp.o) > > > -ECDSA_OBJS-$(CONFIG_FIT_SIGNATURE) :=3D $(addprefix lib/ecdsa/, ecds= a-libcrypto.o) > > > +ECDSA_OBJS-$(CONFIG_TOOLS_USE_LIBCRYPTO) :=3D $(addprefix lib/ecdsa/= , ecdsa-libcrypto.o) > > > -AES_OBJS-$(CONFIG_FIT_CIPHER) :=3D $(addprefix lib/aes/, \ > > > +AES_OBJS-$(CONFIG_TOOLS_USE_LIBCRYPTO) :=3D $(addprefix lib/aes/, \ > > > aes-encrypt.o aes-decrypt.o) > > > # Cryptographic helpers that depend on openssl/libcrypto > > > -LIBCRYPTO_OBJS-$(CONFIG_FIT_SIGNATURE) :=3D $(addprefix lib/, \ > > > +LIBCRYPTO_OBJS-$(CONFIG_TOOLS_USE_LIBCRYPTO) :=3D $(addprefix lib/, \ > > > fdt-libcrypto.o) > > > ROCKCHIP_OBS =3D lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o > > > @@ -136,22 +155,17 @@ fit_info-objs :=3D $(dumpimage-mkimage-objs) = fit_info.o > > > fit_check_sign-objs :=3D $(dumpimage-mkimage-objs) fit_check_sign= =2Eo > > > file2include-objs :=3D file2include.o > > > -ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_FIT_SIGNATURE),) > > > +ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_TOOLS_USE_LIBCRYPTO),) > > > # Add CONFIG_MXS into host CFLAGS, so we can check whether or not r= egister > > > # the mxsimage support within tools/mxsimage.c . > > > HOSTCFLAGS_mxsimage.o +=3D -DCONFIG_MXS > > > endif > > > -ifdef CONFIG_FIT_SIGNATURE > > > +ifdef CONFIG_TOOLS_USE_LIBCRYPTO > > > # This affects include/image.h, but including the board config file > > > # is tricky, so manually define this options here. > > > HOST_EXTRACFLAGS +=3D -DCONFIG_FIT_SIGNATURE > > > -HOST_EXTRACFLAGS +=3D -DCONFIG_FIT_SIGNATURE_MAX_SIZE=3D$(CONFIG_FIT= _SIGNATURE_MAX_SIZE) > > > -endif > > > - > > > -ifdef CONFIG_FIT_CIPHER > > > -# This affects include/image.h, but including the board config file > > > -# is tricky, so manually define this options here. > > > +HOST_EXTRACFLAGS +=3D -DCONFIG_FIT_SIGNATURE_MAX_SIZE=3D0xffffffff > > > HOST_EXTRACFLAGS +=3D -DCONFIG_FIT_CIPHER > > > endif > > > @@ -164,7 +178,7 @@ HOSTCFLAGS_kwbimage.o +=3D -DCONFIG_KWB_SECURE > > > endif > > > # MXSImage needs LibSSL > > > -ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_FIT_= SIGNATURE)$(CONFIG_FIT_CIPHER),) > > > +ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_TOOL= S_USE_LIBCRYPTO),) > > > HOSTCFLAGS_kwbimage.o +=3D \ > > > $(shell pkg-config --cflags libssl libcrypto 2> /dev/null || echo = "") > > > HOSTLDLIBS_mkimage +=3D \ > > > --=20 > > > 2.31.1 > > >=20 --=20 Tom --fh9ZBaUqcBlFuagd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmDKIdkACgkQFHw5/5Y0 tyyHBAv9E2T8ys7jybwWI4RidSJ1leKfLgHfqVKeVlb5++vzctwBUHDtG7bLog1Q Fa8Ma3PxNLwd8YQDNySCJ/7aitRnSvFFyxLn+J4IEkjiK2b+b4Z+tdCWJ/8wHzBc 4JdZIE2lxcFFNYcdwVicJ3Ut7ECLuEt9Cu+NXsbh+jwfNeRtQ14bNNJ0ub84mI6p qJDF4DBYBrx5R76FT7g8T1+1wmh5B/0SV3UPJYInbGPRVJbq0BnQlHCyC+ulojnC w1JEYMUdExT9GxQuuMnz8I2igqRdXK9I7QPszxX2dpBssoTd8JHwgzyAiAXt1HEt VdtOW9jDRvkXQ78jeFJtn+pFenCuYmgSoaYZpstjh1Xix9gM2od0MgWV9LbVEUc+ E2QYHK4OR1aJ9wfufL9gX3JqNA3vF91cU/rtxxmiYd/5OKdhZH7fHEWheBDKqIsf QzyUEfm+WX4oUCxXDYSNdNI6VHRKtOsCl++YL39Pvs+eaINz8HEAwMRN37m8JDRc kH4POdOr =/O0a -----END PGP SIGNATURE----- --fh9ZBaUqcBlFuagd--