Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Minimal configuration for using TLS in the bootloader |
| 3 | * |
Balint Matyi | 5c47631 | 2020-03-31 13:15:39 +0100 | [diff] [blame] | 4 | * Copyright (C) 2006-2020, Arm Limited. All rights reserved. |
Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 5 | * Copyright (C) 2016, Linaro Ltd |
Tamas Ban | 81daed0 | 2019-05-20 15:05:22 +0100 | [diff] [blame] | 6 | * |
Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 7 | * 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 Vincze | cea8b59 | 2019-10-29 16:09:51 +0100 | [diff] [blame] | 25 | * Original code taken from mcuboot project at: |
| 26 | * https://github.com/JuulLabs-OSS/mcuboot |
David Vincze | 2ddc137 | 2019-10-25 11:10:08 +0200 | [diff] [blame] | 27 | * Git SHA of the original version: ac55554059147fff718015be9f4bd3108123f50a |
David Vincze | cea8b59 | 2019-10-29 16:09:51 +0100 | [diff] [blame] | 28 | */ |
| 29 | |
| 30 | /* |
Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 31 | * Minimal configuration for using TLS in the bootloader |
| 32 | * |
Tamas Ban | 581034a | 2017-12-19 19:54:37 +0000 | [diff] [blame] | 33 | * - RSA signature verification |
Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 34 | */ |
| 35 | |
David Vincze | cea8b59 | 2019-10-29 16:09:51 +0100 | [diff] [blame] | 36 | #ifndef MCUBOOT_MBEDTLS_CONFIG_RSA |
| 37 | #define MCUBOOT_MBEDTLS_CONFIG_RSA |
Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 38 | |
Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 39 | /* System support */ |
| 40 | #define MBEDTLS_PLATFORM_C |
| 41 | #define MBEDTLS_PLATFORM_MEMORY |
| 42 | #define MBEDTLS_MEMORY_BUFFER_ALLOC_C |
Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 43 | #define MBEDTLS_NO_PLATFORM_ENTROPY |
| 44 | #define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES |
Tamas Ban | 81daed0 | 2019-05-20 15:05:22 +0100 | [diff] [blame] | 45 | |
| 46 | #define MBEDTLS_PLATFORM_EXIT_ALT |
Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 47 | #define MBEDTLS_PLATFORM_PRINTF_ALT |
| 48 | |
Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 49 | #define MBEDTLS_RSA_C |
Balint Matyi | 5c47631 | 2020-03-31 13:15:39 +0100 | [diff] [blame] | 50 | #define MBEDTLS_PKCS1_V21 |
Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 51 | |
| 52 | /* mbed TLS modules */ |
| 53 | #define MBEDTLS_ASN1_PARSE_C |
| 54 | #define MBEDTLS_ASN1_WRITE_C |
| 55 | #define MBEDTLS_BIGNUM_C |
| 56 | #define MBEDTLS_MD_C |
| 57 | #define MBEDTLS_OID_C |
| 58 | #define MBEDTLS_SHA256_C |
Balint Matyi | 5c47631 | 2020-03-31 13:15:39 +0100 | [diff] [blame] | 59 | #define MBEDTLS_AES_C |
Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 60 | |
| 61 | /* Save RAM by adjusting to our exact needs */ |
Tamas Ban | 81daed0 | 2019-05-20 15:05:22 +0100 | [diff] [blame] | 62 | #if MCUBOOT_SIGN_RSA_LEN == 3072 |
Raef Coles | 0e82adc | 2019-10-17 15:06:26 +0100 | [diff] [blame] | 63 | #define MBEDTLS_MPI_MAX_SIZE 384 |
Tamas Ban | 81daed0 | 2019-05-20 15:05:22 +0100 | [diff] [blame] | 64 | #else /* RSA2048 */ |
Raef Coles | 0e82adc | 2019-10-17 15:06:26 +0100 | [diff] [blame] | 65 | #define MBEDTLS_MPI_MAX_SIZE 256 |
Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 66 | #endif |
| 67 | |
| 68 | #define MBEDTLS_SSL_MAX_CONTENT_LEN 1024 |
| 69 | |
| 70 | /* Save ROM and a few bytes of RAM by specifying our own ciphersuite list */ |
| 71 | #define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 |
| 72 | |
Tamas Ban | f824e74 | 2019-10-25 21:22:26 +0100 | [diff] [blame] | 73 | #ifdef CRYPTO_HW_ACCELERATOR_OTP_PROVISIONING |
| 74 | #define MBEDTLS_CIPHER_C |
Tamas Ban | f824e74 | 2019-10-25 21:22:26 +0100 | [diff] [blame] | 75 | #define MBEDTLS_CCM_C |
Xu Yong | 9830d48 | 2019-11-01 14:28:34 +0800 | [diff] [blame] | 76 | #define MBEDTLS_ECDSA_C |
| 77 | #define MBEDTLS_ECP_C |
| 78 | #define MBEDTLS_ECP_DP_SECP256R1_ENABLED |
| 79 | #define MBEDTLS_ECP_DP_CURVE25519_ENABLED |
Tamas Ban | f824e74 | 2019-10-25 21:22:26 +0100 | [diff] [blame] | 80 | #endif /* CRYPTO_HW_ACCELERATOR_OTP_PROVISIONING */ |
| 81 | |
Raef Coles | 0e82adc | 2019-10-17 15:06:26 +0100 | [diff] [blame] | 82 | #ifdef CRYPTO_HW_ACCELERATOR |
| 83 | #include "mbedtls_accelerator_config.h" |
| 84 | #endif |
| 85 | |
Tamas Ban | f70ef8c | 2017-12-19 15:35:09 +0000 | [diff] [blame] | 86 | #include "mbedtls/check_config.h" |
| 87 | |
David Vincze | cea8b59 | 2019-10-29 16:09:51 +0100 | [diff] [blame] | 88 | #endif /* MCUBOOT_MBEDTLS_CONFIG_RSA */ |