blob: 8ed0792edd14796b704d5fb2a555996cfe00821f [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/* Disable buffer-based memory allocator. This isn't strictly required,
25 * but using the native allocator is faster and works better with
26 * memory management analysis frameworks such as ASan. */
Yanray Wang0c98f9f2023-09-06 15:47:49 +080027#undef MBEDTLS_MEMORY_BUFFER_ALLOC_C
Dave Rodgman4edcf692023-11-15 12:23:29 +000028
29// This macro is enabled in TFM Medium but is disabled here because it is
30// incompatible with baremetal builds in Mbed TLS.
31#undef MBEDTLS_PSA_CRYPTO_STORAGE_C
32
33// This macro is enabled in TFM Medium but is disabled here because it is
34// incompatible with baremetal builds in Mbed TLS.
35#undef MBEDTLS_ENTROPY_NV_SEED
36
37// These platform-related TF-M settings are not useful here.
38#undef MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
39#undef MBEDTLS_PLATFORM_STD_MEM_HDR
40#undef MBEDTLS_PLATFORM_SNPRINTF_MACRO
41#undef MBEDTLS_PLATFORM_PRINTF_ALT
42#undef MBEDTLS_PLATFORM_STD_EXIT_SUCCESS
43#undef MBEDTLS_PLATFORM_STD_EXIT_FAILURE
44
Valerio Setti5e18b902023-12-04 12:07:30 +010045/* CCM is the only cipher/AEAD enabled in TF-M configuration files, but it
Valerio Setti1e3fcc52023-12-06 11:56:08 +010046 * does not need CIPHER_C to be enabled, so we can disable it in order
Valerio Setti5e18b902023-12-04 12:07:30 +010047 * to reduce code size further. */
48#undef MBEDTLS_CIPHER_C
49
Dave Rodgman51e72452023-11-29 09:44:44 +000050/*
51 * In order to get an example config that works cleanly out-of-the-box
52 * for both baremetal and non-baremetal builds, we detect baremetal builds
Dave Rodgman13d26332023-12-13 17:23:46 +000053 * (either IAR, Arm compiler or __ARM_EABI__ defined), and adjust some
54 * variables accordingly.
Dave Rodgman51e72452023-11-29 09:44:44 +000055 */
Dave Rodgman13d26332023-12-13 17:23:46 +000056#if defined(__IAR_SYSTEMS_ICC__) || defined(__ARMCC_VERSION) || defined(__ARM_EABI__)
Dave Rodgman51e72452023-11-29 09:44:44 +000057#define MBEDTLS_NO_PLATFORM_ENTROPY
Dave Rodgman13d26332023-12-13 17:23:46 +000058#else
59/* Use built-in platform entropy functions (TF-M provides its own). */
60#undef MBEDTLS_NO_PLATFORM_ENTROPY
Dave Rodgman51e72452023-11-29 09:44:44 +000061#endif
62
Dave Rodgman4edcf692023-11-15 12:23:29 +000063/***********************************************************************
64 * Local changes to crypto config below this delimiter
65 **********************************************************************/
Dave Rodgmane4cf9b62023-11-29 09:43:20 +000066
67// We expect TF-M to pick this up soon
68#define MBEDTLS_BLOCK_CIPHER_NO_DECRYPT