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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 08ED5C6FD1F for ; Thu, 16 Mar 2023 14:45:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A10E385C1A; Thu, 16 Mar 2023 15:45:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KmidH+Mb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4C31E85C9F; Thu, 16 Mar 2023 15:45:18 +0100 (CET) Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) (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 4857C85C14 for ; Thu, 16 Mar 2023 15:45:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=fr0st61te@gmail.com Received: by mail-lf1-x130.google.com with SMTP id br6so2660300lfb.11 for ; Thu, 16 Mar 2023 07:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678977912; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=Zq6Xi0tiQd4RsyUqk3ep//37radJcotWztVAAGJDCYc=; b=KmidH+Mbwlp5h/gA11atcK+1xWy6Cw3k3KMN+p/q+gqejQX8Js1VqkjgYpXgj4ry6V N/pN/Bt9NO3lLgOCiOje2S5SYUUS1XVKaW97N7DGq+Hp3Beh2lHAF23wWFyVVVKaZdA9 6AXmx4Lth5oAdxQMcpZzDJuCFBpg1M7Vd0DbGfGVR8YXEachRT1/c+EFFMby7wAzrCon xkaqLAKhwM3XS9f71atoVwRYbyr3daiOGPZzGY8hdIguD2qNflJeE0ifqVxzf0Mn2xm5 C0Cq8xvp0/x1CfZP4JEZL18unryFVYNF9zqNkO6vUARmZvC9FgK03Hdxili6czNIHkn0 Blzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678977912; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Zq6Xi0tiQd4RsyUqk3ep//37radJcotWztVAAGJDCYc=; b=epzbqIH2Eyitwp0GwmMpPg3aF2kEr1BSVtTx2GhegD4PssqjWhG8cVc7555Neoc856 6R3ydbyKK7LMnpaC/xyJ8bjlpZY2TyUQN+J0KgM/8RATPUlvR5uWF1GtQIA4Gfw3KmJI PykTDSwwhye2XUcRcw+u29KtpBh+OnCJDaAHeEKdcl1oF4YTF8znn9R5Xb+gFUR+5VFq nqkLJKa08c7pkAtNQ6m6DoPQbU29hDlfB8usgcxyEMgRAEKbv2iPLJqFYQDmopVfTNJ9 UxdhQCHwSowiwc8hoWG8Nx4hzX+AULv19Rd1MlH5DoC/oJx7k9jBzMTyqdNGTM+yvLvF 6YlQ== X-Gm-Message-State: AO0yUKXEFCkupM2BrVj851EUwBnLDDvdRFObxHHZ5ApGlBQTkUhEXrlR yWRU7zWINMNk1f8xa4KEdfc= X-Google-Smtp-Source: AK7set8kBhgnDIXSQtd0Vp+VTwoNjmQnhOojDXnA1soQu0Y9IqnY77QFbNb7oYvOCpD6LMidML8Jtg== X-Received: by 2002:a05:6512:3890:b0:4db:a19:6dfe with SMTP id n16-20020a056512389000b004db0a196dfemr3267233lft.26.1678977912210; Thu, 16 Mar 2023 07:45:12 -0700 (PDT) Received: from [100.119.23.254] (95-31-186-248.broadband.corbina.ru. [95.31.186.248]) by smtp.gmail.com with ESMTPSA id w29-20020ac2599d000000b004db44babad7sm1246881lfn.260.2023.03.16.07.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 07:45:11 -0700 (PDT) Message-ID: <1bee02e6dd2508a9928c228584c3d0bdf7347270.camel@gmail.com> Subject: Re: [PATCH v2 5/5] test_vboot.py: include test of fdt_add_pubkey tool From: Ivan Mikhaylov To: Simon Glass Cc: Jan Kiszka , u-boot@lists.denx.de, Roman Kopytin , Rasmus Villemoes Date: Thu, 16 Mar 2023 17:45:11 +0000 In-Reply-To: References: <20230308011342.21992-1-fr0st61te@gmail.com> <20230308011342.21992-6-fr0st61te@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean On Thu, 2023-03-16 at 07:59 -0600, Simon Glass wrote: > Hi Ivan, >=20 > On Wed, 15 Mar 2023 at 19:17, Ivan Mikhaylov > wrote: > >=20 > > On Fri, 2023-03-10 at 17:46 -0800, Simon Glass wrote: > > > Hi Ivan, > > >=20 > > > On Tue, 7 Mar 2023 at 14:13, Ivan Mikhaylov > > > wrote: > > > >=20 > > > > From: Roman Kopytin > > > >=20 > > > > Signed-off-by: Roman Kopytin > > > > Cc: Rasmus Villemoes > > > > --- > > > > =C2=A0test/py/tests/test_vboot.py | 8 ++++++++ > > > > =C2=A01 file changed, 8 insertions(+) > > > >=20 > > > > diff --git a/test/py/tests/test_vboot.py > > > > b/test/py/tests/test_vboot.py > > > > index e3e7ca4b21..956b8fcd43 100644 > > > > --- a/test/py/tests/test_vboot.py > > > > +++ b/test/py/tests/test_vboot.py > > > > @@ -313,6 +313,13 @@ def test_vboot(u_boot_console, name, > > > > sha_algo, > > > > padding, sign_options, required, > > > >=20 > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 util.run_and_log(c= ons, [fit_check_sign, '-f', fit, '- > > > > k', > > > > dtb]) > > > >=20 > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Create a fresh .dtb w= ithout the public keys > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dtc('sandbox-u-boot.dts= ') > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Then add the dev key = via the fdt_add_pubkey tool > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 util.run_and_log(cons, = [fdt_add_pubkey, '-a', > > > > '%s,rsa2048' > > > > % sha_algo, > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 '-k', tmpdir, '-n', 'dev', '- > > > > r', > > > > 'conf', dtb]) > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 util.run_and_log(cons, = [fit_check_sign, '-f', fit, '- > > > > k', > > > > dtb]) > > > > + > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if full_test: > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 # Make sure that U-Boot checks that the config is > > > > in > > > > the list of > > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 # hashed nodes. If it isn't, a security bypass is > > > > possible. > > > > @@ -500,6 +507,7 @@ def test_vboot(u_boot_console, name, > > > > sha_algo, > > > > padding, sign_options, required, > > > > =C2=A0=C2=A0=C2=A0=C2=A0 mkimage =3D cons.config.build_dir + '/tool= s/mkimage' > > > > =C2=A0=C2=A0=C2=A0=C2=A0 binman =3D cons.config.source_dir + '/tool= s/binman/binman' > > > > =C2=A0=C2=A0=C2=A0=C2=A0 fit_check_sign =3D cons.config.build_dir + > > > > '/tools/fit_check_sign' > > > > +=C2=A0=C2=A0=C2=A0 fdt_add_pubkey =3D cons.config.build_dir + > > > > '/tools/fdt_add_pubkey' > > > > =C2=A0=C2=A0=C2=A0=C2=A0 dtc_args =3D '-I dts -O dtb -i %s' % tmpdi= r > > > > =C2=A0=C2=A0=C2=A0=C2=A0 dtb =3D '%ssandbox-u-boot.dtb' % tmpdir > > > > =C2=A0=C2=A0=C2=A0=C2=A0 sig_node =3D '/configurations/conf-1/signa= ture' > > > > -- > > > > 2.39.1 > > > >=20 > > >=20 > > > Unfortunately this test fails on sandbox: > > >=20 > > > https://source.denx.de/u-boot/custodians/u-boot-dm/-/jobs/591975 > > >=20 > > > I think it would be better to put it in its own test (perhaps in > > > the > > > same file) so we are not doing it on every test run. Also you > > > could > > > check (in a very basic way) that it adds the key correctly since > > > we > > > don't really need another test of the logic of doing that. We are > > > just > > > checking that your tool calls that logic correctly. > > >=20 > > > I'll drop this one when applying, for now. Please take a look. > > >=20 > > > Regards, > > > Simon > >=20 > > Simon, does it look ok? Test for test_vboot is passed fine. >=20 > Please see my message before: >=20 > > Unfortunately this test fails on sandbox: > >=20 > > https://source.denx.de/u-boot/custodians/u-boot-dm/-/jobs/591975 > >=20 > > I think it would be better to put it in its own test (perhaps in > > the > > same file) so we are not doing it on every test run. Also you could > > check (in a very basic way) that it adds the key correctly since we > > don't really need another test of the logic of doing that. We are > > just > > checking that your tool calls that logic correctly. > >=20 > > I'll drop this one when applying, for now. Please take a look. >=20 > I have not applied this patch due to the problem. >=20 > Regards, > Simon >=20 Simon, but I've changed the test and put it in previous note, maybe you didn't notice, I did what you asked: - made own test "test_fdt_add_pubkey" - simple check that with clear dtb you can add keys with fdt_add_pubkey and check with fit_check_sign with signed fit. I've checked that change with sandbox and it passes test_vboot well. Need I re-submit that patch or whole series? Thanks. >=20 >=20 > >=20 > > Thanks. > >=20 > > From 5484d525d4950b064adf1204f5bf055229c942ac Mon Sep 17 00:00:00 > > 2001 > > From: Roman Kopytin > > Date: Thu, 11 Nov 2021 11:15:12 +0300 > > Subject: [PATCH v3] test_vboot.py: include test of fdt_add_pubkey > > tool > >=20 > > Signed-off-by: Roman Kopytin > > Signed-off-by: Ivan Mikhaylov > > Cc: Rasmus Villemoes > > --- > > =C2=A0test/py/tests/test_vboot.py | 33 ++++++++++++++++++++++++++++++++= + > > =C2=A01 file changed, 33 insertions(+) > >=20 > > diff --git a/test/py/tests/test_vboot.py > > b/test/py/tests/test_vboot.py > > index e3e7ca4b21..5ae622fe21 100644 > > --- a/test/py/tests/test_vboot.py > > +++ b/test/py/tests/test_vboot.py > > @@ -491,6 +491,37 @@ def test_vboot(u_boot_console, name, sha_algo, > > padding, sign_options, required, > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Check that the boot = fails if the global signature is not > > provided > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 run_bootm(sha_algo, 'g= lobal image signature', 'signature > > is > > mandatory', False) > >=20 > > +=C2=A0=C2=A0=C2=A0 def test_fdt_add_pubkey(sha_algo, padding, sign_opt= ions): > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 """Test fdt_add_pubkey util= ity with given hash algorithm > > and > > padding. > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 This function tests if fdt_= add_pubkey utility may add > > public > > keys into dtb. > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Args: > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sha= _algo: Either 'sha1' or 'sha256', to select the > > algorithm to use > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pad= ding: Either '' or '-pss', to select the padding to > > use > > for the > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rsa signature algorithm. > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sig= n_options: Options to mkimage when signing a fit > > image. > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 """ > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Create a fresh .dtb witho= ut the public keys > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dtc('sandbox-u-boot.dts') > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 make_fit('sign-configs-%s%s= .its' % (sha_algo, padding)) > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Sign images with our dev = keys > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sign_fit(sha_algo, sign_opt= ions) > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Create a fresh .dtb witho= ut the public keys > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dtc('sandbox-u-boot.dts') > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cons.log.action('%s: Test f= dt_add_pubkey with signed > > configuration' % sha_algo) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Then add the dev key via = the fdt_add_pubkey tool > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 util.run_and_log(cons, [fdt= _add_pubkey, '-a', '%s,%s' % > > ('sha256' if algo_arg else sha_algo, \ > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 'rsa3072' if sha_algo =3D=3D 'sh= a384' > > else > > 'rsa2048'), > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 '-k', tmpdir, '-n', 'dev', '-r', > > 'conf', dtb]) > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Check with fit_check_sign= that FIT is signed with key > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 util.run_and_log(cons, [fit= _check_sign, '-f', fit, '-k', > > dtb]) > > + > > =C2=A0=C2=A0=C2=A0=C2=A0 cons =3D u_boot_console > > =C2=A0=C2=A0=C2=A0=C2=A0 tmpdir =3D os.path.join(cons.config.result_dir= , name) + '/' > > =C2=A0=C2=A0=C2=A0=C2=A0 if not os.path.exists(tmpdir): > > @@ -500,6 +531,7 @@ def test_vboot(u_boot_console, name, sha_algo, > > padding, sign_options, required, > > =C2=A0=C2=A0=C2=A0=C2=A0 mkimage =3D cons.config.build_dir + '/tools/mk= image' > > =C2=A0=C2=A0=C2=A0=C2=A0 binman =3D cons.config.source_dir + '/tools/bi= nman/binman' > > =C2=A0=C2=A0=C2=A0=C2=A0 fit_check_sign =3D cons.config.build_dir + > > '/tools/fit_check_sign' > > +=C2=A0=C2=A0=C2=A0 fdt_add_pubkey =3D cons.config.build_dir + > > '/tools/fdt_add_pubkey' > > =C2=A0=C2=A0=C2=A0=C2=A0 dtc_args =3D '-I dts -O dtb -i %s' % tmpdir > > =C2=A0=C2=A0=C2=A0=C2=A0 dtb =3D '%ssandbox-u-boot.dtb' % tmpdir > > =C2=A0=C2=A0=C2=A0=C2=A0 sig_node =3D '/configurations/conf-1/signature= ' > > @@ -516,6 +548,7 @@ def test_vboot(u_boot_console, name, sha_algo, > > padding, sign_options, required, > > =C2=A0=C2=A0=C2=A0=C2=A0 with open(evil_kernel, 'wb') as fd: > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fd.write(500 * b'\x01'= ) > >=20 > > +=C2=A0=C2=A0=C2=A0 test_fdt_add_pubkey(sha_algo, padding, sign_options= ) > > =C2=A0=C2=A0=C2=A0=C2=A0 try: > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # We need to use our o= wn device tree file. Remember to > > restore > > it > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # afterwards. > > -- > > 2.39.1 > >=20 > >=20