blob: 197b80814e6297c5fe821efdec86bd6b8d7b587b [file] [log] [blame]
Yanray Wangb153aae2023-09-06 12:32:10 +08001/**
2 * \file config-tfm.h
3 *
Gilles Peskinee23fa412023-09-06 17:16:36 +02004 * \brief TF-M medium profile, adapted to work on other platforms.
Yanray Wangb153aae2023-09-06 12:32:10 +08005 */
6/*
7 * Copyright The Mbed TLS Contributors
Yanray Wang8636d472023-11-08 10:07:01 +08008 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Yanray Wangb153aae2023-09-06 12:32:10 +08009 */
10
Gilles Peskinee23fa412023-09-06 17:16:36 +020011/* TF-M medium profile: mbedtls legacy configuration */
Yanray Wang4419d382023-09-07 11:28:27 +080012#include "../configs/ext/tfm_mbedcrypto_config_profile_medium.h"
Yanray Wangb153aae2023-09-06 12:32:10 +080013
Gilles Peskinee23fa412023-09-06 17:16:36 +020014/* TF-M medium profile: PSA crypto configuration */
Yanray Wangb153aae2023-09-06 12:32:10 +080015#define MBEDTLS_PSA_CRYPTO_CONFIG_FILE "../configs/ext/crypto_config_profile_medium.h"
Yanray Wang0c98f9f2023-09-06 15:47:49 +080016
Gilles Peskinee23fa412023-09-06 17:16:36 +020017/***********************************************************/
18/* Tweak the configuration to remove dependencies on TF-M. */
19/***********************************************************/
Yanray Wang0c98f9f2023-09-06 15:47:49 +080020
Gilles Peskinee23fa412023-09-06 17:16:36 +020021/* MBEDTLS_PSA_CRYPTO_SPM needs third-party files, so disable it. */
Yanray Wang0c98f9f2023-09-06 15:47:49 +080022#undef MBEDTLS_PSA_CRYPTO_SPM
Gilles Peskinee23fa412023-09-06 17:16:36 +020023
Gilles Peskinee23fa412023-09-06 17:16:36 +020024/* Use built-in platform entropy functions (TF-M provides its own). */
Yanray Wang0c98f9f2023-09-06 15:47:49 +080025#undef MBEDTLS_NO_PLATFORM_ENTROPY
Gilles Peskinee23fa412023-09-06 17:16:36 +020026
27/* Disable buffer-based memory allocator. This isn't strictly required,
28 * but using the native allocator is faster and works better with
29 * memory management analysis frameworks such as ASan. */
Yanray Wang0c98f9f2023-09-06 15:47:49 +080030#undef MBEDTLS_MEMORY_BUFFER_ALLOC_C
Dave Rodgman4edcf692023-11-15 12:23:29 +000031
32// This macro is enabled in TFM Medium but is disabled here because it is
33// incompatible with baremetal builds in Mbed TLS.
34#undef MBEDTLS_PSA_CRYPTO_STORAGE_C
35
36// This macro is enabled in TFM Medium but is disabled here because it is
37// incompatible with baremetal builds in Mbed TLS.
38#undef MBEDTLS_ENTROPY_NV_SEED
39
40// These platform-related TF-M settings are not useful here.
41#undef MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
42#undef MBEDTLS_PLATFORM_STD_MEM_HDR
43#undef MBEDTLS_PLATFORM_SNPRINTF_MACRO
44#undef MBEDTLS_PLATFORM_PRINTF_ALT
45#undef MBEDTLS_PLATFORM_STD_EXIT_SUCCESS
46#undef MBEDTLS_PLATFORM_STD_EXIT_FAILURE
47
Valerio Setti5e18b902023-12-04 12:07:30 +010048/* CCM is the only cipher/AEAD enabled in TF-M configuration files, but it
Valerio Setti1e3fcc52023-12-06 11:56:08 +010049 * does not need CIPHER_C to be enabled, so we can disable it in order
Valerio Setti5e18b902023-12-04 12:07:30 +010050 * to reduce code size further. */
51#undef MBEDTLS_CIPHER_C
52
Dave Rodgman51e72452023-11-29 09:44:44 +000053/*
54 * In order to get an example config that works cleanly out-of-the-box
55 * for both baremetal and non-baremetal builds, we detect baremetal builds
56 * and set this variable automatically.
57 */
58#if defined(__IAR_SYSTEMS_ICC__) || defined(__ARM_EABI__)
59#define MBEDTLS_NO_PLATFORM_ENTROPY
60#endif
61
Dave Rodgman4edcf692023-11-15 12:23:29 +000062/***********************************************************************
63 * Local changes to crypto config below this delimiter
64 **********************************************************************/
Dave Rodgmane4cf9b62023-11-29 09:43:20 +000065
66// We expect TF-M to pick this up soon
67#define MBEDTLS_BLOCK_CIPHER_NO_DECRYPT