mbedtls_config.h 2.95 KB
Newer Older
1
/*
2
 * Copyright (c) 2015-2020, Arm Limited. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
 */
6
7
#ifndef MBEDTLS_CONFIG_H
#define MBEDTLS_CONFIG_H
8
9

/*
Juan Castillo's avatar
Juan Castillo committed
10
 * Key algorithms currently supported on mbed TLS libraries
11
 */
12
13
#define TF_MBEDTLS_RSA			1
#define TF_MBEDTLS_ECDSA		2
Qixiang Xu's avatar
Qixiang Xu committed
14
#define TF_MBEDTLS_RSA_AND_ECDSA	3
15

16
17
18
19
20
#define TF_MBEDTLS_USE_RSA (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA \
		|| TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA_AND_ECDSA)
#define TF_MBEDTLS_USE_ECDSA (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_ECDSA \
		|| TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA_AND_ECDSA)

21
22
23
24
25
26
27
/*
 * Hash algorithms currently supported on mbed TLS libraries
 */
#define TF_MBEDTLS_SHA256		1
#define TF_MBEDTLS_SHA384		2
#define TF_MBEDTLS_SHA512		3

28
/*
Juan Castillo's avatar
Juan Castillo committed
29
 * Configuration file to build mbed TLS with the required features for
30
31
32
 * Trusted Boot
 */

Juan Castillo's avatar
Juan Castillo committed
33
34
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
35
36
/* Prevent mbed TLS from using snprintf so that it can use tf_snprintf. */
#define MBEDTLS_PLATFORM_SNPRINTF_ALT
37

Juan Castillo's avatar
Juan Castillo committed
38
#define MBEDTLS_PKCS1_V21
39

Juan Castillo's avatar
Juan Castillo committed
40
41
42
#define MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION
#define MBEDTLS_X509_CHECK_KEY_USAGE
#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE
43

Juan Castillo's avatar
Juan Castillo committed
44
45
#define MBEDTLS_ASN1_PARSE_C
#define MBEDTLS_ASN1_WRITE_C
46

Juan Castillo's avatar
Juan Castillo committed
47
48
#define MBEDTLS_BASE64_C
#define MBEDTLS_BIGNUM_C
49

Juan Castillo's avatar
Juan Castillo committed
50
51
#define MBEDTLS_ERROR_C
#define MBEDTLS_MD_C
52

Juan Castillo's avatar
Juan Castillo committed
53
54
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
#define MBEDTLS_OID_C
55

Juan Castillo's avatar
Juan Castillo committed
56
57
58
#define MBEDTLS_PK_C
#define MBEDTLS_PK_PARSE_C
#define MBEDTLS_PK_WRITE_C
59

Juan Castillo's avatar
Juan Castillo committed
60
#define MBEDTLS_PLATFORM_C
61

62
#if TF_MBEDTLS_USE_ECDSA
Juan Castillo's avatar
Juan Castillo committed
63
64
65
#define MBEDTLS_ECDSA_C
#define MBEDTLS_ECP_C
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
66
#define MBEDTLS_ECP_NO_INTERNAL_RNG
67
68
#endif
#if TF_MBEDTLS_USE_RSA
Qixiang Xu's avatar
Qixiang Xu committed
69
70
#define MBEDTLS_RSA_C
#define MBEDTLS_X509_RSASSA_PSS_SUPPORT
71
72
#endif

Juan Castillo's avatar
Juan Castillo committed
73
#define MBEDTLS_SHA256_C
74
75
76
#if (TF_MBEDTLS_HASH_ALG_ID != TF_MBEDTLS_SHA256)
#define MBEDTLS_SHA512_C
#endif
77

Juan Castillo's avatar
Juan Castillo committed
78
#define MBEDTLS_VERSION_C
79

Juan Castillo's avatar
Juan Castillo committed
80
81
#define MBEDTLS_X509_USE_C
#define MBEDTLS_X509_CRT_PARSE_C
82

83
84
85
86
87
88
#if TF_MBEDTLS_USE_AES_GCM
#define MBEDTLS_AES_C
#define MBEDTLS_CIPHER_C
#define MBEDTLS_GCM_C
#endif

89
/* MPI / BIGNUM options */
90
91
92
93
94
95
96
97
98
99
100
#define MBEDTLS_MPI_WINDOW_SIZE			2

#if TF_MBEDTLS_USE_RSA
#if TF_MBEDTLS_KEY_SIZE <= 2048
#define MBEDTLS_MPI_MAX_SIZE			256
#else
#define MBEDTLS_MPI_MAX_SIZE			512
#endif
#else
#define MBEDTLS_MPI_MAX_SIZE			256
#endif
101
102

/* Memory buffer allocator options */
103
#define MBEDTLS_MEMORY_ALIGN_MULTIPLE		8
104

105
106
107
108
109
110
/*
 * Prevent the use of 128-bit division which
 * creates dependency on external libraries.
 */
#define MBEDTLS_NO_UDBL_DIVISION

111
#ifndef __ASSEMBLER__
112
113
/* System headers required to build mbed TLS with the current configuration */
#include <stdlib.h>
114
#include <mbedtls/check_config.h>
115
#endif
116

117
118
119
/*
 * Determine Mbed TLS heap size
 * 13312 = 13*1024
120
121
 * 11264 = 11*1024
 * 7168  = 7*1024
122
 */
123
#if TF_MBEDTLS_USE_ECDSA
124
#define TF_MBEDTLS_HEAP_SIZE		U(13312)
125
126
#elif TF_MBEDTLS_USE_RSA
#if TF_MBEDTLS_KEY_SIZE <= 2048
127
#define TF_MBEDTLS_HEAP_SIZE		U(7168)
128
129
130
#else
#define TF_MBEDTLS_HEAP_SIZE		U(11264)
#endif
131
132
#endif

133
#endif /* MBEDTLS_CONFIG_H */