Skip to content

Commit 1a113c5

Browse files
author
gojimmypi
committed
Espressif add TLS Client/Server local user_settings.h
1 parent 8eaf09d commit 1a113c5

2 files changed

Lines changed: 760 additions & 0 deletions

File tree

Lines changed: 380 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,380 @@
1+
/* user_settings.h
2+
*
3+
* Copyright (C) 2006-2023 wolfSSL Inc.
4+
*
5+
* This file is part of wolfSSL.
6+
*
7+
* wolfSSL is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* wolfSSL is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20+
*/
21+
22+
/* This is the user_settings.h file for the wolfssl_client TLS example.
23+
* For application-specific settings, please see client-tls.h file */
24+
25+
#include <sdkconfig.h> /* essential to chip set detection */
26+
27+
/* optional timezone used when setting time */
28+
#define TIME_ZONE "PST+8PDT,M3.2.0,M11.1.0"
29+
30+
/* #define SHOW_SSID_AND_PASSWORD */ /* remove this to not show in startup log */
31+
32+
#undef WOLFSSL_ESPIDF
33+
#undef WOLFSSL_ESP32
34+
#undef WOLFSSL_ESPWROOM32SE
35+
#undef WOLFSSL_ESP32
36+
#undef WOLFSSL_ESP8266
37+
38+
/* The Espressif sdkconfig will have chipset info.
39+
**
40+
** Possible values:
41+
**
42+
** CONFIG_IDF_TARGET_ESP32
43+
** CONFIG_IDF_TARGET_ESP32S2
44+
** CONFIG_IDF_TARGET_ESP32S3
45+
** CONFIG_IDF_TARGET_ESP32C3
46+
** CONFIG_IDF_TARGET_ESP32C6
47+
*/
48+
49+
#define WOLFSSL_ESPIDF
50+
51+
/*
52+
* choose ONE of these Espressif chips to define:
53+
*
54+
* WOLFSSL_ESP32
55+
* WOLFSSL_ESPWROOM32SE
56+
* WOLFSSL_ESP8266
57+
*/
58+
59+
#define WOLFSSL_ESP32
60+
61+
#if defined(CONFIG_IDF_TARGET_ESP32)
62+
/* HW Enabled by default for ESP32. To disable: */
63+
/* #define NO_ESP32_CRYPT */
64+
/* #define NO_WOLFSSL_ESP32_CRYPT_HASH */
65+
/* #define NO_WOLFSSL_ESP32_CRYPT_AES */
66+
/* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */
67+
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
68+
/* HW Disabled by default for ESP32-S2. */
69+
#define NO_ESP32_CRYPT
70+
#define NO_WOLFSSL_ESP32_CRYPT_HASH
71+
#define NO_WOLFSSL_ESP32_CRYPT_AES
72+
#define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI
73+
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
74+
/* HW Enabled by default for ESP32. To disable: */
75+
/* #define NO_ESP32_CRYPT */
76+
/* #define NO_WOLFSSL_ESP32_CRYPT_HASH */
77+
/* #define NO_WOLFSSL_ESP32_CRYPT_AES */
78+
/* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */
79+
#elif defined(CONFIG_IDF_TARGET_ESP32C2)
80+
#define NO_ESP32_CRYPT
81+
#define NO_WOLFSSL_ESP32_CRYPT_HASH
82+
#define NO_WOLFSSL_ESP32_CRYPT_AES
83+
#define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI
84+
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
85+
/* HW Disabled by default for ESP32-C3. */
86+
#define NO_ESP32_CRYPT
87+
#define NO_WOLFSSL_ESP32_CRYPT_HASH
88+
#define NO_WOLFSSL_ESP32_CRYPT_AES
89+
#define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI
90+
#elif defined(CONFIG_IDF_TARGET_ESP32C6)
91+
/* HW Disabled by default for ESP32-C6. */
92+
#define NO_ESP32_CRYPT
93+
#define NO_WOLFSSL_ESP32_CRYPT_HASH
94+
#define NO_WOLFSSL_ESP32_CRYPT_AES
95+
#define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI
96+
#elif defined(CONFIG_IDF_TARGET_ESP32H2)
97+
/* HW Disabled by default for ESP32-H2. */
98+
#define NO_ESP32_CRYPT
99+
#define NO_WOLFSSL_ESP32_CRYPT_HASH
100+
#define NO_WOLFSSL_ESP32_CRYPT_AES
101+
#define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI
102+
#else
103+
/* HW Disabled by default for all other ESP32-[?]. */
104+
#define NO_ESP32_CRYPT
105+
#define NO_WOLFSSL_ESP32_CRYPT_HASH
106+
#define NO_WOLFSSL_ESP32_CRYPT_AES
107+
#define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI
108+
#endif
109+
110+
111+
/* optionally turn off SHA512/224 SHA512/256 */
112+
/* #define WOLFSSL_NOSHA512_224 */
113+
/* #define WOLFSSL_NOSHA512_256 */
114+
115+
#define BENCH_EMBEDDED
116+
117+
/* TLS 1.3 */
118+
#define WOLFSSL_TLS13
119+
#define HAVE_TLS_EXTENSIONS
120+
#define WC_RSA_PSS
121+
#define HAVE_HKDF
122+
#define HAVE_AEAD
123+
#define HAVE_SUPPORTED_CURVES
124+
125+
#define WOLFSSL_BENCHMARK_FIXED_UNITS_KB
126+
127+
/* when you want to use SINGLE THREAD */
128+
/* #define SINGLE_THREADED */
129+
#define NO_FILESYSTEM
130+
131+
#define HAVE_AESGCM
132+
133+
#define WOLFSSL_RIPEMD
134+
/* when you want to use SHA224 */
135+
/* #define WOLFSSL_SHA224 */
136+
137+
#define NO_OLD_TLS
138+
139+
/* when you want to use SHA384 */
140+
/* #define WOLFSSL_SHA384 */
141+
142+
/* #define WOLFSSL_SHA3 */
143+
144+
#define WOLFSSL_SHA512
145+
#define HAVE_ECC
146+
#define HAVE_CURVE25519
147+
#define CURVE25519_SMALL
148+
#define HAVE_ED25519
149+
150+
/* when you want to use pkcs7 */
151+
/* #define HAVE_PKCS7 */
152+
153+
#if defined(HAVE_PKCS7)
154+
#define HAVE_AES_KEYWRAP
155+
#define HAVE_X963_KDF
156+
#define WOLFSSL_AES_DIRECT
157+
#endif
158+
159+
/* optional DH */
160+
/* #define PROJECT_DH */
161+
#ifdef PROJECT_DH
162+
#define HAVE_DH
163+
#define HAVE_FFDHE_2048
164+
#endif
165+
166+
/* when you want to use aes counter mode */
167+
/* #define WOLFSSL_AES_DIRECT */
168+
/* #define WOLFSSL_AES_COUNTER */
169+
170+
/* esp32-wroom-32se specific definition */
171+
#if defined(WOLFSSL_ESPWROOM32SE)
172+
#define WOLFSSL_ATECC508A
173+
#define HAVE_PK_CALLBACKS
174+
/* when you want to use a custom slot allocation for ATECC608A */
175+
/* unless your configuration is unusual, you can use default */
176+
/* implementation. */
177+
/* #define CUSTOM_SLOT_ALLOCATION */
178+
#endif
179+
180+
/* RSA primitive specific definition */
181+
#if defined(WOLFSSL_ESP32) || defined(WOLFSSL_ESPWROOM32SE)
182+
/* Define USE_FAST_MATH and SMALL_STACK */
183+
#define ESP32_USE_RSA_PRIMITIVE
184+
/* threshold for performance adjustment for HW primitive use */
185+
/* X bits of G^X mod P greater than */
186+
#define EPS_RSA_EXPT_XBTIS 36
187+
/* X and Y of X * Y mod P greater than */
188+
#define ESP_RSA_MULM_BITS 36
189+
#endif
190+
#define RSA_LOW_MEM
191+
192+
/* debug options */
193+
/* #define DEBUG_WOLFSSL */
194+
/* #define WOLFSSL_ESP32_CRYPT_DEBUG */
195+
/* #define WOLFSSL_ESP32_HW_LOCK_DEBUG */
196+
/* #define WOLFSSL_ATECC508A_DEBUG */
197+
198+
/* date/time */
199+
/* if it cannot adjust time in the device, */
200+
/* enable macro below */
201+
/* #define NO_ASN_TIME */
202+
/* #define XTIME time */
203+
204+
/* adjust wait-timeout count if you see timeout in RSA HW acceleration */
205+
#define ESP_RSA_TIMEOUT_CNT 0x249F00
206+
207+
/* see esp_ShowExtendedSystemInfo in esp32-crypt.h for startup log info */
208+
#define HAVE_VERSION_EXTENDED_INFO
209+
210+
211+
/* debug options */
212+
/* #define ESP_VERIFY_MEMBLOCK */
213+
#define WOLFSSL_HW_METRICS
214+
/* #define DEBUG_WOLFSSL_VERBOSE */
215+
/* #define DEBUG_WOLFSSL */
216+
/* #define WOLFSSL_ESP32_CRYPT_DEBUG */
217+
#define NO_RECOVER_SOFTWARE_CALC
218+
219+
/* optionally turn off individual math HW acceleration features */
220+
221+
/* Turn off Large Number Multiplication:
222+
** [Z = X * Y] in esp_mp_mul() */
223+
/* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */
224+
225+
/* Turn off Large Number Modular Exponentiation:
226+
** [Z = X^Y mod M] in esp_mp_exptmod() */
227+
/* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */
228+
229+
/* Turn off Large Number Modular Multiplication
230+
** [Z = X × Y mod M] in esp_mp_mulmod() */
231+
/* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */
232+
233+
234+
/* this is known to fail in TFM: */
235+
/* #define HONOR_MATH_USED_LENGTH */
236+
237+
/* this is known to fail in TFM */
238+
/* #define CHECK_MP_READ_UNSIGNED_BIN */
239+
240+
#define WOLFSSL_PUBLIC_MP /* used by benchmark */
241+
242+
/* optional SM4 Ciphers. See https://github.com/wolfSSL/wolfsm */
243+
/* Uncomment this section to enable SM
244+
#define WOLFSSL_SM2
245+
#define WOLFSSL_SM3
246+
#define WOLFSSL_SM4
247+
*/
248+
249+
#if defined(WOLFSSL_SM2) || defined(WOLFSSL_SM3) || defined(WOLFSSL_SM4)
250+
/* see https://github.com/wolfSSL/wolfssl/pull/6537
251+
*
252+
* see settings.h for other features turned on with SM4 ciphers.
253+
*/
254+
#undef USE_CERT_BUFFERS_1024
255+
#define USE_CERT_BUFFERS_1024
256+
257+
#undef WOLFSSL_SM4_ECB
258+
#define WOLFSSL_SM4_ECB
259+
260+
#undef WOLFSSL_SM4_CBC
261+
#define WOLFSSL_SM4_CBC
262+
263+
#undef WOLFSSL_SM4_CTR
264+
#define WOLFSSL_SM4_CTR
265+
266+
#undef WOLFSSL_SM4_GCM
267+
#define WOLFSSL_SM4_GCM
268+
269+
#undef WOLFSSL_SM4_CCM
270+
#define WOLFSSL_SM4_CCM
271+
272+
#define HAVE_POLY1305
273+
#define HAVE_CHACHA
274+
275+
#undef HAVE_AESGCM
276+
#define HAVE_AESGCM
277+
278+
#undef HAVE_ECC
279+
#define HAVE_ECC
280+
281+
/* see https://github.com/wolfSSL/wolfssl/pull/6825 */
282+
#include <wolfssl/certs_test_sm.h>
283+
284+
#define CTX_CA_CERT root_sm2
285+
#define CTX_CA_CERT_SIZE sizeof_root_sm2
286+
#define CTX_CA_CERT_TYPE WOLFSSL_FILETYPE_PEM
287+
#define CTX_SERVER_CERT server_sm2
288+
#define CTX_SERVER_CERT_SIZE sizeof_server_sm2
289+
#define CTX_SERVER_CERT_TYPE WOLFSSL_FILETYPE_PEM
290+
#define CTX_SERVER_KEY server_sm2_priv
291+
#define CTX_SERVER_KEY_SIZE sizeof_server_sm2_priv
292+
#define CTX_SERVER_KEY_TYPE WOLFSSL_FILETYPE_PEM
293+
/*
294+
* SM optional cipher suite settings:
295+
*
296+
#define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3"
297+
#define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-CCM-SM3"
298+
#define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CBC-SM3"
299+
#define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-GCM-SM3"
300+
#define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CCM-SM3"
301+
*/
302+
#define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3:" \
303+
"TLS13-SM4-CCM-SM3:" \
304+
"TLS-SM4-GCM-SM3:" /* not a valid command-line cipher */ \
305+
"TLS-SM4-CCM-SM3:" /* not a valid command-line cipher */ \
306+
"ECDHE-ECDSA-SM4-CBC-SM3:" \
307+
"ECDHE-ECDSA-SM4-GCM-SM3:" \
308+
"ECDHE-ECDSA-SM4-CCM-SM3"
309+
310+
#else
311+
/* default settings */
312+
#define USE_CERT_BUFFERS_2048
313+
#define USE_CERT_BUFFERS_256
314+
#define CTX_CA_CERT ca_cert_der_2048
315+
#define CTX_CA_CERT_SIZE sizeof_ca_cert_der_2048
316+
#define CTX_CA_CERT_TYPE WOLFSSL_FILETYPE_ASN1
317+
#define CTX_SERVER_CERT server_cert_der_2048
318+
#define CTX_SERVER_CERT_SIZE sizeof_server_cert_der_2048
319+
#define CTX_SERVER_CERT_TYPE WOLFSSL_FILETYPE_ASN1
320+
#define CTX_SERVER_KEY server_key_der_2048
321+
#define CTX_SERVER_KEY_SIZE sizeof_server_key_der_2048
322+
#define CTX_SERVER_KEY_TYPE WOLFSSL_FILETYPE_ASN1
323+
/*
324+
* Optional Cipher Suite Specification
325+
*
326+
* nothing defined, default used = "TLS13-AES128-GCM-SHA256"
327+
#define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CBC-SM3"
328+
#define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CBC-SM3:"
329+
#define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-AES128-GCM-SHA256"
330+
#define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-AES128-GCM-SHA256:"
331+
#define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-AES128-GCM-SHA256:DHE-PSK-AES128-GCM-SHA256"
332+
#define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-AES128-GCM-SHA256:PSK-AES128-GCM-SHA256:"
333+
#define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES128-GCM-SHA256:TLS13-AES256-GCM-SHA384:"
334+
#define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-CHACHA20-POLY1305-SHA256"
335+
#define WOLFSSL_ESP32_CIPHER_SUITE "TLS_CHACHA20_POLY1305_SHA256"
336+
#define WOLFSSL_ESP32_CIPHER_SUITE "TLS_SM4_CCM_SM3"
337+
*/
338+
#endif
339+
340+
#undef HAVE_ECC
341+
#define HAVE_ECC
342+
343+
#undef HAVE_SUPPORTED_CURVES
344+
#define HAVE_SUPPORTED_CURVES
345+
346+
/* Optionally include alternate HW test library: alt_hw_test.h */
347+
/* When enabling, the ./components/wolfssl/CMakeLists.txt file
348+
* will need the name of the library in the idf_component_register
349+
* for the PRIV_REQUIRES list. */
350+
/* #define INCLUDE_ALT_HW_TEST */
351+
352+
/* #define NO_HW_MATH_TEST */
353+
354+
355+
/* when turning on ECC508 / ECC608 support
356+
#define WOLFSSL_ESPWROOM32SE
357+
#define HAVE_PK_CALLBACKS
358+
#define WOLFSSL_ATECC508A
359+
#define ATCA_WOLFSSL
360+
*/
361+
362+
/* USE_FAST_MATH is default */
363+
#define USE_FAST_MATH
364+
365+
/* use SP_MATH */
366+
/*
367+
#undef USE_FAST_MATH
368+
#define WOLFSSL_SP_MATH_ALL
369+
*/
370+
371+
/* use integer heap math */
372+
/*
373+
#undef USE_FAST_MATH
374+
#define USE_INTEGER_HEAP_MATH
375+
*/
376+
377+
/* optionally use DPORT_ACCESS_READ_BUFFER */
378+
/*
379+
#define USE_ESP_DPORT_ACCESS_READ_BUFFER
380+
*/

0 commit comments

Comments
 (0)