Yanray Wang | b153aae | 2023-09-06 12:32:10 +0800 | [diff] [blame] | 1 | /** |
| 2 | * \file config-tfm.h |
| 3 | * |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 4 | * \brief TF-M medium profile, adapted to work on other platforms. |
Yanray Wang | b153aae | 2023-09-06 12:32:10 +0800 | [diff] [blame] | 5 | */ |
| 6 | /* |
| 7 | * Copyright The Mbed TLS Contributors |
Yanray Wang | 8636d47 | 2023-11-08 10:07:01 +0800 | [diff] [blame] | 8 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Yanray Wang | b153aae | 2023-09-06 12:32:10 +0800 | [diff] [blame] | 9 | */ |
| 10 | |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 11 | /* TF-M medium profile: mbedtls legacy configuration */ |
Yanray Wang | 4419d38 | 2023-09-07 11:28:27 +0800 | [diff] [blame] | 12 | #include "../configs/ext/tfm_mbedcrypto_config_profile_medium.h" |
Yanray Wang | b153aae | 2023-09-06 12:32:10 +0800 | [diff] [blame] | 13 | |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 14 | /* TF-M medium profile: PSA crypto configuration */ |
Yanray Wang | b153aae | 2023-09-06 12:32:10 +0800 | [diff] [blame] | 15 | #define MBEDTLS_PSA_CRYPTO_CONFIG_FILE "../configs/ext/crypto_config_profile_medium.h" |
Yanray Wang | 0c98f9f | 2023-09-06 15:47:49 +0800 | [diff] [blame] | 16 | |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 17 | /***********************************************************/ |
| 18 | /* Tweak the configuration to remove dependencies on TF-M. */ |
| 19 | /***********************************************************/ |
Yanray Wang | 0c98f9f | 2023-09-06 15:47:49 +0800 | [diff] [blame] | 20 | |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 21 | /* MBEDTLS_PSA_CRYPTO_SPM needs third-party files, so disable it. */ |
Yanray Wang | 0c98f9f | 2023-09-06 15:47:49 +0800 | [diff] [blame] | 22 | #undef MBEDTLS_PSA_CRYPTO_SPM |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 23 | |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 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. */ |
Yanray Wang | 0c98f9f | 2023-09-06 15:47:49 +0800 | [diff] [blame] | 27 | #undef MBEDTLS_MEMORY_BUFFER_ALLOC_C |
Dave Rodgman | 4edcf69 | 2023-11-15 12:23:29 +0000 | [diff] [blame] | 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 | |
Dave Rodgman | 51e7245 | 2023-11-29 09:44:44 +0000 | [diff] [blame] | 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 |
Dave Rodgman | 13d2633 | 2023-12-13 17:23:46 +0000 | [diff] [blame] | 48 | * (either IAR, Arm compiler or __ARM_EABI__ defined), and adjust some |
| 49 | * variables accordingly. |
Dave Rodgman | 51e7245 | 2023-11-29 09:44:44 +0000 | [diff] [blame] | 50 | */ |
Dave Rodgman | 13d2633 | 2023-12-13 17:23:46 +0000 | [diff] [blame] | 51 | #if defined(__IAR_SYSTEMS_ICC__) || defined(__ARMCC_VERSION) || defined(__ARM_EABI__) |
Dave Rodgman | 51e7245 | 2023-11-29 09:44:44 +0000 | [diff] [blame] | 52 | #define MBEDTLS_NO_PLATFORM_ENTROPY |
Dave Rodgman | 13d2633 | 2023-12-13 17:23:46 +0000 | [diff] [blame] | 53 | #else |
| 54 | /* Use built-in platform entropy functions (TF-M provides its own). */ |
| 55 | #undef MBEDTLS_NO_PLATFORM_ENTROPY |
Dave Rodgman | 51e7245 | 2023-11-29 09:44:44 +0000 | [diff] [blame] | 56 | #endif |
| 57 | |
Dave Rodgman | 4edcf69 | 2023-11-15 12:23:29 +0000 | [diff] [blame] | 58 | /*********************************************************************** |
| 59 | * Local changes to crypto config below this delimiter |
| 60 | **********************************************************************/ |
Dave Rodgman | e4cf9b6 | 2023-11-29 09:43:20 +0000 | [diff] [blame] | 61 | |
| 62 | // We expect TF-M to pick this up soon |
| 63 | #define MBEDTLS_BLOCK_CIPHER_NO_DECRYPT |
Dave Rodgman | 7565b54 | 2023-12-13 17:26:57 +0000 | [diff] [blame] | 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 |