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 |
| 8 | * SPDX-License-Identifier: Apache-2.0 |
| 9 | * |
| 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 11 | * not use this file except in compliance with the License. |
| 12 | * You may obtain a copy of the License at |
| 13 | * |
| 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | * |
| 16 | * Unless required by applicable law or agreed to in writing, software |
| 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 | * See the License for the specific language governing permissions and |
| 20 | * limitations under the License. |
| 21 | */ |
| 22 | |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 23 | /* TF-M medium profile: mbedtls legacy configuration */ |
Yanray Wang | 4419d38 | 2023-09-07 11:28:27 +0800 | [diff] [blame^] | 24 | #include "../configs/ext/tfm_mbedcrypto_config_profile_medium.h" |
Yanray Wang | b153aae | 2023-09-06 12:32:10 +0800 | [diff] [blame] | 25 | |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 26 | /* TF-M medium profile: PSA crypto configuration */ |
Yanray Wang | b153aae | 2023-09-06 12:32:10 +0800 | [diff] [blame] | 27 | #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] | 28 | |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 29 | /***********************************************************/ |
| 30 | /* Tweak the configuration to remove dependencies on TF-M. */ |
| 31 | /***********************************************************/ |
Yanray Wang | 0c98f9f | 2023-09-06 15:47:49 +0800 | [diff] [blame] | 32 | |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 33 | /* MBEDTLS_PSA_CRYPTO_SPM needs third-party files, so disable it. */ |
Yanray Wang | 0c98f9f | 2023-09-06 15:47:49 +0800 | [diff] [blame] | 34 | #undef MBEDTLS_PSA_CRYPTO_SPM |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 35 | |
| 36 | /* TF-M provides its own dummy implementations to save code size. |
| 37 | * We don't have any way to disable the tests that need these feature, |
Yanray Wang | 4419d38 | 2023-09-07 11:28:27 +0800 | [diff] [blame^] | 38 | * so we just keep AES decryption enabled. We will resolve this through |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 39 | * an official way to disable AES decryption, then this deviation |
| 40 | * will no longer be needed: |
| 41 | * https://github.com/Mbed-TLS/mbedtls/issues/7368 |
| 42 | */ |
Yanray Wang | 0c98f9f | 2023-09-06 15:47:49 +0800 | [diff] [blame] | 43 | #undef MBEDTLS_AES_SETKEY_DEC_ALT |
| 44 | #undef MBEDTLS_AES_DECRYPT_ALT |
Gilles Peskine | da26a51 | 2023-09-06 17:15:49 +0200 | [diff] [blame] | 45 | /* The configuration we have enables MBEDTLS_PK_PARSE_C and MBEDTLS_PK_WRITE_C |
| 46 | * but not MBEDTLS_OID_C. This is inconsistent, and leads to a link error |
| 47 | * when using one of the mbedtls_pk_parse_xxx or mbedtls_pk_write_xxx |
| 48 | * functions that depend on an mbedtls_oid_xxx function. |
| 49 | * Mbed TLS needs PK parse/write for RSA with PSA, but the medium |
| 50 | * profile doesn't have RSA. Later versions of TF-M no longer enable |
| 51 | * PK parse/write: it wasn't a wanted feature. So disable it here |
| 52 | * (otherwise we'd have to enable MBEDTLS_OID_C). |
| 53 | */ |
| 54 | #undef MBEDTLS_PK_PARSE_C |
| 55 | #undef MBEDTLS_PK_WRITE_C |
Yanray Wang | 0c98f9f | 2023-09-06 15:47:49 +0800 | [diff] [blame] | 56 | |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 57 | /* Use built-in platform entropy functions (TF-M provides its own). */ |
Yanray Wang | 0c98f9f | 2023-09-06 15:47:49 +0800 | [diff] [blame] | 58 | #undef MBEDTLS_NO_PLATFORM_ENTROPY |
Gilles Peskine | e23fa41 | 2023-09-06 17:16:36 +0200 | [diff] [blame] | 59 | |
| 60 | /* Disable buffer-based memory allocator. This isn't strictly required, |
| 61 | * but using the native allocator is faster and works better with |
| 62 | * memory management analysis frameworks such as ASan. */ |
Yanray Wang | 0c98f9f | 2023-09-06 15:47:49 +0800 | [diff] [blame] | 63 | #undef MBEDTLS_MEMORY_BUFFER_ALLOC_C |