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