xref: /third_party/mbedtls/configs/config-tfm.h (revision a8e1175b)
1/**
2 * \file config-tfm.h
3 *
4 * \brief TF-M medium profile, adapted to work on other platforms.
5 */
6/*
7 *  Copyright The Mbed TLS Contributors
8 *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9 */
10
11/* TF-M medium profile: mbedtls legacy configuration */
12#include "../configs/ext/tfm_mbedcrypto_config_profile_medium.h"
13
14/* TF-M medium profile: PSA crypto configuration */
15#define MBEDTLS_PSA_CRYPTO_CONFIG_FILE "../configs/ext/crypto_config_profile_medium.h"
16
17/***********************************************************/
18/* Tweak the configuration to remove dependencies on TF-M. */
19/***********************************************************/
20
21/* MBEDTLS_PSA_CRYPTO_SPM needs third-party files, so disable it. */
22#undef MBEDTLS_PSA_CRYPTO_SPM
23
24/* 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. */
27#undef MBEDTLS_MEMORY_BUFFER_ALLOC_C
28
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
45/*
46 * In order to get an example config that works cleanly out-of-the-box
47 * for both baremetal and non-baremetal builds, we detect baremetal builds
48 * (either IAR, Arm compiler or __ARM_EABI__ defined), and adjust some
49 * variables accordingly.
50 */
51#if defined(__IAR_SYSTEMS_ICC__) || defined(__ARMCC_VERSION) || defined(__ARM_EABI__)
52#define MBEDTLS_NO_PLATFORM_ENTROPY
53#else
54/* Use built-in platform entropy functions (TF-M provides its own). */
55#undef MBEDTLS_NO_PLATFORM_ENTROPY
56#endif
57
58/***********************************************************************
59 * Local changes to crypto config below this delimiter
60 **********************************************************************/
61
62// We expect TF-M to pick this up soon
63#define MBEDTLS_BLOCK_CIPHER_NO_DECRYPT
64
65/* CCM is the only cipher/AEAD enabled in TF-M configuration files, but it
66 * does not need CIPHER_C to be enabled, so we can disable it in order
67 * to reduce code size further. */
68#undef MBEDTLS_CIPHER_C
69