binman: add CST backend selection for i.MX8M signing
PATCH 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]
--- tools/binman/etype/nxp_imx8mcst.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
tools/binman/etype/nxp_imx8mcst.py +11 -1
@@ -90,6 +90,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 +165,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.51.0
Hi Marek,
Quoted 50 lines · Marek Vasut
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]>---
Cc: Alper Nebi Yasak <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]--- tools/binman/etype/nxp_imx8mcst.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)tools/binman/etype/nxp_imx8mcst.py +11
-2@@ -90,6 +90,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 +165,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 --
Quoted 2 lines
2.51.0
This should be documented somewhere, likely in the comment for this entry type, so it ends up visible in the docs.
Also, this code path will need a test, please.
Regards,
Simon
On 2/13/26 6:53 PM, Simon Glass wrote:
Hello Simon,
Quoted 14 lines
Quoted 14 lines
tools/binman/etype/nxp_imx8mcst.py +7
-1@@ -161,8 +165,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:
Quoted 8 lines
Quoted 5 lines
tools/binman/etype/nxp_imx8mcst.py +0
-1outdata = tools.read_file(output_fname) # fixme: 0x2000 should be CONFIG_CSF_SIZE --2.51.0
This should be documented somewhere, likely in the comment for this entry type, so it ends up visible in the docs.
I will send a V2 with documentation.
Quoted 1 line
Also, this code path will need a test, please.
How do you propose to test this ?
Hi Marek,
Quoted 28 lines · Marek Vasut
On 2/13/26 6:53 PM, Simon Glass wrote:
Hello Simon,
Quoted 14 lines
Quoted 14 lines
tools/binman/etype/nxp_imx8mcst.py +7
-1@@ -161,8 +165,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:Quoted 8 lines
Quoted 5 lines
tools/binman/etype/nxp_imx8mcst.py +0
-1outdata = tools.read_file(output_fname) # fixme: 0x2000 should be CONFIG_CSF_SIZE --2.51.0
This should be documented somewhere, likely in the comment for this entry type, so it ends up visible in the docs.
Quoted 4 lines
I will send a V2 with documentation.
Quoted 1 line
Also, this code path will need a test, please.
How do you propose to test this ?
Extend or copy one of the existing imx8 tests, perhaps with a new .dts
- and I suppose set the env var and see that it works too?
Note that imx8 has basic test coverage but there is quite a bit missing:
tools/binman/btool/cst.py 18 4 78% tools/binman/etype/nxp_imx8mcst.py 89 69 22% tools/binman/etype/nxp_imx8mimage.py 38 6 84%
I shed a small tear whenever I see that :-)
Regards,
Simon
On 2/13/26 9:20 PM, Simon Glass wrote:
Hello Simon,
Quoted 11 lines
Quoted 7 lines
Quoted 2 lines
This should be documented somewhere, likely in the comment for this entry type, so it ends up visible in the docs.
I will send a V2 with documentation.
Quoted 1 line
Also, this code path will need a test, please.
How do you propose to test this ?
Extend or copy one of the existing imx8 tests, perhaps with a new .dts
- and I suppose set the env var and see that it works too?
Quoted 7 lines
Note that imx8 has basic test coverage but there is quite a bit missing:
tools/binman/btool/cst.py 18 4 78% tools/binman/etype/nxp_imx8mcst.py 89 69 22% tools/binman/etype/nxp_imx8mimage.py 38 6 84%I shed a small tear whenever I see that :-)
See [PATCH] binman: Fill in most of the imx8mimage and imx8mcst tests .