1*4882a593SmuzhiyunHigh Assurance Boot (HAB) for i.MX6 CPUs 2*4882a593Smuzhiyun 3*4882a593SmuzhiyunTo enable the authenticated or encrypted boot mode of U-Boot, it is 4*4882a593Smuzhiyunrequired to set the proper configuration for the target board. This 5*4882a593Smuzhiyunis done by adding the following configuration in the defconfig file: 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunCONFIG_SECURE_BOOT=y 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunIn addition, the U-Boot image to be programmed into the 10*4882a593Smuzhiyunboot media needs to be properly constructed, i.e. it must contain a 11*4882a593Smuzhiyunproper Command Sequence File (CSF). 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunThe Initial Vector Table contains a pointer to the CSF. Please see 14*4882a593Smuzhiyundoc/README.imximage for how to prepare u-boot.imx. 15*4882a593Smuzhiyun 16*4882a593SmuzhiyunThe CSF itself is being generated by Freescale HAB tools. 17*4882a593Smuzhiyun 18*4882a593Smuzhiyunmkimage will output additional information about "HAB Blocks" 19*4882a593Smuzhiyunwhich can be used in the Freescale tooling to authenticate U-Boot 20*4882a593Smuzhiyun(entries in the CSF file). 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunImage Type: Freescale IMX Boot Image 23*4882a593SmuzhiyunImage Ver: 2 (i.MX53/6 compatible) 24*4882a593SmuzhiyunData Size: 327680 Bytes = 320.00 kB = 0.31 MB 25*4882a593SmuzhiyunLoad Address: 177ff420 26*4882a593SmuzhiyunEntry Point: 17800000 27*4882a593SmuzhiyunHAB Blocks: 177ff400 00000000 0004dc00 28*4882a593Smuzhiyun ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ 29*4882a593Smuzhiyun | | | 30*4882a593Smuzhiyun | | -------- (1) 31*4882a593Smuzhiyun | | 32*4882a593Smuzhiyun | ------------------- (2) 33*4882a593Smuzhiyun | 34*4882a593Smuzhiyun --------------------------- (3) 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun(1) Size of area in file u-boot.imx to sign 37*4882a593Smuzhiyun This area should include the IVT, the Boot Data the DCD 38*4882a593Smuzhiyun and U-Boot itself. 39*4882a593Smuzhiyun(2) Start of area in u-boot.imx to sign 40*4882a593Smuzhiyun(3) Start of area in RAM to authenticate 41*4882a593Smuzhiyun 42*4882a593SmuzhiyunCONFIG_SECURE_BOOT currently enables only an additional command 43*4882a593Smuzhiyun'hab_status' in U-Boot to retrieve the HAB status and events. This 44*4882a593Smuzhiyuncan be useful while developing and testing HAB. 45*4882a593Smuzhiyun 46*4882a593SmuzhiyunCommands to generate a signed U-Boot using Freescale HAB tools: 47*4882a593Smuzhiyuncst --o U-Boot_CSF.bin < U-Boot.CSF 48*4882a593Smuzhiyunobjcopy -I binary -O binary --pad-to 0x2000 --gap-fill=0x00 \ 49*4882a593Smuzhiyun U-Boot_CSF.bin U-Boot_CSF_pad.bin 50*4882a593Smuzhiyuncat u-boot.imx U-Boot_CSF_pad.bin > u-boot-signed.imx 51*4882a593Smuzhiyun 52*4882a593SmuzhiyunNOTE: U-Boot_CSF.bin needs to be padded to the value specified in 53*4882a593Smuzhiyunthe imximage.cfg file. 54*4882a593Smuzhiyun 55*4882a593SmuzhiyunSetup U-Boot Image for Encrypted Boot 56*4882a593Smuzhiyun------------------------------------- 57*4882a593SmuzhiyunAn authenticated U-Boot image is used as starting point for 58*4882a593SmuzhiyunEncrypted Boot. The image is encrypted by Freescale's Code 59*4882a593SmuzhiyunSigning Tool (CST). The CST replaces only the image data of 60*4882a593Smuzhiyunu-boot.imx with the encrypted data. The Initial Vector Table, 61*4882a593SmuzhiyunDCD, and Boot data, remains in plaintext. 62*4882a593Smuzhiyun 63*4882a593SmuzhiyunThe image data is encrypted with a Encryption Key (DEK). 64*4882a593SmuzhiyunTherefore, this key is needed to decrypt the data during the 65*4882a593Smuzhiyunbooting process. The DEK is protected by wrapping it in a Blob, 66*4882a593Smuzhiyunwhich needs to be appended to the U-Boot image and specified in 67*4882a593Smuzhiyunthe CSF file. 68*4882a593Smuzhiyun 69*4882a593SmuzhiyunThe DEK blob is generated by an authenticated U-Boot image with 70*4882a593Smuzhiyunthe dek_blob cmd enabled. The image used for DEK blob generation 71*4882a593Smuzhiyunneeds to have the following configurations enabled: 72*4882a593Smuzhiyun 73*4882a593SmuzhiyunCONFIG_SECURE_BOOT 74*4882a593SmuzhiyunCONFIG_SYS_FSL_SEC_COMPAT 4 /* HAB version */ 75*4882a593SmuzhiyunCONFIG_FSL_CAAM 76*4882a593SmuzhiyunCONFIG_CMD_DEKBLOB 77*4882a593SmuzhiyunCONFIG_SYS_FSL_SEC_LE 78*4882a593Smuzhiyun 79*4882a593SmuzhiyunNote: The encrypted boot feature is only supported by HABv4 or 80*4882a593Smuzhiyungreater. 81*4882a593Smuzhiyun 82*4882a593SmuzhiyunThe dek_blob command then can be used to generate the DEK blob of 83*4882a593Smuzhiyuna DEK previously loaded in memory. The command is used as follows: 84*4882a593Smuzhiyun 85*4882a593Smuzhiyundek_blob <DEK address> <Output Address> <Key Size in Bits> 86*4882a593Smuzhiyunexample: dek_blob 0x10800000 0x10801000 192 87*4882a593Smuzhiyun 88*4882a593SmuzhiyunThe resulting DEK blob then is used to construct the encrypted 89*4882a593SmuzhiyunU-Boot image. Note that the blob needs to be transferred back 90*4882a593Smuzhiyunto the host.Then the following commands are used to construct 91*4882a593Smuzhiyunthe final image. 92*4882a593Smuzhiyun 93*4882a593Smuzhiyunobjcopy -I binary -O binary --pad-to 0x2000 --gap-fill=0x00 \ 94*4882a593Smuzhiyun U-Boot_CSF.bin U-Boot_CSF_pad.bin 95*4882a593Smuzhiyuncat u-boot.imx U-Boot_CSF_pad.bin > u-boot-signed.imx 96*4882a593Smuzhiyunobjcopy -I binary -O binary --pad-to <blob_dst> --gap-fill=0x00 \ 97*4882a593Smuzhiyun u-boot-signed.imx u-boot-signed-pad.bin 98*4882a593Smuzhiyuncat u-boot-signed-pad.imx DEK_blob.bin > u-boot-encrypted.imx 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun NOTE: u-boot-signed.bin needs to be padded to the value 101*4882a593Smuzhiyun equivalent to the address in which the DEK blob is specified 102*4882a593Smuzhiyun in the CSF. 103