Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 1 | /* |
Alexei Fedorov | 42cb1aa | 2020-09-21 12:23:54 +0100 | [diff] [blame] | 2 | * Copyright (c) 2015-2020, Arm Limited. All rights reserved. |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 5 | */ |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 6 | #ifndef MBEDTLS_CONFIG_H |
| 7 | #define MBEDTLS_CONFIG_H |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 8 | |
| 9 | /* |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 10 | * Key algorithms currently supported on mbed TLS libraries |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 11 | */ |
Qixiang Xu | 1c2aef1 | 2017-08-24 15:12:20 +0800 | [diff] [blame] | 12 | #define TF_MBEDTLS_RSA 1 |
| 13 | #define TF_MBEDTLS_ECDSA 2 |
Qixiang Xu | aa05eea | 2017-08-24 15:26:39 +0800 | [diff] [blame] | 14 | #define TF_MBEDTLS_RSA_AND_ECDSA 3 |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 15 | |
Justin Chadwell | f9b32c1 | 2019-07-29 17:13:10 +0100 | [diff] [blame] | 16 | #define TF_MBEDTLS_USE_RSA (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA \ |
| 17 | || TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA_AND_ECDSA) |
| 18 | #define TF_MBEDTLS_USE_ECDSA (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_ECDSA \ |
| 19 | || TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA_AND_ECDSA) |
| 20 | |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 21 | /* |
Qixiang Xu | 1a1f291 | 2017-11-09 13:56:29 +0800 | [diff] [blame] | 22 | * Hash algorithms currently supported on mbed TLS libraries |
| 23 | */ |
| 24 | #define TF_MBEDTLS_SHA256 1 |
| 25 | #define TF_MBEDTLS_SHA384 2 |
| 26 | #define TF_MBEDTLS_SHA512 3 |
| 27 | |
| 28 | /* |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 29 | * Configuration file to build mbed TLS with the required features for |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 30 | * Trusted Boot |
| 31 | */ |
| 32 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 33 | #define MBEDTLS_PLATFORM_MEMORY |
| 34 | #define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
Antonio Nino Diaz | 6b90f5e | 2017-05-19 11:37:22 +0100 | [diff] [blame] | 35 | /* Prevent mbed TLS from using snprintf so that it can use tf_snprintf. */ |
| 36 | #define MBEDTLS_PLATFORM_SNPRINTF_ALT |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 37 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 38 | #define MBEDTLS_PKCS1_V21 |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 39 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 40 | #define MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION |
| 41 | #define MBEDTLS_X509_CHECK_KEY_USAGE |
| 42 | #define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 43 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 44 | #define MBEDTLS_ASN1_PARSE_C |
| 45 | #define MBEDTLS_ASN1_WRITE_C |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 46 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 47 | #define MBEDTLS_BASE64_C |
| 48 | #define MBEDTLS_BIGNUM_C |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 49 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 50 | #define MBEDTLS_ERROR_C |
| 51 | #define MBEDTLS_MD_C |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 52 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 53 | #define MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 54 | #define MBEDTLS_OID_C |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 55 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 56 | #define MBEDTLS_PK_C |
| 57 | #define MBEDTLS_PK_PARSE_C |
| 58 | #define MBEDTLS_PK_WRITE_C |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 59 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 60 | #define MBEDTLS_PLATFORM_C |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 61 | |
Justin Chadwell | f9b32c1 | 2019-07-29 17:13:10 +0100 | [diff] [blame] | 62 | #if TF_MBEDTLS_USE_ECDSA |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 63 | #define MBEDTLS_ECDSA_C |
| 64 | #define MBEDTLS_ECP_C |
| 65 | #define MBEDTLS_ECP_DP_SECP256R1_ENABLED |
Alexei Fedorov | 42cb1aa | 2020-09-21 12:23:54 +0100 | [diff] [blame] | 66 | #define MBEDTLS_ECP_NO_INTERNAL_RNG |
Justin Chadwell | f9b32c1 | 2019-07-29 17:13:10 +0100 | [diff] [blame] | 67 | #endif |
| 68 | #if TF_MBEDTLS_USE_RSA |
Qixiang Xu | aa05eea | 2017-08-24 15:26:39 +0800 | [diff] [blame] | 69 | #define MBEDTLS_RSA_C |
| 70 | #define MBEDTLS_X509_RSASSA_PSS_SUPPORT |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 71 | #endif |
| 72 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 73 | #define MBEDTLS_SHA256_C |
Qixiang Xu | 1a1f291 | 2017-11-09 13:56:29 +0800 | [diff] [blame] | 74 | #if (TF_MBEDTLS_HASH_ALG_ID != TF_MBEDTLS_SHA256) |
| 75 | #define MBEDTLS_SHA512_C |
| 76 | #endif |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 77 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 78 | #define MBEDTLS_VERSION_C |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 79 | |
Juan Castillo | bae6b2a | 2015-11-05 09:24:53 +0000 | [diff] [blame] | 80 | #define MBEDTLS_X509_USE_C |
| 81 | #define MBEDTLS_X509_CRT_PARSE_C |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 82 | |
Sumit Garg | 392e4df | 2019-11-15 10:43:00 +0530 | [diff] [blame] | 83 | #if TF_MBEDTLS_USE_AES_GCM |
| 84 | #define MBEDTLS_AES_C |
| 85 | #define MBEDTLS_CIPHER_C |
| 86 | #define MBEDTLS_GCM_C |
| 87 | #endif |
| 88 | |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 89 | /* MPI / BIGNUM options */ |
Justin Chadwell | f9b32c1 | 2019-07-29 17:13:10 +0100 | [diff] [blame] | 90 | #define MBEDTLS_MPI_WINDOW_SIZE 2 |
| 91 | |
| 92 | #if TF_MBEDTLS_USE_RSA |
| 93 | #if TF_MBEDTLS_KEY_SIZE <= 2048 |
| 94 | #define MBEDTLS_MPI_MAX_SIZE 256 |
| 95 | #else |
| 96 | #define MBEDTLS_MPI_MAX_SIZE 512 |
| 97 | #endif |
| 98 | #else |
| 99 | #define MBEDTLS_MPI_MAX_SIZE 256 |
| 100 | #endif |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 101 | |
| 102 | /* Memory buffer allocator options */ |
Justin Chadwell | f9b32c1 | 2019-07-29 17:13:10 +0100 | [diff] [blame] | 103 | #define MBEDTLS_MEMORY_ALIGN_MULTIPLE 8 |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 104 | |
Alexei Fedorov | 42cb1aa | 2020-09-21 12:23:54 +0100 | [diff] [blame] | 105 | /* |
| 106 | * Prevent the use of 128-bit division which |
| 107 | * creates dependency on external libraries. |
| 108 | */ |
| 109 | #define MBEDTLS_NO_UDBL_DIVISION |
| 110 | |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 111 | #ifndef __ASSEMBLER__ |
Qixiang Xu | de431b1 | 2017-10-13 09:23:42 +0800 | [diff] [blame] | 112 | /* System headers required to build mbed TLS with the current configuration */ |
| 113 | #include <stdlib.h> |
Masahiro Yamada | 64b0c9a | 2019-09-04 14:09:07 +0900 | [diff] [blame] | 114 | #include <mbedtls/check_config.h> |
Qixiang Xu | de431b1 | 2017-10-13 09:23:42 +0800 | [diff] [blame] | 115 | #endif |
Juan Castillo | a57a4d5 | 2015-04-02 15:44:20 +0100 | [diff] [blame] | 116 | |
John Tsichritzis | 30f8964 | 2018-06-07 16:31:34 +0100 | [diff] [blame] | 117 | /* |
| 118 | * Determine Mbed TLS heap size |
| 119 | * 13312 = 13*1024 |
Justin Chadwell | f9b32c1 | 2019-07-29 17:13:10 +0100 | [diff] [blame] | 120 | * 11264 = 11*1024 |
| 121 | * 7168 = 7*1024 |
John Tsichritzis | 30f8964 | 2018-06-07 16:31:34 +0100 | [diff] [blame] | 122 | */ |
Justin Chadwell | f9b32c1 | 2019-07-29 17:13:10 +0100 | [diff] [blame] | 123 | #if TF_MBEDTLS_USE_ECDSA |
John Tsichritzis | 30f8964 | 2018-06-07 16:31:34 +0100 | [diff] [blame] | 124 | #define TF_MBEDTLS_HEAP_SIZE U(13312) |
Justin Chadwell | f9b32c1 | 2019-07-29 17:13:10 +0100 | [diff] [blame] | 125 | #elif TF_MBEDTLS_USE_RSA |
| 126 | #if TF_MBEDTLS_KEY_SIZE <= 2048 |
John Tsichritzis | 30f8964 | 2018-06-07 16:31:34 +0100 | [diff] [blame] | 127 | #define TF_MBEDTLS_HEAP_SIZE U(7168) |
Justin Chadwell | f9b32c1 | 2019-07-29 17:13:10 +0100 | [diff] [blame] | 128 | #else |
| 129 | #define TF_MBEDTLS_HEAP_SIZE U(11264) |
| 130 | #endif |
John Tsichritzis | 30f8964 | 2018-06-07 16:31:34 +0100 | [diff] [blame] | 131 | #endif |
| 132 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 133 | #endif /* MBEDTLS_CONFIG_H */ |