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: Thu, 16 May 2024 03:53:07 +0200 [thread overview]
Message-ID: <272ca2c6-9a33-4252-8d8f-45d1cccf3f33@denx.de> (raw)
In-Reply-To: <CAJ+vNU0F1Xa4Tm5P=eC5DgidLSGD8sKfjZ=y9J7Fx4kW01qoFQ@mail.gmail.com>
On 5/16/24 12:31 AM, Tim Harvey wrote:
Hi,
> (this is a resend... apologies if its a duplicate. I got some strange
> bounce that mime types were included so I'm resending with the otuput
> of strace cliped out)
>
> strace was a good idea and showed me what was going on.
>
> The previous documentation stated to pass your keys via env vars that
> were full paths to key certificates. Using strace shows me that it
> will use the directory the KEY certificate is in and try to open up
> ../keys/*_usr_key.pem if the key path is specified. So apparently the
> 'File' in the CST config file is used indirectly. Pointing to the
> usr_key.pem isn't enough either by the way, it seems to need both of
> these:
>
> so if I hack the path to my certs in like this it works:diff --git
> a/tools/binman/etype/nxp_imx8mcst.py
> b/tools/binman/etype/nxp_imx8mcst.py
> index 132127ad4827..b432200960df 100644
> --- a/tools/binman/etype/nxp_imx8mcst.py
> +++ b/tools/binman/etype/nxp_imx8mcst.py
> @@ -67,10 +67,11 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
>
> def ReadNode(self):
> super().ReadNode()
> + self.certpath =3D '/usr/src/nxp/cst-3.3.2/crts/';
=3D , seems like your email is acting funny today indeed.
> self.loader_address =3D fdt_util.GetInt(self._node, 'nxp,loader-ad=
> dress')
> self.srk_table =3D fdt_util.GetString(self._node,
> 'nxp,srk-table', 'SRK_1_2_3_4_table.bin')
> - self.csf_crt =3D fdt_util.GetString(self._node, 'nxp,csf-crt',
> 'CSF1_1_sha256_4096_65537_v3_usr_crt.pem')
> - self.img_crt =3D fdt_util.GetString(self._node, 'nxp,img-crt',
> 'IMG1_1_sha256_4096_65537_v3_usr_crt.pem')
> + self.csf_crt =3D fdt_util.GetString(self._node, 'nxp,csf-crt',
> self.certpath + '/CSF1_1_sha256_4096_65537_v3_usr_crt.pem')
> + self.img_crt =3D fdt_util.GetString(self._node, 'nxp,img-crt',
> self.certpath + '/IMG1_1_sha256_4096_65537_v3_usr_crt.pem')
What about this:
diff --git a/tools/binman/etype/nxp_imx8mcst.py
b/tools/binman/etype/nxp_imx8mcst.py
index 132127ad482..9ead7488a2d 100644
--- a/tools/binman/etype/nxp_imx8mcst.py
+++ b/tools/binman/etype/nxp_imx8mcst.py
@@ -68,9 +68,9 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
def ReadNode(self):
super().ReadNode()
self.loader_address = fdt_util.GetInt(self._node,
'nxp,loader-address')
- self.srk_table = fdt_util.GetString(self._node,
'nxp,srk-table', 'SRK_1_2_3_4_table.bin')
- self.csf_crt = fdt_util.GetString(self._node, 'nxp,csf-crt',
'CSF1_1_sha256_4096_65537_v3_usr_crt.pem')
- self.img_crt = fdt_util.GetString(self._node, 'nxp,img-crt',
'IMG1_1_sha256_4096_65537_v3_usr_crt.pem')
+ self.srk_table = os.getenv('SRK_TABLE',
fdt_util.GetString(self._node, 'nxp,srk-table', 'SRK_1_2_3_4_table.bin'))
+ self.csf_crt = os.getenv('CSF_KEY',
fdt_util.GetString(self._node, 'nxp,csf-crt',
'CSF1_1_sha256_4096_65537_v3_usr_crt.pem'))
+ self.img_crt = os.getenv('IMG_KEY',
fdt_util.GetString(self._node, 'nxp,img-crt',
'IMG1_1_sha256_4096_65537_v3_usr_crt.pem'))
self.unlock = fdt_util.GetBool(self._node, 'nxp,unlock')
self.ReadEntries()
Then you can also use the old behavior with keys supplied via env vars.
This might in fact be useful for build systems too.
> self.unlock =3D fdt_util.GetBool(self._node, 'nxp,unlock')
> self.ReadEntries()
>
> $ make -j8
> BINMAN .binman_stamp
> OFCHK .config
>
> Strace indicatest the following with the above patch:
> openat(AT_FDCWD,
> "/usr/src/nxp/cst-3.3.2/crts//IMG1_1_sha256_4096_65537_v3_usr_crt.pem",
> O_RDONLY)
> ...
> openat(AT_FDCWD,
> "/usr/src/nxp/cst-3.3.2/keys//IMG1_1_sha256_4096_65537_v3_usr_key.pem",
> O_RDONLY)
> ^^^ look how it sneakily changes the PATH!
>
> And without the above patch using a key file without a path:
> openat(AT_FDCWD, "IMG1_1_sha256_4096_65537_v3_usr_crt.pem", O_RDONLY)
> ...
> openat(AT_FDCWD, "IMG1_1_sha256_4096_65537_v3_usr_key.pem", O_RDONLY)
> ENOENT (No such file or directory)
> ^^^ fails
>
> Simply copying both usr_crt.pem and usr_key.pem to the build directory
> still fails:
> 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:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad
> decrypt:crypto/evp/evp_enc.c:612:
> 0:error:23077074:PKCS12 routines:PKCS12_pbe_crypt:pkcs12 cipherfinal
> error:crypto/pkcs12/p12_decr.c:62:
> 0:error:2306A075:PKCS12 routines:PKCS12_item_decrypt_d2i:pkcs12 pbe
> crypt error:crypto/pkcs12/p12_decr.c:93:
> 0:error:0907B00D:PEM routines:PEM_read_bio_PrivateKey:ASN1
> lib:crypto/pem/pem_pkey.c:88:
>
> Do you not run into this and if not is it because you have put full
> paths in the dtsi overriding the defaults I'm using?
I just do '$ cp -Lv /CST/{keys,crts}/* .' to copy the keys and certs
into the build directory for testing.
> Maybe this has
> something to do with how my keys were generated or the version of cst
> I'm using or maybe we just need to also add a directory which can be
> symlinked to or something.
I use the imx-code-signing-tool 3.4.0+dfsg-2+b1 from debian .
> Another thing that I'm seeing is that this leaves a bunch of turd files around:
> cfg-out.section.nxp-imx8mcst@0.nxp-imx8mimage
> cfg-out.section.nxp-imx8mimage
> input.section.nxp-imx8mcst@0
> input.section.nxp-imx8mcst@0.nxp-imx8mimage
> input.section.nxp-imx8mimage
> nxp.csf-config-txt.section.nxp-imx8mcst@0
> nxp.cst-input-data.section.nxp-imx8mcst@0
> nxp.imx8mimage.cfg.section.nxp-imx8mcst@0.nxp-imx8mimage
> nxp.imx8mimage.cfg.section.nxp-imx8mimage
>
> These intermediate files should be cleaned up after signing is complete.
Those are intermediate build artifacts, sort of like .o files or such,
so they should be OK to keep around, right ?
next prev parent reply other threads:[~2024-05-16 1:53 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
2024-05-15 22:16 ` Tim Harvey
2024-05-15 22:31 ` Tim Harvey
2024-05-16 1:53 ` Marek Vasut [this message]
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=272ca2c6-9a33-4252-8d8f-45d1cccf3f33@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