binman: add CST backend selection for i.MX8M signing
PATCH v4 1/1 binman: add CST backend selection for i.MX8M signing
Add support for setting the CST backend, both via DT property and CST_BACKEND environment variable. The CST currently supports two backends, 'ssl' and 'pkcs11', with 'ssl' being the default when CST tool is invoked without any -b parameter. Keep 'ssl' backend as the default, but explicitly pass it via the '-b' parameter, unless the user selects 'pkcs11' via either method.
---
Cc: Alper Nebi Yasak <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
---
V2: Fill in documentation for all used DT properties
V3: Fill third copy of documentation into nxp_imx8mcst.py
V4: Rebase and resend
--- doc/imx/habv4/guides/mx8m_spl_secure_boot.txt | 30 ++++++++++++------- tools/binman/etype/nxp_imx8mcst.py | 19 +++++++++++- 2 files changed, 37 insertions(+), 12 deletions(-)
doc/imx/habv4/guides/mx8m_spl_secure_boot.txt +19 -11
@@ -167,17 +167,25 @@ The nxp-imx8mcst etype is configurable using either DT properties or environment variables. The following DT properties and environment variables are supported. Note that environment variables override DT properties. -+--------------------+-----------+------------------------------------------------------------------+ -| DT property | Variable | Description | -+====================+===========+==================================================================+ -| nxp,loader-address | | SPL base address | -+--------------------+-----------+------------------------------------------------------------------+ -| nxp,srk-table | SRK_TABLE | full path to SRK_1_2_3_4_table.bin | -+--------------------+-----------+------------------------------------------------------------------+ -| nxp,csf-crt | CSF_KEY | full path to the CSF Key CSF1_1_sha256_4096_65537_v3_usr_crt.pem | -+--------------------+-----------+------------------------------------------------------------------+ -| nxp,img-crt | IMG_KEY | full path to the IMG Key IMG1_1_sha256_4096_65537_v3_usr_crt.pem | -+--------------------+-----------+------------------------------------------------------------------+ ++--------------------+-------------+------------------------------------------------------------------+ +| DT property | Variable | Description | ++====================+=============+==================================================================+ +| nxp,loader-address | | SPL base address | ++--------------------+-------------+------------------------------------------------------------------+ +| nxp,srk-table | SRK_TABLE | full path to SRK_1_2_3_4_table.bin | ++--------------------+-------------+------------------------------------------------------------------+ +| nxp,csf-crt | CSF_KEY | full path to the CSF Key CSF1_1_sha256_4096_65537_v3_usr_crt.pem | ++--------------------+-------------+------------------------------------------------------------------+ +| nxp,img-crt | IMG_KEY | full path to the IMG Key IMG1_1_sha256_4096_65537_v3_usr_crt.pem | ++--------------------+-------------+------------------------------------------------------------------+ +| nxp,fast-auth | | enable fast authentication method | ++--------------------+-------------+------------------------------------------------------------------+ +| nxp,srk-crt | SRK_KEY | full path to the SRK Key SRK1_sha256_4096_65537_v3_ca_crt.pem | ++--------------------+-------------+------------------------------------------------------------------+ +| nxp,unlock | | unlock CAAM in SPL | ++--------------------+-------------+------------------------------------------------------------------+ +| nxp,cst-backend | CST_BACKEND | CST tool backend, default is 'ssl', or selectable 'pkcs11' | ++--------------------+-------------+------------------------------------------------------------------+ Environment variables can be set as follows to point the build process to external key material:
tools/binman/etype/nxp_imx8mcst.py +18 -1
@@ -65,6 +65,13 @@ class Entry_nxp_imx8mcst(Entry_mkimage): Properties / Entry arguments: - nxp,loader-address - loader address (SPL text base) + - nxp,srk-table - full path to SRK_1_2_3_4_table.bin + - nxp,csf-crt - full path to the CSF Key CSF1_1_sha256_4096_65537_v3_usr_crt.pem + - nxp,img-crt - full path to the IMG Key IMG1_1_sha256_4096_65537_v3_usr_crt.pem + - nxp,fast-auth - enable fast authentication method + - nxp,srk-crt - full path to the SRK Key SRK1_sha256_4096_65537_v3_ca_crt.pem + - nxp,unlock - unlock CAAM in SPL + - nxp,cst-backend - CST tool backend, default is 'ssl', or selectable 'pkcs11' """ def __init__(self, section, etype, node):
@@ -90,6 +97,10 @@ class Entry_nxp_imx8mcst(Entry_mkimage): 'SRK_KEY', fdt_util.GetString(self._node, 'nxp,srk-crt', f'SRK1_{KEY_NAME}.pem')) + self.backend = os.getenv( + 'CST_BACKEND', fdt_util.GetString(self._node, 'nxp,cst-backend', + 'ssl')) + self.unlock = fdt_util.GetBool(self._node, 'nxp,unlock') self.ReadEntries()
@@ -161,8 +172,14 @@ class Entry_nxp_imx8mcst(Entry_mkimage): with open(cfg_fname, 'w') as cfgf: config.write(cfgf) + # SSL is the default backend, PKCS11 backend is optional + if self.backend == "pkcs11": + cst_backend = "pkcs11" + else: + cst_backend = "ssl" + output_fname = tools.get_output_filename(f'nxp.csf-output-blob.{uniq}') - args = ['-i', cfg_fname, '-o', output_fname] + args = ['-i', cfg_fname, '-o', output_fname, '-b', cst_backend] if self.cst.run_cmd(*args) is not None: outdata = tools.read_file(output_fname) # fixme: 0x2000 should be CONFIG_CSF_SIZE
Signature · 1 line
2.53.0
Hi Marek,
Quoted 17 lines · Marek Vasut
binman: add CST backend selection for i.MX8M signing
Add support for setting the CST backend, both via DT property and
CST_BACKENDenvironment variable. The CST currently supports two backends, 'ssl' and 'pkcs11', with 'ssl' being the default when CST tool is invoked without any -b parameter. Keep 'ssl' backend as the default, but explicitly pass it via the '-b' parameter, unless the user selects 'pkcs11' via either method.Signed-off-by Marek Vasut <[email protected]>
doc/imx/habv4/guides/mx8m_spl_secure_boot.txt| 30 +++++++++++++++++----------tools/binman/etype/nxp_imx8mcst.py | 19 ++++++++++++++++- 2 files changed, 37 insertions(+), 12 deletions(-)
tools/binman/etype/nxp_imx8mcst.py class Entry_nxp_imx8mcst(Entry_mkimage): · line 100
Quoted 4 lines
tools/binman/etype/nxp_imx8mcst.py +4
-0@@ -90,6 +97,10 @@ class Entry_nxp_imx8mcst(Entry_mkimage): + self.backend = os.getenv( + 'CST_BACKEND', fdt_util.GetString(self._node, 'nxp,cst-backend', + 'ssl')) +
Please add a binman test covering this new feature - see testNxpImx8mCSTFastAuth in ftest.py and the vendor/nxp_imx8_csf*.dts fixtures. The missing coverage line for me is 177 (cst_backend = "pkcs11" )
Are you able to run 'binman test -T' ?
PLMK if you need help.
Regards,
Simon
Quoted 18 lines · Simon Glass
Hi Marek,
Quoted 14 lines · Marek Vasut
binman: add CST backend selection for i.MX8M signing
Add support for setting the CST backend, both via DT property and
CST_BACKENDenvironment variable. The CST currently supports two backends, 'ssl' and 'pkcs11', with 'ssl' being the default when CST tool is invoked without any -b parameter. Keep 'ssl' backend as the default, but explicitly pass it via the '-b' parameter, unless the user selects 'pkcs11' via either method.Signed-off-by Marek Vasut <[email protected]>
doc/imx/habv4/guides/mx8m_spl_secure_boot.txt| 30 +++++++++++++++++----------tools/binman/etype/nxp_imx8mcst.py | 19 ++++++++++++++++- 2 files changed, 37 insertions(+), 12 deletions(-)
Quoted 11 lines
tools/binman/etype/nxp_imx8mcst.py class Entry_nxp_imx8mcst(Entry_mkimage): · line 100
Quoted 6 lines
tools/binman/etype/nxp_imx8mcst.py +4
-0@@ -90,6 +97,10 @@ class Entry_nxp_imx8mcst(Entry_mkimage): + self.backend = os.getenv( + 'CST_BACKEND', fdt_util.GetString(self._node, 'nxp,cst-backend', + 'ssl')) +Please add a binman test covering this new feature - see testNxpImx8mCSTFastAuth in
ftest.pyand thevendor/nxp_imx8_csf*.dtsfixtures. The missing coverage line for me is 177 (cst_backend= "pkcs11" )
The pkcs11 option requires a HSM, how do you propose to test that ?
Quoted 31 lines · Marek Vasut
Quoted 18 lines · Simon Glass
Hi Marek,
Quoted 14 lines · Marek Vasut
binman: add CST backend selection for i.MX8M signing
Add support for setting the CST backend, both via DT property and
CST_BACKENDenvironment variable. The CST currently supports two backends, 'ssl' and 'pkcs11', with 'ssl' being the default when CST tool is invoked without any -b parameter. Keep 'ssl' backend as the default, but explicitly pass it via the '-b' parameter, unless the user selects 'pkcs11' via either method.Signed-off-by Marek Vasut <[email protected]>
doc/imx/habv4/guides/mx8m_spl_secure_boot.txt| 30 +++++++++++++++++----------tools/binman/etype/nxp_imx8mcst.py | 19 ++++++++++++++++- 2 files changed, 37 insertions(+), 12 deletions(-)Quoted 11 lines
tools/binman/etype/nxp_imx8mcst.py class Entry_nxp_imx8mcst(Entry_mkimage): · line 100
Quoted 6 lines
tools/binman/etype/nxp_imx8mcst.py +4
-0@@ -90,6 +97,10 @@ class Entry_nxp_imx8mcst(Entry_mkimage): + self.backend = os.getenv( + 'CST_BACKEND', fdt_util.GetString(self._node, 'nxp,cst-backend', + 'ssl')) +Please add a binman test covering this new feature - see testNxpImx8mCSTFastAuth in
ftest.pyand thevendor/nxp_imx8_csf*.dtsfixtures. The missing coverage line for me is 177 (cst_backend= "pkcs11" )
Quoted 1 line
The pkcs11 option requires a HSM, how do you propose to test that ?
We have softhsm already in the CI container and tools/binman/btool/softhsm2_util.py and tools/binman/ftest.py has an example that might be useful.
Signature · 1 line
Tom