blob: 4bd07d31516ed5bddc80921816fb990ce8a347d0 [file] [log] [blame]
Stefano Babic4aa97492013-06-27 11:42:38 +02001High Assurance Boot (HAB) for i.MX6 CPUs
2
Ulises Cardenas7e56f502015-04-20 13:47:58 -05003To enable the authenticated or encrypted boot mode of U-Boot, it is
4required to set the proper configuration for the target board. This
Fabio Estevamd97c2602017-01-05 21:33:08 -02005is done by adding the following configuration in the defconfig file:
Ulises Cardenas7e56f502015-04-20 13:47:58 -05006
Fabio Estevamd97c2602017-01-05 21:33:08 -02007CONFIG_SECURE_BOOT=y
Ulises Cardenas7e56f502015-04-20 13:47:58 -05008
9In addition, the U-Boot image to be programmed into the
Stefano Babic4aa97492013-06-27 11:42:38 +020010boot media needs to be properly constructed, i.e. it must contain a
11proper Command Sequence File (CSF).
12
13The Initial Vector Table contains a pointer to the CSF. Please see
14doc/README.imximage for how to prepare u-boot.imx.
15
16The CSF itself is being generated by Freescale HAB tools.
17
18mkimage will output additional information about "HAB Blocks"
19which can be used in the Freescale tooling to authenticate U-Boot
20(entries in the CSF file).
21
22Image Type: Freescale IMX Boot Image
23Image Ver: 2 (i.MX53/6 compatible)
24Data Size: 327680 Bytes = 320.00 kB = 0.31 MB
25Load Address: 177ff420
26Entry Point: 17800000
27HAB Blocks: 177ff400 00000000 0004dc00
Wolfgang Denkec7fbf52013-10-04 17:43:24 +020028 ^^^^^^^^ ^^^^^^^^ ^^^^^^^^
Stefano Babic4aa97492013-06-27 11:42:38 +020029 | | |
30 | | -------- (1)
31 | |
32 | ------------------- (2)
33 |
34 --------------------------- (3)
35
36(1) Size of area in file u-boot.imx to sign
37 This area should include the IVT, the Boot Data the DCD
38 and U-Boot itself.
39(2) Start of area in u-boot.imx to sign
40(3) Start of area in RAM to authenticate
41
42CONFIG_SECURE_BOOT currently enables only an additional command
43'hab_status' in U-Boot to retrieve the HAB status and events. This
44can be useful while developing and testing HAB.
45
46Commands to generate a signed U-Boot using Freescale HAB tools:
47cst --o U-Boot_CSF.bin < U-Boot.CSF
48objcopy -I binary -O binary --pad-to 0x2000 --gap-fill=0x00 \
49 U-Boot_CSF.bin U-Boot_CSF_pad.bin
50cat u-boot.imx U-Boot_CSF_pad.bin > u-boot-signed.imx
51
52NOTE: U-Boot_CSF.bin needs to be padded to the value specified in
53the imximage.cfg file.
Raul Cardenasb5a36d82015-02-27 11:22:06 -060054
55Setup U-Boot Image for Encrypted Boot
56-------------------------------------
57An authenticated U-Boot image is used as starting point for
58Encrypted Boot. The image is encrypted by Freescale's Code
59Signing Tool (CST). The CST replaces only the image data of
60u-boot.imx with the encrypted data. The Initial Vector Table,
61DCD, and Boot data, remains in plaintext.
62
63The image data is encrypted with a Encryption Key (DEK).
64Therefore, this key is needed to decrypt the data during the
65booting process. The DEK is protected by wrapping it in a Blob,
66which needs to be appended to the U-Boot image and specified in
67the CSF file.
68
69The DEK blob is generated by an authenticated U-Boot image with
70the dek_blob cmd enabled. The image used for DEK blob generation
Fabio Estevamdcd1c4c2018-01-21 15:57:32 -020071needs to have the following configurations enabled in Kconfig:
Raul Cardenasb5a36d82015-02-27 11:22:06 -060072
Fabio Estevamdcd1c4c2018-01-21 15:57:32 -020073CONFIG_SECURE_BOOT=y
74CONFIG_CMD_DEKBLOB=y
Raul Cardenasb5a36d82015-02-27 11:22:06 -060075
76Note: The encrypted boot feature is only supported by HABv4 or
77greater.
78
79The dek_blob command then can be used to generate the DEK blob of
80a DEK previously loaded in memory. The command is used as follows:
81
82dek_blob <DEK address> <Output Address> <Key Size in Bits>
83example: dek_blob 0x10800000 0x10801000 192
84
85The resulting DEK blob then is used to construct the encrypted
86U-Boot image. Note that the blob needs to be transferred back
87to the host.Then the following commands are used to construct
88the final image.
89
90objcopy -I binary -O binary --pad-to 0x2000 --gap-fill=0x00 \
91 U-Boot_CSF.bin U-Boot_CSF_pad.bin
92cat u-boot.imx U-Boot_CSF_pad.bin > u-boot-signed.imx
93objcopy -I binary -O binary --pad-to <blob_dst> --gap-fill=0x00 \
94 u-boot-signed.imx u-boot-signed-pad.bin
95cat u-boot-signed-pad.imx DEK_blob.bin > u-boot-encrypted.imx
96
97 NOTE: u-boot-signed.bin needs to be padded to the value
98 equivalent to the address in which the DEK blob is specified
99 in the CSF.