18aa05055SPaul BeesleyTrusted Board Boot 28aa05055SPaul Beesley================== 340d553cfSPaul Beesley 45d9711feSSandrine BailleuxThe `Trusted Board Boot` (TBB) feature prevents malicious firmware from running 55d9711feSSandrine Bailleuxon the platform by authenticating all firmware images up to and including the 65d9711feSSandrine Bailleuxnormal world bootloader. It does this by establishing a `Chain of Trust` using 740d553cfSPaul BeesleyPublic-Key-Cryptography Standards (PKCS). 840d553cfSPaul Beesley 940d553cfSPaul BeesleyThis document describes the design of Trusted Firmware-A (TF-A) TBB, which is an 1040d553cfSPaul Beesleyimplementation of the `Trusted Board Boot Requirements (TBBR)`_ specification, 115d9711feSSandrine BailleuxArm DEN0006D. It should be used in conjunction with the :ref:`Firmware Update 125d9711feSSandrine Bailleux(FWU)` design document, which implements a specific aspect of the TBBR. 1340d553cfSPaul Beesley 1440d553cfSPaul BeesleyChain of Trust 1540d553cfSPaul Beesley-------------- 1640d553cfSPaul Beesley 175d9711feSSandrine BailleuxA Chain of Trust (CoT) starts with a set of implicitly trusted components, which 185d9711feSSandrine Bailleuxare used to establish trust in the next layer of components, and so on, in a 195d9711feSSandrine Bailleux`chained` manner. 2040d553cfSPaul Beesley 215d9711feSSandrine BailleuxThe chain of trust depends on several factors, including: 225d9711feSSandrine Bailleux 235d9711feSSandrine Bailleux- The set of firmware images in use on this platform. 245d9711feSSandrine Bailleux Typically, most platforms share a common set of firmware images (BL1, BL2, 255d9711feSSandrine Bailleux BL31, BL33) but extra platform-specific images might be required. 265d9711feSSandrine Bailleux 275d9711feSSandrine Bailleux- The key provisioning scheme: which keys need to programmed into the device 285d9711feSSandrine Bailleux and at which stage during the platform's manufacturing lifecycle. 295d9711feSSandrine Bailleux 305d9711feSSandrine Bailleux- The key ownership model: who owns which key. 315d9711feSSandrine Bailleux 325d9711feSSandrine BailleuxAs these vary across platforms, chains of trust also vary across 335d9711feSSandrine Bailleuxplatforms. Although each platform is free to define its own CoT based on its 345d9711feSSandrine Bailleuxneeds, TF-A provides a set of "default" CoTs fitting some typical trust models, 355d9711feSSandrine Bailleuxwhich platforms may reuse. The rest of this section presents general concepts 365d9711feSSandrine Bailleuxwhich apply to all these default CoTs. 375d9711feSSandrine Bailleux 385d9711feSSandrine BailleuxThe implicitly trusted components forming the trust anchor are: 395d9711feSSandrine Bailleux 405d9711feSSandrine Bailleux- A Root of Trust Public Key (ROTPK), or a hash of it. 415d9711feSSandrine Bailleux 42*4639f890SRyan Everett On Arm development platforms, a hash of the ROTPK (hash algorithm selected by 43*4639f890SRyan Everett the ``HASH_ALG`` build option, with sha256 as default) is stored in the 44316c5cc6SSandrine Bailleux trusted root-key storage registers. Alternatively, a development ROTPK might 45316c5cc6SSandrine Bailleux be used and its hash embedded into the BL1 and BL2 images (only for 46316c5cc6SSandrine Bailleux development purposes). 4740d553cfSPaul Beesley 4840d553cfSPaul Beesley- The BL1 image, on the assumption that it resides in ROM so cannot be 4940d553cfSPaul Beesley tampered with. 5040d553cfSPaul Beesley 5140d553cfSPaul BeesleyThe remaining components in the CoT are either certificates or boot loader 5240d553cfSPaul Beesleyimages. The certificates follow the `X.509 v3`_ standard. This standard 5340d553cfSPaul Beesleyenables adding custom extensions to the certificates, which are used to store 5440d553cfSPaul Beesleyessential information to establish the CoT. 5540d553cfSPaul Beesley 565d9711feSSandrine BailleuxAll certificates are self-signed. There is no need for a Certificate Authority 575d9711feSSandrine Bailleux(CA) because the CoT is not established by verifying the validity of a 585d9711feSSandrine Bailleuxcertificate's issuer but by the content of the certificate extensions. To sign 595d9711feSSandrine Bailleuxthe certificates, different signature schemes are available, please refer to the 605d9711feSSandrine Bailleux:ref:`Build Options` for more details. 6140d553cfSPaul Beesley 6240d553cfSPaul BeesleyThe certificates are categorised as "Key" and "Content" certificates. Key 6340d553cfSPaul Beesleycertificates are used to verify public keys which have been used to sign content 6440d553cfSPaul Beesleycertificates. Content certificates are used to store the hash of a boot loader 6540d553cfSPaul Beesleyimage. An image can be authenticated by calculating its hash and matching it 66316c5cc6SSandrine Bailleuxwith the hash extracted from the content certificate. Various hash algorithms 67316c5cc6SSandrine Bailleuxare supported to calculate all hashes, please refer to the :ref:`Build Options` 685d9711feSSandrine Bailleuxfor more details. The public keys and hashes are included as non-standard 69316c5cc6SSandrine Bailleuxextension fields in the `X.509 v3`_ certificates. 7040d553cfSPaul Beesley 715d9711feSSandrine BailleuxThe next sections now present specificities of each default CoT provided in 725d9711feSSandrine BailleuxTF-A. 735d9711feSSandrine Bailleux 745d9711feSSandrine BailleuxDefault CoT #1: TBBR 755d9711feSSandrine Bailleux~~~~~~~~~~~~~~~~~~~~ 765d9711feSSandrine Bailleux 775d9711feSSandrine BailleuxThe `TBBR` CoT is named after the specification it follows to the letter. 785d9711feSSandrine Bailleux 795d9711feSSandrine BailleuxIn the TBBR CoT, all firmware binaries and certificates are (directly or 805d9711feSSandrine Bailleuxindirectly) linked to the Root of Trust Public Key (ROTPK). Typically, the same 815d9711feSSandrine Bailleuxvendor owns the ROTPK, the Trusted key and the Non-Trusted Key. Thus, this vendor 825d9711feSSandrine Bailleuxis involved in signing every BL3x Key Certificate. 835d9711feSSandrine Bailleux 845d9711feSSandrine BailleuxThe keys used to establish this CoT are: 8540d553cfSPaul Beesley 8640d553cfSPaul Beesley- **Root of trust key** 8740d553cfSPaul Beesley 882afa143aSSandrine Bailleux The private part of this key is used to sign the trusted boot firmware 892afa143aSSandrine Bailleux certificate and the trusted key certificate. The public part is the ROTPK. 9040d553cfSPaul Beesley 9140d553cfSPaul Beesley- **Trusted world key** 9240d553cfSPaul Beesley 9340d553cfSPaul Beesley The private part is used to sign the key certificates corresponding to the 9440d553cfSPaul Beesley secure world images (SCP_BL2, BL31 and BL32). The public part is stored in 952afa143aSSandrine Bailleux one of the extension fields in the trusted key certificate. 9640d553cfSPaul Beesley 9740d553cfSPaul Beesley- **Non-trusted world key** 9840d553cfSPaul Beesley 9940d553cfSPaul Beesley The private part is used to sign the key certificate corresponding to the 1002afa143aSSandrine Bailleux non-secure world image (BL33). The public part is stored in one of the 1012afa143aSSandrine Bailleux extension fields in the trusted key certificate. 10240d553cfSPaul Beesley 103316c5cc6SSandrine Bailleux- **BL3X keys** 10440d553cfSPaul Beesley 10540d553cfSPaul Beesley For each of SCP_BL2, BL31, BL32 and BL33, the private part is used to 106316c5cc6SSandrine Bailleux sign the content certificate for the BL3X image. The public part is stored 10740d553cfSPaul Beesley in one of the extension fields in the corresponding key certificate. 10840d553cfSPaul Beesley 10940d553cfSPaul BeesleyThe following images are included in the CoT: 11040d553cfSPaul Beesley 11140d553cfSPaul Beesley- BL1 11240d553cfSPaul Beesley- BL2 11340d553cfSPaul Beesley- SCP_BL2 (optional) 11440d553cfSPaul Beesley- BL31 11540d553cfSPaul Beesley- BL33 11640d553cfSPaul Beesley- BL32 (optional) 11740d553cfSPaul Beesley 11840d553cfSPaul BeesleyThe following certificates are used to authenticate the images. 11940d553cfSPaul Beesley 1202afa143aSSandrine Bailleux- **Trusted boot firmware certificate** 12140d553cfSPaul Beesley 1222afa143aSSandrine Bailleux It is self-signed with the private part of the ROT key. It contains a hash of 1232afa143aSSandrine Bailleux the BL2 image and hashes of various firmware configuration files 1242afa143aSSandrine Bailleux (TB_FW_CONFIG, HW_CONFIG, FW_CONFIG). 12540d553cfSPaul Beesley 12640d553cfSPaul Beesley- **Trusted key certificate** 12740d553cfSPaul Beesley 12840d553cfSPaul Beesley It is self-signed with the private part of the ROT key. It contains the 12940d553cfSPaul Beesley public part of the trusted world key and the public part of the non-trusted 13040d553cfSPaul Beesley world key. 13140d553cfSPaul Beesley 1322afa143aSSandrine Bailleux- **SCP firmware key certificate** 13340d553cfSPaul Beesley 13440d553cfSPaul Beesley It is self-signed with the trusted world key. It contains the public part of 13540d553cfSPaul Beesley the SCP_BL2 key. 13640d553cfSPaul Beesley 1372afa143aSSandrine Bailleux- **SCP firmware content certificate** 13840d553cfSPaul Beesley 13940d553cfSPaul Beesley It is self-signed with the SCP_BL2 key. It contains a hash of the SCP_BL2 14040d553cfSPaul Beesley image. 14140d553cfSPaul Beesley 1422afa143aSSandrine Bailleux- **SoC firmware key certificate** 14340d553cfSPaul Beesley 14440d553cfSPaul Beesley It is self-signed with the trusted world key. It contains the public part of 14540d553cfSPaul Beesley the BL31 key. 14640d553cfSPaul Beesley 1472afa143aSSandrine Bailleux- **SoC firmware content certificate** 14840d553cfSPaul Beesley 1492afa143aSSandrine Bailleux It is self-signed with the BL31 key. It contains hashes of the BL31 image and 1502afa143aSSandrine Bailleux its configuration file (SOC_FW_CONFIG). 15140d553cfSPaul Beesley 1522afa143aSSandrine Bailleux- **Trusted OS key certificate** 15340d553cfSPaul Beesley 15440d553cfSPaul Beesley It is self-signed with the trusted world key. It contains the public part of 15540d553cfSPaul Beesley the BL32 key. 15640d553cfSPaul Beesley 1572afa143aSSandrine Bailleux- **Trusted OS content certificate** 15840d553cfSPaul Beesley 1592afa143aSSandrine Bailleux It is self-signed with the BL32 key. It contains hashes of the BL32 image(s) 1602afa143aSSandrine Bailleux and its configuration file(s) (TOS_FW_CONFIG). 16140d553cfSPaul Beesley 1622afa143aSSandrine Bailleux- **Non-trusted firmware key certificate** 16340d553cfSPaul Beesley 16440d553cfSPaul Beesley It is self-signed with the non-trusted world key. It contains the public 16540d553cfSPaul Beesley part of the BL33 key. 16640d553cfSPaul Beesley 1672afa143aSSandrine Bailleux- **Non-trusted firmware content certificate** 16840d553cfSPaul Beesley 1692afa143aSSandrine Bailleux It is self-signed with the BL33 key. It contains hashes of the BL33 image and 1702afa143aSSandrine Bailleux its configuration file (NT_FW_CONFIG). 17140d553cfSPaul Beesley 1722afa143aSSandrine BailleuxThe SCP firmware and Trusted OS certificates are optional, but they must be 1732afa143aSSandrine Bailleuxpresent if the corresponding SCP_BL2 or BL32 images are present. 17440d553cfSPaul Beesley 1755d9711feSSandrine BailleuxThe following diagram summarizes the part of the TBBR CoT enforced by BL2. Some 1765d9711feSSandrine Bailleuximages (SCP, debug certificates, secure partitions, configuration files) are not 1775d9711feSSandrine Bailleuxshown here for conciseness: 1785d9711feSSandrine Bailleux 1795d9711feSSandrine Bailleux.. image:: ../resources/diagrams/cot-tbbr.jpg 1805d9711feSSandrine Bailleux 1815d9711feSSandrine BailleuxDefault CoT #2: Dualroot 1825d9711feSSandrine Bailleux~~~~~~~~~~~~~~~~~~~~~~~~ 1835d9711feSSandrine Bailleux 1845d9711feSSandrine BailleuxThe `dualroot` CoT is targeted at systems where the Normal World firmware is 1855d9711feSSandrine Bailleuxowned by a different entity than the Secure World Firmware, and those 2 entities 1865d9711feSSandrine Bailleuxdo not wish to share any keys or have any dependency between each other when it 1875d9711feSSandrine Bailleuxcomes to signing their respective images. It establishes 2 separate signing 1885d9711feSSandrine Bailleuxdomains, each with its own Root of Trust key. In that sense, this CoT has 2 1895d9711feSSandrine Bailleuxroots of trust, hence the `dualroot` name. 1905d9711feSSandrine Bailleux 1915d9711feSSandrine BailleuxAlthough the dualroot CoT reuses some of the TBBR CoT components and concepts, 1925d9711feSSandrine Bailleuxit differs on the BL33 image's chain of trust, which is rooted into a new key, 1935d9711feSSandrine Bailleuxcalled `Platform ROTPK`, or `PROTPK` for short. 1945d9711feSSandrine Bailleux 1955d9711feSSandrine BailleuxThe following diagram summarizes the part of the dualroot CoT enforced by 1965d9711feSSandrine BailleuxBL2. Some images (SCP, debug certificates, secure partitions, configuration 1975d9711feSSandrine Bailleuxfiles) are not shown here for conciseness: 1985d9711feSSandrine Bailleux 1995d9711feSSandrine Bailleux.. image:: ../resources/diagrams/cot-dualroot.jpg 2005d9711feSSandrine Bailleux 2015d9711feSSandrine BailleuxDefault CoT #3: CCA 2025d9711feSSandrine Bailleux~~~~~~~~~~~~~~~~~~~ 2035d9711feSSandrine Bailleux 2045d9711feSSandrine BailleuxThis CoT is targeted at Arm CCA systems. The Arm CCA security model recommends 2055d9711feSSandrine Bailleuxmaking supply chains for the Arm CCA firmware, the secure world firmware and the 2065d9711feSSandrine Bailleuxplatform owner firmware, independent. Hence, this CoT has 3 roots of trust, one 2075d9711feSSandrine Bailleuxfor each supply chain. 2085d9711feSSandrine Bailleux 20940d553cfSPaul BeesleyTrusted Board Boot Sequence 21040d553cfSPaul Beesley--------------------------- 21140d553cfSPaul Beesley 21240d553cfSPaul BeesleyThe CoT is verified through the following sequence of steps. The system panics 21340d553cfSPaul Beesleyif any of the steps fail. 21440d553cfSPaul Beesley 21540d553cfSPaul Beesley- BL1 loads and verifies the BL2 content certificate. The issuer public key is 21640d553cfSPaul Beesley read from the verified certificate. A hash of that key is calculated and 21740d553cfSPaul Beesley compared with the hash of the ROTPK read from the trusted root-key storage 21840d553cfSPaul Beesley registers. If they match, the BL2 hash is read from the certificate. 21940d553cfSPaul Beesley 220e1c5026aSPaul Beesley .. note:: 221e1c5026aSPaul Beesley The matching operation is platform specific and is currently 22240d553cfSPaul Beesley unimplemented on the Arm development platforms. 22340d553cfSPaul Beesley 22440d553cfSPaul Beesley- BL1 loads the BL2 image. Its hash is calculated and compared with the hash 22540d553cfSPaul Beesley read from the certificate. Control is transferred to the BL2 image if all 22640d553cfSPaul Beesley the comparisons succeed. 22740d553cfSPaul Beesley 22840d553cfSPaul Beesley- BL2 loads and verifies the trusted key certificate. The issuer public key is 22940d553cfSPaul Beesley read from the verified certificate. A hash of that key is calculated and 23040d553cfSPaul Beesley compared with the hash of the ROTPK read from the trusted root-key storage 23140d553cfSPaul Beesley registers. If the comparison succeeds, BL2 reads and saves the trusted and 23240d553cfSPaul Beesley non-trusted world public keys from the verified certificate. 23340d553cfSPaul Beesley 23440d553cfSPaul BeesleyThe next two steps are executed for each of the SCP_BL2, BL31 & BL32 images. 23540d553cfSPaul BeesleyThe steps for the optional SCP_BL2 and BL32 images are skipped if these images 23640d553cfSPaul Beesleyare not present. 23740d553cfSPaul Beesley 23840d553cfSPaul Beesley- BL2 loads and verifies the BL3x key certificate. The certificate signature 23940d553cfSPaul Beesley is verified using the trusted world public key. If the signature 24040d553cfSPaul Beesley verification succeeds, BL2 reads and saves the BL3x public key from the 24140d553cfSPaul Beesley certificate. 24240d553cfSPaul Beesley 24340d553cfSPaul Beesley- BL2 loads and verifies the BL3x content certificate. The signature is 24440d553cfSPaul Beesley verified using the BL3x public key. If the signature verification succeeds, 24540d553cfSPaul Beesley BL2 reads and saves the BL3x image hash from the certificate. 24640d553cfSPaul Beesley 24740d553cfSPaul BeesleyThe next two steps are executed only for the BL33 image. 24840d553cfSPaul Beesley 24940d553cfSPaul Beesley- BL2 loads and verifies the BL33 key certificate. If the signature 25040d553cfSPaul Beesley verification succeeds, BL2 reads and saves the BL33 public key from the 25140d553cfSPaul Beesley certificate. 25240d553cfSPaul Beesley 25340d553cfSPaul Beesley- BL2 loads and verifies the BL33 content certificate. If the signature 25440d553cfSPaul Beesley verification succeeds, BL2 reads and saves the BL33 image hash from the 25540d553cfSPaul Beesley certificate. 25640d553cfSPaul Beesley 25740d553cfSPaul BeesleyThe next step is executed for all the boot loader images. 25840d553cfSPaul Beesley 25940d553cfSPaul Beesley- BL2 calculates the hash of each image. It compares it with the hash obtained 26040d553cfSPaul Beesley from the corresponding content certificate. The image authentication succeeds 26140d553cfSPaul Beesley if the hashes match. 26240d553cfSPaul Beesley 26340d553cfSPaul BeesleyThe Trusted Board Boot implementation spans both generic and platform-specific 26440d553cfSPaul BeesleyBL1 and BL2 code, and in tool code on the host build machine. The feature is 26543f35ef5SPaul Beesleyenabled through use of specific build flags as described in 26643f35ef5SPaul Beesley:ref:`Build Options`. 26740d553cfSPaul Beesley 26840d553cfSPaul BeesleyOn the host machine, a tool generates the certificates, which are included in 26940d553cfSPaul Beesleythe FIP along with the boot loader images. These certificates are loaded in 27040d553cfSPaul BeesleyTrusted SRAM using the IO storage framework. They are then verified by an 27140d553cfSPaul BeesleyAuthentication module included in TF-A. 27240d553cfSPaul Beesley 27340d553cfSPaul BeesleyThe mechanism used for generating the FIP and the Authentication module are 27440d553cfSPaul Beesleydescribed in the following sections. 27540d553cfSPaul Beesley 27640d553cfSPaul BeesleyAuthentication Framework 27740d553cfSPaul Beesley------------------------ 27840d553cfSPaul Beesley 27940d553cfSPaul BeesleyThe authentication framework included in TF-A provides support to implement 28040d553cfSPaul Beesleythe desired trusted boot sequence. Arm platforms use this framework to 28134760951SPaul Beesleyimplement the boot requirements specified in the 28234760951SPaul Beesley`Trusted Board Boot Requirements (TBBR)`_ document. 28340d553cfSPaul Beesley 28440d553cfSPaul BeesleyMore information about the authentication framework can be found in the 28534760951SPaul Beesley:ref:`Authentication Framework & Chain of Trust` document. 28640d553cfSPaul Beesley 28740d553cfSPaul BeesleyCertificate Generation Tool 28840d553cfSPaul Beesley--------------------------- 28940d553cfSPaul Beesley 29040d553cfSPaul BeesleyThe ``cert_create`` tool is built and runs on the host machine as part of the 29140d553cfSPaul BeesleyTF-A build process when ``GENERATE_COT=1``. It takes the boot loader images 292616b3ce2SRobin van der Grachtand keys as inputs and generates the certificates (in DER format) required to 293616b3ce2SRobin van der Grachtestablish the CoT. The input keys must either be a file in PEM format or a 294616b3ce2SRobin van der GrachtPKCS11 URI in case a HSM is used. New keys can be generated by the tool in 295616b3ce2SRobin van der Grachtcase they are not provided. The certificates are then passed as inputs to 296616b3ce2SRobin van der Grachtthe ``fiptool`` utility for creating the FIP. 29740d553cfSPaul Beesley 298316c5cc6SSandrine BailleuxThe certificates are also stored individually in the output build directory. 29940d553cfSPaul Beesley 30043f35ef5SPaul BeesleyThe tool resides in the ``tools/cert_create`` directory. It uses the OpenSSL SSL 30143f35ef5SPaul Beesleylibrary version to generate the X.509 certificates. The specific version of the 30243f35ef5SPaul Beesleylibrary that is required is given in the :ref:`Prerequisites` document. 30343f35ef5SPaul Beesley 30443f35ef5SPaul BeesleyInstructions for building and using the tool can be found at 30543f35ef5SPaul Beesley:ref:`tools_build_cert_create`. 30640d553cfSPaul Beesley 307f97062a5SSumit GargAuthenticated Encryption Framework 308f97062a5SSumit Garg---------------------------------- 309f97062a5SSumit Garg 310f97062a5SSumit GargThe authenticated encryption framework included in TF-A provides support to 311f97062a5SSumit Gargimplement the optional firmware encryption feature. This feature can be 312f97062a5SSumit Gargoptionally enabled on platforms to implement the optional requirement: 313f97062a5SSumit GargR060_TBBR_FUNCTION as specified in the `Trusted Board Boot Requirements (TBBR)`_ 314f97062a5SSumit Gargdocument. 315f97062a5SSumit Garg 316f97062a5SSumit GargFirmware Encryption Tool 317f97062a5SSumit Garg------------------------ 318f97062a5SSumit Garg 319f97062a5SSumit GargThe ``encrypt_fw`` tool is built and runs on the host machine as part of the 320f97062a5SSumit GargTF-A build process when ``DECRYPTION_SUPPORT != none``. It takes the plain 321f97062a5SSumit Gargfirmware image as input and generates the encrypted firmware image which can 322f97062a5SSumit Gargthen be passed as input to the ``fiptool`` utility for creating the FIP. 323f97062a5SSumit Garg 324f97062a5SSumit GargThe encrypted firmwares are also stored individually in the output build 325f97062a5SSumit Gargdirectory. 326f97062a5SSumit Garg 327f97062a5SSumit GargThe tool resides in the ``tools/encrypt_fw`` directory. It uses OpenSSL SSL 328f97062a5SSumit Garglibrary version 1.0.1 or later to do authenticated encryption operation. 329f97062a5SSumit GargInstructions for building and using the tool can be found in the 330f97062a5SSumit Garg:ref:`tools_build_enctool`. 331f97062a5SSumit Garg 33240d553cfSPaul Beesley-------------- 33340d553cfSPaul Beesley 334*4639f890SRyan Everett*Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved.* 33540d553cfSPaul Beesley 33640d553cfSPaul Beesley.. _X.509 v3: https://tools.ietf.org/rfc/rfc5280.txt 3374290d343SSandrine Bailleux.. _Trusted Board Boot Requirements (TBBR): https://developer.arm.com/docs/den0006/latest 338