blob: ae24b98db7fd4d9045a6aa4499259e6eec993683 [file] [log] [blame]
David Hu5fc31c12020-05-16 22:36:06 +08001########################################
2Trusted Firmware-M Profile Medium Design
3########################################
4
5:Authors: David Hu
6:Organization: Arm Limited
7:Contact: david.hu@arm.com
8
9************
10Introduction
11************
12
13Compared with Profile Small, Profile Medium aims to securely connect devices to
14Cloud services with asymmetric cipher support.
15Profile Medium target devices need more resources for more cipher algorithms
16and higher isolation levels.
17
18For more descriptions and background of TF-M Profile, please refer to Profile
19Small design document [PROFILE-S]_.
20
21**************
22Overall design
23**************
24
25TF-M Profile Medium defines the following feature set:
26
27 - Firmware Framework
28
29 - Inter-Process Communication (IPC) model [PSA-FF-M]_
30 - Isolation level 2 [PSA-FF-M]_
31
32 - Internal Trusted Storage (ITS)
33
34 - Crypto
35
David Huf40be932021-05-12 15:52:16 +080036 - Support both symmetric cryptography and asymmetric cryptography
David Hu5fc31c12020-05-16 22:36:06 +080037 - Asymmetric key based cipher suite suggested in TLS/DTLS profiles for
38 IoT [RFC7925]_ and CoAP [RFC7252]_, including
39
40 - Authenticated Encryption with Associated Data (AEAD) algorithm
41 - Asymmetric key algorithm based signature and verification
42 - Public-key cryptography based key exchange
43 - Hash function
44 - HMAC for default Pseudorandom Function (PRF)
45
46 - Asymmetric digital signature and verification for Initial Attestation
47 Token (IAT)
48
49 - Initial Attestation
50
51 - Asymmetric key algorithm based Initial Attestation
52
53 - Lightweight boot
54
55 - Anti-rollback protection
56 - Multiple image boot
57
58 - Protected Storage (PS) if off-chip storage device is integrated
59
60 - Data confidentiality
61 - Data integrity
62 - Rollback protection
63
64**************
65Design details
66**************
67
68More details of TF-M Profile Medium design are described in following sections.
69
70Firmware framework
71==================
72
73Profile Medium with IPC model and isolation level 2 aims to support usage
74scenarios which require more complicated secure service model and additional
75protection to PSA RoT.
76
77Level 2 isolation
78-----------------
79
80Profile Medium selects isolation level 2 by default. In addition to isolation
81level 1, the PSA Root of Trust (PSA RoT) is also protected from access by the
82Application Root of Trust (App RoT) in level 2 isolation.
83
84IPC model
85---------
86
87Profile Medium enables IPC model by default. IPC model can achieve a more
88flexible framework and higher levels of isolation, but may require more memory
89footprint and bring in longer latency, compared to Library model.
90
91TF-M IPC model implementation follows the PSA Firmware Framework for M
92(PSA-FF-M) [PSA-FF-M]_.
93
94Crypto service
95==============
96
David Huf40be932021-05-12 15:52:16 +080097Compared to Profile Small, Profile Medium includes asymmetric cryptography to
98support direct connection to Cloud services via common protocols, such as
99TLS/DTLS 1.2.
David Hu5fc31c12020-05-16 22:36:06 +0800100
101As suggested in CoAP [RFC7252]_ and [RFC7925]_, TF-M Profile Medium by default
102selects ``TLS_ECDHE_ECDSA_WITH_AES_128_CCM`` as reference, which requires:
103
104 - ECDHE_ECDSA as key exchange algorithm.
105 - AES-128-CCM (AES CCM mode with 128-bit key) as AEAD algorithm.
106 Platforms can implement AES-128-CCM with truncated authentication tag to
107 achieve less network bandwidth [RFC7925]_.
108 - SHA256 as Hash function.
109 - HMAC as Message Authentication Code algorithm.
110
111Applications can also support TLS PSK [RFC4279]_ cipher suites, such as
112``TLS_PSK_WITH_AES_128_CCM`` [RFC7925]_.
113
114.. note ::
115
116 **Implementation note**
117
118 Developers can replace default algorithms with others or implement more
119 algorithms according to actual usage scenarios and device capabilities.
120
121 If a Crypto hardware accelerator is integrated, the cipher suites and
122 algorithms also depend on those accelerator features.
123
124More details of cipher suite are described below.
125
126Digital signature and verification
127----------------------------------
128
129ECDSA is selected by default in Profile Medium.
130ECDSA requires much shorter keys compared with RSA at the same security level.
131Therefore, ECDSA can cost less storage area for assets and less network
132bandwidth to setup a TLS connection.
133ECDSA is also preferred for forward compatibility of future TLS versions.
134
135As requested in [RFC7251]_, ECC curve ``secp256r1`` should be supported. More
136ECC curves can be added based on the requirements in production.
137
138If usage scenarios require RSA algorithm for backward compatibility and legacy
139applications, platforms can add RSA support or replace ECDSA with RSA. The
140cipher suite should be switched accordingly.
141
142AEAD algorithm
143--------------
144
145If Protected Storage (PS) is implemented, it is recommended to select the same
146AEAD algorithm for PS service as the one used by TLS/DTLS cipher suite.
147
148Internal Trusted Storage
149========================
150
151The configuration of ITS is the same as those in Profile Small [PROFILE-S]_.
152
153Lightweight boot
154================
155
156BL2 implementation can be device specific. Devices may implement diverse
157boot processes with different features and configurations.
158However, the boot loader must support anti-rollback protection. Boot loader must
159be able to prevent unauthorized rollback, to protect devices from being
160downgraded to earlier versions with known vulnerabilities.
161
162MCUBoot in TF-M is configured as multiple image boot by default in Profile
163Medium. In multiple image boot, secure and non-secure images can be signed
164independently with different keys and they can be updated separately. It can
165support multiple vendors scenarios, in which non-secure and secure images are
166generated and updated by different vendors.
167Multiple image boot may require more storage area compared with single image
168boot.
169
170Protected Storage
171=================
172
173PS service is required if an off-chip storage device is integrated and used on
174the platform.
175
176TF-M PS service relies on an AEAD algorithm to ensure data confidentiality and
177integrity. It is recommended to select the same AEAD algorithm as the one used
178for TLS/DTLS cipher suite.
179
180Anti-rollback protection in PS relies on non-volatile counter(s) provided by
181TF-M Platform Secure Partition (SP).
182
183TF-M audit logging service
184==========================
185
186TF-M audit logging service allows secure services in the system to log critical
187system events and information.
188
189TF-M audit logging service is not enabled in Profile Medium since its IPC model
190dedicated interface is not ready yet.
191
192.. note ::
193
194 **Implementation note**
195
196 Please note that there is no dedicated PSA specification for Audit Logging
197 yet.
198 The design, interfaces and implementation of TF-M audit logging service may
199 change.
200
201**************
202Implementation
203**************
204
205Overview
206========
207
Anton Komlevb8e3af02020-08-28 10:23:57 +0100208The basic idea is to add dedicated profile CMake configuration files under
209folder ``config/profile`` for TF-M Profile Medium default configuration, the
210same as Profile Small does.
David Hu5fc31c12020-05-16 22:36:06 +0800211
212The top-level Profile Medium config file collects all the necessary
213configuration flags and set them to default values, to explicitly enable the
214features required in Profile Medium and disable the unnecessary ones, during
215TF-M build.
216
217A platform/use case can provide a configuration extension file to overwrite
218Profile Medium default setting and append other configurations.
219This configuration extension file can be added via parameter
Anton Komlevb8e3af02020-08-28 10:23:57 +0100220``TFM_EXTRA_CONFIG_PATH`` in build command line.
David Hu5fc31c12020-05-16 22:36:06 +0800221
Anton Komlevb8e3af02020-08-28 10:23:57 +0100222The behaviour of the Profile Medium build flow (particularly the order of
223configuration loading and overriding) can be found at
224:ref:`tfm_cmake_configuration`
David Hu5fc31c12020-05-16 22:36:06 +0800225
226The details of configurations will be covered in each module in
227`Implementation details`_.
228
229Implementation details
230======================
231
232This section discusses the details of Profile Medium implementation.
233
234Top-level configuration files
235-----------------------------
236
Anton Komlevb8e3af02020-08-28 10:23:57 +0100237The firmware framework configurations in ``config/profile/profile_medium`` are
238shown below.
David Hu5fc31c12020-05-16 22:36:06 +0800239
240.. table:: Config flags in Profile Medium top-level CMake config file
241 :widths: auto
242 :align: center
243
Anton Komlevb8e3af02020-08-28 10:23:57 +0100244 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
245 | Configs | Default value | Descriptions |
246 +============================================+=====================================================================================================+=====================================+
247 | ``TFM_ISOLATION_LEVEL`` | ``2`` | Select level 2 isolation |
248 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
249 | ``TFM_PSA_API`` | ``True`` | Select IPC model |
250 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
251 | ``TFM_PARTITION_INTERNAL_TRUSTED_STORAGE`` | ``ON`` | Enable ITS SP |
252 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
253 | ``ITS_BUF_SIZE`` | ``32`` | ITS internal transient buffer size |
254 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
255 | ``TFM_PARTITION_CRYPTO`` | ``ON`` | Enable Crypto service |
256 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
David Huf40be932021-05-12 15:52:16 +0800257 | ``CRYPTO_ASYM_ENCRYPT_MODULE_DISABLED`` | ``ON`` | Disable Crypto asymmetric |
258 | | | encryption operations |
259 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
Anton Komlevb8e3af02020-08-28 10:23:57 +0100260 | ``TFM_MBEDCRYPTO_CONFIG_PATH`` | ``${CMAKE_SOURCE_DIR}/lib/ext/mbedcrypto/mbedcrypto_config/tfm_mbedcrypto_config_profile_medium.h`` | Mbed Crypto config file path |
261 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
262 | ``TFM_PARTITION_INITIAL_ATTESTATION`` | ``ON`` | Enable Initial Attestation service |
263 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
264 | ``TFM_PARTITION_PROTECTED_STORAGE`` [1]_ | ``ON`` | Enable PS service |
265 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
266 | ``TFM_PARTITION_PLATFORM`` | ``ON`` | Enable TF-M Platform SP |
267 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
268 | ``TFM_PARTITION_AUDIT_LOG`` | ``OFF`` | Disable TF-M audit logging service |
269 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
David Hu5fc31c12020-05-16 22:36:06 +0800270
271.. [1] PS service is enabled by default. Platforms without off-chip storage
272 devices can turn off ``TFM_PARTITION_PROTECTED_STORAGE`` to disable PS
273 service. See `Protected Storage Secure Partition`_ for details.
274
Anton Komlevb8e3af02020-08-28 10:23:57 +0100275.. Note::
David Hu5fc31c12020-05-16 22:36:06 +0800276
Anton Komlevb8e3af02020-08-28 10:23:57 +0100277 Where a configuration is the same as the default in
278 ``config/config_default.cmake``, it is omitted from the profile configuration
279 file.
David Hu5fc31c12020-05-16 22:36:06 +0800280
Anton Komlevb8e3af02020-08-28 10:23:57 +0100281Test configuration
282^^^^^^^^^^^^^^^^^^
283
284Standard regression test configuration applies. This means that enabling
285regression testing via
286
287``-DTEST_S=ON -DTEST_NS=ON``
288
289Will enable testing for all enabled partitions. See above for details of enabled
290partitions. Because Profile Medium enables IPC mode, the IPC tests are also
291enabled.
292
293Some cryptography tests are disabled due to the reduced Mbed Crypto config.
294
295.. table:: TFM options in Profile Medium top-level CMake config file
David Hu5fc31c12020-05-16 22:36:06 +0800296 :widths: auto
297 :align: center
298
David Huf40be932021-05-12 15:52:16 +0800299 +--------------------------------------------+---------------+--------------------------------+
300 | Configs | Default value | Descriptions |
301 +============================================+===============+================================+
302 | ``TFM_CRYPTO_TEST_ALG_CBC`` | ``OFF`` | Disable CBC mode test |
303 +--------------------------------------------+---------------+--------------------------------+
304 | ``TFM_CRYPTO_TEST_ALG_CCM`` | ``ON`` | Enable CCM mode test |
305 +--------------------------------------------+---------------+--------------------------------+
306 | ``TFM_CRYPTO_TEST_ALG_CFB`` | ``OFF`` | Disable CFB mode test |
307 +--------------------------------------------+---------------+--------------------------------+
308 | ``TFM_CRYPTO_TEST_ALG_CTR`` | ``OFF`` | Disable CTR mode test |
309 +--------------------------------------------+---------------+--------------------------------+
310 | ``TFM_CRYPTO_TEST_ALG_GCM`` | ``OFF`` | Disable GCM mode test |
311 +--------------------------------------------+---------------+--------------------------------+
312 | ``TFM_CRYPTO_TEST_ALG_SHA_512`` | ``OFF`` | Disable SHA-512 algorithm test |
313 +--------------------------------------------+---------------+--------------------------------+
314 | ``TFM_CRYPTO_TEST_HKDF`` | ``OFF`` | Disable HKDF algorithm test |
315 +--------------------------------------------+---------------+--------------------------------+
David Hu5fc31c12020-05-16 22:36:06 +0800316
317Device configuration extension
318^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
319
320To change default configurations and add platform specific configurations,
Anton Komlevb8e3af02020-08-28 10:23:57 +0100321a platform can add a platform configuration file at
322``platform/ext<TFM_PLATFORM>/config.cmake``
David Hu5fc31c12020-05-16 22:36:06 +0800323
324Crypto service configurations
325-----------------------------
326
327Crypto Secure Partition
328^^^^^^^^^^^^^^^^^^^^^^^
329
David Huf40be932021-05-12 15:52:16 +0800330TF-M Profile Medium enables Crypto SP in top-level CMake config file.
331The following PSA Crypto operationts are enabled by default.
332
333 - Hash operations
334 - Message authentication codes
335 - Symmetric ciphers
336 - AEAD operations
337 - Asymmetric key algorithm based signature and verification
338 - Key derivation
339 - Key management
David Hu5fc31c12020-05-16 22:36:06 +0800340
341Mbed Crypto configurations
342^^^^^^^^^^^^^^^^^^^^^^^^^^
343
344TF-M Profile Medium adds a dedicated Mbed Crypto config file
Anton Komlevb8e3af02020-08-28 10:23:57 +0100345``tfm_mbedcrypto_config_profile_medium.h`` at
David Huf40be932021-05-12 15:52:16 +0800346``/lib/ext/mbedcrypto/mbedcrypto_config`` folder, instead of the common one
347``tfm_mbedcrypto_config_default.h`` [CRYPTO-DESIGN]_.
David Hu5fc31c12020-05-16 22:36:06 +0800348
349Major Mbed Crypto configurations are set as listed below:
350
351 - Enable SHA256
352 - Enable generic message digest wrappers
353 - Enable AES
354 - Enable CCM mode for symmetric ciphers
355 - Disable other modes for symmetric ciphers
356 - Enable ECDH
357 - Enable ECDSA
358 - Select ECC curve ``secp256r1``
359 - Other configurations required by selected option above
360
361Other configurations can be selected to optimize the memory footprint of Crypto
362module.
363
Anton Komlevb8e3af02020-08-28 10:23:57 +0100364A device/use case can append an extra config header to the Profile Medium
365default Mbed Crypto config file. This can be done by setting the
366``TFM_MBEDCRYPTO_PLATFORM_EXTRA_CONFIG_PATH`` cmake variable in the platform
367config file ``platform/ext<TFM_PLATFORM>/config.cmake``. This cmake variable is
368a wrapper around the ``MBEDTLS_USER_CONFIG_FILE`` options, but is preferred as
369it keeps all configuration in cmake.
David Hu5fc31c12020-05-16 22:36:06 +0800370
371Internal Trusted Storage configurations
372---------------------------------------
373
374ITS service is enabled in top-level Profile Medium CMake config file by default.
375
376The internal transient buffer size ``ITS_BUF_SIZE`` [ITS-INTEGRATE]_ is set to
37732 bytes by default. A platform/use case can overwrite the buffer size in its
378specific configuration extension according to its actual requirement of assets
379and Flash attributes.
380
381Profile Medium CMake config file won't touch the configurations of device
382specific Flash hardware attributes [ITS-INTEGRATE]_.
383
384Protected Storage Secure Partition
385----------------------------------
386
387Data confidentiality, integrity and anti-rollback protection are enabled by
388default in PS.
389
390If PS is selected, AES-CCM is used as AEAD algorithm by default. It requires to
391enable PS implementation to select diverse AEAD algorithm.
392
393If platforms don't integrate any off-chip storage device, platforms can disable
394PS in platform specific configuration extension file via
Anton Komlevb8e3af02020-08-28 10:23:57 +0100395``platform/ext<TFM_PLATFORM>/config.cmake``.
David Hu5fc31c12020-05-16 22:36:06 +0800396
397BL2 setting
398-----------
399
400Profile Medium enables MCUBoot provided by TF-M by default. A platform can
401overwrite this configuration by disabling MCUBoot in its configuration extension
Anton Komlevb8e3af02020-08-28 10:23:57 +0100402file ``platform/ext<TFM_PLATFORM>/config.cmake``.
David Hu5fc31c12020-05-16 22:36:06 +0800403
404If MCUBoot provided by TF-M is enabled, multiple image boot is selected by
405default in TF-M Profile Medium top-level CMake config file.
406
407If a device implements its own boot loader, the configurations are
408implementation defined.
409
410****************
411Platform support
412****************
413
414To enable Profile Medium on a platform, the platform specific CMake file should
415be added into the platform support list in top-level Profile Medium CMake config
416file.
417
418Building Profile Medium
419=======================
420
Anton Komlevb8e3af02020-08-28 10:23:57 +0100421To build Profile Medium, argument ``TFM_PROFILE`` in build command line should be
422set to ``profile_medium``.
David Hu5fc31c12020-05-16 22:36:06 +0800423
424Take AN521 as an example:
425
426The following commands build Profile Medium without test cases on **AN521** with
427build type **MinSizeRel**, built by **Armclang**.
428
429.. code-block:: bash
430
Anton Komlevb8e3af02020-08-28 10:23:57 +0100431 cd <TFM root dir>
432 mkdir build && cd build
Summer Qin2de23d02021-05-14 13:44:14 +0800433 cmake -DTFM_PLATFORM=arm/mps2/an521 \
Raef Coles69817322020-10-19 14:14:14 +0100434 -DTFM_TOOLCHAIN_FILE=../toolchain_ARMCLANG.cmake \
Anton Komlevb8e3af02020-08-28 10:23:57 +0100435 -DTFM_PROFILE=profile_medium \
436 -DCMAKE_BUILD_TYPE=MinSizeRel \
437 ../
438 cmake --build ./ -- install
David Hu5fc31c12020-05-16 22:36:06 +0800439
440The following commands build Profile Medium with regression test cases on
441**AN521** with build type **MinSizeRel**, built by **Armclang**.
442
443.. code-block:: bash
444
Anton Komlevb8e3af02020-08-28 10:23:57 +0100445 cd <TFM root dir>
446 mkdir build && cd build
Summer Qin2de23d02021-05-14 13:44:14 +0800447 cmake -DTFM_PLATFORM=arm/mps2/an521 \
Raef Coles69817322020-10-19 14:14:14 +0100448 -DTFM_TOOLCHAIN_FILE=../toolchain_ARMCLANG.cmake \
Anton Komlevb8e3af02020-08-28 10:23:57 +0100449 -DTFM_PROFILE=profile_medium \
450 -DCMAKE_BUILD_TYPE=MinSizeRel \
451 -DTEST_S=ON -DTEST_NS=ON \
452 ../
453 cmake --build ./ -- install
454
455.. Note::
456
457 - For devices with more contrained memory and flash requirements, it is
458 possible to build with either only TEST_S enabled or only TEST_NS enabled.
459 This will decrease the size of the test images. Note that both test suites
460 must still be run to ensure correct operation.
David Hu5fc31c12020-05-16 22:36:06 +0800461
462More details of building instructions and parameters can be found TF-M build
463instruction guide [TFM-BUILD]_.
464
David Hu5fc31c12020-05-16 22:36:06 +0800465*********
466Reference
467*********
468
469.. [PSA-FF-M] `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>`_
470
471.. [RFC7925] `Transport Layer Security (TLS) / Datagram Transport Layer Security (DTLS) Profiles for the Internet of Things <https://tools.ietf.org/html/rfc7925>`_
472
Summer Qinabf66982021-04-06 17:22:15 +0800473.. [PROFILE-S] :doc:`Trusted Firmware-M Profile Small Design </docs/technical_references/profiles/tfm_profile_small>`
David Hu5fc31c12020-05-16 22:36:06 +0800474
475.. [RFC7252] `The Constrained Application Protocol (CoAP) <https://tools.ietf.org/html/rfc7252>`_
476
477.. [RFC4279] `Pre-Shared Key Ciphersuites for Transport Layer Security (TLS) <https://tools.ietf.org/html/rfc4279>`_
478
479.. [RFC7251] `AES-CCM Elliptic Curve Cryptography (ECC) Cipher Suites for TLS <https://tools.ietf.org/html/rfc7251>`_
480
Summer Qinabf66982021-04-06 17:22:15 +0800481.. [CRYPTO-DESIGN] :doc:`Crypto design </docs/technical_references/tfm_crypto_design>`
David Hu5fc31c12020-05-16 22:36:06 +0800482
Summer Qinabf66982021-04-06 17:22:15 +0800483.. [ITS-INTEGRATE] :doc:`ITS integration guide </docs/integration_guide/services/tfm_its_integration_guide>`
David Hu5fc31c12020-05-16 22:36:06 +0800484
485.. [TFM-BUILD] :doc:`TF-M build instruction </docs/getting_started/tfm_build_instruction>`
486
487--------------
488
Summer Qinabf66982021-04-06 17:22:15 +0800489*Copyright (c) 2020-2021, Arm Limited. All rights reserved.*