blob: f3e094ce8c923c4c6ae4539d7c3065b4c744b86e [file] [log] [blame]
Paul Beesleyfc9ee362019-03-07 15:47:15 +00001Trusted Board Boot
2==================
Douglas Raillardd7c21b72017-06-28 15:23:03 +01003
Sandrine Bailleuxb8904402024-02-02 15:21:29 +01004The `Trusted Board Boot` (TBB) feature prevents malicious firmware from running
5on the platform by authenticating all firmware images up to and including the
6normal world bootloader. It does this by establishing a `Chain of Trust` using
Douglas Raillardd7c21b72017-06-28 15:23:03 +01007Public-Key-Cryptography Standards (PKCS).
8
Sandrine Bailleux30918422019-04-24 10:41:24 +02009This document describes the design of Trusted Firmware-A (TF-A) TBB, which is an
10implementation of the `Trusted Board Boot Requirements (TBBR)`_ specification,
Sandrine Bailleuxb8904402024-02-02 15:21:29 +010011Arm DEN0006D. It should be used in conjunction with the :ref:`Firmware Update
12(FWU)` design document, which implements a specific aspect of the TBBR.
Douglas Raillardd7c21b72017-06-28 15:23:03 +010013
14Chain of Trust
15--------------
16
Sandrine Bailleuxb8904402024-02-02 15:21:29 +010017A Chain of Trust (CoT) starts with a set of implicitly trusted components, which
18are used to establish trust in the next layer of components, and so on, in a
19`chained` manner.
Douglas Raillardd7c21b72017-06-28 15:23:03 +010020
Sandrine Bailleuxb8904402024-02-02 15:21:29 +010021The chain of trust depends on several factors, including:
22
23- The set of firmware images in use on this platform.
24 Typically, most platforms share a common set of firmware images (BL1, BL2,
25 BL31, BL33) but extra platform-specific images might be required.
26
27- The key provisioning scheme: which keys need to programmed into the device
28 and at which stage during the platform's manufacturing lifecycle.
29
30- The key ownership model: who owns which key.
31
32As these vary across platforms, chains of trust also vary across
33platforms. Although each platform is free to define its own CoT based on its
34needs, TF-A provides a set of "default" CoTs fitting some typical trust models,
35which platforms may reuse. The rest of this section presents general concepts
36which apply to all these default CoTs.
37
38The implicitly trusted components forming the trust anchor are:
39
40- A Root of Trust Public Key (ROTPK), or a hash of it.
41
Ryan Everettc15d3e92024-11-13 17:01:51 +000042 On Arm development platforms, a hash of the ROTPK (hash algorithm selected by
43 the ``HASH_ALG`` build option, with sha256 as default) is stored in the
Sandrine Bailleux54b47dc2020-03-03 13:00:10 +010044 trusted root-key storage registers. Alternatively, a development ROTPK might
45 be used and its hash embedded into the BL1 and BL2 images (only for
46 development purposes).
Douglas Raillardd7c21b72017-06-28 15:23:03 +010047
48- The BL1 image, on the assumption that it resides in ROM so cannot be
49 tampered with.
50
51The remaining components in the CoT are either certificates or boot loader
52images. The certificates follow the `X.509 v3`_ standard. This standard
53enables adding custom extensions to the certificates, which are used to store
54essential information to establish the CoT.
55
Sandrine Bailleuxb8904402024-02-02 15:21:29 +010056All certificates are self-signed. There is no need for a Certificate Authority
57(CA) because the CoT is not established by verifying the validity of a
58certificate's issuer but by the content of the certificate extensions. To sign
59the certificates, different signature schemes are available, please refer to the
60:ref:`Build Options` for more details.
Douglas Raillardd7c21b72017-06-28 15:23:03 +010061
62The certificates are categorised as "Key" and "Content" certificates. Key
63certificates are used to verify public keys which have been used to sign content
64certificates. Content certificates are used to store the hash of a boot loader
65image. An image can be authenticated by calculating its hash and matching it
Sandrine Bailleux54b47dc2020-03-03 13:00:10 +010066with the hash extracted from the content certificate. Various hash algorithms
67are supported to calculate all hashes, please refer to the :ref:`Build Options`
Sandrine Bailleuxb8904402024-02-02 15:21:29 +010068for more details. The public keys and hashes are included as non-standard
Sandrine Bailleux54b47dc2020-03-03 13:00:10 +010069extension fields in the `X.509 v3`_ certificates.
Douglas Raillardd7c21b72017-06-28 15:23:03 +010070
Sandrine Bailleuxb8904402024-02-02 15:21:29 +010071The next sections now present specificities of each default CoT provided in
72TF-A.
73
74Default CoT #1: TBBR
75~~~~~~~~~~~~~~~~~~~~
76
77The `TBBR` CoT is named after the specification it follows to the letter.
78
79In the TBBR CoT, all firmware binaries and certificates are (directly or
80indirectly) linked to the Root of Trust Public Key (ROTPK). Typically, the same
81vendor owns the ROTPK, the Trusted key and the Non-Trusted Key. Thus, this vendor
82is involved in signing every BL3x Key Certificate.
83
84The keys used to establish this CoT are:
Douglas Raillardd7c21b72017-06-28 15:23:03 +010085
86- **Root of trust key**
87
Sandrine Bailleux3e992d62024-02-09 13:41:09 +010088 The private part of this key is used to sign the trusted boot firmware
89 certificate and the trusted key certificate. The public part is the ROTPK.
Douglas Raillardd7c21b72017-06-28 15:23:03 +010090
91- **Trusted world key**
92
93 The private part is used to sign the key certificates corresponding to the
Sandrine Bailleux15530dd2019-02-08 15:26:36 +010094 secure world images (SCP_BL2, BL31 and BL32). The public part is stored in
Sandrine Bailleux3e992d62024-02-09 13:41:09 +010095 one of the extension fields in the trusted key certificate.
Douglas Raillardd7c21b72017-06-28 15:23:03 +010096
97- **Non-trusted world key**
98
99 The private part is used to sign the key certificate corresponding to the
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100100 non-secure world image (BL33). The public part is stored in one of the
101 extension fields in the trusted key certificate.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100102
Sandrine Bailleux54b47dc2020-03-03 13:00:10 +0100103- **BL3X keys**
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100104
Sandrine Bailleux15530dd2019-02-08 15:26:36 +0100105 For each of SCP_BL2, BL31, BL32 and BL33, the private part is used to
Sandrine Bailleux54b47dc2020-03-03 13:00:10 +0100106 sign the content certificate for the BL3X image. The public part is stored
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100107 in one of the extension fields in the corresponding key certificate.
108
109The following images are included in the CoT:
110
111- BL1
112- BL2
Sandrine Bailleux15530dd2019-02-08 15:26:36 +0100113- SCP_BL2 (optional)
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100114- BL31
115- BL33
116- BL32 (optional)
117
118The following certificates are used to authenticate the images.
119
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100120- **Trusted boot firmware certificate**
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100121
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100122 It is self-signed with the private part of the ROT key. It contains a hash of
123 the BL2 image and hashes of various firmware configuration files
124 (TB_FW_CONFIG, HW_CONFIG, FW_CONFIG).
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100125
126- **Trusted key certificate**
127
128 It is self-signed with the private part of the ROT key. It contains the
129 public part of the trusted world key and the public part of the non-trusted
130 world key.
131
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100132- **SCP firmware key certificate**
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100133
134 It is self-signed with the trusted world key. It contains the public part of
Sandrine Bailleux15530dd2019-02-08 15:26:36 +0100135 the SCP_BL2 key.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100136
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100137- **SCP firmware content certificate**
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100138
Sandrine Bailleux15530dd2019-02-08 15:26:36 +0100139 It is self-signed with the SCP_BL2 key. It contains a hash of the SCP_BL2
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100140 image.
141
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100142- **SoC firmware key certificate**
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100143
144 It is self-signed with the trusted world key. It contains the public part of
145 the BL31 key.
146
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100147- **SoC firmware content certificate**
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100148
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100149 It is self-signed with the BL31 key. It contains hashes of the BL31 image and
150 its configuration file (SOC_FW_CONFIG).
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100151
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100152- **Trusted OS key certificate**
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100153
154 It is self-signed with the trusted world key. It contains the public part of
155 the BL32 key.
156
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100157- **Trusted OS content certificate**
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100158
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100159 It is self-signed with the BL32 key. It contains hashes of the BL32 image(s)
160 and its configuration file(s) (TOS_FW_CONFIG).
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100161
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100162- **Non-trusted firmware key certificate**
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100163
164 It is self-signed with the non-trusted world key. It contains the public
165 part of the BL33 key.
166
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100167- **Non-trusted firmware content certificate**
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100168
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100169 It is self-signed with the BL33 key. It contains hashes of the BL33 image and
170 its configuration file (NT_FW_CONFIG).
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100171
Sandrine Bailleux3e992d62024-02-09 13:41:09 +0100172The SCP firmware and Trusted OS certificates are optional, but they must be
173present if the corresponding SCP_BL2 or BL32 images are present.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100174
Sandrine Bailleuxb8904402024-02-02 15:21:29 +0100175The following diagram summarizes the part of the TBBR CoT enforced by BL2. Some
176images (SCP, debug certificates, secure partitions, configuration files) are not
177shown here for conciseness:
178
179.. image:: ../resources/diagrams/cot-tbbr.jpg
180
181Default CoT #2: Dualroot
182~~~~~~~~~~~~~~~~~~~~~~~~
183
184The `dualroot` CoT is targeted at systems where the Normal World firmware is
185owned by a different entity than the Secure World Firmware, and those 2 entities
186do not wish to share any keys or have any dependency between each other when it
187comes to signing their respective images. It establishes 2 separate signing
188domains, each with its own Root of Trust key. In that sense, this CoT has 2
189roots of trust, hence the `dualroot` name.
190
191Although the dualroot CoT reuses some of the TBBR CoT components and concepts,
192it differs on the BL33 image's chain of trust, which is rooted into a new key,
193called `Platform ROTPK`, or `PROTPK` for short.
194
195The following diagram summarizes the part of the dualroot CoT enforced by
196BL2. Some images (SCP, debug certificates, secure partitions, configuration
197files) are not shown here for conciseness:
198
199.. image:: ../resources/diagrams/cot-dualroot.jpg
200
201Default CoT #3: CCA
202~~~~~~~~~~~~~~~~~~~
203
204This CoT is targeted at Arm CCA systems. The Arm CCA security model recommends
205making supply chains for the Arm CCA firmware, the secure world firmware and the
206platform owner firmware, independent. Hence, this CoT has 3 roots of trust, one
207for each supply chain.
208
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100209Trusted Board Boot Sequence
210---------------------------
211
212The CoT is verified through the following sequence of steps. The system panics
213if any of the steps fail.
214
215- BL1 loads and verifies the BL2 content certificate. The issuer public key is
216 read from the verified certificate. A hash of that key is calculated and
217 compared with the hash of the ROTPK read from the trusted root-key storage
218 registers. If they match, the BL2 hash is read from the certificate.
219
Paul Beesleyba3ed402019-03-13 16:20:44 +0000220 .. note::
221 The matching operation is platform specific and is currently
222 unimplemented on the Arm development platforms.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100223
224- BL1 loads the BL2 image. Its hash is calculated and compared with the hash
225 read from the certificate. Control is transferred to the BL2 image if all
226 the comparisons succeed.
227
228- BL2 loads and verifies the trusted key certificate. The issuer public key is
229 read from the verified certificate. A hash of that key is calculated and
230 compared with the hash of the ROTPK read from the trusted root-key storage
231 registers. If the comparison succeeds, BL2 reads and saves the trusted and
232 non-trusted world public keys from the verified certificate.
233
Sandrine Bailleux15530dd2019-02-08 15:26:36 +0100234The next two steps are executed for each of the SCP_BL2, BL31 & BL32 images.
235The steps for the optional SCP_BL2 and BL32 images are skipped if these images
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100236are not present.
237
238- BL2 loads and verifies the BL3x key certificate. The certificate signature
239 is verified using the trusted world public key. If the signature
240 verification succeeds, BL2 reads and saves the BL3x public key from the
241 certificate.
242
243- BL2 loads and verifies the BL3x content certificate. The signature is
244 verified using the BL3x public key. If the signature verification succeeds,
245 BL2 reads and saves the BL3x image hash from the certificate.
246
247The next two steps are executed only for the BL33 image.
248
249- BL2 loads and verifies the BL33 key certificate. If the signature
250 verification succeeds, BL2 reads and saves the BL33 public key from the
251 certificate.
252
253- BL2 loads and verifies the BL33 content certificate. If the signature
254 verification succeeds, BL2 reads and saves the BL33 image hash from the
255 certificate.
256
257The next step is executed for all the boot loader images.
258
259- BL2 calculates the hash of each image. It compares it with the hash obtained
260 from the corresponding content certificate. The image authentication succeeds
261 if the hashes match.
262
263The Trusted Board Boot implementation spans both generic and platform-specific
264BL1 and BL2 code, and in tool code on the host build machine. The feature is
Paul Beesleyd2fcc4e2019-05-29 13:59:40 +0100265enabled through use of specific build flags as described in
266:ref:`Build Options`.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100267
268On the host machine, a tool generates the certificates, which are included in
269the FIP along with the boot loader images. These certificates are loaded in
270Trusted SRAM using the IO storage framework. They are then verified by an
Dan Handley610e7e12018-03-01 18:44:00 +0000271Authentication module included in TF-A.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100272
273The mechanism used for generating the FIP and the Authentication module are
274described in the following sections.
275
276Authentication Framework
277------------------------
278
Dan Handley610e7e12018-03-01 18:44:00 +0000279The authentication framework included in TF-A provides support to implement
280the desired trusted boot sequence. Arm platforms use this framework to
Paul Beesleyf8640672019-04-12 14:19:42 +0100281implement the boot requirements specified in the
282`Trusted Board Boot Requirements (TBBR)`_ document.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100283
284More information about the authentication framework can be found in the
Paul Beesleyf8640672019-04-12 14:19:42 +0100285:ref:`Authentication Framework & Chain of Trust` document.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100286
287Certificate Generation Tool
288---------------------------
289
290The ``cert_create`` tool is built and runs on the host machine as part of the
Dan Handley610e7e12018-03-01 18:44:00 +0000291TF-A build process when ``GENERATE_COT=1``. It takes the boot loader images
Robin van der Gracht06b5cdb2023-09-12 11:16:23 +0200292and keys as inputs and generates the certificates (in DER format) required to
293establish the CoT. The input keys must either be a file in PEM format or a
294PKCS11 URI in case a HSM is used. New keys can be generated by the tool in
295case they are not provided. The certificates are then passed as inputs to
296the ``fiptool`` utility for creating the FIP.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100297
Sandrine Bailleux54b47dc2020-03-03 13:00:10 +0100298The certificates are also stored individually in the output build directory.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100299
Paul Beesleyd2fcc4e2019-05-29 13:59:40 +0100300The tool resides in the ``tools/cert_create`` directory. It uses the OpenSSL SSL
301library version to generate the X.509 certificates. The specific version of the
302library that is required is given in the :ref:`Prerequisites` document.
303
304Instructions for building and using the tool can be found at
305:ref:`tools_build_cert_create`.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100306
Sumit Gargc0c369c2019-11-15 18:47:53 +0530307Authenticated Encryption Framework
308----------------------------------
309
310The authenticated encryption framework included in TF-A provides support to
311implement the optional firmware encryption feature. This feature can be
312optionally enabled on platforms to implement the optional requirement:
313R060_TBBR_FUNCTION as specified in the `Trusted Board Boot Requirements (TBBR)`_
314document.
315
Sumit Gargc0c369c2019-11-15 18:47:53 +0530316Firmware Encryption Tool
317------------------------
318
319The ``encrypt_fw`` tool is built and runs on the host machine as part of the
320TF-A build process when ``DECRYPTION_SUPPORT != none``. It takes the plain
321firmware image as input and generates the encrypted firmware image which can
322then be passed as input to the ``fiptool`` utility for creating the FIP.
323
324The encrypted firmwares are also stored individually in the output build
325directory.
326
327The tool resides in the ``tools/encrypt_fw`` directory. It uses OpenSSL SSL
328library version 1.0.1 or later to do authenticated encryption operation.
329Instructions for building and using the tool can be found in the
330:ref:`tools_build_enctool`.
331
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100332--------------
333
Ryan Everettc15d3e92024-11-13 17:01:51 +0000334*Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved.*
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100335
Paul Beesley2437ddc2019-02-08 16:43:05 +0000336.. _X.509 v3: https://tools.ietf.org/rfc/rfc5280.txt
Sandrine Bailleuxf2384172024-02-02 11:16:12 +0100337.. _Trusted Board Boot Requirements (TBBR): https://developer.arm.com/docs/den0006/latest