AnsweredAssumed Answered

iMX8M Mini EVK, HAB and extending root of trust

Question asked by Neil Shipp on May 21, 2019
Latest reply on Jun 9, 2019 by Yuri Muhin

I'm attempting to extend the root of trust for HAB on the iMX8M Mini.  I can create a signed flash.bin file with SPL, ATF, OpTEE, and UBoot whose signature is checked and loaded successfully.  hab_status shows no events in the hab.  However I cannot create a signed image that extends the root of trust.  If I load the image to ${loadaddr} and run hab_auth_img, I get the following output:

 

u-boot=> hab_auth_img 0x40480000 0x2960 0x1000
hab fuse not enabled

Authenticate image from DDR location 0x40480000...

Secure boot disabled

HAB Configuration: 0xf0, HAB State: 0x66

--------- HAB Event 1 -----------------
event data:
        0xdb 0x00 0x24 0x43 0x33 0x30 0xee 0x1d
        0x00 0x08 0x00 0x02 0x00 0x00 0x00 0x00
        0x55 0x55 0x00 0x02 0x00 0x00 0x00 0x00
        0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
        0x00 0x00 0x00 0x06

STS = HAB_FAILURE (0x33)
RSN = HAB_ENG_FAIL (0x30)
CTX = HAB_CTX_EXIT (0xEE)
ENG = HAB_ENG_CAAM (0x1D)

 

To simplify the test, I've created an empty 4kbyte image file of just zeros and

appended a simple IVT that points at the start of the memory block where it's loaded, the ivt self pointer and the csf pointer:

:/mnt/d/imx8/imx8mm-hab$ hexdump blank-pad-ivt.bin
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0001000 00d1 4120 0000 4048 0000 0000 0000 0000
0001010 0000 0000 1000 4048 1020 4048 0000 0000
0001020

 

I modified the csf file I used to generate the fit blob in the flash.bin file and generated and appended the binary to the above file.

 

:/mnt/d/imx8/imx8mm-hab$ cat csf_blank.txt
[Header]
    Version = 4.3
    Hash Algorithm = sha256
    Engine = CAAM
    Engine Configuration = 0
    Certificate Format = X509
    Signature Format = CMS

[Install SRK]
    # Index of the key location in the SRK table to be installed
    File = "../crts/SRK_1_2_3_4_table.bin"
    Source index = 0

[Install CSFK]
    # Key used to authenticate the CSF data
    File = "../crts/CSF1_1_sha256_4096_65537_v3_usr_crt.pem"

[Authenticate CSF]

[Install Key]
    # Key slot index used to authenticate the key to be installed
    Verification index = 0
    # Target key slot in HAB key store where key will be installed
    Target index = 2
    # Key to install
    File = "../crts/IMG1_1_sha256_4096_65537_v3_usr_crt.pem"

[Authenticate Data]
    # Key slot index used to authenticate the image data
    Verification index = 2
    # Authenticate Start Address, Offset, Length and file

    Blocks = 0x40480000 0x0 0x1020 "blank-pad-ivt.bin"

 

I'm using the 4.14.98_2.0.0ga U-Boot, and have used the example csf templates under uboot/doc/imx/habv4/csf_examples/mx8m_mx8mm to generate the initial signed flash.bin.  I'm using a set of 4096 bit keys and the csf files have been updated to reflect that.

 

I read through the HabV4 documentation in the cst 3.1.0.tar file and thought that it's possible that the auth check of the fit blob in the flash.bin file after the initial auth check of SPL was causing issues, so I tried adding an Unlock command to the csf_fit.txt file to leave it unlocked for my image check.  I had no success.

 

[Unlock]
    # Leave Job Ring and DECO master ID registers Unlocked
    Engine = CAAM
    Features = MID

 

What am I doing wrong?  Any help would be appreciated. 

 

I tried modifying the data in the memory block to invalidate the signature, and when I do that I get more HAB events about invalid assertions so it appears the block is being validated.  So my problem appears to be that the data and signatures are valid but the CAAM context exit call is failing.

Outcomes