trusted-board-boot.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. Trusted Board Boot
  2. ==================
  3. The `Trusted Board Boot` (TBB) feature prevents malicious firmware from running
  4. on the platform by authenticating all firmware images up to and including the
  5. normal world bootloader. It does this by establishing a `Chain of Trust` using
  6. Public-Key-Cryptography Standards (PKCS).
  7. This document describes the design of Trusted Firmware-A (TF-A) TBB, which is an
  8. implementation of the `Trusted Board Boot Requirements (TBBR)`_ specification,
  9. Arm DEN0006D. It should be used in conjunction with the :ref:`Firmware Update
  10. (FWU)` design document, which implements a specific aspect of the TBBR.
  11. Chain of Trust
  12. --------------
  13. A Chain of Trust (CoT) starts with a set of implicitly trusted components, which
  14. are used to establish trust in the next layer of components, and so on, in a
  15. `chained` manner.
  16. The chain of trust depends on several factors, including:
  17. - The set of firmware images in use on this platform.
  18. Typically, most platforms share a common set of firmware images (BL1, BL2,
  19. BL31, BL33) but extra platform-specific images might be required.
  20. - The key provisioning scheme: which keys need to programmed into the device
  21. and at which stage during the platform's manufacturing lifecycle.
  22. - The key ownership model: who owns which key.
  23. As these vary across platforms, chains of trust also vary across
  24. platforms. Although each platform is free to define its own CoT based on its
  25. needs, TF-A provides a set of "default" CoTs fitting some typical trust models,
  26. which platforms may reuse. The rest of this section presents general concepts
  27. which apply to all these default CoTs.
  28. The implicitly trusted components forming the trust anchor are:
  29. - A Root of Trust Public Key (ROTPK), or a hash of it.
  30. On Arm development platforms, a SHA-256 hash of the ROTPK is stored in the
  31. trusted root-key storage registers. Alternatively, a development ROTPK might
  32. be used and its hash embedded into the BL1 and BL2 images (only for
  33. development purposes).
  34. - The BL1 image, on the assumption that it resides in ROM so cannot be
  35. tampered with.
  36. The remaining components in the CoT are either certificates or boot loader
  37. images. The certificates follow the `X.509 v3`_ standard. This standard
  38. enables adding custom extensions to the certificates, which are used to store
  39. essential information to establish the CoT.
  40. All certificates are self-signed. There is no need for a Certificate Authority
  41. (CA) because the CoT is not established by verifying the validity of a
  42. certificate's issuer but by the content of the certificate extensions. To sign
  43. the certificates, different signature schemes are available, please refer to the
  44. :ref:`Build Options` for more details.
  45. The certificates are categorised as "Key" and "Content" certificates. Key
  46. certificates are used to verify public keys which have been used to sign content
  47. certificates. Content certificates are used to store the hash of a boot loader
  48. image. An image can be authenticated by calculating its hash and matching it
  49. with the hash extracted from the content certificate. Various hash algorithms
  50. are supported to calculate all hashes, please refer to the :ref:`Build Options`
  51. for more details. The public keys and hashes are included as non-standard
  52. extension fields in the `X.509 v3`_ certificates.
  53. The next sections now present specificities of each default CoT provided in
  54. TF-A.
  55. Default CoT #1: TBBR
  56. ~~~~~~~~~~~~~~~~~~~~
  57. The `TBBR` CoT is named after the specification it follows to the letter.
  58. In the TBBR CoT, all firmware binaries and certificates are (directly or
  59. indirectly) linked to the Root of Trust Public Key (ROTPK). Typically, the same
  60. vendor owns the ROTPK, the Trusted key and the Non-Trusted Key. Thus, this vendor
  61. is involved in signing every BL3x Key Certificate.
  62. The keys used to establish this CoT are:
  63. - **Root of trust key**
  64. The private part of this key is used to sign the trusted boot firmware
  65. certificate and the trusted key certificate. The public part is the ROTPK.
  66. - **Trusted world key**
  67. The private part is used to sign the key certificates corresponding to the
  68. secure world images (SCP_BL2, BL31 and BL32). The public part is stored in
  69. one of the extension fields in the trusted key certificate.
  70. - **Non-trusted world key**
  71. The private part is used to sign the key certificate corresponding to the
  72. non-secure world image (BL33). The public part is stored in one of the
  73. extension fields in the trusted key certificate.
  74. - **BL3X keys**
  75. For each of SCP_BL2, BL31, BL32 and BL33, the private part is used to
  76. sign the content certificate for the BL3X image. The public part is stored
  77. in one of the extension fields in the corresponding key certificate.
  78. The following images are included in the CoT:
  79. - BL1
  80. - BL2
  81. - SCP_BL2 (optional)
  82. - BL31
  83. - BL33
  84. - BL32 (optional)
  85. The following certificates are used to authenticate the images.
  86. - **Trusted boot firmware certificate**
  87. It is self-signed with the private part of the ROT key. It contains a hash of
  88. the BL2 image and hashes of various firmware configuration files
  89. (TB_FW_CONFIG, HW_CONFIG, FW_CONFIG).
  90. - **Trusted key certificate**
  91. It is self-signed with the private part of the ROT key. It contains the
  92. public part of the trusted world key and the public part of the non-trusted
  93. world key.
  94. - **SCP firmware key certificate**
  95. It is self-signed with the trusted world key. It contains the public part of
  96. the SCP_BL2 key.
  97. - **SCP firmware content certificate**
  98. It is self-signed with the SCP_BL2 key. It contains a hash of the SCP_BL2
  99. image.
  100. - **SoC firmware key certificate**
  101. It is self-signed with the trusted world key. It contains the public part of
  102. the BL31 key.
  103. - **SoC firmware content certificate**
  104. It is self-signed with the BL31 key. It contains hashes of the BL31 image and
  105. its configuration file (SOC_FW_CONFIG).
  106. - **Trusted OS key certificate**
  107. It is self-signed with the trusted world key. It contains the public part of
  108. the BL32 key.
  109. - **Trusted OS content certificate**
  110. It is self-signed with the BL32 key. It contains hashes of the BL32 image(s)
  111. and its configuration file(s) (TOS_FW_CONFIG).
  112. - **Non-trusted firmware key certificate**
  113. It is self-signed with the non-trusted world key. It contains the public
  114. part of the BL33 key.
  115. - **Non-trusted firmware content certificate**
  116. It is self-signed with the BL33 key. It contains hashes of the BL33 image and
  117. its configuration file (NT_FW_CONFIG).
  118. The SCP firmware and Trusted OS certificates are optional, but they must be
  119. present if the corresponding SCP_BL2 or BL32 images are present.
  120. The following diagram summarizes the part of the TBBR CoT enforced by BL2. Some
  121. images (SCP, debug certificates, secure partitions, configuration files) are not
  122. shown here for conciseness:
  123. .. image:: ../resources/diagrams/cot-tbbr.jpg
  124. Default CoT #2: Dualroot
  125. ~~~~~~~~~~~~~~~~~~~~~~~~
  126. The `dualroot` CoT is targeted at systems where the Normal World firmware is
  127. owned by a different entity than the Secure World Firmware, and those 2 entities
  128. do not wish to share any keys or have any dependency between each other when it
  129. comes to signing their respective images. It establishes 2 separate signing
  130. domains, each with its own Root of Trust key. In that sense, this CoT has 2
  131. roots of trust, hence the `dualroot` name.
  132. Although the dualroot CoT reuses some of the TBBR CoT components and concepts,
  133. it differs on the BL33 image's chain of trust, which is rooted into a new key,
  134. called `Platform ROTPK`, or `PROTPK` for short.
  135. The following diagram summarizes the part of the dualroot CoT enforced by
  136. BL2. Some images (SCP, debug certificates, secure partitions, configuration
  137. files) are not shown here for conciseness:
  138. .. image:: ../resources/diagrams/cot-dualroot.jpg
  139. Default CoT #3: CCA
  140. ~~~~~~~~~~~~~~~~~~~
  141. This CoT is targeted at Arm CCA systems. The Arm CCA security model recommends
  142. making supply chains for the Arm CCA firmware, the secure world firmware and the
  143. platform owner firmware, independent. Hence, this CoT has 3 roots of trust, one
  144. for each supply chain.
  145. Trusted Board Boot Sequence
  146. ---------------------------
  147. The CoT is verified through the following sequence of steps. The system panics
  148. if any of the steps fail.
  149. - BL1 loads and verifies the BL2 content certificate. The issuer public key is
  150. read from the verified certificate. A hash of that key is calculated and
  151. compared with the hash of the ROTPK read from the trusted root-key storage
  152. registers. If they match, the BL2 hash is read from the certificate.
  153. .. note::
  154. The matching operation is platform specific and is currently
  155. unimplemented on the Arm development platforms.
  156. - BL1 loads the BL2 image. Its hash is calculated and compared with the hash
  157. read from the certificate. Control is transferred to the BL2 image if all
  158. the comparisons succeed.
  159. - BL2 loads and verifies the trusted key certificate. The issuer public key is
  160. read from the verified certificate. A hash of that key is calculated and
  161. compared with the hash of the ROTPK read from the trusted root-key storage
  162. registers. If the comparison succeeds, BL2 reads and saves the trusted and
  163. non-trusted world public keys from the verified certificate.
  164. The next two steps are executed for each of the SCP_BL2, BL31 & BL32 images.
  165. The steps for the optional SCP_BL2 and BL32 images are skipped if these images
  166. are not present.
  167. - BL2 loads and verifies the BL3x key certificate. The certificate signature
  168. is verified using the trusted world public key. If the signature
  169. verification succeeds, BL2 reads and saves the BL3x public key from the
  170. certificate.
  171. - BL2 loads and verifies the BL3x content certificate. The signature is
  172. verified using the BL3x public key. If the signature verification succeeds,
  173. BL2 reads and saves the BL3x image hash from the certificate.
  174. The next two steps are executed only for the BL33 image.
  175. - BL2 loads and verifies the BL33 key certificate. If the signature
  176. verification succeeds, BL2 reads and saves the BL33 public key from the
  177. certificate.
  178. - BL2 loads and verifies the BL33 content certificate. If the signature
  179. verification succeeds, BL2 reads and saves the BL33 image hash from the
  180. certificate.
  181. The next step is executed for all the boot loader images.
  182. - BL2 calculates the hash of each image. It compares it with the hash obtained
  183. from the corresponding content certificate. The image authentication succeeds
  184. if the hashes match.
  185. The Trusted Board Boot implementation spans both generic and platform-specific
  186. BL1 and BL2 code, and in tool code on the host build machine. The feature is
  187. enabled through use of specific build flags as described in
  188. :ref:`Build Options`.
  189. On the host machine, a tool generates the certificates, which are included in
  190. the FIP along with the boot loader images. These certificates are loaded in
  191. Trusted SRAM using the IO storage framework. They are then verified by an
  192. Authentication module included in TF-A.
  193. The mechanism used for generating the FIP and the Authentication module are
  194. described in the following sections.
  195. Authentication Framework
  196. ------------------------
  197. The authentication framework included in TF-A provides support to implement
  198. the desired trusted boot sequence. Arm platforms use this framework to
  199. implement the boot requirements specified in the
  200. `Trusted Board Boot Requirements (TBBR)`_ document.
  201. More information about the authentication framework can be found in the
  202. :ref:`Authentication Framework & Chain of Trust` document.
  203. Certificate Generation Tool
  204. ---------------------------
  205. The ``cert_create`` tool is built and runs on the host machine as part of the
  206. TF-A build process when ``GENERATE_COT=1``. It takes the boot loader images
  207. and keys as inputs and generates the certificates (in DER format) required to
  208. establish the CoT. The input keys must either be a file in PEM format or a
  209. PKCS11 URI in case a HSM is used. New keys can be generated by the tool in
  210. case they are not provided. The certificates are then passed as inputs to
  211. the ``fiptool`` utility for creating the FIP.
  212. The certificates are also stored individually in the output build directory.
  213. The tool resides in the ``tools/cert_create`` directory. It uses the OpenSSL SSL
  214. library version to generate the X.509 certificates. The specific version of the
  215. library that is required is given in the :ref:`Prerequisites` document.
  216. Instructions for building and using the tool can be found at
  217. :ref:`tools_build_cert_create`.
  218. Authenticated Encryption Framework
  219. ----------------------------------
  220. The authenticated encryption framework included in TF-A provides support to
  221. implement the optional firmware encryption feature. This feature can be
  222. optionally enabled on platforms to implement the optional requirement:
  223. R060_TBBR_FUNCTION as specified in the `Trusted Board Boot Requirements (TBBR)`_
  224. document.
  225. Firmware Encryption Tool
  226. ------------------------
  227. The ``encrypt_fw`` tool is built and runs on the host machine as part of the
  228. TF-A build process when ``DECRYPTION_SUPPORT != none``. It takes the plain
  229. firmware image as input and generates the encrypted firmware image which can
  230. then be passed as input to the ``fiptool`` utility for creating the FIP.
  231. The encrypted firmwares are also stored individually in the output build
  232. directory.
  233. The tool resides in the ``tools/encrypt_fw`` directory. It uses OpenSSL SSL
  234. library version 1.0.1 or later to do authenticated encryption operation.
  235. Instructions for building and using the tool can be found in the
  236. :ref:`tools_build_enctool`.
  237. --------------
  238. *Copyright (c) 2015-2020, Arm Limited and Contributors. All rights reserved.*
  239. .. _X.509 v3: https://tools.ietf.org/rfc/rfc5280.txt
  240. .. _Trusted Board Boot Requirements (TBBR): https://developer.arm.com/docs/den0006/latest