blob: 5eb9d59749922257eca2af8dcce60f9cb527f1de [file] [log] [blame]
Tamas Banf70ef8c2017-12-19 15:35:09 +00001/*
2 * Minimal configuration for using TLS in the bootloader
3 *
Summer Qin7c0d8d32021-12-17 15:43:08 +08004 * Copyright (C) 2006-2022, Arm Limited. All rights reserved.
Tamas Banf70ef8c2017-12-19 15:35:09 +00005 * Copyright (C) 2016, Linaro Ltd
Tamas Ban81daed02019-05-20 15:05:22 +01006 *
Tamas Banf70ef8c2017-12-19 15:35:09 +00007 * SPDX-License-Identifier: Apache-2.0
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
10 * not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 * This file is part of mbed TLS (https://tls.mbed.org)
22 */
23
24/*
David Vinczecea8b592019-10-29 16:09:51 +010025 * Original code taken from mcuboot project at:
Tamas Banc5b2f2b2020-11-12 09:47:05 +000026 * https://github.com/mcu-tools/mcuboot
David Vincze2ddc1372019-10-25 11:10:08 +020027 * Git SHA of the original version: ac55554059147fff718015be9f4bd3108123f50a
David Vinczecea8b592019-10-29 16:09:51 +010028 */
29
30/*
Antonio de Angelisa3843cd2022-10-06 15:50:59 +010031 * Minimal configuration for using mbed TLS in the bootloader
Tamas Banf70ef8c2017-12-19 15:35:09 +000032 *
Tamas Ban581034a2017-12-19 19:54:37 +000033 * - RSA signature verification
Antonio de Angelisa3843cd2022-10-06 15:50:59 +010034 * - Optionally, enable support for PSA Crypto APIs
Tamas Banf70ef8c2017-12-19 15:35:09 +000035 */
36
Balint Matyi69e2d2e2020-07-08 10:53:54 +010037#ifndef __MCUBOOT_MBEDTLS_CFG__
38#define __MCUBOOT_MBEDTLS_CFG__
Tamas Banf70ef8c2017-12-19 15:35:09 +000039
Antonio de Angelisa3843cd2022-10-06 15:50:59 +010040#if defined(MCUBOOT_USE_PSA_CRYPTO)
41/* Enable PSA Crypto Core without support for the permanent storage
42 * Don't define MBEDTLS_PSA_CRYPTO_STORAGE_C to make sure that support
43 * for permanent keys is not enabled, as it is not available during boot
44 */
45#define MBEDTLS_PSA_CRYPTO_C
46#define MBEDTLS_PK_PARSE_C
47#define MBEDTLS_PK_WRITE_C
48#define MBEDTLS_PK_C
49#define MBEDTLS_CTR_DRBG_C
50#define MBEDTLS_CIPHER_C
51#define MBEDTLS_ENTROPY_C
52#define MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
53#endif /* MCUBOOT_USE_PSA_CRYPTO */
54
Tamas Banf70ef8c2017-12-19 15:35:09 +000055/* System support */
56#define MBEDTLS_PLATFORM_C
57#define MBEDTLS_PLATFORM_MEMORY
58#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
Tamas Banf70ef8c2017-12-19 15:35:09 +000059#define MBEDTLS_NO_PLATFORM_ENTROPY
60#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
Tamas Ban81daed02019-05-20 15:05:22 +010061
62#define MBEDTLS_PLATFORM_EXIT_ALT
Tamas Banf70ef8c2017-12-19 15:35:09 +000063#define MBEDTLS_PLATFORM_PRINTF_ALT
64
Tamas Banf70ef8c2017-12-19 15:35:09 +000065#define MBEDTLS_RSA_C
Balint Matyi5c476312020-03-31 13:15:39 +010066#define MBEDTLS_PKCS1_V21
Tamas Banf70ef8c2017-12-19 15:35:09 +000067
68/* mbed TLS modules */
69#define MBEDTLS_ASN1_PARSE_C
70#define MBEDTLS_ASN1_WRITE_C
71#define MBEDTLS_BIGNUM_C
72#define MBEDTLS_MD_C
73#define MBEDTLS_OID_C
74#define MBEDTLS_SHA256_C
Sherry Zhangc7baf592021-07-15 14:54:17 +080075#define MBEDTLS_SHA224_C
Balint Matyi5c476312020-03-31 13:15:39 +010076#define MBEDTLS_AES_C
Raef Coles95e527c2020-10-28 08:20:29 +000077#define MBEDTLS_CIPHER_MODE_CTR
Tamas Banf70ef8c2017-12-19 15:35:09 +000078
79/* Save RAM by adjusting to our exact needs */
Tamas Ban81daed02019-05-20 15:05:22 +010080#if MCUBOOT_SIGN_RSA_LEN == 3072
Raef Coles0e82adc2019-10-17 15:06:26 +010081#define MBEDTLS_MPI_MAX_SIZE 384
Tamas Ban81daed02019-05-20 15:05:22 +010082#else /* RSA2048 */
Raef Coles0e82adc2019-10-17 15:06:26 +010083#define MBEDTLS_MPI_MAX_SIZE 256
Tamas Banf70ef8c2017-12-19 15:35:09 +000084#endif
85
86#define MBEDTLS_SSL_MAX_CONTENT_LEN 1024
87
88/* Save ROM and a few bytes of RAM by specifying our own ciphersuite list */
89#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8
90
Tamas Banf824e742019-10-25 21:22:26 +010091#ifdef CRYPTO_HW_ACCELERATOR_OTP_PROVISIONING
Antonio de Angelisa3843cd2022-10-06 15:50:59 +010092#ifndef MBEDTLS_CIPHER_C
Tamas Banf824e742019-10-25 21:22:26 +010093#define MBEDTLS_CIPHER_C
Antonio de Angelisa3843cd2022-10-06 15:50:59 +010094#endif
Tamas Banf824e742019-10-25 21:22:26 +010095#define MBEDTLS_CCM_C
Xu Yong9830d482019-11-01 14:28:34 +080096#define MBEDTLS_ECDSA_C
97#define MBEDTLS_ECP_C
98#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
99#define MBEDTLS_ECP_DP_CURVE25519_ENABLED
Tamas Banf824e742019-10-25 21:22:26 +0100100#endif /* CRYPTO_HW_ACCELERATOR_OTP_PROVISIONING */
101
Raef Coles0e82adc2019-10-17 15:06:26 +0100102#ifdef CRYPTO_HW_ACCELERATOR
Michel Jaouene991ffb2023-02-20 12:08:43 +0100103#ifndef LEGACY_DRIVER_API_ENABLED
Summer Qin36f79f72022-07-05 14:53:35 +0800104/*
105 * Forcing the legacy driver API enabled all the time regardless of
106 * cmake configuration in BL2.
107 */
Michel Jaouene991ffb2023-02-20 12:08:43 +0100108#define LEGACY_DRIVER_API_ENABLED
109#warning "Use legacy driver API for BL2"
Raef Coles0e82adc2019-10-17 15:06:26 +0100110#include "mbedtls_accelerator_config.h"
Michel Jaouene991ffb2023-02-20 12:08:43 +0100111#undef LEGACY_DRIVER_API_ENABLED
Summer Qin36f79f72022-07-05 14:53:35 +0800112#else
113#include "mbedtls_accelerator_config.h"
Michel Jaouene991ffb2023-02-20 12:08:43 +0100114#endif /* !LEGACY_DRIVER_API_ENABLED */
Raef Coles0e82adc2019-10-17 15:06:26 +0100115#endif
116
Balint Matyi69e2d2e2020-07-08 10:53:54 +0100117#endif /* __MCUBOOT_MBEDTLS_CFG__ */