blob: 89edd29780de079ae33cc3d59b6b2df0ed42b79a [file] [log] [blame]
David Hu1391e522021-01-21 20:12:32 +08001#######################################
2Trusted Firmware-M Profile Large Design
3#######################################
4
5:Authors: David Hu
6:Organization: Arm Limited
7:Contact: david.hu@arm.com
8
9************
10Introduction
11************
12
13TF-M Profiles defines 3 profiles: Profile Small, Profile Medium and Profile
14Large. Each profile provides a predefined list of TF-M configurations to meet
15the security requirement of typical use cases with device hardware constraints.
16TF-M Profiles align with PSA specifications and certification requirements.
17
18As one of TF-M Profiles, Profile Large protects less resource-constrained Arm
19Cortex-M devices.
20
21Compared to Profile Small [1]_ and Profile Medium [2]_, Profile Large aims to
22enable more secure features to support higher level of security required in more
23complex usage scenarios.
24
25 - Isolation level 3 enables additional isolation between
26 :term:`Application RoT` (App RoT) services.
27 - More crypto algorithms and cipher suites are selected to securely connect
28 devices to remote services offered by various major Cloud Service
29 Providers (CSP)
30 - Basic software countermeasures against physical attacks can be enabled.
31
32Profile Large can be aligned as a reference implementation with the requirements
33defined in PSA Certified Level 3 Lightweight Protection Profile [3]_.
34
35**************
36Overall design
37**************
38
39TF-M Profile Large defines the following feature set:
40
41 - Firmware Framework
42
43 - Inter-Process Communication (IPC) model [4]_
44 - Isolation level 3 [4]_
45
46 - Internal Trusted Storage (ITS)
47
48 - Crypto
49
50 - Support both symmetric ciphers and asymmetric ciphers
51 - Asymmetric key based cipher suites defined in TLS 1.2 [5]_ to support
52 direct secure connection to major CSPs, including
53
54 - Authenticated Encryption with Associated Data (AEAD) algorithm
55 - Asymmetric key algorithm based signature and verification
56 - Public-key cryptography based key exchange
57 - Hash function
58 - HMAC for default Pseudorandom Function (PRF)
59
60 - Asymmetric digital signature and verification for Initial Attestation
61 Token (IAT)
62 - Asymmetric algorithms for firmware image signature verification
63 - Key derivation
64
65 - Initial Attestation
66
67 - Asymmetric key algorithm based Initial Attestation
68
69 - Secure boot
70
71 - Anti-rollback protection
72 - Multiple image boot
73
74 - Protected Storage (PS) if off-chip storage device is integrated
75
76 - Data confidentiality
77 - Data integrity
78 - Rollback protection
79
80 - Software countermeasures against physical attacks
81
82**************
83Design details
84**************
85
86More details of TF-M Profile Large design are described in following sections.
87
88Firmware framework
89==================
90
91Profile Large selects IPC model and isolation level 3 by default.
92
93Isolation level 3 supports additional isolation between App RoT services,
94compared to isolation level 2. It can protect :term:`RoT` services from each
95other when their vendors don't trust each other.
96
97Crypto service
98==============
99
100Profile Large supports direct connection to Cloud services via common protocols,
101such as TLS 1.2.
102
103In some usage scenarios, PSA RoT can be managed by device manufacturer or other
104vendors and is out of control of application developers.
105Profile Large selects alternative crypto algorithms for each crypto function to
106support multiple common cipher suites required by various major CSPs. Therefore,
107application developers can support services for diverse CSPs on same devices
108with Profile Large, without relying on PSA RoT upgrades of crypto.
109
110Devices meeting Profile Large should be in a position to offer at least two
111alternatives to every cryptographic primitive for symmetric, asymmetric and
112hash, and be able to use them for encryption, AEAD, signature and verification.
113
114It will cost more resource in Profile Large to support more crypto algorithms
115and cipher suites, compared to Profile Medium [2]_.
116
117Boot loader
118===========
119
120BL2 implementation can be device specific. Devices may implement diverse
121boot processes with different features and configurations.
122However, the boot loader must support anti-rollback protection. Boot loader must
123be able to prevent unauthorized rollback, to protect devices from being
124downgraded to earlier versions with known vulnerabilities.
125
126MCUBoot in TF-M is configured as multiple image boot by default in Profile
127Large. In multiple image boot, secure and non-secure images can be signed
128independently with different keys and they can be updated separately. It can
129support multiple vendors scenarios, in which non-secure and secure images are
130generated and updated by different vendors.
131Multiple image boot may cost larger memory footprint compared with single image
132boot.
133
134Boot loader can implement software countermeasures to mitigate physical attacks.
135
136Protected Storage
137=================
138
139PS service is required if an off-chip storage device is integrated and used on
140the platform.
141
142Anti-rollback protection in PS relies on non-volatile counter(s) provided by
143TF-M Platform :term:`Secure Partition` (SP).
144
145TF-M audit logging service
146==========================
147
148TF-M audit logging service allows secure services in the system to log TF-M
149events and information.
150
151TF-M audit logging service is not enabled in Profile Large since its IPC model
152dedicated interface is not ready yet.
153
154.. note ::
155
156 **Implementation note**
157
158 Please note that there is no dedicated PSA specification for Audit Logging
159 yet.
160 The design, interfaces and implementation of TF-M audit logging service may
161 change.
162
163Software countermeasures against physical attacks
164=================================================
165
166TF-M Profile Large enables TF-M Fault Injection Hardening (FIH) library Profile
167Medium by default. It enables the following countermeasure techniques:
168
169 - Control flow monitor
170 - Failure loop hardening
171 - Complex constants
172 - Redundant variables and condition checks
173
174Refer to TF-M physical attack mitigation design document [6]_ for FIH library
175details.
176
177.. note ::
178
179 **TF-M FIH library is still under development**.
180
181 TF-M FIH library hardens TF-M critical execution steps to make physical
182 attacks more difficult, together with device hardware countermeasures.
183 It is not guaranteed that TF-M FIH library is able to mitigate all kinds of
184 physical attacks.
185
186.. note ::
187
188 **Implementation note**
189
190 TF-M FIH library doesn't cover platform specific critical configurations.
191 Platforms shall implement software countermeasures against physical attacks
192 to protect platform specific implementation.
193
194**************
195Implementation
196**************
197
198Overview
199========
200
201The basic idea is to add dedicated profile CMake configuration files under
202folder ``config/profile`` for TF-M Profile Large default configuration, the
203same as other TF-M Profiles do.
204
205The top-level Profile Large config file collects all the necessary configuration
206flags and set them to default values, to explicitly enable the features required
207in Profile Large and disable the unnecessary ones, during TF-M build.
208
209A platform/use case can provide a configuration extension file to overwrite
210Profile Large default setting and append other configurations.
211This configuration extension file can be added via parameter
212``TFM_EXTRA_CONFIG_PATH`` in build command line.
213
214The behaviour of the Profile Large build flow (particularly the order of
215configuration loading and overriding) can be found at
216:ref:`tfm_cmake_configuration`
217
218The details of configurations will be covered in each module in
219`Implementation details`_.
220
221Implementation details
222======================
223
224This section discusses the details of Profile Large implementation.
225
226Top-level configuration files
227-----------------------------
228
229The firmware framework configurations in ``config/profile/profile_large`` are
230shown below.
231
232.. table:: Config flags in Profile Large top-level CMake config file
233 :widths: auto
234 :align: center
235
236 +--------------------------------------------+------------------------------------+----------------------------------------------------------------------------------------------------+
237 | Configs | Descriptions | Default value |
238 +============================================+====================================+====================================================================================================+
239 | ``TFM_ISOLATION_LEVEL`` | Select level 3 isolation | ``3`` |
240 +--------------------------------------------+------------------------------------+----------------------------------------------------------------------------------------------------+
David Hu062594f2021-03-22 11:03:57 +0800241 | ``TFM_PSA_API`` | Select IPC model | ``ON`` |
David Hu1391e522021-01-21 20:12:32 +0800242 +--------------------------------------------+------------------------------------+----------------------------------------------------------------------------------------------------+
243 | ``TFM_PARTITION_INTERNAL_TRUSTED_STORAGE`` | Enable ITS SP | ``ON`` |
244 +--------------------------------------------+------------------------------------+----------------------------------------------------------------------------------------------------+
245 | ``ITS_BUF_SIZE`` | ITS internal transient buffer size | ``64`` |
246 +--------------------------------------------+------------------------------------+----------------------------------------------------------------------------------------------------+
247 | ``TFM_PARTITION_CRYPTO`` | Enable Crypto service | ``ON`` |
248 +--------------------------------------------+------------------------------------+----------------------------------------------------------------------------------------------------+
249 | ``TFM_MBEDCRYPTO_CONFIG_PATH`` | MbedTLS config file path | ``${CMAKE_SOURCE_DIR}/lib/ext/mbedcrypto/mbedcrypto_config/tfm_mbedcrypto_config_profile_large.h`` |
250 +--------------------------------------------+------------------------------------+----------------------------------------------------------------------------------------------------+
251 | ``TFM_PARTITION_INITIAL_ATTESTATION`` | Enable Initial Attestation service | ``ON`` |
252 +--------------------------------------------+------------------------------------+----------------------------------------------------------------------------------------------------+
253 | ``TFM_PARTITION_PROTECTED_STORAGE`` [a]_ | Enable PS service | ``ON`` |
254 +--------------------------------------------+------------------------------------+----------------------------------------------------------------------------------------------------+
255 | ``TFM_PARTITION_PLATFORM`` | Enable TF-M Platform SP | ``ON`` |
256 +--------------------------------------------+------------------------------------+----------------------------------------------------------------------------------------------------+
257 | ``TFM_PARTITION_AUDIT_LOG`` | Disable TF-M audit logging service | ``OFF`` |
258 +--------------------------------------------+------------------------------------+----------------------------------------------------------------------------------------------------+
259
260.. [a] PS service is enabled by default. Platforms without off-chip storage
261 devices can turn off ``TFM_PARTITION_PROTECTED_STORAGE`` to disable PS
262 service. See `Protected Storage Secure Partition`_ for details.
263
264Crypto service configurations
265-----------------------------
266
267Crypto Secure Partition
268^^^^^^^^^^^^^^^^^^^^^^^
269
270TF-M Profile Large enables Crypto SP in top-level CMake config file and selects
271all the Crypto modules.
272
273MbedTLS configurations
274^^^^^^^^^^^^^^^^^^^^^^
275
276TF-M Profile Large adds a dedicated MbedTLS config file
277``tfm_mbedcrypto_config_profile_large.h`` under
278``/lib/ext/mbedcrypto/mbedcrypto_config`` folder, instead of the common one
279``tfm_mbedcrypto_config_default.h`` [7]_.
280
281Major MbedTLS configurations are set as listed below:
282
283 - Enable SHA256 and SHA512
284 - Enable generic message digest wrappers
285 - Enable AES
286 - Enable CCM mode, GCM mode and CBC mode for symmetric ciphers
287 - Disable other modes for symmetric ciphers
288 - Enable ECDH
289 - Enable ECDSA
290 - Enable RSA
291 - Select ECC curve ``secp256r1`` and ``secp384r1``
292 - Enable HMAC-based key derivation function
293 - Other configurations required by selected option above
294
295A device/use case can append an extra config header to the Profile Large default
296MbedTLS config file to override the default settings. This can be done by
297setting the ``TFM_MBEDCRYPTO_PLATFORM_EXTRA_CONFIG_PATH`` cmake variable in the
298platform config file ``platform/ext<TFM_PLATFORM>/config.cmake``.
299This cmake variable is a wrapper around the ``MBEDTLS_USER_CONFIG_FILE``
300options, but is preferred as it keeps all configuration in cmake.
301
302Internal Trusted Storage configurations
303---------------------------------------
304
305ITS service is enabled in top-level Profile Large CMake config file by default.
306
307The internal transient buffer size ``ITS_BUF_SIZE`` [8]_ is set to 64 bytes by
308default. A platform/use case can overwrite the buffer size in its specific
309configuration extension according to its actual requirement of assets and Flash
310attributes.
311
312Profile Large CMake config file won't touch the configurations of device
313specific Flash hardware attributes.
314
315Protected Storage Secure Partition
316----------------------------------
317
318Data confidentiality, integrity and anti-rollback protection are enabled by
319default in PS.
320
321If PS is selected, AES-CCM is used as AEAD algorithm by default. If platform
322hardware crypto accelerator supports the AEAD algorithm, the AEAD operations can
323be executed in hardware crypto accelerator.
324
325If platforms don't integrate any off-chip storage device, platforms can disable
326PS in platform specific configuration extension file via
327``platform/ext<TFM_PLATFORM>/config.cmake``.
328
329BL2 setting
330-----------
331
332Profile Large enables MCUBoot provided by TF-M by default. A platform can
333overwrite this configuration by disabling MCUBoot in its configuration extension
334file ``platform/ext<TFM_PLATFORM>/config.cmake``.
335
336If MCUBoot provided by TF-M is enabled, multiple image boot is selected by
337default.
338
339If a device implements its own boot loader, the configurations are
340implementation defined.
341
342Software countermeasure against physical attacks
343------------------------------------------------
344
345Profile Large selects TF-M FIH library Profile Medium by specifying
346``-DTFM_FIH_PROFILE=MEDIUM`` in top-level CMake config file.
347
348System integrators shall implement software countermeasures in platform specific
349implementations.
350
351Device configuration extension
352------------------------------
353
354To change default configurations and add platform specific configurations,
355a platform can add a platform configuration file at
356``platform/ext<TFM_PLATFORM>/config.cmake``
357
358Test configuration
359------------------
360
361Some cryptography tests are disabled due to the reduced MbedTLS config.
362Profile Large specific test configurations are also specified in Profile Large
363top-level CMake config file ``config/profile/profile_large``.
364
365.. table:: Profile Large crypto test configuration
366 :widths: auto
367 :align: center
368
369 +--------------------------------------------+---------------+-----------------------------------------+
370 | Configs | Default value | Descriptions |
371 +============================================+===============+=========================================+
372 | ``TFM_CRYPTO_TEST_ALG_CBC`` | ``ON`` | Test CBC cryptography mode |
373 +--------------------------------------------+---------------+-----------------------------------------+
374 | ``TFM_CRYPTO_TEST_ALG_CCM`` | ``ON`` | Test CCM cryptography mode |
375 +--------------------------------------------+---------------+-----------------------------------------+
376 | ``TFM_CRYPTO_TEST_ALG_GCM`` | ``ON`` | Test GCM cryptography mode |
377 +--------------------------------------------+---------------+-----------------------------------------+
378 | ``TFM_CRYPTO_TEST_ALG_SHA_512`` | ``ON`` | Test SHA-512 cryptography algorithm |
379 +--------------------------------------------+---------------+-----------------------------------------+
380 | ``TFM_CRYPTO_TEST_HKDF`` | ``ON`` | Test HMAC-based key derivation function |
381 +--------------------------------------------+---------------+-----------------------------------------+
382 | ``TFM_CRYPTO_TEST_ALG_CFB`` | ``OFF`` | Test CFB cryptography mode |
383 +--------------------------------------------+---------------+-----------------------------------------+
384 | ``TFM_CRYPTO_TEST_ALG_CTR`` | ``OFF`` | Test CTR cryptography mode |
385 +--------------------------------------------+---------------+-----------------------------------------+
386
387****************
388Platform support
389****************
390
391To enable Profile Large on a platform, the platform specific CMake file should
392be added into the platform support list in top-level Profile Large CMake config
393file.
394
395Building Profile Large
396======================
397
398To build Profile Large, argument ``TFM_PROFILE`` in build command line should be
399set to ``profile_large``.
400
401Take AN521 as an example:
402
403The following commands build Profile Large without test cases on **AN521** with
404build type **MinSizeRel**, built by **Armclang**.
405
406.. code-block:: bash
407
408 cd <TFM root dir>
409 mkdir build && cd build
Summer Qin2de23d02021-05-14 13:44:14 +0800410 cmake -DTFM_PLATFORM=arm/mps2/an521 \
David Hu1391e522021-01-21 20:12:32 +0800411 -DTFM_TOOLCHAIN_FILE=../toolchain_ARMCLANG.cmake \
412 -DTFM_PROFILE=profile_large \
413 -DCMAKE_BUILD_TYPE=MinSizeRel \
414 ../
415 cmake --build ./ -- install
416
417The following commands build Profile Large with regression test cases on
418**AN521** with build type **MinSizeRel**, built by **Armclang**.
419
420.. code-block:: bash
421
422 cd <TFM root dir>
423 mkdir build && cd build
Summer Qin2de23d02021-05-14 13:44:14 +0800424 cmake -DTFM_PLATFORM=arm/mps2/an521 \
David Hu1391e522021-01-21 20:12:32 +0800425 -DTFM_TOOLCHAIN_FILE=../toolchain_ARMCLANG.cmake \
426 -DTFM_PROFILE=profile_large \
427 -DCMAKE_BUILD_TYPE=MinSizeRel \
428 -DTEST_S=ON -DTEST_NS=ON \
429 ../
430 cmake --build ./ -- install
431
432More details of building instructions and parameters can be found TF-M build
433instruction guide [9]_.
434
435*********
436Reference
437*********
438
Summer Qinabf66982021-04-06 17:22:15 +0800439.. [1] :doc:`Trusted Firmware-M Profile Small Design </docs/technical_references/profiles/tfm_profile_small>`
David Hu1391e522021-01-21 20:12:32 +0800440
Summer Qinabf66982021-04-06 17:22:15 +0800441.. [2] :doc:`Trusted Firmware-M Profile Medium Design </docs/technical_references/profiles/tfm_profile_medium>`
David Hu1391e522021-01-21 20:12:32 +0800442
443.. [3] `PSA Certified Level 3 Lightweight Protection Profile <https://www.psacertified.org/app/uploads/2020/12/JSADEN009-PSA_Certified_Level_3_LW_PP-1.0-BET02.pdf>`_
444
445.. [4] `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>`_
446
447.. [5] `The Transport Layer Security (TLS) Protocol Version 1.2 <https://tools.ietf.org/html/rfc5246>`_
448
Summer Qinabf66982021-04-06 17:22:15 +0800449.. [6] :doc:`Physical attack mitigation in Trusted Firmware-M </docs/technical_references/tfm_physical_attack_mitigation>`
David Hu1391e522021-01-21 20:12:32 +0800450
Summer Qinabf66982021-04-06 17:22:15 +0800451.. [7] :doc:`Crypto design </docs/technical_references/tfm_crypto_design>`
David Hu1391e522021-01-21 20:12:32 +0800452
Summer Qinabf66982021-04-06 17:22:15 +0800453.. [8] :doc:`ITS integration guide </docs/integration_guide/services/tfm_its_integration_guide>`
David Hu1391e522021-01-21 20:12:32 +0800454
455.. [9] :doc:`TF-M build instruction </docs/getting_started/tfm_build_instruction>`
456
457--------------
458
459*Copyright (c) 2021, Arm Limited. All rights reserved.*