blob: ae68dc8040de2e967d8e1ab358820fc9b0498bfa [file] [log] [blame]
Breno Lima626d5d72018-02-22 00:42:55 +000011. High Assurance Boot (HAB) for i.MX CPUs
2------------------------------------------
Stefano Babic4aa97492013-06-27 11:42:38 +02003
Ulises Cardenas7e56f502015-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 Estevamd97c2602017-01-05 21:33:08 -02006is done by adding the following configuration in the defconfig file:
Ulises Cardenas7e56f502015-04-20 13:47:58 -05007
Fabio Estevamd97c2602017-01-05 21:33:08 -02008CONFIG_SECURE_BOOT=y
Ulises Cardenas7e56f502015-04-20 13:47:58 -05009
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
Breno Lima7950a0f2018-02-22 00:42:56 +000014The CSF itself is generated by the i.MX High Assurance Boot Reference
15Code Signing Tool.
16https://www.nxp.com/webapp/sps/download/license.jsp?colCode=IMX_CST_TOOL
Stefano Babic4aa97492013-06-27 11:42:38 +020017
Breno Lima7950a0f2018-02-22 00:42:56 +000018More information about the CSF and HAB can be found in the AN4581.
19https://www.nxp.com/docs/en/application-note/AN4581.pdf
20
21We don't want to explain how to create a PKI tree or SRK table as
22this is well explained in the Application Note.
Stefano Babic4aa97492013-06-27 11:42:38 +020023
Breno Lima7950a0f2018-02-22 00:42:56 +0000242. Secure Boot on non-SPL targets
25---------------------------------
26
27On non-SPL targets a singe U-Boot binary is generated, mkimage will
28output additional information about "HAB Blocks" which can be used
29in the CST to authenticate the U-Boot image (entries in the CSF file).
Stefano Babic4aa97492013-06-27 11:42:38 +020030
31Image Type: Freescale IMX Boot Image
32Image Ver: 2 (i.MX53/6 compatible)
33Data Size: 327680 Bytes = 320.00 kB = 0.31 MB
34Load Address: 177ff420
35Entry Point: 17800000
Rasmus Villemoes1c3c5492018-03-23 12:08:03 +010036HAB Blocks: 0x177ff400 0x00000000 0x0004dc00
37 ^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^
38 | | |
39 | | ----- (1)
40 | |
41 | ---------------- (2)
Stefano Babic4aa97492013-06-27 11:42:38 +020042 |
43 --------------------------- (3)
44
Breno Lima7950a0f2018-02-22 00:42:56 +000045(1) Size of area in file u-boot-dtb.imx to sign
Stefano Babic4aa97492013-06-27 11:42:38 +020046 This area should include the IVT, the Boot Data the DCD
47 and U-Boot itself.
Breno Lima7950a0f2018-02-22 00:42:56 +000048(2) Start of area in u-boot-dtb.imx to sign
Stefano Babic4aa97492013-06-27 11:42:38 +020049(3) Start of area in RAM to authenticate
50
51CONFIG_SECURE_BOOT currently enables only an additional command
52'hab_status' in U-Boot to retrieve the HAB status and events. This
53can be useful while developing and testing HAB.
54
Breno Lima7950a0f2018-02-22 00:42:56 +000055Commands to generate a signed U-Boot using i.MX HAB CST tool:
56# Compile CSF and create signature
57cst --o csf-u-boot.bin --i command_sequence_uboot.csf
58# Append compiled CSF to Binary
59cat u-boot-dtb.imx csf-u-boot.bin > u-boot-signed.imx
Breno Lima626d5d72018-02-22 00:42:55 +000060
Breno Lima7950a0f2018-02-22 00:42:56 +0000613. Secure Boot on SPL targets
62-----------------------------
Breno Lima626d5d72018-02-22 00:42:55 +000063
64This version of U-Boot is able to build a signable version of the SPL
65as well as a signable version of the U-Boot image. The signature can
66be verified through High Assurance Boot (HAB).
67
Breno Lima626d5d72018-02-22 00:42:55 +000068After building, you need to create a command sequence file and use
Breno Lima7950a0f2018-02-22 00:42:56 +000069i.MX HAB Code Signing Tool to sign both binaries. After creation,
Breno Lima626d5d72018-02-22 00:42:55 +000070the mkimage tool outputs the required information about the HAB Blocks
71parameter for the CSF. During the build, the information is preserved
72in log files named as the binaries. (SPL.log and u-boot-ivt.log).
73
Breno Lima626d5d72018-02-22 00:42:55 +000074Example Output of the SPL (imximage) creation:
75 Image Type: Freescale IMX Boot Image
76 Image Ver: 2 (i.MX53/6/7 compatible)
77 Mode: DCD
78 Data Size: 61440 Bytes = 60.00 kB = 0.06 MB
79 Load Address: 00907420
80 Entry Point: 00908000
Rasmus Villemoes1c3c5492018-03-23 12:08:03 +010081 HAB Blocks: 0x00907400 0x00000000 0x0000cc00
Breno Lima626d5d72018-02-22 00:42:55 +000082
83Example Output of the u-boot-ivt.img (firmware_ivt) creation:
84 Image Name: U-Boot 2016.11-rc1-31589-g2a4411
85 Created: Sat Nov 5 21:53:28 2016
86 Image Type: ARM U-Boot Firmware with HABv4 IVT (uncompressed)
87 Data Size: 352192 Bytes = 343.94 kB = 0.34 MB
88 Load Address: 17800000
89 Entry Point: 00000000
90 HAB Blocks: 0x177fffc0 0x0000 0x00054020
91
Breno Lima626d5d72018-02-22 00:42:55 +000092# Compile CSF and create signature
Breno Lima7950a0f2018-02-22 00:42:56 +000093cst --o csf-u-boot.bin --i command_sequence_uboot.csf
94cst --o csf-SPL.bin --i command_sequence_spl.csf
Breno Lima626d5d72018-02-22 00:42:55 +000095# Append compiled CSF to Binary
96cat SPL csf-SPL.bin > SPL-signed
97cat u-boot-ivt.img csf-u-boot.bin > u-boot-signed.img
98
Breno Lima7950a0f2018-02-22 00:42:56 +000099These two signed binaries can be used on an i.MX in closed
Breno Lima626d5d72018-02-22 00:42:55 +0000100configuration when the according SRK Table Hash has been flashed.