blob: 056ade77230a8eca70e9fc772267f7d6bdbf27c5 [file] [log] [blame]
Breno Limab887f0a2018-02-22 00:42:55 +000011. High Assurance Boot (HAB) for i.MX CPUs
2------------------------------------------
Stefano Babic0187c982013-06-27 11:42:38 +02003
Ulises Cardenas8148b822015-04-20 13:47:58 -05004To enable the authenticated or encrypted boot mode of U-Boot, it is
5required to set the proper configuration for the target board. This
Fabio Estevam7a037cc2017-01-05 21:33:08 -02006is done by adding the following configuration in the defconfig file:
Ulises Cardenas8148b822015-04-20 13:47:58 -05007
Fabio Estevam7a037cc2017-01-05 21:33:08 -02008CONFIG_SECURE_BOOT=y
Ulises Cardenas8148b822015-04-20 13:47:58 -05009
10In addition, the U-Boot image to be programmed into the
Stefano Babic0187c982013-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 Denk93e14592013-10-04 17:43:24 +020029 ^^^^^^^^ ^^^^^^^^ ^^^^^^^^
Stefano Babic0187c982013-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 Cardenas02000202015-02-27 11:22:06 -060055
Breno Limab887f0a2018-02-22 00:42:55 +000056
572. Using Secure Boot on i.MX6 machines with SPL support
58-------------------------------------------------------
59
60This version of U-Boot is able to build a signable version of the SPL
61as well as a signable version of the U-Boot image. The signature can
62be verified through High Assurance Boot (HAB).
63
64CONFIG_SECURE_BOOT is needed to build those two binaries.
65After building, you need to create a command sequence file and use
66Freescales Code Signing Tool to sign both binaries. After creation,
67the mkimage tool outputs the required information about the HAB Blocks
68parameter for the CSF. During the build, the information is preserved
69in log files named as the binaries. (SPL.log and u-boot-ivt.log).
70
71More information about the CSF and HAB can be found in the AN4581.
72https://cache.freescale.com/files/32bit/doc/app_note/AN4581.pdf
73
74We don't want to explain how to create a PKI tree or SRK table as
75this is well explained in the Application Note.
76
77Example Output of the SPL (imximage) creation:
78 Image Type: Freescale IMX Boot Image
79 Image Ver: 2 (i.MX53/6/7 compatible)
80 Mode: DCD
81 Data Size: 61440 Bytes = 60.00 kB = 0.06 MB
82 Load Address: 00907420
83 Entry Point: 00908000
84 HAB Blocks: 00907400 00000000 0000cc00
85
86Example Output of the u-boot-ivt.img (firmware_ivt) creation:
87 Image Name: U-Boot 2016.11-rc1-31589-g2a4411
88 Created: Sat Nov 5 21:53:28 2016
89 Image Type: ARM U-Boot Firmware with HABv4 IVT (uncompressed)
90 Data Size: 352192 Bytes = 343.94 kB = 0.34 MB
91 Load Address: 17800000
92 Entry Point: 00000000
93 HAB Blocks: 0x177fffc0 0x0000 0x00054020
94
95The CST (Code Signing Tool) can be downloaded from NXP.
96# Compile CSF and create signature
97./cst --o csf-u-boot.bin < command_sequence_uboot.csf
98./cst --o csf-SPL.bin < command_sequence_spl.csf
99# Append compiled CSF to Binary
100cat SPL csf-SPL.bin > SPL-signed
101cat u-boot-ivt.img csf-u-boot.bin > u-boot-signed.img
102
103These two signed binaries can be used on an i.MX6 in closed
104configuration when the according SRK Table Hash has been flashed.
105
1063. Setup U-Boot Image for Encrypted Boot
107-----------------------------------------
Raul Cardenas02000202015-02-27 11:22:06 -0600108An authenticated U-Boot image is used as starting point for
109Encrypted Boot. The image is encrypted by Freescale's Code
110Signing Tool (CST). The CST replaces only the image data of
111u-boot.imx with the encrypted data. The Initial Vector Table,
112DCD, and Boot data, remains in plaintext.
113
114The image data is encrypted with a Encryption Key (DEK).
115Therefore, this key is needed to decrypt the data during the
116booting process. The DEK is protected by wrapping it in a Blob,
117which needs to be appended to the U-Boot image and specified in
118the CSF file.
119
120The DEK blob is generated by an authenticated U-Boot image with
121the dek_blob cmd enabled. The image used for DEK blob generation
Fabio Estevam79d08022018-01-21 15:57:32 -0200122needs to have the following configurations enabled in Kconfig:
Raul Cardenas02000202015-02-27 11:22:06 -0600123
Fabio Estevam79d08022018-01-21 15:57:32 -0200124CONFIG_SECURE_BOOT=y
125CONFIG_CMD_DEKBLOB=y
Raul Cardenas02000202015-02-27 11:22:06 -0600126
127Note: The encrypted boot feature is only supported by HABv4 or
128greater.
129
130The dek_blob command then can be used to generate the DEK blob of
131a DEK previously loaded in memory. The command is used as follows:
132
133dek_blob <DEK address> <Output Address> <Key Size in Bits>
134example: dek_blob 0x10800000 0x10801000 192
135
136The resulting DEK blob then is used to construct the encrypted
137U-Boot image. Note that the blob needs to be transferred back
138to the host.Then the following commands are used to construct
139the final image.
140
141objcopy -I binary -O binary --pad-to 0x2000 --gap-fill=0x00 \
142 U-Boot_CSF.bin U-Boot_CSF_pad.bin
143cat u-boot.imx U-Boot_CSF_pad.bin > u-boot-signed.imx
144objcopy -I binary -O binary --pad-to <blob_dst> --gap-fill=0x00 \
145 u-boot-signed.imx u-boot-signed-pad.bin
146cat u-boot-signed-pad.imx DEK_blob.bin > u-boot-encrypted.imx
147
148 NOTE: u-boot-signed.bin needs to be padded to the value
149 equivalent to the address in which the DEK blob is specified
150 in the CSF.