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