no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
noos_mbedtls_config.h
Go to the documentation of this file.
1/***************************************************************************/
34
35#ifndef NOOS_MBEDTLS_CONFIG_H
36#define NOOS_MBEDTLS_CONFIG_H
37
38/*
39 * For an easy configuration of mbedtls library only this macros from user
40 * configuration should be modified. For more in deepth configuration see
41 * https://tls.mbed.org/ and noos/libraries/mbedtls/includes/config.h
42 */
43
44#define MBEDTLS_DEBUG_C
45#define MBEDTLS_ERROR_C
46
47/* Latest supported version by mbedtls */
48#define ENABLE_TLS1_2
49
50/*
51 * Enabled chipersuites.
52 * Ordered from most preferred to least preferred in terms of security.
53 *
54 * These are the chipersuites supported by http://test.mosquitto.org
55 * or the local mqtt server: https://mosquitto.org/download
56 * For the moment there will be examples only for this servers but these
57 * chipersuites should work for other servers too.
58 */
59
60//#define ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_256_GCM_SHA384
61//#define ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_256_CBC_SHA
62#define ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_GCM_SHA256
63//#define ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_CBC_SHA256
64//#define ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_CBC_SHA
65
66/* Eliptic curves to be used by the chiper */
67#define ENABLE_ECP_DP_SECP256R1_ENABLED
68//#define ENABLE_ECP_DP_SECP384R1_ENABLED
69
70/*
71 * Parse certificates in PEM format.
72 * If not defined, only DER format can be used.
73 * On ADuCM3029 DER is recommended due to memmory limitations
74 */
75#define ENABLE_PEM_CERT
76
77/*
78 * Maximum length (in bytes) of incoming and outgoing plaintext fragments.
79 * If not defined, default of 16kb will be used.
80 * 2000 is a eoungh to do the tls handshake and is no to much
81 * platforms with memory constrains like ADuCM3029
82 */
83//#define MAX_CONTENT_LEN 2500
84
85/*
86 * ENABLE_MEMORY_OPTIMIZATIONS should be defined in the case memory
87 * is not enough. This could happen is using both a secure connection with
88 * server an client verification.
89 */
90#define ENABLE_MEMORY_OPTIMIZATIONS
91
92/* Minimal requirements */
93/* Hardware entropy is used (trng.h) */
94#define MBEDTLS_NO_PLATFORM_ENTROPY
95/* Needed in order to use TLS features */
96#define MBEDTLS_SSL_TLS_C
97/* TLS Client features */
98#define MBEDTLS_SSL_CLI_C
99
100/*
101 * Define available chippersuites. Available only if the requierements are meet.
102 * The requierements are generated depending on user configuration
103 */
104#define MBEDTLS_SSL_CIPHERSUITES \
105 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,\
106 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,\
107 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,\
108 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,\
109 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
110
111#ifdef MAX_CONTENT_LEN
112#define MBEDTLS_SSL_MAX_CONTENT_LEN MAX_CONTENT_LEN
113#endif
114
115#ifdef ENABLE_TLS1_2
116
117#define MBEDTLS_SSL_PROTO_TLS1_2
118
119/* Key exchange enabled types */
120#if (defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_256_GCM_SHA384) || \
121 defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_256_CBC_SHA) || \
122 defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_GCM_SHA256) || \
123 defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_CBC_SHA256) || \
124 defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_CBC_SHA) )
125
126/* Enable KEY_EXCHANGE_ECDHE_RSA_ENABLED if used one of these chipersuites is defined */
127#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
128
129#endif /* Chipers that use ENABLE_KEY_EXCHANGE_ECDHE_RSA_ENABLED */
130#endif /* ENABLE_TLS1_2 */
131
132#ifdef ENABLE_MEMORY_OPTIMIZATIONS
133
134#define MBEDTLS_AES_ROM_TABLES
135#define MBEDTLS_ECP_WINDOW_SIZE 2
136
137#endif /* ENABLE_MEMORY_OPTIMIZATIONS */
138
139#ifdef ENABLE_PEM_CERT
140
141#define MBEDTLS_BASE64_C
142#define MBEDTLS_PEM_PARSE_C
143
144#endif /* ENABLE_PEM_CERT */
145
146/* Dependencies for MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */
147#ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
148
149#define MBEDTLS_RSA_C
150#define MBEDTLS_BIGNUM_C
151#define MBEDTLS_OID_C
152#define MBEDTLS_ECDH_C
153#define MBEDTLS_ECP_C
154#define MBEDTLS_PK_C
155#define MBEDTLS_PK_PARSE_C
156#define MBEDTLS_PKCS1_V15
157#define MBEDTLS_ASN1_PARSE_C
158#define MBEDTLS_X509_USE_C
159#define MBEDTLS_X509_CRT_PARSE_C
160
161#ifdef ENABLE_ECP_DP_SECP256R1_ENABLED
162#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
163#endif
164#ifdef ENABLE_ECP_DP_SECP384R1_ENABLED
165#define MBEDTLS_ECP_DP_SECP384R1_ENABLED
166#endif
167
168#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */
169
170#ifdef MBEDTLS_SSL_TLS_C
171#define MBEDTLS_MD_C
172#define MBEDTLS_CIPHER_C
173#endif /* MBEDTLS_SSL_TLS_C */
174
175#if (defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_256_GCM_SHA384) ||\
176 defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_256_CBC_SHA) ||\
177 defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_CBC_SHA) ||\
178 defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_GCM_SHA256) ||\
179 defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_CBC_SHA256) )
180
181# define MBEDTLS_AES_C
182
183# if (defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_256_CBC_SHA) || \
184 defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_CBC_SHA) || \
185 defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_CBC_SHA256) )
186# define MBEDTLS_CIPHER_MODE_CBC
187# if defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_CBC_SHA256)
188# define MBEDTLS_SHA256_C
189# endif
190# if (defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_256_CBC_SHA) || \
191 defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_CBC_SHA))
192# define MBEDTLS_SHA1_C
193# endif
194# endif
195
196# if (defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_GCM_SHA256) || \
197 defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_256_GCM_SHA384))
198# define MBEDTLS_GCM_C
199# if (defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_128_GCM_SHA256))
200# define MBEDTLS_SHA256_C
201# endif
202# if (defined(ENABLE_CHIPERSUITE_ECDHE_RSA_WITH_AES_256_GCM_SHA384))
203# define MBEDTLS_SHA512_C
204# endif
205# endif
206
207#endif
208
209#ifdef MBEDTLS_SSL_PROTO_TLS1_2
210#if (!defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_SHA256_C) &&\
211 !defined(MBEDTLS_SHA1_C))
212#define MBEDTLS_SHA256_C
213#endif
214#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
215
216/* Check if the configuration is ok */
217#include "mbedtls/check_config.h"
218
219#endif /* NOOS_MBEDTLS_CONFIG_H */