blob: 14896d40f3a10e31ac1ed0b87519bb6a10498931 [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
Dave Rodgman51e72452023-11-29 09:44:44 +000045/*
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
Dave Rodgman13d26332023-12-13 17:23:46 +000048 * (either IAR, Arm compiler or __ARM_EABI__ defined), and adjust some
49 * variables accordingly.
Dave Rodgman51e72452023-11-29 09:44:44 +000050 */
Dave Rodgman13d26332023-12-13 17:23:46 +000051#if defined(__IAR_SYSTEMS_ICC__) || defined(__ARMCC_VERSION) || defined(__ARM_EABI__)
Dave Rodgman51e72452023-11-29 09:44:44 +000052#define MBEDTLS_NO_PLATFORM_ENTROPY
Dave Rodgman13d26332023-12-13 17:23:46 +000053#else
54/* Use built-in platform entropy functions (TF-M provides its own). */
55#undef MBEDTLS_NO_PLATFORM_ENTROPY
Dave Rodgman51e72452023-11-29 09:44:44 +000056#endif
57
Dave Rodgman4edcf692023-11-15 12:23:29 +000058/***********************************************************************
59 * Local changes to crypto config below this delimiter
60 **********************************************************************/
Dave Rodgmane4cf9b62023-11-29 09:43:20 +000061
62// We expect TF-M to pick this up soon
63#define MBEDTLS_BLOCK_CIPHER_NO_DECRYPT
Dave Rodgman7565b542023-12-13 17:26:57 +000064
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