blob: 7ca83b6c9425170d9ed6990fa9b4411502334d59 [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
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 Peskinee23fa412023-09-06 17:16:36 +020023/* TF-M medium profile: mbedtls legacy configuration */
24#include "ext/tfm_mbedcrypto_config_profile_medium.h"
Yanray Wangb153aae2023-09-06 12:32:10 +080025
Gilles Peskinee23fa412023-09-06 17:16:36 +020026/* TF-M medium profile: PSA crypto configuration */
Yanray Wangb153aae2023-09-06 12:32:10 +080027#define MBEDTLS_PSA_CRYPTO_CONFIG_FILE "../configs/ext/crypto_config_profile_medium.h"
Yanray Wang0c98f9f2023-09-06 15:47:49 +080028
Gilles Peskinee23fa412023-09-06 17:16:36 +020029/***********************************************************/
30/* Tweak the configuration to remove dependencies on TF-M. */
31/***********************************************************/
Yanray Wang0c98f9f2023-09-06 15:47:49 +080032
Gilles Peskinee23fa412023-09-06 17:16:36 +020033/* MBEDTLS_PSA_CRYPTO_SPM needs third-party files, so disable it. */
Yanray Wang0c98f9f2023-09-06 15:47:49 +080034#undef MBEDTLS_PSA_CRYPTO_SPM
Gilles Peskinee23fa412023-09-06 17:16:36 +020035
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,
38 * so we just keep AES decryption enabled. We will resolve this though
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 Wang0c98f9f2023-09-06 15:47:49 +080043#undef MBEDTLS_AES_SETKEY_DEC_ALT
44#undef MBEDTLS_AES_DECRYPT_ALT
Gilles Peskineda26a512023-09-06 17:15:49 +020045/* 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 Wang0c98f9f2023-09-06 15:47:49 +080056
Gilles Peskinee23fa412023-09-06 17:16:36 +020057/* Use built-in platform entropy functions (TF-M provides its own). */
Yanray Wang0c98f9f2023-09-06 15:47:49 +080058#undef MBEDTLS_NO_PLATFORM_ENTROPY
Gilles Peskinee23fa412023-09-06 17:16:36 +020059
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 Wang0c98f9f2023-09-06 15:47:49 +080063#undef MBEDTLS_MEMORY_BUFFER_ALLOC_C