From 15a48e411db5958a9ca8c647ab907725c29608bd Mon Sep 17 00:00:00 2001 From: gojimmypi <13059545+gojimmypi@users.noreply.github.com> Date: Sat, 23 Apr 2022 12:30:34 -0700 Subject: [PATCH 1/3] Add WOLFSSL_ESP8266 for ESP-IDF --- wolfcrypt/src/random.c | 2 +- wolfssl/wolfcrypt/settings.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index fbd91d468..20826e3e1 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -2455,7 +2455,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) } #elif defined(WOLFSSL_ESPIDF) - #if defined(WOLFSSL_ESPWROOM32) || defined(WOLFSSL_ESPWROOM32SE) + #if defined(WOLFSSL_ESPWROOM32) || defined(WOLFSSL_ESPWROOM32SE) || defined(WOLFSSL_ESP8266) #include int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 8d4ca1e71..365c269a9 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -203,6 +203,9 @@ /* Uncomment next line if using Espressif ESP32-WROOM-32SE */ /* #define WOLFSSL_ESPWROOM32SE */ +/* Uncomment next line if using Espressif ESP8266 */ +/* #define WOLFSSL_ESP8266 */ + /* Uncomment next line if using ARM CRYPTOCELL*/ /* #define WOLFSSL_CRYPTOCELL */ From 7233732159db87514b0aca22d9e4396e86cf723f Mon Sep 17 00:00:00 2001 From: gojimmypi <13059545+gojimmypi@users.noreply.github.com> Date: Tue, 26 Apr 2022 17:58:14 -0700 Subject: [PATCH 2/3] move ESP8266-specific to separate section --- wolfcrypt/src/random.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 20826e3e1..5328f2e29 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -2455,7 +2455,33 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) } #elif defined(WOLFSSL_ESPIDF) - #if defined(WOLFSSL_ESPWROOM32) || defined(WOLFSSL_ESPWROOM32SE) || defined(WOLFSSL_ESP8266) + + /* Espressif */ + #if defined(WOLFSSL_ESPWROOM32) || defined(WOLFSSL_ESPWROOM32SE) + + /* Espressif ESP32 */ + #include + + int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) + { + word32 rand; + while (sz > 0) { + word32 len = sizeof(rand); + if (sz < len) + len = sz; + /* Get one random 32-bit word from hw RNG */ + rand = esp_random( ); + XMEMCPY(output, &rand, len); + output += len; + sz -= len; + } + + return 0; + } + + #elif defined(WOLFSSL_ESP8266) + + /* Espressif ESP8266 */ #include int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) From 83f4f9e5ef43e14722e2456be6def7d7098f1aab Mon Sep 17 00:00:00 2001 From: gojimmypi <13059545+gojimmypi@users.noreply.github.com> Date: Wed, 27 Apr 2022 08:41:33 -0700 Subject: [PATCH 3/3] Espressif notes for user_settings.h preference --- IDE/Espressif/ESP-IDF/user_settings.h | 15 ++++++++++++-- wolfssl/wolfcrypt/settings.h | 29 ++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/IDE/Espressif/ESP-IDF/user_settings.h b/IDE/Espressif/ESP-IDF/user_settings.h index 4e9d1d918..23386646d 100644 --- a/IDE/Espressif/ESP-IDF/user_settings.h +++ b/IDE/Espressif/ESP-IDF/user_settings.h @@ -20,10 +20,21 @@ */ #undef WOLFSSL_ESPIDF #define WOLFSSL_ESPIDF + +/* + * choose ONE of these Espressif chips to define: + * + * WOLFSSL_ESPWROOM32 + * WOLFSSL_ESPWROOM32SE + * WOLFSSL_ESP8266 + * + * comment out the others: + */ + #define WOLFSSL_ESPWROOM32 -/* Uncomment next line if using Espressif ESP32-WROOM-32SE */ -/* comment the above line #define WOLFSSL_ESPWROOM32 */ /* #define WOLFSSL_ESPWROOM32SE */ +/* #define WOLFSSL_ESP8266 */ + #define BENCH_EMBEDDED #define USE_CERT_BUFFERS_2048 diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 365c269a9..3871bba02 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -19,6 +19,27 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ +/* + * ************************************************************************ + * + * ******************************** NOTICE ******************************** + * + * ************************************************************************ + * + * This method of uncommenting a line in settings.h is outdated. + * + * Please use user_settings.h / WOLFSSL_USER_SETTINGS + * + * or + * + * ./configure CFLAGS="-DFLAG" + * + * For more information see: + * + * https://www.wolfssl.com/how-do-i-manage-the-build-configuration-of-wolfssl/ + * + */ + /* Place OS specific preprocessor flags, defines, includes here, will be included into every file because types.h includes it */ @@ -194,6 +215,11 @@ /* Uncomment next line if building for using Apache mynewt */ /* #define WOLFSSL_APACHE_MYNEWT */ +/* For Espressif chips see example user_settings.h + * + * https://github.com/wolfSSL/wolfssl/blob/master/IDE/Espressif/ESP-IDF/user_settings.h + */ + /* Uncomment next line if building for using ESP-IDF */ /* #define WOLFSSL_ESPIDF */ @@ -203,9 +229,6 @@ /* Uncomment next line if using Espressif ESP32-WROOM-32SE */ /* #define WOLFSSL_ESPWROOM32SE */ -/* Uncomment next line if using Espressif ESP8266 */ -/* #define WOLFSSL_ESP8266 */ - /* Uncomment next line if using ARM CRYPTOCELL*/ /* #define WOLFSSL_CRYPTOCELL */