U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: Tim Harvey <tharvey@gateworks.com>
Cc: u-boot@lists.denx.de, anton.gres@ifm.com, ch@denx.de,
	"NXP i.MX U-Boot Team" <uboot-imx@nxp.com>,
	Adam Ford <aford173@gmail.com>,
	Alper Nebi Yasak <alpernebiyasak@gmail.com>,
	Andrejs Cainikovs <andrejs.cainikovs@toradex.com>,
	Angus Ainslie <angus@akkea.ca>,
	Emanuele Ghidoli <emanuele.ghidoli@toradex.com>,
	Fabio Estevam <festevam@gmail.com>,
	Francesco Dolcini <francesco.dolcini@toradex.com>,
	Marcel Ziswiler <marcel.ziswiler@toradex.com>,
	Rasmus Villemoes <rasmus.villemoes@prevas.dk>,
	Simon Glass <sjg@chromium.org>,
	Stefan Eichenberger <stefan.eichenberger@toradex.com>,
	Stefano Babic <sbabic@denx.de>, Tom Rini <trini@konsulko.com>,
	kernel@puri.sm, u-boot@dh-electronics.com
Subject: Re: [PATCH v2 4/4] imx: hab: Use nxp_imx8mcst etype for i.MX8M flash.bin signing
Date: Tue, 14 May 2024 22:23:22 +0200	[thread overview]
Message-ID: <1bb31e71-6fe3-44ce-90dc-6bc7a7fc4d94@denx.de> (raw)
In-Reply-To: <CAJ+vNU2=k911jK8rYuaCx7qUN9GyCF6GLjuhLi0y82+yq1hYng@mail.gmail.com>

On 5/14/24 8:34 PM, Tim Harvey wrote:

Hi,

