Paul Beesley | fc9ee36 | 2019-03-07 15:47:15 +0000 | [diff] [blame] | 1 | Trusted Board Boot |
| 2 | ================== |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 3 | |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 4 | The Trusted Board Boot (TBB) feature prevents malicious firmware from running on |
| 5 | the platform by authenticating all firmware images up to and including the |
| 6 | normal world bootloader. It does this by establishing a Chain of Trust using |
| 7 | Public-Key-Cryptography Standards (PKCS). |
| 8 | |
Sandrine Bailleux | 3091842 | 2019-04-24 10:41:24 +0200 | [diff] [blame] | 9 | This document describes the design of Trusted Firmware-A (TF-A) TBB, which is an |
| 10 | implementation of the `Trusted Board Boot Requirements (TBBR)`_ specification, |
Paul Beesley | f864067 | 2019-04-12 14:19:42 +0100 | [diff] [blame] | 11 | Arm DEN0006D. It should be used in conjunction with the |
| 12 | :ref:`Firmware Update (FWU)` design document, which implements a specific aspect |
| 13 | of the TBBR. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 14 | |
| 15 | Chain of Trust |
| 16 | -------------- |
| 17 | |
| 18 | A Chain of Trust (CoT) starts with a set of implicitly trusted components. On |
Dan Handley | 610e7e1 | 2018-03-01 18:44:00 +0000 | [diff] [blame] | 19 | the Arm development platforms, these components are: |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 20 | |
| 21 | - A SHA-256 hash of the Root of Trust Public Key (ROTPK). It is stored in the |
Sandrine Bailleux | 54b47dc | 2020-03-03 13:00:10 +0100 | [diff] [blame] | 22 | trusted root-key storage registers. Alternatively, a development ROTPK might |
| 23 | be used and its hash embedded into the BL1 and BL2 images (only for |
| 24 | development purposes). |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 25 | |
| 26 | - The BL1 image, on the assumption that it resides in ROM so cannot be |
| 27 | tampered with. |
| 28 | |
| 29 | The remaining components in the CoT are either certificates or boot loader |
| 30 | images. The certificates follow the `X.509 v3`_ standard. This standard |
| 31 | enables adding custom extensions to the certificates, which are used to store |
| 32 | essential information to establish the CoT. |
| 33 | |
| 34 | In the TBB CoT all certificates are self-signed. There is no need for a |
| 35 | Certificate Authority (CA) because the CoT is not established by verifying the |
| 36 | validity of a certificate's issuer but by the content of the certificate |
Sandrine Bailleux | 54b47dc | 2020-03-03 13:00:10 +0100 | [diff] [blame] | 37 | extensions. To sign the certificates, different signature schemes are available, |
| 38 | please refer to the :ref:`Build Options` for more details. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 39 | |
| 40 | The certificates are categorised as "Key" and "Content" certificates. Key |
| 41 | certificates are used to verify public keys which have been used to sign content |
| 42 | certificates. Content certificates are used to store the hash of a boot loader |
| 43 | image. An image can be authenticated by calculating its hash and matching it |
Sandrine Bailleux | 54b47dc | 2020-03-03 13:00:10 +0100 | [diff] [blame] | 44 | with the hash extracted from the content certificate. Various hash algorithms |
| 45 | are supported to calculate all hashes, please refer to the :ref:`Build Options` |
| 46 | for more details.. The public keys and hashes are included as non-standard |
| 47 | extension fields in the `X.509 v3`_ certificates. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 48 | |
| 49 | The keys used to establish the CoT are: |
| 50 | |
| 51 | - **Root of trust key** |
| 52 | |
| 53 | The private part of this key is used to sign the BL2 content certificate and |
| 54 | the trusted key certificate. The public part is the ROTPK. |
| 55 | |
| 56 | - **Trusted world key** |
| 57 | |
| 58 | The private part is used to sign the key certificates corresponding to the |
Sandrine Bailleux | 15530dd | 2019-02-08 15:26:36 +0100 | [diff] [blame] | 59 | secure world images (SCP_BL2, BL31 and BL32). The public part is stored in |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 60 | one of the extension fields in the trusted world certificate. |
| 61 | |
| 62 | - **Non-trusted world key** |
| 63 | |
| 64 | The private part is used to sign the key certificate corresponding to the |
| 65 | non secure world image (BL33). The public part is stored in one of the |
| 66 | extension fields in the trusted world certificate. |
| 67 | |
Sandrine Bailleux | 54b47dc | 2020-03-03 13:00:10 +0100 | [diff] [blame] | 68 | - **BL3X keys** |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 69 | |
Sandrine Bailleux | 15530dd | 2019-02-08 15:26:36 +0100 | [diff] [blame] | 70 | For each of SCP_BL2, BL31, BL32 and BL33, the private part is used to |
Sandrine Bailleux | 54b47dc | 2020-03-03 13:00:10 +0100 | [diff] [blame] | 71 | sign the content certificate for the BL3X image. The public part is stored |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 72 | in one of the extension fields in the corresponding key certificate. |
| 73 | |
| 74 | The following images are included in the CoT: |
| 75 | |
| 76 | - BL1 |
| 77 | - BL2 |
Sandrine Bailleux | 15530dd | 2019-02-08 15:26:36 +0100 | [diff] [blame] | 78 | - SCP_BL2 (optional) |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 79 | - BL31 |
| 80 | - BL33 |
| 81 | - BL32 (optional) |
| 82 | |
| 83 | The following certificates are used to authenticate the images. |
| 84 | |
| 85 | - **BL2 content certificate** |
| 86 | |
| 87 | It is self-signed with the private part of the ROT key. It contains a hash |
| 88 | of the BL2 image. |
| 89 | |
| 90 | - **Trusted key certificate** |
| 91 | |
| 92 | It is self-signed with the private part of the ROT key. It contains the |
| 93 | public part of the trusted world key and the public part of the non-trusted |
| 94 | world key. |
| 95 | |
Sandrine Bailleux | 15530dd | 2019-02-08 15:26:36 +0100 | [diff] [blame] | 96 | - **SCP_BL2 key certificate** |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 97 | |
| 98 | It is self-signed with the trusted world key. It contains the public part of |
Sandrine Bailleux | 15530dd | 2019-02-08 15:26:36 +0100 | [diff] [blame] | 99 | the SCP_BL2 key. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 100 | |
Sandrine Bailleux | 15530dd | 2019-02-08 15:26:36 +0100 | [diff] [blame] | 101 | - **SCP_BL2 content certificate** |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 102 | |
Sandrine Bailleux | 15530dd | 2019-02-08 15:26:36 +0100 | [diff] [blame] | 103 | It is self-signed with the SCP_BL2 key. It contains a hash of the SCP_BL2 |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 104 | image. |
| 105 | |
| 106 | - **BL31 key certificate** |
| 107 | |
| 108 | It is self-signed with the trusted world key. It contains the public part of |
| 109 | the BL31 key. |
| 110 | |
| 111 | - **BL31 content certificate** |
| 112 | |
| 113 | It is self-signed with the BL31 key. It contains a hash of the BL31 image. |
| 114 | |
| 115 | - **BL32 key certificate** |
| 116 | |
| 117 | It is self-signed with the trusted world key. It contains the public part of |
| 118 | the BL32 key. |
| 119 | |
| 120 | - **BL32 content certificate** |
| 121 | |
| 122 | It is self-signed with the BL32 key. It contains a hash of the BL32 image. |
| 123 | |
| 124 | - **BL33 key certificate** |
| 125 | |
| 126 | It is self-signed with the non-trusted world key. It contains the public |
| 127 | part of the BL33 key. |
| 128 | |
| 129 | - **BL33 content certificate** |
| 130 | |
| 131 | It is self-signed with the BL33 key. It contains a hash of the BL33 image. |
| 132 | |
Sandrine Bailleux | 15530dd | 2019-02-08 15:26:36 +0100 | [diff] [blame] | 133 | The SCP_BL2 and BL32 certificates are optional, but they must be present if the |
| 134 | corresponding SCP_BL2 or BL32 images are present. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 135 | |
| 136 | Trusted Board Boot Sequence |
| 137 | --------------------------- |
| 138 | |
| 139 | The CoT is verified through the following sequence of steps. The system panics |
| 140 | if any of the steps fail. |
| 141 | |
| 142 | - BL1 loads and verifies the BL2 content certificate. The issuer public key is |
| 143 | read from the verified certificate. A hash of that key is calculated and |
| 144 | compared with the hash of the ROTPK read from the trusted root-key storage |
| 145 | registers. If they match, the BL2 hash is read from the certificate. |
| 146 | |
Paul Beesley | ba3ed40 | 2019-03-13 16:20:44 +0000 | [diff] [blame] | 147 | .. note:: |
| 148 | The matching operation is platform specific and is currently |
| 149 | unimplemented on the Arm development platforms. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 150 | |
| 151 | - BL1 loads the BL2 image. Its hash is calculated and compared with the hash |
| 152 | read from the certificate. Control is transferred to the BL2 image if all |
| 153 | the comparisons succeed. |
| 154 | |
| 155 | - BL2 loads and verifies the trusted key certificate. The issuer public key is |
| 156 | read from the verified certificate. A hash of that key is calculated and |
| 157 | compared with the hash of the ROTPK read from the trusted root-key storage |
| 158 | registers. If the comparison succeeds, BL2 reads and saves the trusted and |
| 159 | non-trusted world public keys from the verified certificate. |
| 160 | |
Sandrine Bailleux | 15530dd | 2019-02-08 15:26:36 +0100 | [diff] [blame] | 161 | The next two steps are executed for each of the SCP_BL2, BL31 & BL32 images. |
| 162 | The steps for the optional SCP_BL2 and BL32 images are skipped if these images |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 163 | are not present. |
| 164 | |
| 165 | - BL2 loads and verifies the BL3x key certificate. The certificate signature |
| 166 | is verified using the trusted world public key. If the signature |
| 167 | verification succeeds, BL2 reads and saves the BL3x public key from the |
| 168 | certificate. |
| 169 | |
| 170 | - BL2 loads and verifies the BL3x content certificate. The signature is |
| 171 | verified using the BL3x public key. If the signature verification succeeds, |
| 172 | BL2 reads and saves the BL3x image hash from the certificate. |
| 173 | |
| 174 | The next two steps are executed only for the BL33 image. |
| 175 | |
| 176 | - BL2 loads and verifies the BL33 key certificate. If the signature |
| 177 | verification succeeds, BL2 reads and saves the BL33 public key from the |
| 178 | certificate. |
| 179 | |
| 180 | - BL2 loads and verifies the BL33 content certificate. If the signature |
| 181 | verification succeeds, BL2 reads and saves the BL33 image hash from the |
| 182 | certificate. |
| 183 | |
| 184 | The next step is executed for all the boot loader images. |
| 185 | |
| 186 | - BL2 calculates the hash of each image. It compares it with the hash obtained |
| 187 | from the corresponding content certificate. The image authentication succeeds |
| 188 | if the hashes match. |
| 189 | |
| 190 | The Trusted Board Boot implementation spans both generic and platform-specific |
| 191 | BL1 and BL2 code, and in tool code on the host build machine. The feature is |
Paul Beesley | d2fcc4e | 2019-05-29 13:59:40 +0100 | [diff] [blame] | 192 | enabled through use of specific build flags as described in |
| 193 | :ref:`Build Options`. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 194 | |
| 195 | On the host machine, a tool generates the certificates, which are included in |
| 196 | the FIP along with the boot loader images. These certificates are loaded in |
| 197 | Trusted SRAM using the IO storage framework. They are then verified by an |
Dan Handley | 610e7e1 | 2018-03-01 18:44:00 +0000 | [diff] [blame] | 198 | Authentication module included in TF-A. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 199 | |
| 200 | The mechanism used for generating the FIP and the Authentication module are |
| 201 | described in the following sections. |
| 202 | |
| 203 | Authentication Framework |
| 204 | ------------------------ |
| 205 | |
Dan Handley | 610e7e1 | 2018-03-01 18:44:00 +0000 | [diff] [blame] | 206 | The authentication framework included in TF-A provides support to implement |
| 207 | the desired trusted boot sequence. Arm platforms use this framework to |
Paul Beesley | f864067 | 2019-04-12 14:19:42 +0100 | [diff] [blame] | 208 | implement the boot requirements specified in the |
| 209 | `Trusted Board Boot Requirements (TBBR)`_ document. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 210 | |
| 211 | More information about the authentication framework can be found in the |
Paul Beesley | f864067 | 2019-04-12 14:19:42 +0100 | [diff] [blame] | 212 | :ref:`Authentication Framework & Chain of Trust` document. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 213 | |
| 214 | Certificate Generation Tool |
| 215 | --------------------------- |
| 216 | |
| 217 | The ``cert_create`` tool is built and runs on the host machine as part of the |
Dan Handley | 610e7e1 | 2018-03-01 18:44:00 +0000 | [diff] [blame] | 218 | TF-A build process when ``GENERATE_COT=1``. It takes the boot loader images |
| 219 | and keys as inputs (keys must be in PEM format) and generates the |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 220 | certificates (in DER format) required to establish the CoT. New keys can be |
| 221 | generated by the tool in case they are not provided. The certificates are then |
| 222 | passed as inputs to the ``fiptool`` utility for creating the FIP. |
| 223 | |
Sandrine Bailleux | 54b47dc | 2020-03-03 13:00:10 +0100 | [diff] [blame] | 224 | The certificates are also stored individually in the output build directory. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 225 | |
Paul Beesley | d2fcc4e | 2019-05-29 13:59:40 +0100 | [diff] [blame] | 226 | The tool resides in the ``tools/cert_create`` directory. It uses the OpenSSL SSL |
| 227 | library version to generate the X.509 certificates. The specific version of the |
| 228 | library that is required is given in the :ref:`Prerequisites` document. |
| 229 | |
| 230 | Instructions for building and using the tool can be found at |
| 231 | :ref:`tools_build_cert_create`. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 232 | |
Sumit Garg | c0c369c | 2019-11-15 18:47:53 +0530 | [diff] [blame] | 233 | Authenticated Encryption Framework |
| 234 | ---------------------------------- |
| 235 | |
| 236 | The authenticated encryption framework included in TF-A provides support to |
| 237 | implement the optional firmware encryption feature. This feature can be |
| 238 | optionally enabled on platforms to implement the optional requirement: |
| 239 | R060_TBBR_FUNCTION as specified in the `Trusted Board Boot Requirements (TBBR)`_ |
| 240 | document. |
| 241 | |
| 242 | Note that due to security considerations and complexity of this feature, it is |
| 243 | marked as experimental. |
| 244 | |
| 245 | Firmware Encryption Tool |
| 246 | ------------------------ |
| 247 | |
| 248 | The ``encrypt_fw`` tool is built and runs on the host machine as part of the |
| 249 | TF-A build process when ``DECRYPTION_SUPPORT != none``. It takes the plain |
| 250 | firmware image as input and generates the encrypted firmware image which can |
| 251 | then be passed as input to the ``fiptool`` utility for creating the FIP. |
| 252 | |
| 253 | The encrypted firmwares are also stored individually in the output build |
| 254 | directory. |
| 255 | |
| 256 | The tool resides in the ``tools/encrypt_fw`` directory. It uses OpenSSL SSL |
| 257 | library version 1.0.1 or later to do authenticated encryption operation. |
| 258 | Instructions for building and using the tool can be found in the |
| 259 | :ref:`tools_build_enctool`. |
| 260 | |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 261 | -------------- |
| 262 | |
Sandrine Bailleux | 54b47dc | 2020-03-03 13:00:10 +0100 | [diff] [blame] | 263 | *Copyright (c) 2015-2020, Arm Limited and Contributors. All rights reserved.* |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 264 | |
Paul Beesley | 2437ddc | 2019-02-08 16:43:05 +0000 | [diff] [blame] | 265 | .. _X.509 v3: https://tools.ietf.org/rfc/rfc5280.txt |
Paul Beesley | f864067 | 2019-04-12 14:19:42 +0100 | [diff] [blame] | 266 | .. _Trusted Board Boot Requirements (TBBR): https://developer.arm.com/docs/den0006/latest/trusted-board-boot-requirements-client-tbbr-client-armv8-a |