Issue in building image with Secure boot on IMX8MP processor

hi, i am trying to build torizon image with secure boot support.

I was getting error during do_patch process of openssh so i commented following lines in openssh_%.bbappend file (just to skip this patch for testing purpose):
#FILESEXTRAPATHS:prepend := “${THISDIR}/files:”

#SRC_URI += “file://0001-Disable-race-condition-in-signal-handler-from-sshsig.patch”.

After that build process fails @ do_compile on imx-boot while creating flash_evk_emmc_fastboot-csf-spl.csf file.
In flash_evk_emmc_fastboot-csf-spl.log following error is logged:
“Super Root Key table is invalid in file /home/sarthak/cst-3.4.1/crts/SRK_1_2_3_4_table.bin”
i have generated the certificates with following inputs:
Do you want to use an existing CA key (y/n)?: n

Key type options (confirm targeted device supports desired key type):
Select the key type (possible values: rsa, rsa-pss, ecc)?: rsa
Enter key length in bits for PKI tree: 2048
Enter the digest algorithm to use: sha256
Enter PKI tree duration (years): 10
Do you want the SRK certificates to have the CA flag set? (y/n)?: n

…/linux64/bin/srktool -a -s sha256 -t SRK_1_2_3_4_table.bin -e SRK_1_2_3_4_fuse.bin -f 1 -c SRK1_sha256_2048_65537_v3_usr_crt.der,./SRK2_sha256_2048_65537_v3_usr_crt.der,./SRK3_sha256_2048_65537_v3_usr_crt.der,./SRK4_sha256_2048_65537_v3_usr_crt.der

I add following lines to auto.conf file :
INHERIT += “tdx-signed”
TDX_IMX_HAB_ENABLE = “1”
UBOOT_SIGN_ENABLE = “1”
TDX_IMX_HAB_CST_KEY_SIZE = “2048”
TDX_IMX_HAB_CST_DIG_ALGO = “sha256”
TDX_IMX_HAB_CST_DIR = “/home/sarthak/cst-3.4.1”
TDX_IMX_HAB_CST_CERTS_DIR = “/home/sarthak/cst-3.4.1/crts”
TDX_IMX_HAB_CST_SRK_CERT = “${TDX_IMX_HAB_CST_CERTS_DIR}/SRK1_sha256_2048_65537_v3_usr_crt.der”
error (9.0 KB)

Greetings @vikas,

I’m a little confused. In your post you said the error you got was:

In flash_evk_emmc_fastboot-csf-spl.log following error is logged:
“Super Root Key table is invalid in file /home/sarthak/cst-3.4.1/crts/SRK_1_2_3_4_table.bin”

But, then in the error log you shared it shows a completely different error:

Certificate file name (defined by TDX_IMX_HAB_CST_SRK_CERT) does not match expected pattern - could not determine if CA flag is set.

Which one is the real issue?

Anyways, for starters you should only manually set the variables denoted in this README: meta-toradex-security/docs/README-secure-boot-imx.md at kirkstone-6.x.y · toradex/meta-toradex-security · GitHub

I see you’re setting TDX_IMX_HAB_CST_SRK_CERT, but you should not set this manually since our layer determines this variable dynamically during build-time. This could be the cause of the error seen in your logs.

Also you should set TDX_IMX_HAB_CST_SRK_CA to 0 since you didn’t set the CA flag in your setup.

Finally for this error regarding openssh. We recently removed this patch from our layers, so you’re probably using an old version of our layer: openssh: remove patch for CVE-2024-6387 · torizon/meta-toradex-torizon@159617f · GitHub

Best Regards,
Jeremias

Hi Jeremias,
thanks for the reply.
My actual problem is:
“Super Root Key table is invalid in file /home/sarthak/cst-3.4.1/crts/SRK_1_2_3_4_table.bin”

I was experimenting with certificate and mistakenly uploaded the wrong error log.
please find the correct log.

i have made the changes as suggested i.e-

configure secure boot

