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 | |
| 334 | The basic idea is to add dedicated top-level CMake configuration files under |
| 335 | folder ``configs`` for TF-M Profile Small default configuration. |
| 336 | |
| 337 | The top-level Profile Small config file collects all the necessary configuration |
| 338 | flags and set them to default values, to explicitly enable the features required |
| 339 | in TF-M Profile Small and disable the unnecessary ones, during TF-M build. |
| 340 | |
| 341 | An alternative option is to set only a global flag in top-level Profile Small |
| 342 | CMake file and configure the remaining configurations in dedicated CMake files |
| 343 | of each module/secure service. However, since configuration flags are |
| 344 | distributed in multiple CMake files, it will become difficult for a platform/use |
| 345 | case to overwrite default configurations. |
| 346 | Therefore it is more reasonable to explicitly set all critical configurations in |
| 347 | a top-level CMake file. |
| 348 | |
| 349 | A platform/use case can provide a configuration extension file to overwrite |
| 350 | Profile Small default setting and append other configurations. |
| 351 | This configuration extension file can be added via parameter |
| 352 | ``TFM_PROFILE_CONFIG_EXT`` in build command line. The top-level config file will |
| 353 | include the device configuration extension file to load platform/use case |
| 354 | specific configurations. |
| 355 | |
| 356 | The overall build flow of Profile Small is shown as the flowchart below. |
| 357 | |
| 358 | .. uml:: |
| 359 | |
| 360 | @startuml |
| 361 | |
| 362 | title Overall build flow |
| 363 | |
| 364 | start |
| 365 | |
| 366 | :Profile Small CMake file; |
| 367 | note left |
| 368 | Top-level CMake config file under ""configs"". |
| 369 | Set configurations to default values. |
| 370 | endnote |
| 371 | |
| 372 | if (Platform config\nextension specified?) then (Yes) |
| 373 | :Include platform specific\nconfig extension file; |
| 374 | note left |
| 375 | Platform specific configuration extension file |
| 376 | is provided via ""TFM_PROFILE_CONFIG_EXT"" in |
| 377 | build command line. |
| 378 | endnote |
| 379 | |
| 380 | :Overwrite default configurations; |
| 381 | else (No) |
| 382 | endif |
| 383 | |
| 384 | :CommonConfig.cmake; |
| 385 | note left |
| 386 | Normal building sequence |
| 387 | endnote |
| 388 | |
| 389 | stop |
| 390 | |
| 391 | @enduml |
| 392 | |
| 393 | The control flags set in the top-level Profile Small config file are listed |
| 394 | below. |
| 395 | The details will be covered in each module in `Implementation details`_. |
| 396 | |
| 397 | .. list-table:: Config flags in Profile S top-level CMake config file |
| 398 | :widths: 20 15 30 |
| 399 | :header-rows: 1 |
| 400 | |
| 401 | * - Configs |
| 402 | - Default value |
| 403 | - Descriptions |
| 404 | * - ``CORE_IPC`` |
| 405 | - ``False`` |
| 406 | - Library model is selected |
| 407 | * - ``TFM_LVL`` |
| 408 | - ``1`` |
| 409 | - Level 1 isolation |
| 410 | * - ``TFM_PARTITION_INTERNAL_TRUSTED_STORAGE`` |
| 411 | - ``ON`` |
| 412 | - Enable ITS SP |
| 413 | * - ``ITS_RAM_FS`` |
| 414 | - ``OFF`` |
| 415 | - Stop using RAM to simulate Flash |
| 416 | * - ``ITS_BUF_SIZE`` |
| 417 | - ``32`` |
| 418 | - ITS internal transient buffer size |
| 419 | * - ``TFM_PARTITION_CRYPTO`` |
| 420 | - ``ON`` |
| 421 | - Enable Crypto service |
| 422 | * - ``CRYPTO_ASYMMETRIC_MODULE_DISABLED`` |
| 423 | - ``ON`` |
| 424 | - Disable asymmetric cipher in Crypto service |
| 425 | * - ``CRYPTO_AEAD_MODULE_DISABLED`` |
| 426 | - ``OFF`` |
| 427 | - Enable AEAD in Crypto service |
| 428 | * - ``CRYPTO_KEY_DERIVATION_MODULE_DISABLED`` |
| 429 | - ``ON`` |
| 430 | - Disable key derivation in Crypto service |
| 431 | * - ``MBEDTLS_CONFIG_FILE`` |
| 432 | - ``tfm_profile_s_mbedcrypto_config`` |
| 433 | - Default mbed-crypto config file for Profile Small under |
| 434 | ``platform/ext/common`` |
| 435 | * - ``TFM_PARTITION_AUDIT_LOG`` |
| 436 | - ``OFF`` |
| 437 | - Disable Audit Logging Logging service |
| 438 | * - ``TFM_PARTITION_SECURE_STORAGE`` |
| 439 | - ``OFF`` |
| 440 | - Disable Protected Storage service |
| 441 | * - ``TFM_PARTITION_INITIAL_ATTESTATION`` |
| 442 | - ``ON`` |
| 443 | - Enable Initial Attestation service |
| 444 | * - ``SYMMETRIC_INITIAL_ATTESTATION`` |
| 445 | - ``ON`` |
| 446 | - Select Initial Attestation based on symmetric key algorithms |
| 447 | * - ``TFM_PARTITION_PLATFORM`` |
| 448 | - ``OFF`` |
| 449 | - Disable Platform service |
| 450 | |
| 451 | Test cases settings in top-level Profile Small config files are listed below. |
| 452 | The ``Default config`` stands for configuration without tests and the |
| 453 | ``Regression config`` stands for configuration with regression tests. |
| 454 | |
| 455 | .. list-table:: Test config flags in Profile S top-level CMake config file |
| 456 | :widths: 20 20 15 15 |
| 457 | :header-rows: 1 |
| 458 | |
| 459 | * - Test cases |
| 460 | - Configs |
| 461 | - Default config |
| 462 | - Regression config |
| 463 | * - Regression test |
| 464 | - ``REGRESSION`` |
| 465 | - ``OFF`` |
| 466 | - ``ON`` |
| 467 | * - Core test |
| 468 | - ``CORE_TEST`` |
| 469 | - ``OFF`` |
| 470 | - ``ON`` |
| 471 | * - PSA API test |
| 472 | - ``PSA_API_TEST`` |
| 473 | - ``OFF`` |
| 474 | - ``OFF`` |
| 475 | |
| 476 | Implementation details |
| 477 | ====================== |
| 478 | |
| 479 | This section discusses the details of Profile Small implementation. |
| 480 | |
| 481 | .. note :: |
| 482 | |
| 483 | **Implementation note** |
| 484 | |
| 485 | The following sections focus on the feature selection via configuration |
| 486 | setting. |
| 487 | Dedicated optimization on memory footprint is not covered in this document. |
| 488 | |
| 489 | Top-level Profile Small CMake config file |
| 490 | ----------------------------------------- |
| 491 | |
| 492 | There are two top-level Profile Small CMake config files under folder |
| 493 | ``configs``. |
| 494 | |
| 495 | - ``ConfigDefaultProfileS.cmake`` completes Profile Small default configurations |
| 496 | without test cases. |
| 497 | - ``ConfigRegressionProfileS.cmake`` enables regression and core test cases for |
| 498 | the features defined Profile Small, besides default configurations. |
| 499 | |
| 500 | The details of configuration control flags set in top-level configuration file |
| 501 | are listed in following sections. |
| 502 | |
| 503 | Device configuration extension |
| 504 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 505 | |
| 506 | To overwrite default configurations and add platform specific configurations, |
| 507 | a platform can set the path to its own configuration extension file in parameter |
| 508 | ``TFM_PROFILE_CONFIG_EXT`` in command line. |
| 509 | |
| 510 | A platform can also add its device specific configurations into its specific |
| 511 | CMake file under ``platform/ext/`` folder. |
| 512 | |
| 513 | TF-M framework setting |
| 514 | ---------------------- |
| 515 | |
| 516 | The top-level Profile Small CMake config file selects Library model and level 1 |
| 517 | isolation. |
| 518 | |
| 519 | Crypto service configuration |
| 520 | ---------------------------- |
| 521 | |
| 522 | Crypto Secure Partition |
| 523 | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 524 | |
| 525 | TF-M Profile Small enables Crypto Secure Partition (SP) in its top-level CMake |
| 526 | config file. Crypto SP modules not supported in TF-M Profile Small are disabled. |
| 527 | The disabled modules are shown below. |
| 528 | |
| 529 | - Disable asymmetric cipher |
| 530 | - Disable key derivation |
| 531 | |
| 532 | Other modules and configurations [10]_ are kept as default values. |
| 533 | |
| 534 | Additional configuration flags with more fine granularity can be added to |
| 535 | control building of specific crypto algorithms and corresponding test cases. |
| 536 | |
| 537 | Mbed Crypto configurations |
| 538 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 539 | |
| 540 | TF-M Profile Small adds a dedicated Mbed Crypto config file |
| 541 | ``tfm_profile_s_mbedcrypto_config.h`` under ``platform/ext/common``. |
| 542 | TF-M Profile Small specifies ``tfm_profile_s_mbedcrypto_config.h`` as the |
| 543 | default Mbed Crypto config in ``MBEDTLS_CONFIG_FILE`` in top-level CMake config |
| 544 | file, instead of the common one ``tfm_mbedcrypto_config.h`` [10]_. |
| 545 | |
| 546 | Major Mbed Crypto configurations are set as listed below: |
| 547 | |
| 548 | - Enable SHA256 |
| 549 | - Enable generic message digest wrappers |
| 550 | - Enable AES |
| 551 | - Enable CCM mode for symmetric ciphers |
| 552 | - Disable other modes for symmetric ciphers |
| 553 | - Disable asymmetric ciphers |
| 554 | - Disable HMAC-based key derivation function (HKDF) |
| 555 | |
| 556 | Other configurations can be selected to optimize the memory footprint of Crypto |
| 557 | module. |
| 558 | |
| 559 | A device/use case can replace Profile Small default Mbed Crypto config file with |
| 560 | its specific one to overwrite the default configurations. Alternatively, a |
| 561 | device can overwrite the configurations by appending a config file via |
| 562 | ``MBEDTLS_USER_CONFIG_FILE``. |
| 563 | |
| 564 | Internal Trusted Storage configurations |
| 565 | --------------------------------------- |
| 566 | |
| 567 | ITS service is enabled in top-level Profile Small CMake config file. |
| 568 | |
| 569 | The internal transient buffer size ``ITS_BUF_SIZE`` [7]_ is set to 32 bytes by |
| 570 | default. A platform/use case can overwrite the buffer size in its specific |
| 571 | configuration extension according to its actual requirement of assets and Flash |
| 572 | attributes. |
| 573 | |
| 574 | Profile Small CMake config file won't touch the configurations of device |
| 575 | specific Flash hardware attributes [7]_. |
| 576 | |
| 577 | Initial Attestation secure service |
| 578 | ---------------------------------- |
| 579 | |
| 580 | TF-M Profile Small provides a reference implementation of symmetric key |
| 581 | algorithms based Initial Attestation, using HMAC SHA-256 as MAC algorithm in |
| 582 | ``COSE_Mac0`` structure. The implementation follows PSA Attestation API document |
| 583 | [8]_. |
| 584 | |
| 585 | Profile Small top-level config file enables Initial Attestation secure service |
| 586 | and selects symmetric key algorithms based Initial Attestation by default. |
| 587 | |
| 588 | - Set ``TFM_PARTITION_INITIAL_ATTESTATION`` to ``ON`` |
| 589 | - Set ``SYMMETRIC_INITIAL_ATTESTATION`` to ``ON`` |
| 590 | |
| 591 | Symmetric and asymmetric key algorithms based Initial Attestation can share the |
| 592 | same generations of token claims, except Instance ID claim. |
| 593 | |
| 594 | Profile Small may implement the procedure or rely on a 3rd-party tool to |
| 595 | construct and sign ``COSE_Mac0`` structure. |
| 596 | |
| 597 | Details of symmetric key algorithms based Initial Attestation design will be |
| 598 | covered in a dedicated document. |
| 599 | |
| 600 | Disabled secure services |
| 601 | ------------------------ |
| 602 | |
| 603 | Audit logging, Protected Storage, and Platform Service are disabled by default |
| 604 | in Profile Small top-level CMake config file. |
| 605 | |
| 606 | BL2 setting |
| 607 | ----------- |
| 608 | |
| 609 | Profile Small enables MCUBoot provided by TF-M by default. A platform can |
| 610 | overwrite this configuration by disabling MCUBoot in its configuration extension |
| 611 | file or in its specific CMake file under ``platform/ext/`` folder. |
| 612 | |
| 613 | If MCUBoot provided by TF-M is enabled, single image boot is selected in TF-M |
| 614 | Profile Small top-level CMake config file. |
| 615 | |
| 616 | The following table lists the configurations specified in Profile Small |
| 617 | top-level config file for MCUBoot provided by TF-M. |
| 618 | |
| 619 | .. list-table:: MCUBoot config flags in Profile S top-level CMake config file |
| 620 | :widths: 30 15 30 |
| 621 | :header-rows: 1 |
| 622 | |
| 623 | * - Configs |
| 624 | - Default value |
| 625 | - Descriptions |
| 626 | * - ``BL2`` |
| 627 | - ``True`` |
| 628 | - MCUBoot is enabled |
| 629 | * - ``MCUBOOT_IMAGE_NUMBER`` |
| 630 | - ``1`` |
| 631 | - Single image boot |
| 632 | |
| 633 | If a device implements its own boot loader, the configurations are |
| 634 | implementation defined. |
| 635 | |
| 636 | **************** |
| 637 | Platform support |
| 638 | **************** |
| 639 | |
| 640 | To enable Profile Small on a platform, the platform specific CMake file should |
| 641 | be added into the platform support list in top-level Profile Small CMake config |
| 642 | file. |
| 643 | |
| 644 | Building Profile Small |
| 645 | ====================== |
| 646 | |
| 647 | To build Profile Small, argument ``PROJ_CONFIG`` in build command line should be |
| 648 | set to ``ConfigRegressionProfileS.cmake`` or ``ConfigRegressionProfileS.cmake``. |
| 649 | |
| 650 | Take AN521 as an example. |
| 651 | |
| 652 | The following commands build Profile Small without test cases on **AN521** with |
| 653 | build type **MinSizeRel**, built by **Armclang**. |
| 654 | |
| 655 | .. code-block:: bash |
| 656 | |
| 657 | cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigDefaultProfileS.cmake` \ |
| 658 | -DTARGET_PLATFORM=AN521 \ |
| 659 | -DCMAKE_BUILD_TYPE=MinSizeRel \ |
| 660 | -DCOMPILER=ARMCLANG ../ |
| 661 | cmake --build ./ -- install |
| 662 | |
| 663 | The following commands build Profile Small with regression test cases on **AN521** |
| 664 | with build type **MinSizeRel**, built by **Armclang**. |
| 665 | |
| 666 | .. code-block:: bash |
| 667 | |
| 668 | cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigRegressionProfileS.cmake` \ |
| 669 | -DTARGET_PLATFORM=AN521 \ |
| 670 | -DCMAKE_BUILD_TYPE=MinSizeRel \ |
| 671 | -DCOMPILER=ARMCLANG ../ |
| 672 | cmake --build ./ -- install |
| 673 | |
| 674 | More details of building instructions and parameters can be found TF-M build |
| 675 | instruction guide [11]_. |
| 676 | |
| 677 | The following commands include platform specific configuration extension file |
| 678 | via ``TFM_PROFILE_CONFIG_EXT`` in command line. ``TFM_PROFILE_CONFIG_EXT`` can |
| 679 | be an absolute path or a relative one to TF-M code root directory. |
| 680 | |
| 681 | .. code-block:: bash |
| 682 | |
| 683 | cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigDefaultProfileS.cmake` \ |
| 684 | -DTARGET_PLATFORM=AN521 \ |
| 685 | -DCMAKE_BUILD_TYPE=MinSizeRel \ |
| 686 | -DCOMPILER=ARMCLANG \ |
| 687 | -DTFM_PROFILE_CONFIG_EXT=path/to/config_ext_file ../ |
| 688 | cmake --build ./ -- install |
| 689 | |
| 690 | ********* |
| 691 | Reference |
| 692 | ********* |
| 693 | |
| 694 | .. [1] `Pre-Shared Key Ciphersuites for Transport Layer Security (TLS) <https://tools.ietf.org/html/rfc4279>`_ |
| 695 | |
| 696 | .. [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>`_ |
| 697 | |
| 698 | .. [3] `PSA analyze stage <https://developer.arm.com/architectures/security-architectures/platform-security-architecture#analyze>`_ |
| 699 | |
| 700 | .. [4] `AES-CCM Cipher Suites for Transport Layer Security (TLS) <https://tools.ietf.org/html/rfc6655>`_ |
| 701 | |
| 702 | .. [5] `Updated Security Considerations for the MD5 Message-Digest and the HMAC-MD5 Algorithms <https://tools.ietf.org/html/rfc6151>`_ |
| 703 | |
| 704 | .. [6] `Transitioning the Use of Cryptographic Algorithms and Key Lengths <https://www.nist.gov/publications/transitioning-use-cryptographic-algorithms-and-key-lengths>`_ |
| 705 | |
| 706 | .. [7] :doc:`ITS integration guide </docs/user_guides/services/tfm_its_integration_guide>` |
| 707 | |
| 708 | .. [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>`_ |
| 709 | |
| 710 | .. [9] :doc:`Secure boot </docs/user_guides/tfm_secure_boot>` |
| 711 | |
| 712 | .. [10] :doc:`Crypto design </docs/design_documents/tfm_crypto_design>` |
| 713 | |
| 714 | .. [11] :doc:`TF-M build instruction </docs/user_guides/tfm_build_instruction>` |
| 715 | |
| 716 | -------------- |
| 717 | |
| 718 | *Copyright (c) 2020, Arm Limited. All rights reserved.* |