David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 1 | ####################################### |
| 2 | Trusted Firmware-M Profile Small Design |
| 3 | ####################################### |
| 4 | |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 5 | ************ |
| 6 | Introduction |
| 7 | ************ |
| 8 | |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 9 | As one of the TF-M Profiles, TF-M Profile Small (Profile S) consists of |
| 10 | lightweight TF-M framework and basic Secure Services to keep smallest memory |
| 11 | footprint, supporting fundamental security features on devices with ultra |
| 12 | constrained resource. |
| 13 | |
| 14 | This profile enables connecting with Edge Gateways and IoT Cloud Services |
| 15 | supporting secure connection based solely on symmetric cryptography. |
| 16 | |
| 17 | This document summarizes and discusses the features specified in TF-M Profile |
| 18 | Small. |
| 19 | |
| 20 | ************** |
| 21 | Overall design |
| 22 | ************** |
| 23 | |
| 24 | TF-M Profile Small defines the following features: |
| 25 | |
| 26 | - Lightweight framework |
| 27 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 28 | - Secure Function (SFN) model [2]_ |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 29 | - Level 1 isolation |
| 30 | - Buffer sharing allowed |
| 31 | - Single secure context |
| 32 | |
| 33 | - Crypto |
| 34 | |
| 35 | - Symmetric cipher only |
| 36 | - Cipher suite for symmetric-key algorithms based protocols, such as |
| 37 | cipher suites defined in TLS pre-shared key (TLS-PSK) [1]_. |
| 38 | |
| 39 | - Advanced Encryption Standard (AES) as symmetric crypto algorithm |
| 40 | - SHA256 as Hash function |
| 41 | - HMAC as Message Authentication Code algorithm |
David Hu | e69294d | 2022-06-21 22:21:37 +0800 | [diff] [blame] | 42 | - Only enable multi-part functions in hash, symmetric ciphers, |
| 43 | Message Authentication Code (MAC) and Authenticated Encryption with |
| 44 | Associated Data (AEAD) operations. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 45 | |
| 46 | - Internal Trusted Storage (ITS) |
| 47 | |
| 48 | - No encryption |
| 49 | - No rollback protection |
| 50 | - Decrease internal transient buffer size |
| 51 | |
| 52 | - Initial Attestation |
| 53 | |
| 54 | - Based on symmetric key algorithms |
| 55 | |
| 56 | - Lightweight boot |
| 57 | |
| 58 | - Single image boot |
| 59 | - Anti-rollback protection is enabled |
| 60 | |
| 61 | |
Summer Qin | 369d1e9 | 2022-10-13 14:48:16 +0800 | [diff] [blame] | 62 | Protected Storage, firmware update and other Secure Services provided by TF-M are |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 63 | disabled by default. |
| 64 | |
| 65 | ************** |
| 66 | Design details |
| 67 | ************** |
| 68 | |
| 69 | More details of TF-M Profile Small design are discussed in following sections. |
| 70 | |
| 71 | Lightweight framework |
| 72 | ===================== |
| 73 | |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 74 | TF-M framework model |
| 75 | -------------------- |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 76 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 77 | SFN model is selected by default in Profile Small implementation. |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 78 | SFN model is defined in FF-M 1.1 extensions [2]_. It is a more simple |
| 79 | implementation of TF-M framework and may also reduce memory footprint, compared |
| 80 | with Inter-Process Communication (IPC) model [3]_. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 81 | |
| 82 | Level 1 isolation |
| 83 | ----------------- |
| 84 | |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 85 | PSA Security Model [4]_ defines 3 levels of isolation. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 86 | |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 87 | - Level 1 isolation isolates Secure Processing Environment (SPE) from |
| 88 | Non-secure Processing Environment (NSPE). |
| 89 | - PSA Root of Trust (PSA RoT) and Application Root of Trust (ARoT) are |
| 90 | isolated from each other in level 2 isolation. |
| 91 | - Individual secure partitions are isolated from each other even within a |
| 92 | particular security domain (PSA RoT, ARoT), in level 3 isolation. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 93 | |
| 94 | Profile Small dedicated use cases with simple service model may not require |
| 95 | level 2 or level 3 isolation. Devices which Profile Small aims at may be unable |
| 96 | to implement stricter isolation, limited by hardware capabilities. |
| 97 | |
| 98 | Level 1 isolation reduces requirements enforced by hardware isolation and cost |
| 99 | of software for management. |
| 100 | |
| 101 | .. note :: |
| 102 | |
| 103 | **Security note** |
| 104 | |
| 105 | If a device or a use case enforces level 2 or level 3 isolation, it is |
| 106 | suggested to apply other configurations, other than TF-M Profile Small. |
| 107 | |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 108 | Crypto service |
| 109 | ============== |
| 110 | |
| 111 | TF-M Profile Small only requires symmetric crypto since symmetric algorithms |
| 112 | require shorter keys and less computational burden, compared with asymmetric |
| 113 | crypto. |
| 114 | |
| 115 | By default, TF-M Profile Small requires the same capabilities as defined in |
| 116 | TLS-PSK, to support symmetric key algorithms based protocols. |
| 117 | |
| 118 | .. note :: |
| 119 | |
| 120 | **Implementation note** |
| 121 | |
| 122 | Please note that TF-M Profile Small doesn't require that TLS-PSK is |
| 123 | mandatory in applications. Instead, Profile Small only requires the same |
| 124 | capabilities as defined in TLS-PSK, such as one symmetric cipher algorithm |
| 125 | and one hash function. |
| 126 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 127 | TF-M Profile Small selects TLS-PSK cipher suite TLS_PSK_WITH_AES_128_CCM [5]_ |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 128 | as reference, which requires: |
| 129 | |
| 130 | - AES-128-CCM (AES CCM mode with 128-bit key) as symmetric crypto algorithm |
| 131 | - SHA256 as Hash function |
| 132 | - HMAC as Message Authentication Code algorithm |
| 133 | |
| 134 | TLS_PSK_WITH_AES_128_CCM is selected since it requires small key length and less |
| 135 | hardware capabilities, while keeping enough level of security. |
| 136 | |
| 137 | .. note :: |
| 138 | |
| 139 | **Implementation note** |
| 140 | |
| 141 | Developers can replace default algorithms with others or implement more |
| 142 | algorithms. |
| 143 | |
| 144 | Proper symmetric key algorithms and cipher suites should be selected |
| 145 | according to device capabilities, the use case and the requirement of peers |
| 146 | in connection. |
| 147 | |
| 148 | Refer to `Crypto service configuration`_ for implementation details of |
| 149 | configuring algorithms and cipher suites. |
| 150 | |
| 151 | .. note :: |
| 152 | |
| 153 | **Security note** |
| 154 | |
| 155 | It is recommended not to use MD5 or SHA-1 for message digests as they are |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 156 | subject to collision attacks [6]_ [7]_. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 157 | |
David Hu | e69294d | 2022-06-21 22:21:37 +0800 | [diff] [blame] | 158 | By default, Profile Small only enables multi-part functions defined in PSA |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 159 | Cryptography API [13]_ in hash, symmetric ciphers, MAC and AEAD operations. |
David Hu | e69294d | 2022-06-21 22:21:37 +0800 | [diff] [blame] | 160 | Disabling single-part functions optimizes the code size of TF-M crypto service. |
| 161 | Multi-part operations allows the message data to be processed in fragments |
| 162 | instead of all at once. In static memory allocation, single-part operation may |
| 163 | require to allocate a large memory space to support long message with unknown |
| 164 | length. Therefore single-part operations can help users optimize memory |
| 165 | footprint, especially while dealing with streaming data on IoT devices. |
| 166 | |
| 167 | It may slightly increase the code size in applications to replace single-part |
| 168 | implementation with mulit-part implementation. Althgouth the code size increment |
| 169 | can be qaulified, if users are concerned about the code size increment, they can |
| 170 | enable single-part operations by toggling Profile Small default configuration. |
| 171 | |
| 172 | It may increase latency and overall time cost to implement cryptography |
| 173 | functionality with single-part operations, compared to with multi-part ones. |
| 174 | Users can enable single-part operations if the usage scenario requires |
| 175 | single-part opreations to meet its perfermance metrics. |
| 176 | |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 177 | Secure Storage |
| 178 | ============== |
| 179 | |
| 180 | TF-M Profile Small assumes that extremely constrained devices only contain basic |
| 181 | on-chip storage, without external or removable storage. |
| 182 | As a result, TF-M Profile Small includes ITS service and disables Protected |
| 183 | Storage service. |
| 184 | |
| 185 | Encryption and rollback protection |
| 186 | ---------------------------------- |
| 187 | |
| 188 | Neither encryption nor rollback protection is enabled in current ITS |
| 189 | implementation. |
| 190 | |
| 191 | It is expected that ITS relies solely on the physical inaccessibility property |
| 192 | of on-chip storage, together with PSA isolation, without requiring additional |
| 193 | cryptographic protection. |
| 194 | |
| 195 | Internal transient buffer |
| 196 | ------------------------- |
| 197 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 198 | ITS implements a internal transient buffer [8]_ to hold the data read |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 199 | from/written to storage, especially for flash, to solve the alignment and |
| 200 | security issues. |
| 201 | |
| 202 | The internal transient buffer is aligned to the flash device’s program unit. |
| 203 | Copying data to it from the caller can align all write requests to the flash |
| 204 | device’s program unit. |
| 205 | The internal transient buffer can help protect Flash access from some attacks, |
| 206 | such as TOCTOU attack. |
| 207 | |
| 208 | Although removing this internal buffer can save some memory consumption, |
| 209 | typically 512 bytes, it may bring alignment or security issues. |
| 210 | Therefore, to achieve a better trade-off between memory footprint and security, |
| 211 | TF-M Profile Small optimizes the internal buffer size to 32 bytes by default. |
| 212 | |
| 213 | As discussed in `Crypto service`_, TF-M Profile Small requires AES-128 and |
| 214 | SHA-256, which use 128-bit key and 256-bit key respectively. |
| 215 | Besides, either long public/private keys or PKI-based certificates should be |
| 216 | very rare as asymmetric crypto is not supported in Profile Small. |
| 217 | Therefore, a 32-byte internal buffer should cover the assets in TF-M Profile |
| 218 | Small use cases. |
| 219 | |
| 220 | The buffer size can be adjusted according to use case and device Flash |
| 221 | attributes. Refer to `Internal Trusted Storage configurations`_ for more |
| 222 | details. |
| 223 | |
| 224 | Initial Attestation |
| 225 | =================== |
| 226 | |
| 227 | Profile Small requires an Initial Attestation secure service based on symmetric |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 228 | key algorithms. Refer to PSA Attestation API document [9]_ for details of |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 229 | Initial Attestation based on symmetric key algorithms. |
| 230 | |
| 231 | It can heavily increase memory footprint to support Initial Attestation based on |
| 232 | asymmetric key algorithms, due to asymmetric ciphers and related PKI modules. |
| 233 | |
| 234 | .. note :: |
| 235 | |
| 236 | **Implementation note** |
| 237 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 238 | As pointed out by PSA Attestation API document [9]_, the use cases of |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 239 | Initial Attestation based on symmetric key algorithms can be limited due to |
| 240 | the associated infrastructure costs for key management and operational |
| 241 | complexities. It may also restrict the ability to interoperate with |
| 242 | scenarios that involve third parties. |
| 243 | |
| 244 | If asymmetric key algorithms based Initial Attestation is required in use |
| 245 | scenarios, it is recommended to select other TF-M Profiles which support |
| 246 | asymmetric key algorithms. |
| 247 | |
| 248 | .. note :: |
| 249 | |
| 250 | **Implementation note** |
| 251 | |
| 252 | It is recommended to utilize the same MAC algorithm supported in Crypto |
| 253 | service to complete the signing in ``COSE_Mac0``, to minimize memory |
| 254 | footprint. |
| 255 | |
| 256 | Lightweight boot |
| 257 | ================ |
| 258 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 259 | If MCUBoot provided by TF-M is enabled, single image boot [10]_ is selected by |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 260 | default in Profile Small. |
| 261 | In case of single image boot, secure and non-secure images are handled as a |
| 262 | single blob and signed together during image generation. |
| 263 | |
| 264 | However, secure and non-secure images must be updated together in single image |
| 265 | boot. It may decrease the flexibility of image update and cost longer update |
| 266 | process. Since the image sizes should usually be small with limited |
| 267 | functionalities in Profile Small dedicated use case, the cost may still be |
| 268 | reasonable. |
| 269 | |
| 270 | BL2 implementation can be device specific. Devices may implement diverse |
| 271 | boot processes with different features and configurations. |
| 272 | However, anti-rollback protection is required as a mandatory feature of boot |
| 273 | loader. Boot loader should be able to prevent unauthorized rollback, to protect |
| 274 | devices from being downgraded to earlier versions with known vulnerabilities. |
| 275 | |
| 276 | ************** |
| 277 | Implementation |
| 278 | ************** |
| 279 | |
| 280 | Overview |
| 281 | ======== |
| 282 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 283 | The basic idea is to add dedicated profile CMake configuration files under |
| 284 | folder ``config/profile`` for TF-M Profile Small default configuration. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 285 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 286 | The top-level Profile Small config file collects all the necessary |
| 287 | configuration flags and set them to default values, to explicitly enable the |
| 288 | features required in Profile Small and disable the unnecessary ones, during |
| 289 | TF-M build. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 290 | |
| 291 | A platform/use case can provide a configuration extension file to overwrite |
| 292 | Profile Small default setting and append other configurations. |
| 293 | This configuration extension file can be added via parameter |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 294 | ``TFM_EXTRA_CONFIG_PATH`` in build command line. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 295 | |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 296 | The behavior of the Profile Small build flow (particularly the order of |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 297 | configuration loading and overriding) can be found at |
| 298 | :ref:`tfm_cmake_configuration` |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 299 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 300 | The details of configurations will be covered in each module in |
| 301 | `Implementation details`_. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 302 | |
| 303 | Implementation details |
| 304 | ====================== |
| 305 | |
| 306 | This section discusses the details of Profile Small implementation. |
| 307 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 308 | Top-level configuration files |
| 309 | ----------------------------- |
| 310 | |
| 311 | The firmware framework configurations in ``config/profile/profile_small`` are |
| 312 | shown below. |
| 313 | |
| 314 | .. table:: TFM options in Profile Small top-level CMake config file |
| 315 | :widths: auto |
| 316 | :align: center |
| 317 | |
| 318 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
| 319 | | Configs | Default value | Descriptions | |
| 320 | +============================================+=====================================================================================================+=====================================+ |
| 321 | | ``TFM_ISOLATION_LEVEL`` | ``1`` | Select level 2 isolation | |
| 322 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 323 | | ``TFM_PARTITION_INTERNAL_TRUSTED_STORAGE`` | ``ON`` | Enable ITS SP | |
| 324 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
| 325 | | ``ITS_BUF_SIZE`` | ``32`` | ITS internal transient buffer size | |
| 326 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
| 327 | | ``TFM_PARTITION_CRYPTO`` | ``ON`` | Enable Crypto service | |
| 328 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
| 329 | | ``TFM_MBEDCRYPTO_CONFIG_PATH`` | ``${CMAKE_SOURCE_DIR}/lib/ext/mbedcrypto/mbedcrypto_config/tfm_mbedcrypto_config_profile_small.h`` | Mbed Crypto config file path | |
| 330 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
Summer Qin | b898d81 | 2022-06-08 15:01:35 +0800 | [diff] [blame] | 331 | | ``TFM_MBEDCRYPTO_PSA_CRYPTO_CONFIG_PATH`` | ``${CMAKE_SOURCE_DIR}/lib/ext/mbedcrypto/mbedcrypto_config/crypto_config_profile_small.h`` | Mbed Crypto PSA config file path | |
| 332 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
Jianliang Shen | 78ca8d4 | 2022-11-16 17:33:18 +0800 | [diff] [blame] | 333 | | ``CRYPTO_ASYM_SIGN_MODULE_ENABLED`` | ``OFF`` | Enable asymmetric signature | |
David Hu | 0c250bc | 2021-05-12 10:55:53 +0800 | [diff] [blame] | 334 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
Jianliang Shen | 78ca8d4 | 2022-11-16 17:33:18 +0800 | [diff] [blame] | 335 | | ``CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED`` | ``OFF`` | Enable asymmetric encryption | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 336 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
| 337 | | ``TFM_PARTITION_INITIAL_ATTESTATION`` | ``ON`` | Enable Initial Attestation service | |
| 338 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
| 339 | | ``SYMMETRIC_INITIAL_ATTESTATION`` | ``ON`` | Enable symmetric attestation | |
| 340 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
| 341 | | ``TFM_PARTITION_PROTECTED_STORAGE`` | ``OFF`` | Enable PS service | |
| 342 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
| 343 | | ``TFM_PARTITION_PLATFORM`` | ``OFF`` | Enable TF-M Platform SP | |
| 344 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 345 | |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 346 | .. note :: |
| 347 | |
| 348 | **Implementation note** |
| 349 | |
| 350 | The following sections focus on the feature selection via configuration |
| 351 | setting. |
| 352 | Dedicated optimization on memory footprint is not covered in this document. |
| 353 | |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 354 | Device configuration extension |
| 355 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 356 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 357 | To change default configurations and add platform specific configurations, |
| 358 | a platform can add a platform configuration file at |
| 359 | ``platform/ext<TFM_PLATFORM>/config.cmake`` |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 360 | |
| 361 | TF-M framework setting |
| 362 | ---------------------- |
| 363 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 364 | The top-level Profile Small CMake config file selects SFN model and level 1 |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 365 | isolation. |
| 366 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 367 | In SFN model, ``-DPSA_FRAMEWORK_HAS_MM_IOVEC`` is enabled by default. |
| 368 | It reduces memory footprint by avoiding the transient copy from input |
Sherry Zhang | b1dcfe4 | 2022-05-19 10:46:49 +0800 | [diff] [blame] | 369 | vectors and copy to output vectors. |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 370 | |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 371 | Crypto service configuration |
| 372 | ---------------------------- |
| 373 | |
| 374 | Crypto Secure Partition |
| 375 | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 376 | |
| 377 | TF-M Profile Small enables Crypto Secure Partition (SP) in its top-level CMake |
| 378 | config file. Crypto SP modules not supported in TF-M Profile Small are disabled. |
David Hu | e69294d | 2022-06-21 22:21:37 +0800 | [diff] [blame] | 379 | The disabled modules/features are shown below. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 380 | |
| 381 | - Disable asymmetric cipher |
David Hu | e69294d | 2022-06-21 22:21:37 +0800 | [diff] [blame] | 382 | - Disable single-part operations in Hash, MAC, AEAD and symmetric ciphers |
| 383 | via selecting ``CRYPTO_SINGLE_PART_FUNCS_DISABLED`` |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 384 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 385 | Other modules and configurations [11]_ are kept as default values. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 386 | |
| 387 | Additional configuration flags with more fine granularity can be added to |
| 388 | control building of specific crypto algorithms and corresponding test cases. |
| 389 | |
| 390 | Mbed Crypto configurations |
| 391 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 392 | |
| 393 | TF-M Profile Small adds a dedicated Mbed Crypto config file |
Summer Qin | b898d81 | 2022-06-08 15:01:35 +0800 | [diff] [blame] | 394 | ``tfm_mbedcrypto_config_profile_small.h`` and Mbed Crypto PSA config file |
| 395 | ``crypto_config_profile_small.h`` at ``/lib/ext/mbedcrypto/mbedcrypto_config`` |
| 396 | folder, instead of the common one ``tfm_mbedcrypto_config_default.h`` and |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 397 | ``crypto_config_default.h`` [11]_. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 398 | |
| 399 | Major Mbed Crypto configurations are set as listed below: |
| 400 | |
| 401 | - Enable SHA256 |
| 402 | - Enable generic message digest wrappers |
| 403 | - Enable AES |
| 404 | - Enable CCM mode for symmetric ciphers |
| 405 | - Disable other modes for symmetric ciphers |
| 406 | - Disable asymmetric ciphers |
| 407 | - Disable HMAC-based key derivation function (HKDF) |
| 408 | |
| 409 | Other configurations can be selected to optimize the memory footprint of Crypto |
| 410 | module. |
| 411 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 412 | A device/use case can append an extra config header to the Profile Small |
| 413 | default Mbed Crypto config file. This can be done by setting the |
| 414 | ``TFM_MBEDCRYPTO_PLATFORM_EXTRA_CONFIG_PATH`` cmake variable in the platform |
| 415 | config file ``platform/ext<TFM_PLATFORM>/config.cmake``. This cmake variable is |
| 416 | a wrapper around the ``MBEDTLS_USER_CONFIG_FILE`` options, but is preferred as |
| 417 | it keeps all configuration in cmake. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 418 | |
| 419 | Internal Trusted Storage configurations |
| 420 | --------------------------------------- |
| 421 | |
| 422 | ITS service is enabled in top-level Profile Small CMake config file. |
| 423 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 424 | The internal transient buffer size ``ITS_BUF_SIZE`` [8]_ is set to 32 bytes by |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 425 | default. A platform/use case can overwrite the buffer size in its specific |
| 426 | configuration extension according to its actual requirement of assets and Flash |
| 427 | attributes. |
| 428 | |
| 429 | Profile Small CMake config file won't touch the configurations of device |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 430 | specific Flash hardware attributes [8]_. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 431 | |
| 432 | Initial Attestation secure service |
| 433 | ---------------------------------- |
| 434 | |
| 435 | TF-M Profile Small provides a reference implementation of symmetric key |
| 436 | algorithms based Initial Attestation, using HMAC SHA-256 as MAC algorithm in |
| 437 | ``COSE_Mac0`` structure. The implementation follows PSA Attestation API document |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 438 | [9]_. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 439 | |
| 440 | Profile Small top-level config file enables Initial Attestation secure service |
| 441 | and selects symmetric key algorithms based Initial Attestation by default. |
| 442 | |
| 443 | - Set ``TFM_PARTITION_INITIAL_ATTESTATION`` to ``ON`` |
| 444 | - Set ``SYMMETRIC_INITIAL_ATTESTATION`` to ``ON`` |
| 445 | |
| 446 | Symmetric and asymmetric key algorithms based Initial Attestation can share the |
| 447 | same generations of token claims, except Instance ID claim. |
| 448 | |
| 449 | Profile Small may implement the procedure or rely on a 3rd-party tool to |
| 450 | construct and sign ``COSE_Mac0`` structure. |
| 451 | |
| 452 | Details of symmetric key algorithms based Initial Attestation design will be |
| 453 | covered in a dedicated document. |
| 454 | |
| 455 | Disabled secure services |
| 456 | ------------------------ |
| 457 | |
Summer Qin | 369d1e9 | 2022-10-13 14:48:16 +0800 | [diff] [blame] | 458 | Protected Storage and Platform Service are disabled by default |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 459 | in Profile Small top-level CMake config file. |
| 460 | |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 461 | Test configuration |
| 462 | ------------------ |
| 463 | |
| 464 | Some cryptography tests are disabled due to the reduced Mbed Crypto config. |
| 465 | Some of them are shown in the table below. |
| 466 | |
| 467 | .. table:: TFM options in Profile Small top-level CMake config file |
| 468 | :widths: auto |
| 469 | :align: center |
| 470 | |
Summer Qin | b898d81 | 2022-06-08 15:01:35 +0800 | [diff] [blame] | 471 | +--------------------------------------------+---------------+----------------------------------------+ |
| 472 | | Configs | Default value | Descriptions | |
| 473 | +============================================+===============+========================================+ |
| 474 | | ``TFM_CRYPTO_TEST_ALG_CBC`` | ``OFF`` | Test CBC cryptography mode | |
| 475 | +--------------------------------------------+---------------+----------------------------------------+ |
| 476 | | ``TFM_CRYPTO_TEST_ALG_CCM`` | ``ON`` | Test CCM cryptography mode | |
| 477 | +--------------------------------------------+---------------+----------------------------------------+ |
| 478 | | ``TFM_CRYPTO_TEST_ALG_CFB`` | ``OFF`` | Test CFB cryptography mode | |
| 479 | +--------------------------------------------+---------------+----------------------------------------+ |
| 480 | | ``TFM_CRYPTO_TEST_ALG_ECB`` | ``OFF`` | Test ECB cryptography mode | |
| 481 | +--------------------------------------------+---------------+----------------------------------------+ |
| 482 | | ``TFM_CRYPTO_TEST_ALG_CTR`` | ``OFF`` | Test CTR cryptography mode | |
| 483 | +--------------------------------------------+---------------+----------------------------------------+ |
| 484 | | ``TFM_CRYPTO_TEST_ALG_OFB`` | ``OFF`` | Test OFB cryptography mode | |
| 485 | +--------------------------------------------+---------------+----------------------------------------+ |
| 486 | | ``TFM_CRYPTO_TEST_ALG_GCM`` | ``OFF`` | Test GCM cryptography mode | |
| 487 | +--------------------------------------------+---------------+----------------------------------------+ |
Summer Qin | 32e41f5 | 2022-06-08 15:37:13 +0800 | [diff] [blame] | 488 | | ``TFM_CRYPTO_TEST_ALG_SHA_384`` | ``OFF`` | Test SHA-384 cryptography algorithm | |
| 489 | +--------------------------------------------+---------------+----------------------------------------+ |
Summer Qin | b898d81 | 2022-06-08 15:01:35 +0800 | [diff] [blame] | 490 | | ``TFM_CRYPTO_TEST_ALG_SHA_512`` | ``OFF`` | Test SHA-512 cryptography algorithm | |
| 491 | +--------------------------------------------+---------------+----------------------------------------+ |
| 492 | | ``TFM_CRYPTO_TEST_HKDF`` | ``OFF`` | Test HKDF key derivation algorithm | |
| 493 | +--------------------------------------------+---------------+----------------------------------------+ |
| 494 | | ``TFM_CRYPTO_TEST_ECDH`` | ``OFF`` | Test ECDH key agreement algorithm | |
| 495 | +--------------------------------------------+---------------+----------------------------------------+ |
| 496 | | ``TFM_CRYPTO_TEST_CHACHA20`` | ``OFF`` | Test ChaCha20 stream cipher | |
| 497 | +--------------------------------------------+---------------+----------------------------------------+ |
| 498 | | ``TFM_CRYPTO_TEST_CHACHA20_POLY1305`` | ``OFF`` | Test ChaCha20-Poly1305 AEAD algorithm | |
| 499 | +--------------------------------------------+---------------+----------------------------------------+ |
David Hu | e69294d | 2022-06-21 22:21:37 +0800 | [diff] [blame] | 500 | | ``TFM_CRYPTO_TEST_SINGLE_PART_FUNCS`` | ``OFF`` | Test single-part operations in hash, | |
| 501 | | | | MAC, AEAD and symmetric ciphers | |
| 502 | +--------------------------------------------+---------------+----------------------------------------+ |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 503 | |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 504 | BL2 setting |
| 505 | ----------- |
| 506 | |
| 507 | Profile Small enables MCUBoot provided by TF-M by default. A platform can |
| 508 | overwrite this configuration by disabling MCUBoot in its configuration extension |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 509 | file ``platform/ext<TFM_PLATFORM>/config.cmake``. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 510 | |
| 511 | If MCUBoot provided by TF-M is enabled, single image boot is selected in TF-M |
| 512 | Profile Small top-level CMake config file. |
| 513 | |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 514 | If a device implements its own boot loader, the configurations are |
| 515 | implementation defined. |
| 516 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 517 | .. table:: BL2 options in Profile Small top-level CMake config file |
| 518 | :widths: auto |
| 519 | :align: center |
| 520 | |
| 521 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
| 522 | | Configs | Default value | Descriptions | |
| 523 | +============================================+=====================================================================================================+=====================================+ |
| 524 | | ``BL2`` | ``ON`` | Enable MCUBoot bootloader | |
| 525 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
| 526 | | ``MCUBOOT_IMAGE_NUMBER`` | ``1`` | Combine S and NS images | |
| 527 | +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+ |
| 528 | |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 529 | **************** |
| 530 | Platform support |
| 531 | **************** |
| 532 | |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 533 | Building Profile Small |
| 534 | ====================== |
| 535 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 536 | To build Profile Small, argument ``TFM_PROFILE`` in build command line should be |
| 537 | set to ``profile_small``. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 538 | |
| 539 | Take AN521 as an example. |
| 540 | |
| 541 | The following commands build Profile Small without test cases on **AN521** with |
| 542 | build type **MinSizeRel**, built by **Armclang**. |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 543 | SFN model is selected by default. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 544 | |
| 545 | .. code-block:: bash |
| 546 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 547 | cd <TFM root dir> |
| 548 | mkdir build && cd build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 549 | cmake -DTFM_PLATFORM=arm/mps2/an521 \ |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 550 | -DTFM_TOOLCHAIN_FILE=../toolchain_ARMCLANG.cmake \ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 551 | -DTFM_PROFILE=profile_small \ |
| 552 | -DCMAKE_BUILD_TYPE=MinSizeRel \ |
| 553 | ../ |
| 554 | cmake --build ./ -- install |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 555 | |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 556 | The following commands build Profile Small with regression test cases on |
| 557 | **AN521** with build type **MinSizeRel**, built by **Armclang**. |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 558 | SFN model is selected by default. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 559 | |
| 560 | .. code-block:: bash |
| 561 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 562 | cd <TFM root dir> |
| 563 | mkdir build && cd build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 564 | cmake -DTFM_PLATFORM=arm/mps2/an521 \ |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 565 | -DTFM_TOOLCHAIN_FILE=../toolchain_ARMCLANG.cmake \ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 566 | -DTFM_PROFILE=profile_small \ |
| 567 | -DCMAKE_BUILD_TYPE=MinSizeRel \ |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 568 | -DTEST_NS=ON \ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 569 | ../ |
| 570 | cmake --build ./ -- install |
| 571 | |
| 572 | .. Note:: |
| 573 | |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 574 | - For devices with more constrained memory and flash requirements, it is |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 575 | possible to build with either only TEST_S enabled or only TEST_NS enabled. |
| 576 | This will decrease the size of the test images. Note that both test suites |
| 577 | must still be run to ensure correct operation. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 578 | |
| 579 | More details of building instructions and parameters can be found TF-M build |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 580 | instruction guide [12]_. |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 581 | |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 582 | ********* |
| 583 | Reference |
| 584 | ********* |
| 585 | |
| 586 | .. [1] `Pre-Shared Key Ciphersuites for Transport Layer Security (TLS) <https://tools.ietf.org/html/rfc4279>`_ |
| 587 | |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 588 | .. [2] `Arm Firmware Framework for M 1.1 Extensions <https://developer.arm.com/documentation/aes0039/latest>`_ |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 589 | |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 590 | .. [3] `Arm Platform Security Architecture Firmware Framework 1.0 <https://developer.arm.com/-/media/Files/pdf/PlatformSecurityArchitecture/Architect/DEN0063-PSA_Firmware_Framework-1.0.0-2.pdf?revision=2d1429fa-4b5b-461a-a60e-4ef3d8f7f4b4&hash=3BFD6F3E687F324672F18E5BE9F08EDC48087C93>`_ |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 591 | |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 592 | .. [4] `Platform Security Model 1.1 <https://developer.arm.com/documentation/den0128/latest>`_ |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 593 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 594 | .. [5] `AES-CCM Cipher Suites for Transport Layer Security (TLS) <https://tools.ietf.org/html/rfc6655>`_ |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 595 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 596 | .. [6] `Updated Security Considerations for the MD5 Message-Digest and the HMAC-MD5 Algorithms <https://tools.ietf.org/html/rfc6151>`_ |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 597 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 598 | .. [7] `Transitioning the Use of Cryptographic Algorithms and Key Lengths <https://www.nist.gov/publications/transitioning-use-cryptographic-algorithms-and-key-lengths>`_ |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 599 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 600 | .. [8] :doc:`ITS integration guide </integration_guide/services/tfm_its_integration_guide>` |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 601 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 602 | .. [9] `PSA Attestation API 1.0 (ARM IHI 0085) <https://developer.arm.com/-/media/Files/pdf/PlatformSecurityArchitecture/Implement/IHI0085-PSA_Attestation_API-1.0.2.pdf?revision=eef78753-c77e-4b24-bcf0-65596213b4c1&la=en&hash=E5E0353D612077AFDCE3F2F3708A50C77A74B2A3>`_ |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 603 | |
Anton Komlev | b3f6466 | 2023-01-28 11:53:05 +0000 | [diff] [blame] | 604 | .. [10] :doc:`Secure boot </design_docs/booting/tfm_secure_boot>` |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 605 | |
Anton Komlev | b3f6466 | 2023-01-28 11:53:05 +0000 | [diff] [blame] | 606 | .. [11] :doc:`Crypto design </design_docs/services/tfm_crypto_design>` |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 607 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 608 | .. [12] :doc:`TF-M build instruction </building/tfm_build_instruction>` |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 609 | |
Summer Qin | 2db78c8 | 2022-10-10 17:17:44 +0800 | [diff] [blame] | 610 | .. [13] `PSA Cryptography API 1.0 <https://developer.arm.com/documentation/ihi0086/a/?lang=en>`_ |
David Hu | e69294d | 2022-06-21 22:21:37 +0800 | [diff] [blame] | 611 | |
David Hu | c9a4559 | 2020-02-17 20:26:10 +0800 | [diff] [blame] | 612 | -------------- |
| 613 | |
David Hu | 7b23d2d | 2022-03-01 14:58:23 +0800 | [diff] [blame] | 614 | *Copyright (c) 2020-2022, Arm Limited. All rights reserved.* |