INHERIT += “tdx-signed”
TDX_IMX_HAB_ENABLE = “1”
UBOOT_SIGN_ENABLE = “1”
TDX_IMX_HAB_CST_SRK_CA = “0”
TDX_IMX_HAB_CST_KEY_SIZE = “2048”
TDX_IMX_HAB_CST_DIG_ALGO = “sha256”
TDX_IMX_HAB_CST_DIR = “/home/sarthak/cst-3.4.1”
TDX_IMX_HAB_CST_CERTS_DIR = “/home/sarthak/cst-3.4.1/crts”

But still facing the same error.

it seems that build process is considering HAB process instead of AHAB.
CSF file is attached for your reference.
error_build (9.2 KB)
flash_evk_emmc_fastboot-csf-spl.log (91 Bytes)
flash_evk_emmc_fastboot-csf-spl.csf (1.4 KB)

Update: i am generating certificates using AHAB script.
I am bit confused whether imx8mp support HAB or AHAB, becouse i read somewhere that imx8 onwards support ahab.

i am generating certificates using AHAB script.

Oh I believe this is the issue then. All i.MX8M* SoCs including Verdin i.MX8M Plus use the HAB process not AHAB. This is stated in our README: meta-toradex-security/docs/README-secure-boot-imx.md at kirkstone-6.x.y · toradex/meta-toradex-security · GitHub

This may be the cause of your issue then since you’re using the wrong script to generate things for this SoC. Try again following the process for HAB this time and see if that help your situation.

Best Regards,
Jeremias

Dear jeremias,

Thanks for your reply.
I got confused between iMX8x & iMX8MP.
After generating certificates using HAB script, image builds successfully.

I am newbie to secure boot, i have following quarries:

  1. Only using SRK keys ( fast boot) will validate fit image or not?
  2. I have uploaded generated image to SOM using TEZI, but have not burn hash to som, and i am getting hab_status as-
    Secure boot disabled
    HAB Configuration: 0xf0, HAB state: 0x66
    No HAB Event Found.
    is this intended output? if it is then how i will come to know if secure boot is working or not post fusing the hash ( as hab_status will be same)
  3. Is building image also hardens the bootloader?
  4. how can i build to have complete chain of trust?

Thanks in advance :slight_smile:

After generating certificates using HAB script, image builds successfully.

Perfect that’s great to hear!

Only using SRK keys ( fast boot) will validate fit image or not?

I believe you have a misunderstanding here. The FIT image validation feature is completely seperate from the SRK keys/HAB functionality. They can be implemented separately or together to form a longer chain of trust.

is this intended output? if it is then how i will come to know if secure boot is working or not post fusing the hash ( as hab_status will be same)

The output of hab_status can depend a bit on the SoC and such. In this case if the SoC detects nothing has been fused it will return no error. Once you fuse your key information however it will start using that information. If you fuse your key information and you get a hab error then something went wrong somewhere. If you fuse your key information and get no hab errors then you can be assured that nothing went wrong. This is why the act of fusing keys is a generally delicate process since these fuses are one-time only and can’t be undone.

Is building image also hardens the bootloader?

I assume you’re talking about the u-boot hardening feature as described here: meta-toradex-security/docs/README-secure-boot.md at kirkstone-6.x.y · toradex/meta-toradex-security · GitHub

if you read this section then the feature is enabled by default if you have TDX_IMX_HAB_ENABLE and UBOOT_SIGN_ENABLE set. While building a Torizon OS image. You can of course override this behavior if you don’t want it enabled.

how can i build to have complete chain of trust?

This depends, when you say “complete chain of trust”, what do you mean? Chain of trust depends on the use-case and needs of the system. For your system then how much of it do you want secured, and how do you expect it to be secured?

Best Regards,
Jeremias

Dear jeremais,
thanks for your reply and answering my quarries.
From “complete chain of trust” i mean i want to have my container also validated.
as per toradex documentation, Toradex has not yet have implementation for docker container validation.

Thanks.

mean i want to have my container also validated.
as per toradex documentation, Toradex has not yet have implementation for docker container validation.

That is correct, this is still a work in progress, so keep an eye out for when new developments occur.

Otherwise, I’m glad I was able to help clarify all this for you.

Best Regards,
Jeremias

1 Like