Skip to contentSkip to conversation

imx: hab: fix srktool -c usage by removing spaces

PATCH In review Christoph Fritz 2 participants 6 messages Dec 15, 2024 – Dec 17, 2024 Arm i.MX and Layerscape

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 imx: hab: fix srktool -c usage by removing spaces

The srktool option -c does not allow spaces between certificate filenames. Only commas (',') should separate the filenames. If spaces are incorrectly included, srktool will not display an error or warning message but will only process the first certificate in the list.

So adapt documentation accordingly.

---
 doc/imx/habv4/introduction_habv4.txt | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
doc/imx/habv4/introduction_habv4.txt +7 -6
index 25711bbe95a..53c54b2a88f 100644
@@ -240,16 +240,17 @@ root of trust is established and the HAB code can progress with the image
 authentication.
 
 The srktool can be used for generating the SRK Table and its respective SRK
-Table Hash.
+Table Hash (certificate filenames must be separated by ',' with no spaces).
 
 - Generating SRK Table and SRK Hash in Linux 64-bit machines:
 
+  $ CERTS="SRK1_sha256_2048_65537_v3_ca_crt.pem"
+  $ CERTS="$CERTS,SRK2_sha256_2048_65537_v3_ca_crt.pem"
+  $ CERTS="$CERTS,SRK3_sha256_2048_65537_v3_ca_crt.pem"
+  $ CERTS="$CERTS,SRK4_sha256_2048_65537_v3_ca_crt.pem"
+
   $ ../linux64/bin/srktool -h 4 -t SRK_1_2_3_4_table.bin -e \
-	SRK_1_2_3_4_fuse.bin -d sha256 -c \
-	SRK1_sha256_2048_65537_v3_ca_crt.pem,\
-	SRK2_sha256_2048_65537_v3_ca_crt.pem,\
-	SRK3_sha256_2048_65537_v3_ca_crt.pem,\
-	SRK4_sha256_2048_65537_v3_ca_crt.pem
+	SRK_1_2_3_4_fuse.bin -d sha256 -c "$CERTS"
 
 The SRK_1_2_3_4_table.bin and SRK_1_2_3_4_fuse.bin files can be used in further
 steps as explained in HAB guides available under doc/imx/habv4/guides/
Signature · 1 line
2.39.5
reviewer
#1 lore raw

Hi Christoph,

Review

Quoted 12 lines · Christoph Fritz
(quoted diff) +6 -5
+  $ CERTS="SRK1_sha256_2048_65537_v3_ca_crt.pem"
+  $ CERTS="$CERTS,SRK2_sha256_2048_65537_v3_ca_crt.pem"
+  $ CERTS="$CERTS,SRK3_sha256_2048_65537_v3_ca_crt.pem"
+  $ CERTS="$CERTS,SRK4_sha256_2048_65537_v3_ca_crt.pem"
+
   $ ../linux64/bin/srktool -h 4 -t SRK_1_2_3_4_table.bin -e \
-       SRK_1_2_3_4_fuse.bin -d sha256 -c \
-       SRK1_sha256_2048_65537_v3_ca_crt.pem,\
-       SRK2_sha256_2048_65537_v3_ca_crt.pem,\
-       SRK3_sha256_2048_65537_v3_ca_crt.pem,\
-       SRK4_sha256_2048_65537_v3_ca_crt.pem
+       SRK_1_2_3_4_fuse.bin -d sha256 -c "$CERTS"

What do you think about simplifying like this instead?

doc/imx/habv4/introduction_habv4.txt +2 -4
@@ -244,12 +244,10 @@ Table Hash.
 
 - Generating SRK Table and SRK Hash in Linux 64-bit machines:
 
+  $ CA_CRT="sha256_2048_65537_v3_ca_crt.pem"
   $ ../linux64/bin/srktool -h 4 -t SRK_1_2_3_4_table.bin -e \
        SRK_1_2_3_4_fuse.bin -d sha256 -c \
-       SRK1_sha256_2048_65537_v3_ca_crt.pem,\
-       SRK2_sha256_2048_65537_v3_ca_crt.pem,\
-       SRK3_sha256_2048_65537_v3_ca_crt.pem,\
-       SRK4_sha256_2048_65537_v3_ca_crt.pem
+       SRK1_"$CA_CRT",SRK2_"$CA_CRT",SRK3_"$CA_CRT",SRK4_"$CA_CRT"
 
 The SRK_1_2_3_4_table.bin and SRK_1_2_3_4_fuse.bin files can be used in further
 steps as explained in HAB guides available under doc/imx/habv4/guides/
#2 lore raw

Hi Fabio