>> diff --git a/doc/imx/habv4/guides/mx8m_spl_secure_boot.txt b/doc/imx/habv4/guides/mx8m_spl_secure_boot.txt
>> index e16e5410bd9..ce1de659d8c 100644
>> --- a/doc/imx/habv4/guides/mx8m_spl_secure_boot.txt
>> +++ b/doc/imx/habv4/guides/mx8m_spl_secure_boot.txt
>> @@ -121,6 +121,9 @@ build configuration:
>>   - Defconfig:
>>
>>     CONFIG_IMX_HAB=y
>> +  CONFIG_FSL_CAAM=y
>> +  CONFIG_ARCH_MISC_INIT=y
>> +  CONFIG_SPL_CRYPTO=y
>>
> 
> Hi Marek,
> 
> Thanks for wrapping the dts bits with a config item.
> 
> Is there any other reason to build with CONFIG_IMX_HAB than to use a
> signed image? I see that there are several ARCH_MX6 and ARCH_MX7
> configs that have this enabled (not ARCH_IMX8M so this certainly
> doesn't break anything) and I'm not sure what the value of that is.

I think those few either enabled in preemptively in anticipation of 
possibly using HAB, or are wrong. I suspect it should be disabled for 
those, as it only adds to the board boot time and I am not even sure if 
those machines would boot correctly.

Francesco, maybe you do have MX7 Colibri ?

> I notice that FSL_CAAM is selected when you select IMX_HAB... is there
> any reason why ARCH_MISC_INIT and SPL_CRYPTO should not be selected by
> IMX_HAB as well (future patch perhaps)?

ARCH_MISC_INIT should be selected by SoC Kconfig on MX7 and maybe CAAM 
on MX8M I think . As for SPL_CRYPTO, that should be selected by 
SPL_FSL_CAAM I think.

>>   - Kconfig:
>>
> 
> We definitely need to describe the additional requirements here. Maybe
> something like:
> 
> - Tools:
> cst - NXP code-signing-tool (eg apt install imx-code-signing-tool)
> 
> - Files: (created with NXP IMX_CST_TOOL)
> SRK_1_2_3_4_table.bin (specified by nxp,srk-table node): fuse table
> CSF1_1_sha256_4096_65537_v3_usr_crt.pem (specified by nxp,csf-crt node): CSF_KEY
> IMG1_1_sha256_4096_65537_v3_usr_crt.pem (specified by nxp,img-crt node): IMG_KEY
> 
> The following works fine for me on v2024.01
> export CST_DIR=/usr/src/nxp/cst-3.3.2/
> export CSF_KEY=$CST_DIR/crts/CSF1_1_sha256_4096_65537_v3_usr_crt.pem
> export IMG_KEY=$CST_DIR/crts/IMG1_1_sha256_4096_65537_v3_usr_crt.pem
> export SRK_TABLE=$CST_DIR/crts/SRK_1_2_3_4_table.bin
> export PATH=$CST_DIR/linux64/bin:$PATH
> make && /bin/sh doc/imx/habv4/csf_examples/mx8m/csf.sh
> 
> But with the above defines and your series this fails:
> ln -sf $SRK_TABLE SRK_1_2_3_4_table.bin
> ln -sf $CSF_KEY CSF1_1_sha256_4096_65537_v3_usr_crt.pem
> ln -sf $IMG_KEY IMG1_1_sha256_4096_65537_v3_usr_crt.pem
> make
>    BINMAN  .binman_stamp
> Wrote map file './image.map' to show errors
> binman: Error 1 running 'cst -i
> ./nxp.csf-config-txt.section.nxp-imx8mcst@0 -o
> ./nxp.csf-output-blob.section.nxp-imx8mcst@0': Error:
> Cannot open key file IMG1_1_sha256_4096_65537_v3_usr_key.pem
> 0:error:02001002:system library:fopen:No such file or
> directory:crypto/bio/bss_file.c:288:fopen('IMG1_1_sha256_4096_65537_v3_usr_key.
> pem','r')
> 0:error:20074002:BIO routines:file_ctrl:system lib:crypto/bio/bss_file.c:290:
> 
> make: *** [Makefile:1126: .binman_stamp] Error 1
> 
> So how is it that the default for nxp,img-crt
> IMG1_1_sha256_4096_65537_v3_usr_crt.pem is now looking for
> IMG1_1_sha256_4096_65537_v3_usr_key? It fails also if I cp the files
> vs ln them.
> 
> So what am I missing here?

I think CST is using both the certificate and the key files. Try and run 
strace on the CST to test that:

$ strace cst -i ./nxp.csf-config-txt.section.nxp-imx8mcst@0 -o 
./nxp.csf-output-blob.section.nxp-imx8mcst@0

  reply	other threads:[~2024-05-14 20:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-03  1:05 [PATCH v2 1/4] binman: Add nxp_imx8mcst etype for i.MX8M flash.bin signing Marek Vasut
2024-05-03  1:05 ` [PATCH v2 2/4] ARM: dts: imx: Introduce SPL and FIT labels to i.MX8M DTs binman nodes Marek Vasut
2024-05-03  1:05 ` [PATCH v2 3/4] ARM: dts: imx: Wrap i.MX8M binman SPL and FIT nodes in CST node if IMX_HAB enabled Marek Vasut
2024-05-03  1:05 ` [PATCH v2 4/4] imx: hab: Use nxp_imx8mcst etype for i.MX8M flash.bin signing Marek Vasut
2024-05-14 18:34   ` Tim Harvey
2024-05-14 20:23     ` Marek Vasut [this message]
2024-05-15 22:16       ` Tim Harvey
2024-05-15 22:31       ` Tim Harvey
2024-05-16  1:53         ` Marek Vasut
2024-05-16 15:31           ` Tim Harvey
2024-05-06 11:52 ` [PATCH v2 1/4] binman: Add " Francesco Dolcini
2024-05-06 15:21   ` Marek Vasut
2024-05-07 13:06 ` [PATCH] imx: hab: add documentation about the required keys/certs Claudius Heine
2024-05-07 13:28   ` Marek Vasut
2024-05-08  7:23     ` Claudius Heine
2024-05-13  3:46       ` Marek Vasut
2024-05-14 18:50         ` Tim Harvey
2024-05-15 22:46           ` Tim Harvey
2024-05-16  8:25             ` Claudius Heine
2024-05-16  9:50               ` Rasmus Villemoes
2024-05-16 11:27                 ` Claudius Heine
2024-05-16  8:36   ` [PATCH v2] " Claudius Heine
2024-05-18  8:30     ` Heinrich Schuchardt
2024-05-24 16:27     ` Fabio Estevam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1bb31e71-6fe3-44ce-90dc-6bc7a7fc4d94@denx.de \
    --to=marex@denx.de \
    --cc=aford173@gmail.com \
    --cc=alpernebiyasak@gmail.com \
    --cc=andrejs.cainikovs@toradex.com \
    --cc=angus@akkea.ca \
    --cc=anton.gres@ifm.com \
    --cc=ch@denx.de \
    --cc=emanuele.ghidoli@toradex.com \
    --cc=festevam@gmail.com \
    --cc=francesco.dolcini@toradex.com \
    --cc=kernel@puri.sm \
    --cc=marcel.ziswiler@toradex.com \
    --cc=rasmus.villemoes@prevas.dk \
    --cc=sbabic@denx.de \
    --cc=sjg@chromium.org \
    --cc=stefan.eichenberger@toradex.com \
    --cc=tharvey@gateworks.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@dh-electronics.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox