blob: 35d7cb00137608d4c285c11de4bd1ea7010a0c8a [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
207The basic idea is to add dedicated top-level CMake configuration files under
208folder ``configs`` for TF-M Profile Medium default configuration, as the same as
209Profile Small does.
210
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
219``TFM_PROFILE_CONFIG_EXT`` in build command line. The top-level config file will
220include the device configuration extension file to load platform/use case
221specific configurations.
222
223The overall build flow of Profile Medium is shown as the flowchart below.
224
225.. uml::
226
227 @startuml
228
229 title Overall build flow
230
231 start
232
233 :Profile Medium CMake file;
234 note left
235 Top-level CMake config file under ""configs"".
236 Set configurations to default values.
237 endnote
238
239 if (Platform config\nextension specified?) then (Yes)
240 :Include platform specific\nconfig extension file;
241 note left
242 Platform specific configuration extension file
243 is provided via ""TFM_PROFILE_CONFIG_EXT"" in
244 build command line.
245 endnote
246
247 :Overwrite default configurations;
248 else (No)
249 endif
250
251 :CommonConfig.cmake;
252 note left
253 Normal building sequence
254 endnote
255
256 stop
257
258 @enduml
259
260The details of configurations will be covered in each module in
261`Implementation details`_.
262
263Implementation details
264======================
265
266This section discusses the details of Profile Medium implementation.
267
268Top-level configuration files
269-----------------------------
270
271Profile Medium provides ``ConfigDefaultProfileM`` as a default top-level
272configuration file without test cases.
273
274The firmware framework configurations in ``ConfigDefaultProfileM`` are shown
275below.
276
277.. table:: Config flags in Profile Medium top-level CMake config file
278 :widths: auto
279 :align: center
280
281 +--------------------------------------------+-------------------------------------+-------------------------------------+
282 | Configs | Default value | Descriptions |
283 +============================================+=====================================+=====================================+
284 | ``TFM_LVL`` | ``2`` | Select level 2 isolation |
285 +--------------------------------------------+-------------------------------------+-------------------------------------+
286 | ``CORE_IPC`` | ``True`` | Select IPC model |
287 +--------------------------------------------+-------------------------------------+-------------------------------------+
288 | ``TFM_PARTITION_INTERNAL_TRUSTED_STORAGE`` | ``ON`` | Enable ITS SP |
289 +--------------------------------------------+-------------------------------------+-------------------------------------+
290 | ``ITS_BUF_SIZE`` | ``32`` | ITS internal transient buffer size |
291 +--------------------------------------------+-------------------------------------+-------------------------------------+
292 | ``TFM_PARTITION_CRYPTO`` | ``ON`` | Enable Crypto service |
293 +--------------------------------------------+-------------------------------------+-------------------------------------+
294 | ``MBEDTLS_CONFIG_FILE`` | ``tfm_profile_m_mbedcrypto_config`` | Default Mbed Crypto config file for |
295 | | | Profile Medium under |
296 | | | ``platform/ext/common`` |
297 +--------------------------------------------+-------------------------------------+-------------------------------------+
298 | ``TFM_PARTITION_INITIAL_ATTESTATION`` | ``ON`` | Enable Initial Attestation service |
299 +--------------------------------------------+-------------------------------------+-------------------------------------+
300 | ``TFM_PARTITION_PROTECTED_STORAGE`` [1]_ | ``ON`` | Enable PS service |
301 +--------------------------------------------+-------------------------------------+-------------------------------------+
302 | ``TFM_PARTITION_PLATFORM`` | ``ON`` | Enable TF-M Platform SP |
303 +--------------------------------------------+-------------------------------------+-------------------------------------+
304 | ``TFM_PARTITION_AUDIT_LOG`` | ``OFF`` | Disable TF-M audit logging service |
305 +--------------------------------------------+-------------------------------------+-------------------------------------+
306
307.. [1] PS service is enabled by default. Platforms without off-chip storage
308 devices can turn off ``TFM_PARTITION_PROTECTED_STORAGE`` to disable PS
309 service. See `Protected Storage Secure Partition`_ for details.
310
311Profile Medium provides ``ConfigRegressionProfileM`` as the default top-level
312configuration file with regression tests.
313
314The table below collects ``ConfigRegressionProfileM`` major configurations
315which are not covered or different from those in ``ConfigDefaultProfileM``.
316
317.. table:: Major config flags in Profile Medium top-level CMake config file with tests
318 :widths: auto
319 :align: center
320
321 +------------------+---------------+------------------------+
322 | Configs | Default value | Descriptions |
323 +==================+===============+========================+
324 | ``REGRESSION`` | ``ON`` | Enable Regression test |
325 +------------------+---------------+------------------------+
326 | ``CORE_TEST`` | ``ON`` | Enable Core test |
327 +------------------+---------------+------------------------+
328 | ``IPC_TEST`` | ``ON`` | Enable IPC test |
329 +------------------+---------------+------------------------+
330 | ``PSA_API_TEST`` | ``OFF`` | Disable PSA API test |
331 +------------------+---------------+------------------------+
332
333The test cases should be disabled in ``ConfigRegressionProfileM`` if the
334corresponding feature is not selected in Profile Medium by default.
335
336Device configuration extension
337^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
338
339To change default configurations and add platform specific configurations,
340a platform can set the path to its own configuration extension file in parameter
341``TFM_PROFILE_CONFIG_EXT`` in command line.
342
343A platform can also add its device specific configurations into its specific
344CMake file under ``platform/ext/`` folder.
345
346Crypto service configurations
347-----------------------------
348
349Crypto Secure Partition
350^^^^^^^^^^^^^^^^^^^^^^^
351
352TF-M Profile Medium enables Crypto SP in top-level CMake config file and selects
353all the Crypto modules.
354
355Mbed Crypto configurations
356^^^^^^^^^^^^^^^^^^^^^^^^^^
357
358TF-M Profile Medium adds a dedicated Mbed Crypto config file
359``tfm_profile_m_mbedcrypto_config.h`` under ``platform/ext/common``.
360TF-M Profile Medium specifies ``tfm_profile_m_mbedcrypto_config.h`` as the
361default Mbed Crypto config in ``MBEDTLS_CONFIG_FILE`` in top-level CMake config
362file, instead of the common one ``tfm_mbedcrypto_config.h`` [CRYPTO-DESIGN]_.
363
364Major Mbed Crypto configurations are set as listed below:
365
366 - Enable SHA256
367 - Enable generic message digest wrappers
368 - Enable AES
369 - Enable CCM mode for symmetric ciphers
370 - Disable other modes for symmetric ciphers
371 - Enable ECDH
372 - Enable ECDSA
373 - Select ECC curve ``secp256r1``
374 - Other configurations required by selected option above
375
376Other configurations can be selected to optimize the memory footprint of Crypto
377module.
378
379A device/use case can replace Profile Medium default Mbed Crypto config file
380with its specific one to overwrite the default configurations. Alternatively, a
381device can overwrite the configurations by appending a config file via
382``MBEDTLS_USER_CONFIG_FILE``.
383
384Internal Trusted Storage configurations
385---------------------------------------
386
387ITS service is enabled in top-level Profile Medium CMake config file by default.
388
389The internal transient buffer size ``ITS_BUF_SIZE`` [ITS-INTEGRATE]_ is set to
39032 bytes by default. A platform/use case can overwrite the buffer size in its
391specific configuration extension according to its actual requirement of assets
392and Flash attributes.
393
394Profile Medium CMake config file won't touch the configurations of device
395specific Flash hardware attributes [ITS-INTEGRATE]_.
396
397Protected Storage Secure Partition
398----------------------------------
399
400Data confidentiality, integrity and anti-rollback protection are enabled by
401default in PS.
402
403If PS is selected, AES-CCM is used as AEAD algorithm by default. It requires to
404enable PS implementation to select diverse AEAD algorithm.
405
406If platforms don't integrate any off-chip storage device, platforms can disable
407PS in platform specific configuration extension file via
408``TFM_PROFILE_CONFIG_EXT``.
409Profile Medium provides a configuration extension file example
410``profile_m_config_ext_ps_disabled.cmake`` which disables PS service.
411
412BL2 setting
413-----------
414
415Profile Medium enables MCUBoot provided by TF-M by default. A platform can
416overwrite this configuration by disabling MCUBoot in its configuration extension
417file or in its specific CMake file under ``platform/ext/`` folder.
418
419If MCUBoot provided by TF-M is enabled, multiple image boot is selected by
420default in TF-M Profile Medium top-level CMake config file.
421
422If a device implements its own boot loader, the configurations are
423implementation defined.
424
425****************
426Platform support
427****************
428
429To enable Profile Medium on a platform, the platform specific CMake file should
430be added into the platform support list in top-level Profile Medium CMake config
431file.
432
433Building Profile Medium
434=======================
435
436To build Profile Medium, argument ``PROJ_CONFIG`` in build command line should
437be set to following config files
438
439 - ``ConfigDefaultProfileM.cmake``
440 - ``ConfigRegressionProfileM.cmake``.
441
442Take AN521 as an example:
443
444The following commands build Profile Medium without test cases on **AN521** with
445build type **MinSizeRel**, built by **Armclang**.
446
447.. code-block:: bash
448
449 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigDefaultProfileM.cmake` \
450 -DTARGET_PLATFORM=AN521 \
451 -DCMAKE_BUILD_TYPE=MinSizeRel \
452 -DCOMPILER=ARMCLANG ../
453 cmake --build ./ -- install
454
455The following commands build Profile Medium with regression test cases on
456**AN521** with build type **MinSizeRel**, built by **Armclang**.
457
458.. code-block:: bash
459
460 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigRegressionProfileM.cmake` \
461 -DTARGET_PLATFORM=AN521 \
462 -DCMAKE_BUILD_TYPE=MinSizeRel \
463 -DCOMPILER=ARMCLANG ../
464 cmake --build ./ -- install
465
466More details of building instructions and parameters can be found TF-M build
467instruction guide [TFM-BUILD]_.
468
469The following commands include platform specific configuration extension file
470via ``TFM_PROFILE_CONFIG_EXT`` in command line. ``TFM_PROFILE_CONFIG_EXT`` can
471be an absolute path or a relative one to TF-M code root directory.
472The configuration extension file ``profile_m_config_ext_ps_disabled.cmake`` in
473the example below overwrites and disables PS service.
474
475.. code-block:: bash
476
477 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigDefaultProfileM.cmake` \
478 -DTARGET_PLATFORM=AN521 \
479 -DCMAKE_BUILD_TYPE=MinSizeRel \
480 -DCOMPILER=ARMCLANG \
481 -DTFM_PROFILE_CONFIG_EXT=configs/profile_m_config_ext_ps_disabled.cmake ../
482 cmake --build ./ -- install
483
484
485*********
486Reference
487*********
488
489.. [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>`_
490
491.. [RFC7925] `Transport Layer Security (TLS) / Datagram Transport Layer Security (DTLS) Profiles for the Internet of Things <https://tools.ietf.org/html/rfc7925>`_
492
493.. [PROFILE-S] :doc:`Trusted Firmware-M Profile Small Design </docs/design_documents/tfm_profile_small>`
494
495.. [RFC7252] `The Constrained Application Protocol (CoAP) <https://tools.ietf.org/html/rfc7252>`_
496
497.. [RFC4279] `Pre-Shared Key Ciphersuites for Transport Layer Security (TLS) <https://tools.ietf.org/html/rfc4279>`_
498
499.. [RFC7251] `AES-CCM Elliptic Curve Cryptography (ECC) Cipher Suites for TLS <https://tools.ietf.org/html/rfc7251>`_
500
501.. [CRYPTO-DESIGN] :doc:`Crypto design </docs/design_documents/tfm_crypto_design>`
502
503.. [ITS-INTEGRATE] :doc:`ITS integration guide </docs/reference/services/tfm_its_integration_guide>`
504
505.. [TFM-BUILD] :doc:`TF-M build instruction </docs/getting_started/tfm_build_instruction>`
506
507--------------
508
509*Copyright (c) 2020, Arm Limited. All rights reserved.*