Quoted 22 lines

Review

Quoted 12 lines · Christoph Fritz
(quoted diff) +6 -5
+  $ CERTS="SRK1_sha256_2048_65537_v3_ca_crt.pem"
+  $ CERTS="$CERTS,SRK2_sha256_2048_65537_v3_ca_crt.pem"
+  $ CERTS="$CERTS,SRK3_sha256_2048_65537_v3_ca_crt.pem"
+  $ CERTS="$CERTS,SRK4_sha256_2048_65537_v3_ca_crt.pem"
+
   $ ../linux64/bin/srktool -h 4 -t SRK_1_2_3_4_table.bin -e \
-       SRK_1_2_3_4_fuse.bin -d sha256 -c \
-       SRK1_sha256_2048_65537_v3_ca_crt.pem,\
-       SRK2_sha256_2048_65537_v3_ca_crt.pem,\
-       SRK3_sha256_2048_65537_v3_ca_crt.pem,\
-       SRK4_sha256_2048_65537_v3_ca_crt.pem
+       SRK_1_2_3_4_fuse.bin -d sha256 -c "$CERTS"

What do you think about simplifying like this instead?

doc/imx/habv4/introduction_habv4.txt +0 -0
@@ -244,12 +244,10 @@ Table Hash.
 

doc/imx/habv4/introduction_habv4.txt Table Hash. · line 250

Quoted 10 lines
doc/imx/habv4/introduction_habv4.txt +2 -4
 - Generating SRK Table and SRK Hash in Linux 64-bit machines:
 
+  $ CA_CRT="sha256_2048_65537_v3_ca_crt.pem"
   $ ../linux64/bin/srktool -h 4 -t SRK_1_2_3_4_table.bin -e \
        SRK_1_2_3_4_fuse.bin -d sha256 -c \
-       SRK1_sha256_2048_65537_v3_ca_crt.pem,\
-       SRK2_sha256_2048_65537_v3_ca_crt.pem,\
-       SRK3_sha256_2048_65537_v3_ca_crt.pem,\
-       SRK4_sha256_2048_65537_v3_ca_crt.pem
+       SRK1_"$CA_CRT",SRK2_"$CA_CRT",SRK3_"$CA_CRT",SRK4_"$CA_CRT"

thanks, looks great. Do you want me to adapt the patch and resend?

-- Christoph

reviewer
#3 lore raw

Hi Christoph,

Quoted 1 line · Christoph Fritz

thanks, looks great. Do you want me to adapt the patch and resend?

Yes, please send a v2 and I will apply it.

#4 lore raw

The srktool option -c does not allow spaces between certificate filenames. Only commas (',') should separate the filenames. If spaces are incorrectly included, srktool will not display an error or warning message but will only process the first certificate in the list.

So adapt documentation accordingly.

---
 doc/imx/habv4/introduction_habv4.txt | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
doc/imx/habv4/introduction_habv4.txt +3 -5
index 25711bbe95a..a2f2d836911 100644
@@ -240,16 +240,14 @@ root of trust is established and the HAB code can progress with the image
 authentication.
 
 The srktool can be used for generating the SRK Table and its respective SRK
-Table Hash.
+Table Hash (certificate filenames must be separated by ',' without spaces).
 
 - Generating SRK Table and SRK Hash in Linux 64-bit machines:
 
+  $ CA_CRT="sha256_2048_65537_v3_ca_crt.pem"
   $ ../linux64/bin/srktool -h 4 -t SRK_1_2_3_4_table.bin -e \
 	SRK_1_2_3_4_fuse.bin -d sha256 -c \
-	SRK1_sha256_2048_65537_v3_ca_crt.pem,\
-	SRK2_sha256_2048_65537_v3_ca_crt.pem,\
-	SRK3_sha256_2048_65537_v3_ca_crt.pem,\
-	SRK4_sha256_2048_65537_v3_ca_crt.pem
+	SRK1_"$CA_CRT",SRK2_"$CA_CRT",SRK3_"$CA_CRT",SRK4_"$CA_CRT"
 
 The SRK_1_2_3_4_table.bin and SRK_1_2_3_4_fuse.bin files can be used in further
 steps as explained in HAB guides available under doc/imx/habv4/guides/
Signature · 1 line
2.39.5
reviewer
#5 lore raw
Quoted 9 lines · Christoph Fritz

The srktool option -c does not allow spaces between certificate filenames. Only commas (',') should separate the filenames. If spaces are incorrectly included, srktool will not display an error or warning message but will only process the first certificate in the list.

So adapt documentation accordingly.

Applied to u-boot-imx/next, thanks.