blob: 8413635cc9da3c7539409911355259ec90821328 [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
36 - Support both symmetric ciphers and asymmetric ciphers
37 - 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
97Compared to Profile Small, Profile Medium includes asymmetric cipher to support
98direct connection to Cloud services via common protocols, such as TLS/DTLS 1.2.
99
100As suggested in CoAP [RFC7252]_ and [RFC7925]_, TF-M Profile Medium by default
101selects ``TLS_ECDHE_ECDSA_WITH_AES_128_CCM`` as reference, which requires:
102
103 - ECDHE_ECDSA as key exchange algorithm.
104 - AES-128-CCM (AES CCM mode with 128-bit key) as AEAD algorithm.
105 Platforms can implement AES-128-CCM with truncated authentication tag to
106 achieve less network bandwidth [RFC7925]_.
107 - SHA256 as Hash function.
108 - HMAC as Message Authentication Code algorithm.
109
110Applications can also support TLS PSK [RFC4279]_ cipher suites, such as
111``TLS_PSK_WITH_AES_128_CCM`` [RFC7925]_.
112
113.. note ::
114
115 **Implementation note**
116
117 Developers can replace default algorithms with others or implement more
118 algorithms according to actual usage scenarios and device capabilities.
119
120 If a Crypto hardware accelerator is integrated, the cipher suites and
121 algorithms also depend on those accelerator features.
122
123More details of cipher suite are described below.
124
125Digital signature and verification
126----------------------------------
127
128ECDSA is selected by default in Profile Medium.
129ECDSA requires much shorter keys compared with RSA at the same security level.
130Therefore, ECDSA can cost less storage area for assets and less network
131bandwidth to setup a TLS connection.
132ECDSA is also preferred for forward compatibility of future TLS versions.
133
134As requested in [RFC7251]_, ECC curve ``secp256r1`` should be supported. More
135ECC curves can be added based on the requirements in production.
136
137If usage scenarios require RSA algorithm for backward compatibility and legacy
138applications, platforms can add RSA support or replace ECDSA with RSA. The
139cipher suite should be switched accordingly.
140
141AEAD algorithm
142--------------
143
144If Protected Storage (PS) is implemented, it is recommended to select the same
145AEAD algorithm for PS service as the one used by TLS/DTLS cipher suite.
146
147Internal Trusted Storage
148========================
149
150The configuration of ITS is the same as those in Profile Small [PROFILE-S]_.
151
152Lightweight boot
153================
154
155BL2 implementation can be device specific. Devices may implement diverse
156boot processes with different features and configurations.
157However, the boot loader must support anti-rollback protection. Boot loader must
158be able to prevent unauthorized rollback, to protect devices from being
159downgraded to earlier versions with known vulnerabilities.
160
161MCUBoot in TF-M is configured as multiple image boot by default in Profile
162Medium. In multiple image boot, secure and non-secure images can be signed
163independently with different keys and they can be updated separately. It can
164support multiple vendors scenarios, in which non-secure and secure images are
165generated and updated by different vendors.
166Multiple image boot may require more storage area compared with single image
167boot.
168
169Protected Storage
170=================
171
172PS service is required if an off-chip storage device is integrated and used on
173the platform.
174
175TF-M PS service relies on an AEAD algorithm to ensure data confidentiality and
176integrity. It is recommended to select the same AEAD algorithm as the one used
177for TLS/DTLS cipher suite.
178
179Anti-rollback protection in PS relies on non-volatile counter(s) provided by
180TF-M Platform Secure Partition (SP).
181
182TF-M audit logging service
183==========================
184
185TF-M audit logging service allows secure services in the system to log critical
186system events and information.
187
188TF-M audit logging service is not enabled in Profile Medium since its IPC model
189dedicated interface is not ready yet.
190
191.. note ::
192
193 **Implementation note**
194
195 Please note that there is no dedicated PSA specification for Audit Logging
196 yet.
197 The design, interfaces and implementation of TF-M audit logging service may
198 change.
199
200**************
201Implementation
202**************
203
204Overview
205========
206
Anton Komlevb8e3af02020-08-28 10:23:57 +0100207The basic idea is to add dedicated profile CMake configuration files under
208folder ``config/profile`` for TF-M Profile Medium default configuration, the
209same as Profile Small does.
David Hu5fc31c12020-05-16 22:36:06 +0800210
211The top-level Profile Medium config file collects all the necessary
212configuration flags and set them to default values, to explicitly enable the
213features required in Profile Medium and disable the unnecessary ones, during
214TF-M build.
215
216A platform/use case can provide a configuration extension file to overwrite
217Profile Medium default setting and append other configurations.
218This configuration extension file can be added via parameter
Anton Komlevb8e3af02020-08-28 10:23:57 +0100219``TFM_EXTRA_CONFIG_PATH`` in build command line.
David Hu5fc31c12020-05-16 22:36:06 +0800220
Anton Komlevb8e3af02020-08-28 10:23:57 +0100221The behaviour of the Profile Medium build flow (particularly the order of
222configuration loading and overriding) can be found at
223:ref:`tfm_cmake_configuration`
David Hu5fc31c12020-05-16 22:36:06 +0800224
225The details of configurations will be covered in each module in
226`Implementation details`_.
227
228Implementation details
229======================
230
231This section discusses the details of Profile Medium implementation.
232
233Top-level configuration files
234-----------------------------
235
Anton Komlevb8e3af02020-08-28 10:23:57 +0100236The firmware framework configurations in ``config/profile/profile_medium`` are
237shown below.
David Hu5fc31c12020-05-16 22:36:06 +0800238
239.. table:: Config flags in Profile Medium top-level CMake config file
240 :widths: auto
241 :align: center
242
Anton Komlevb8e3af02020-08-28 10:23:57 +0100243 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
244 | Configs | Default value | Descriptions |
245 +============================================+=====================================================================================================+=====================================+
246 | ``TFM_ISOLATION_LEVEL`` | ``2`` | Select level 2 isolation |
247 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
248 | ``TFM_PSA_API`` | ``True`` | Select IPC model |
249 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
250 | ``TFM_PARTITION_INTERNAL_TRUSTED_STORAGE`` | ``ON`` | Enable ITS SP |
251 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
252 | ``ITS_BUF_SIZE`` | ``32`` | ITS internal transient buffer size |
253 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
254 | ``TFM_PARTITION_CRYPTO`` | ``ON`` | Enable Crypto service |
255 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
256 | ``TFM_MBEDCRYPTO_CONFIG_PATH`` | ``${CMAKE_SOURCE_DIR}/lib/ext/mbedcrypto/mbedcrypto_config/tfm_mbedcrypto_config_profile_medium.h`` | Mbed Crypto config file path |
257 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
258 | ``TFM_PARTITION_INITIAL_ATTESTATION`` | ``ON`` | Enable Initial Attestation service |
259 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
260 | ``TFM_PARTITION_PROTECTED_STORAGE`` [1]_ | ``ON`` | Enable PS service |
261 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
262 | ``TFM_PARTITION_PLATFORM`` | ``ON`` | Enable TF-M Platform SP |
263 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
264 | ``TFM_PARTITION_AUDIT_LOG`` | ``OFF`` | Disable TF-M audit logging service |
265 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
David Hu5fc31c12020-05-16 22:36:06 +0800266
267.. [1] PS service is enabled by default. Platforms without off-chip storage
268 devices can turn off ``TFM_PARTITION_PROTECTED_STORAGE`` to disable PS
269 service. See `Protected Storage Secure Partition`_ for details.
270
Anton Komlevb8e3af02020-08-28 10:23:57 +0100271.. Note::
David Hu5fc31c12020-05-16 22:36:06 +0800272
Anton Komlevb8e3af02020-08-28 10:23:57 +0100273 Where a configuration is the same as the default in
274 ``config/config_default.cmake``, it is omitted from the profile configuration
275 file.
David Hu5fc31c12020-05-16 22:36:06 +0800276
Anton Komlevb8e3af02020-08-28 10:23:57 +0100277Test configuration
278^^^^^^^^^^^^^^^^^^
279
280Standard regression test configuration applies. This means that enabling
281regression testing via
282
283``-DTEST_S=ON -DTEST_NS=ON``
284
285Will enable testing for all enabled partitions. See above for details of enabled
286partitions. Because Profile Medium enables IPC mode, the IPC tests are also
287enabled.
288
289Some cryptography tests are disabled due to the reduced Mbed Crypto config.
290
291.. table:: TFM options in Profile Medium top-level CMake config file
David Hu5fc31c12020-05-16 22:36:06 +0800292 :widths: auto
293 :align: center
294
Anton Komlevb8e3af02020-08-28 10:23:57 +0100295 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
296 | Configs | Default value | Descriptions |
297 +============================================+=====================================================================================================+=====================================+
298 | ``TFM_CRYPTO_TEST_ALG_CBC`` | ``OFF`` | Test CBC cryptography mode |
299 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
300 | ``TFM_CRYPTO_TEST_ALG_CCM`` | ``ON`` | Test CCM cryptography mode |
301 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
302 | ``TFM_CRYPTO_TEST_ALG_CFB`` | ``OFF`` | Test CFB cryptography mode |
303 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
304 | ``TFM_CRYPTO_TEST_ALG_CTR`` | ``OFF`` | Test CTR cryptography mode |
305 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
306 | ``TFM_CRYPTO_TEST_ALG_GCM`` | ``OFF`` | Test GCM cryptography mode |
307 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
308 | ``TFM_CRYPTO_TEST_ALG_SHA_512`` | ``OFF`` | Test SHA-512 cryptography algorithm |
309 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
310 | ``TFM_CRYPTO_TEST_HKDF`` | ``OFF`` | Test SHA-512 cryptography algorithm |
311 +--------------------------------------------+-----------------------------------------------------------------------------------------------------+-------------------------------------+
David Hu5fc31c12020-05-16 22:36:06 +0800312
313Device configuration extension
314^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
315
316To change default configurations and add platform specific configurations,
Anton Komlevb8e3af02020-08-28 10:23:57 +0100317a platform can add a platform configuration file at
318``platform/ext<TFM_PLATFORM>/config.cmake``
David Hu5fc31c12020-05-16 22:36:06 +0800319
320Crypto service configurations
321-----------------------------
322
323Crypto Secure Partition
324^^^^^^^^^^^^^^^^^^^^^^^
325
326TF-M Profile Medium enables Crypto SP in top-level CMake config file and selects
327all the Crypto modules.
328
329Mbed Crypto configurations
330^^^^^^^^^^^^^^^^^^^^^^^^^^
331
332TF-M Profile Medium adds a dedicated Mbed Crypto config file
Anton Komlevb8e3af02020-08-28 10:23:57 +0100333``tfm_mbedcrypto_config_profile_medium.h`` at
334``/lib/ext/mbedcrypto/mbedcrypto_config``
335file, instead of the common one ``tfm_mbedcrypto_config_default.h`` [CRYPTO-DESIGN]_.
David Hu5fc31c12020-05-16 22:36:06 +0800336
337Major Mbed Crypto configurations are set as listed below:
338
339 - Enable SHA256
340 - Enable generic message digest wrappers
341 - Enable AES
342 - Enable CCM mode for symmetric ciphers
343 - Disable other modes for symmetric ciphers
344 - Enable ECDH
345 - Enable ECDSA
346 - Select ECC curve ``secp256r1``
347 - Other configurations required by selected option above
348
349Other configurations can be selected to optimize the memory footprint of Crypto
350module.
351
Anton Komlevb8e3af02020-08-28 10:23:57 +0100352A device/use case can append an extra config header to the Profile Medium
353default Mbed Crypto config file. This can be done by setting the
354``TFM_MBEDCRYPTO_PLATFORM_EXTRA_CONFIG_PATH`` cmake variable in the platform
355config file ``platform/ext<TFM_PLATFORM>/config.cmake``. This cmake variable is
356a wrapper around the ``MBEDTLS_USER_CONFIG_FILE`` options, but is preferred as
357it keeps all configuration in cmake.
David Hu5fc31c12020-05-16 22:36:06 +0800358
359Internal Trusted Storage configurations
360---------------------------------------
361
362ITS service is enabled in top-level Profile Medium CMake config file by default.
363
364The internal transient buffer size ``ITS_BUF_SIZE`` [ITS-INTEGRATE]_ is set to
36532 bytes by default. A platform/use case can overwrite the buffer size in its
366specific configuration extension according to its actual requirement of assets
367and Flash attributes.
368
369Profile Medium CMake config file won't touch the configurations of device
370specific Flash hardware attributes [ITS-INTEGRATE]_.
371
372Protected Storage Secure Partition
373----------------------------------
374
375Data confidentiality, integrity and anti-rollback protection are enabled by
376default in PS.
377
378If PS is selected, AES-CCM is used as AEAD algorithm by default. It requires to
379enable PS implementation to select diverse AEAD algorithm.
380
381If platforms don't integrate any off-chip storage device, platforms can disable
382PS in platform specific configuration extension file via
Anton Komlevb8e3af02020-08-28 10:23:57 +0100383``platform/ext<TFM_PLATFORM>/config.cmake``.
David Hu5fc31c12020-05-16 22:36:06 +0800384
385BL2 setting
386-----------
387
388Profile Medium enables MCUBoot provided by TF-M by default. A platform can
389overwrite this configuration by disabling MCUBoot in its configuration extension
Anton Komlevb8e3af02020-08-28 10:23:57 +0100390file ``platform/ext<TFM_PLATFORM>/config.cmake``.
David Hu5fc31c12020-05-16 22:36:06 +0800391
392If MCUBoot provided by TF-M is enabled, multiple image boot is selected by
393default in TF-M Profile Medium top-level CMake config file.
394
395If a device implements its own boot loader, the configurations are
396implementation defined.
397
398****************
399Platform support
400****************
401
402To enable Profile Medium on a platform, the platform specific CMake file should
403be added into the platform support list in top-level Profile Medium CMake config
404file.
405
406Building Profile Medium
407=======================
408
Anton Komlevb8e3af02020-08-28 10:23:57 +0100409To build Profile Medium, argument ``TFM_PROFILE`` in build command line should be
410set to ``profile_medium``.
David Hu5fc31c12020-05-16 22:36:06 +0800411
412Take AN521 as an example:
413
414The following commands build Profile Medium without test cases on **AN521** with
415build type **MinSizeRel**, built by **Armclang**.
416
417.. code-block:: bash
418
Anton Komlevb8e3af02020-08-28 10:23:57 +0100419 cd <TFM root dir>
420 mkdir build && cd build
421 cmake -DTFM_PLATFORM=mps2/an521 \
Raef Coles69817322020-10-19 14:14:14 +0100422 -DTFM_TOOLCHAIN_FILE=../toolchain_ARMCLANG.cmake \
Anton Komlevb8e3af02020-08-28 10:23:57 +0100423 -DTFM_PROFILE=profile_medium \
424 -DCMAKE_BUILD_TYPE=MinSizeRel \
425 ../
426 cmake --build ./ -- install
David Hu5fc31c12020-05-16 22:36:06 +0800427
428The following commands build Profile Medium with regression test cases on
429**AN521** with build type **MinSizeRel**, built by **Armclang**.
430
431.. code-block:: bash
432
Anton Komlevb8e3af02020-08-28 10:23:57 +0100433 cd <TFM root dir>
434 mkdir build && cd build
435 cmake -DTFM_PLATFORM=mps2/an521 \
Raef Coles69817322020-10-19 14:14:14 +0100436 -DTFM_TOOLCHAIN_FILE=../toolchain_ARMCLANG.cmake \
Anton Komlevb8e3af02020-08-28 10:23:57 +0100437 -DTFM_PROFILE=profile_medium \
438 -DCMAKE_BUILD_TYPE=MinSizeRel \
439 -DTEST_S=ON -DTEST_NS=ON \
440 ../
441 cmake --build ./ -- install
442
443.. Note::
444
445 - For devices with more contrained memory and flash requirements, it is
446 possible to build with either only TEST_S enabled or only TEST_NS enabled.
447 This will decrease the size of the test images. Note that both test suites
448 must still be run to ensure correct operation.
David Hu5fc31c12020-05-16 22:36:06 +0800449
450More details of building instructions and parameters can be found TF-M build
451instruction guide [TFM-BUILD]_.
452
David Hu5fc31c12020-05-16 22:36:06 +0800453*********
454Reference
455*********
456
457.. [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>`_
458
459.. [RFC7925] `Transport Layer Security (TLS) / Datagram Transport Layer Security (DTLS) Profiles for the Internet of Things <https://tools.ietf.org/html/rfc7925>`_
460
David Hu561cd9c2020-06-23 17:05:28 +0800461.. [PROFILE-S] :doc:`Trusted Firmware-M Profile Small Design </docs/design_documents/profiles/tfm_profile_small>`
David Hu5fc31c12020-05-16 22:36:06 +0800462
463.. [RFC7252] `The Constrained Application Protocol (CoAP) <https://tools.ietf.org/html/rfc7252>`_
464
465.. [RFC4279] `Pre-Shared Key Ciphersuites for Transport Layer Security (TLS) <https://tools.ietf.org/html/rfc4279>`_
466
467.. [RFC7251] `AES-CCM Elliptic Curve Cryptography (ECC) Cipher Suites for TLS <https://tools.ietf.org/html/rfc7251>`_
468
469.. [CRYPTO-DESIGN] :doc:`Crypto design </docs/design_documents/tfm_crypto_design>`
470
471.. [ITS-INTEGRATE] :doc:`ITS integration guide </docs/reference/services/tfm_its_integration_guide>`
472
473.. [TFM-BUILD] :doc:`TF-M build instruction </docs/getting_started/tfm_build_instruction>`
474
475--------------
476
477*Copyright (c) 2020, Arm Limited. All rights reserved.*