Hi,
I am integrating HABv4 Secure Boot on the imx8mm within yocto dunfell accordingly to u-boot's documentation under
doc/imx/habv4/guides/mx8m_secure_boot.txt
I am aware of the two components in flash.bin, the spl and the fit image containing uboot, optee, atf, etc.
As far as I understand, the spl gets verified automatically at start and the result of the check can be retrieved with
hab_status
To verify the fit image part of flash.bin, I patched uboot to give me the data that is needed to verify, i.e. start address, length and IVT offset. In my case, I could verify the fit image with:
u-boot=> hab_auth_img 0x401fcdc0 0x3020 0x1000
hab fuse not enabled
Authenticate image from DDR location 0x401fcdc0...
Secure boot disabled
HAB Configuration: 0xf0, HAB State: 0x66
No HAB Events Found!
The CSF data that yields this for SPL is
[Header]
Version = 4.2
Hash Algorithm = sha256
Engine = CAAM
Certificate Format = X509
Signature Format = CMS
[Install SRK]
File = "{{PREFIX}}/usr/share/cst/crts/SRK_1_2_3_4_table.bin"
Source index = 2
[Install NOCAK]
File = "{{PREFIX}}/usr/share/cst/crts/SRK3_sha256_2048_65537_v3_usr_crt.pem"
[Authenticate CSF]
[Authenticate Data]
Verification index = 0
Blocks = 0x7e0fc0 0x0 0x37800 "{{PREFIX}}/imx-boot/1.0-r0/git/iMX8M/flash.bin"
and for the fit image it is
[Header]
Version = 4.2
Hash Algorithm = sha256
Engine = CAAM
Certificate Format = X509
Signature Format = CMS
[Install SRK]
File = "{{PREFIX}}/usr/share/cst/crts/SRK_1_2_3_4_table.bin"
Source index = 2
[Install NOCAK]
File = "{{PREFIX}}/usr/share/cst/crts/SRK3_sha256_2048_65537_v3_usr_crt.pem"
[Authenticate CSF]
[Authenticate Data]
Verification index = 0
Blocks = 0x401fcdc0 0x57c00 0x1020 "{{PREFIX}}/imx-boot/1.0-r0/git/iMX8M/flash.bin"
As you can see, I only verify the fit header in this scenario.
And here is my problem. When I enable secure mode, then the device hangs after
Authenticate image from DDR location 0x401fcdc0...
I assume the device is attempting to verify more than hab_img_auth is doing.
Although I do not get hab events with my set up, a secure mode device is not booting up.
My suspicion is that because not the whole fit image is signed, this is causing issues in secure mode.
So I attempted to sign the remainder of the fit image by extracting the necessary data (addresses offsets and lengths) from print_fit_hab.sh while using the values for TEE_LOAD_ADDR and ATF_LOAD_ADDR from the log of imx-boot:
TEE_LOAD_ADDR=0xbe000000 ATF_LOAD_ADDR=0x00920000 ./mkimage_fit_atf.sh kuk-trizeps8.dtb > u-boot-trizeps8.its
this yields the following CSF for the fit image
[Header]
Version = 4.2
Hash Algorithm = sha256
Engine = CAAM
Certificate Format = X509
Signature Format = CMS
[Install SRK]
File = "{{PREFIX}}/usr/share/cst/crts/SRK_1_2_3_4_table.bin"
Source index = 2
[Install NOCAK]
File = "{{PREFIX}}/usr/share/cst/crts/SRK3_sha256_2048_65537_v3_usr_crt.pem"
[Authenticate CSF]
[Authenticate Data]
Verification index = 0
Blocks = 0x401fcdc0 0x57c00 0x1020 "{{PREFIX}}/imx-boot/1.0-r0/git/iMX8M/flash.bin", \
0x40200000 0x5AC00 0xC4E08 "{{PREFIX}}/imx-boot/1.0-r0/git/iMX8M/flash.bin", \
0x402C4E08 0x11FA08 0x82FB "{{PREFIX}}/imx-boot/1.0-r0/git/iMX8M/flash.bin", \
0x920000 0x127D04 0xB160 "{{PREFIX}}/imx-boot/1.0-r0/git/iMX8M/flash.bin", \
0xBE000000 0x132E64 0x3E228 "{{PREFIX}}/imx-boot/1.0-r0/git/iMX8M/flash.bin"
When I boot this on a non secure boot board (with fuses set as in the example at the beginning), then the spl verifies but when I attempt to verify the fit image, I get:
u-boot=> hab_auth_img 0x401fcdc0 0x3020 0x1000
hab fuse not enabled
Authenticate image from DDR location 0x401fcdc0...
Secure boot disabled
HAB Configuration: 0xf0, HAB State: 0x66
--------- HAB Event 1 -----------------
event data:
0xdb 0x00 0x14 0x43 0x33 0x0c 0xa0 0x00
0x00 0x00 0x00 0x00 0x40 0x1f 0xdd 0xc0
0x00 0x00 0x00 0x20
STS = HAB_FAILURE (0x33)
RSN = HAB_INV_ASSERTION (0x0C)
CTX = HAB_CTX_ASSERT (0xA0)
ENG = HAB_ENG_ANY (0x00)
--------- HAB Event 2 -----------------
event data:
0xdb 0x00 0x14 0x43 0x33 0x0c 0xa0 0x00
0x00 0x00 0x00 0x00 0x40 0x1f 0xcd 0xc0
0x00 0x00 0x00 0x04
STS = HAB_FAILURE (0x33)
RSN = HAB_INV_ASSERTION (0x0C)
CTX = HAB_CTX_ASSERT (0xA0)
ENG = HAB_ENG_ANY (0x00)
--------- HAB Event 3 -----------------
event data:
0xdb 0x00 0x24 0x43 0x33 0x30 0xc0 0x1d
0x00 0x08 0x00 0x02 0x40 0x00 0x05 0x16
0x55 0x55 0x00 0x0f 0xbe 0x00 0x00 0x00
0x00 0x00 0x00 0x01 0x90 0x00 0x08 0x20
0x00 0x00 0x00 0x05
STS = HAB_FAILURE (0x33)
RSN = HAB_ENG_FAIL (0x30)
CTX = HAB_CTX_COMMAND (0xC0)
ENG = HAB_ENG_CAAM (0x1D)
--------- HAB Event 4 -----------------
event data:
0xdb 0x00 0x3c 0x43 0x33 0x18 0xc0 0x00
0xca 0x00 0x34 0x00 0x00 0xc5 0x1d 0x00
0x00 0x00 0x09 0xe8 0x40 0x1f 0xcd 0xc0
0x00 0x00 0x10 0x20 0x40 0x20 0x00 0x00
0x00 0x0c 0x4e 0x08 0x40 0x2c 0x4e 0x08
0x00 0x00 0x82 0xfb 0x00 0x92 0x00 0x00
0x00 0x00 0xb1 0x60 0xbe 0x00 0x00 0x00
0x00 0x03 0xe2 0x28
STS = HAB_FAILURE (0x33)
RSN = HAB_INV_SIGNATURE (0x18)
CTX = HAB_CTX_COMMAND (0xC0)
ENG = HAB_ENG_ANY (0x00)
Parsing Event 4, I understand that this is telling me that the fit image at location
0x40 0x1f 0xcd 0xc0 with length
0x00 0x00 0x10 0x20 cannot be authenticated, as well as
0x40 0x20 0x00 0x00 with length
0x00 0x0c 0x4e 0x08,
0x40 0x2c 0x4e 0x08 with length
0x00 0x00 0x82 0xfb, 0x00 0x92 0x00 0x00 with length
0x00 0x00 0xb1 0x60 and
0xbe 0x00 0x00 0x00 with length
0x00 0x03 0xe2 0x28.
So basically all the data that I added with the help of print_fit_hab.sh.
I went ahead, extracted the components from the fit image (uboot, fdt, atf and tee) verified that beginning, end and location match, which is the case.
At this point I am out of ideas and urgently require assistence.
This setup needs to be ready very soon and I cannot find solutions to my problem in the documentation that is available to me. I was mainly using AN4581.pdf and HAB4_API.pdf.
Due to the urgency of this situation I would gladly accept paid consultancy at this point. Please reach out to me.
The resulting fit image looks like this now:
FIT description: Configuration to load ATF before U-Boot
Created: Sun Sep 4 17:51:40 2022
Image 0 (uboot@1)
Description: U-Boot (64-bit)
Created: Sun Sep 4 17:51:40 2022
Type: Standalone Program
Compression: uncompressed
Data Size: 806408 Bytes = 787.51 KiB = 0.77 MiB
Architecture: AArch64
Load Address: 0x40200000
Entry Point: unavailable
Image 1 (fdt@1)
Description: kuk-trizeps8
Created: Sun Sep 4 17:51:40 2022
Type: Flat Device Tree
Compression: uncompressed
Data Size: 33531 Bytes = 32.75 KiB = 0.03 MiB
Architecture: Unknown Architecture
Image 2 (atf@1)
Description: ARM Trusted Firmware
Created: Sun Sep 4 17:51:40 2022
Type: Firmware
Compression: uncompressed
Data Size: 45408 Bytes = 44.34 KiB = 0.04 MiB
Architecture: AArch64
OS: Unknown OS
Load Address: 0x00920000
Image 3 (tee@1)
Description: TEE firmware
Created: Sun Sep 4 17:51:40 2022
Type: Firmware
Compression: uncompressed
Data Size: 254504 Bytes = 248.54 KiB = 0.24 MiB
Architecture: AArch64
OS: Unknown OS
Load Address: 0xbe000000
Image 4 (dek_blob@1)
Description: dek_blob
Created: Sun Sep 4 17:51:40 2022
Type: Script
Compression: uncompressed
Data Size: 96 Bytes = 0.09 KiB = 0.00 MiB
Default Configuration: 'config@1'
Configuration 0 (config@1)
Description: kuk-trizeps8
Kernel: unavailable
Firmware: uboot@1
FDT: fdt@1
Loadables: dek_blob@1
atf@1
tee@1