diff --git a/.gitignore b/.gitignore index cf7012327..90c76affa 100644 --- a/.gitignore +++ b/.gitignore @@ -418,11 +418,16 @@ user_settings_asm.h # ESP8266 RTOS SDK has a slightly different sdkconfig filename to exclude: /IDE/Espressif/**/sdkconfig.debug /IDE/Espressif/**/sdkconfig.release +/IDE/Espressif/**/sdkconfig-debug +/IDE/Espressif/**/sdkconfig-release # Always include Espressif makefiles (typically only used for ESP8266) !/IDE/Espressif/**/Makefile !/IDE/Espressif/**/component.mk +# Ignore all the example logs +/IDE/Espressif/ESP-IDF/examples/**/logs/* + # MPLAB /IDE/MPLABX16/wolfssl.X/dist/default/ /IDE/MPLABX16/wolfssl.X/.generated_files diff --git a/IDE/Espressif/ESP-IDF/examples/template/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/template/CMakeLists.txt index e0591fce6..ad97cb5a9 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/template/CMakeLists.txt @@ -8,7 +8,12 @@ message(STATUS "Begin project ${CMAKE_PROJECT_NAME}") cmake_minimum_required(VERSION 3.16) # Optional no watchdog typically used for test & benchmark -add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESP_NO_WATCHDOG=1") +else() + add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +endif() + # The wolfSSL CMake file should be able to find the source code. # Otherwise, assign an environment variable or set it here: @@ -123,8 +128,8 @@ endif() # Not only is a project-level "set(COMPONENTS" not needed here, this will cause # an unintuitive error about Unknown CMake command "esptool_py_flash_project_args". -message(STATUS "begin optional PROTOCOL_EXAMPLES_DIR include") if(0) + message(STATUS "Begin optional PROTOCOL_EXAMPLES_DIR include") # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) @@ -135,9 +140,10 @@ if(0) else() message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") endif() + message(STATUS "End optional PROTOCOL_EXAMPLES_DIR include") endif() + include($ENV{IDF_PATH}/tools/cmake/project.cmake) -message(STATUS "end optional include") project(wolfssl_template) message(STATUS "end project") diff --git a/IDE/Espressif/ESP-IDF/examples/template/Makefile b/IDE/Espressif/ESP-IDF/examples/template/Makefile new file mode 100644 index 000000000..e2b2e18e1 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/template/Makefile @@ -0,0 +1,14 @@ +# +# This is a project Makefile. It is assumed the directory this Makefile resides in is a +# project subdirectory. +# + +CFLAGS += -DWOLFSSL_USER_SETTINGS + +# Some of the tests are CPU intenstive, so we'll force the watchdog timer off. +# There's an espressif NO_WATCHDOG; we don't use it, as it is reset by sdkconfig. +CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 + +PROJECT_NAME := wolfssl_template + +include $(IDF_PATH)/make/project.mk diff --git a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/CMakeLists.txt index 7c1054f19..cc7ef0d47 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/CMakeLists.txt @@ -408,17 +408,22 @@ endif() if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) # There's no esp_timer, no driver components for the ESP8266 - message(STATUS "Early expansion EXCLUDES esp_timer for esp8266: ${THIS_INCLUDE_TIMER}") - message(STATUS "Early expansion EXCLUDES driver for esp8266: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "") - set(THIS_INCLUDE_DRIVER "") - set(THIS_ESP_TLS "") + message(STATUS "Early expansion EXCLUDES for esp8266:") + message(STATUS "THIS_INCLUDE_DRIVER: '${THIS_INCLUDE_DRIVER}'") + message(STATUS "THIS_INCLUDE_TIMER: '${THIS_INCLUDE_TIMER}'") + message(STATUS "Early expansion INCLUDE for esp8266:") + message(STATUS "THIS_INCLUDE_PTHREAD: '${THIS_INCLUDE_PTHREAD}'") + set(THIS_ESP_TLS "") + set(THIS_INCLUDE_DRIVER "") + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_PTHREAD "pthread") else() message(STATUS "Early expansion includes esp_timer: ${THIS_INCLUDE_TIMER}") message(STATUS "Early expansion includes driver: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_ESP_TLS "esp-tls") set(THIS_INCLUDE_DRIVER "driver") - set(THIS_ESP_TLS "esp-tls") + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_PTHREAD "") # Let the app know that we've included the esp-tls component requirement. # This is critical for use the the esp-tls component. See wolfssl esp_crt_bundle.c file. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_REQUIRED_ESP_TLS=1") @@ -430,6 +435,7 @@ if(CMAKE_BUILD_EARLY_EXPANSION) REQUIRES "${COMPONENT_REQUIRES}" PRIV_REQUIRES # esp_hw_support "${THIS_ESP_TLS}" + "${THIS_INCLUDE_PTHREAD}" "${THIS_INCLUDE_TIMER}" "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark ) diff --git a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/component.mk b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/component.mk index 3292ae5eb..290563e69 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/component.mk @@ -66,7 +66,19 @@ CFLAGS +=-DWOLFSSL_USER_SETTINGS # https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples # When this wolfssl component.mk makefile is in [project]/components/wolfssl # The root is 7 directories up from here (the location of of this component.mk): -WOLFSSL_ROOT := ../../../../../../.. +# +WOLFSSL_ROOT ?= ../../../../../../.. +THIS_DIR := $(shell pwd) +WOLFSSL_ROOT_OBJ := $(THIS_DIR) + +# When running make from commandline or VisualGDB, the current path varies: +ifeq ("$(VISUALGDB_DIR)","") + # current path is typically /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/wolfssl + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL)) +else + # current path is typically /C/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/Debug/wolfssl + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL)) +endif # To set the location of a different location, it is best to use relative paths. # @@ -92,14 +104,16 @@ WOLFSSL_ROOT := ../../../../../../.. # CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt # CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif -abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) +abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) # print-wolfssl-path-value: # @echo "WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)" # @echo "WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)" -$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) -$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info THIS_DIR defined: $(THIS_DIR)) +$(info WOLFSSL_ROOT_OBJ defined: $(WOLFSSL_ROOT_OBJ)) # NOTE: The wolfSSL include directory (e.g. user_settings.h) is # located HERE in THIS project, and *not* in the wolfSSL root. @@ -109,6 +123,7 @@ COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/. COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + # COMPONENT_ADD_INCLUDEDIRS += $ENV(IDF_PATH)/components/freertos/include/freertos # COMPONENT_ADD_INCLUDEDIRS += "$ENV(IDF_PATH)/soc/esp32s3/include/soc" @@ -122,27 +137,27 @@ COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/atmel -COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT)/wolfcrypt/src/aes_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/evp.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/misc.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/sha512_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_x25519_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/aes_gcm_x86_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/src/bio.o - +COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/evp.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/misc.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/sha512_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/fe_x25519_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_gcm_x86_asm.o ## ## wolfSSL ## -COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o -# COMPONENT_OBJS += src/conf.o +## reminder object files may end up in `./build` or `build/debug` or `build/release`, depending on build environment & settings. +## +# COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o # part of ssl.c, omitted to avoid "does not need to be compiled separately" +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/conf.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/crl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/internal.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/keys.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ocsp.o -# COMPONENT_OBJS += src/pk.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/pk.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/quic.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/sniffer.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o @@ -154,8 +169,8 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/wolfio.o -# COMPONENT_OBJS += src/x509.o -# COMPONENT_OBJS += src/x509_str.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509.o # part of ssl.c +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509_str.o # part of ssl.c ## ## wolfcrypt @@ -276,21 +291,16 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_wifi_lib. ## ## wolfcrypt benchmark (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark ## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark ## ## wolfcrypt test (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test - -## -## wolfcrypt -## -## COMPONENT_PRIV_INCLUDEDIRS += $(PROJECT_PATH)/components/wolfssl/include -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test +## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test/include $(info ********** end wolfssl component **********) diff --git a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include/user_settings.h b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include/user_settings.h index ec2021618..7349338aa 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include/user_settings.h +++ b/IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include/user_settings.h @@ -20,6 +20,11 @@ */ #define WOLFSSL_ESPIDF_COMPONENT_VERSION 0x01 +/* Examples such as test and benchmark are known to cause watchdog timeouts. + * Note this is often set in project Makefile: + * CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 */ +#define WOLFSSL_ESP_NO_WATCHDOG 1 + /* The Espressif project config file. See also sdkconfig.defaults */ #include "sdkconfig.h" @@ -219,6 +224,17 @@ #endif #endif +/* Enable AES for all examples */ +#ifdef NO_AES + #warning "Found NO_AES, wolfSSL AES Cannot be enabled. Check config." +#else + #define WOLFSSL_AES + #define WOLFSSL_AES_COUNTER + + /* Typically only needed for wolfssl_test, see docs. */ + #define WOLFSSL_AES_DIRECT +#endif + /* Pick a cert buffer size: */ /* #define USE_CERT_BUFFERS_2048 */ /* #define USE_CERT_BUFFERS_1024 */ @@ -273,6 +289,10 @@ /* Optionally enable some wolfSSH settings */ #if defined(ESP_ENABLE_WOLFSSH) || defined(CONFIG_ESP_ENABLE_WOLFSSH) + /* Enable wolfSSH. Espressif examples need a few more settings, below */ + #undef WOLFSSL_WOLFSSH + #define WOLFSSL_WOLFSSH + /* The default SSH Windows size is massive for an embedded target. * Limit it: */ #define DEFAULT_WINDOW_SZ 2000 @@ -386,7 +406,10 @@ #if defined(CONFIG_IDF_TARGET_ESP32C2) || \ defined(CONFIG_IDF_TARGET_ESP8684) /* Optionally set smaller size here */ - #define HAVE_FFDHE_4096 + #ifdef HAVE_FFDHE_4096 + /* this size may be problematic on the C2 */ + #endif + #define HAVE_FFDHE_2048 #else #define HAVE_FFDHE_4096 #endif diff --git a/IDE/Espressif/ESP-IDF/examples/template/main/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/template/main/CMakeLists.txt index 3a360077d..6a3deddc4 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/main/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/template/main/CMakeLists.txt @@ -1,11 +1,18 @@ # wolfSSL Espressif Example Project/main CMakeLists.txt -# v1.1 +# v1.2 # # wolfssl template # message(STATUS "Begin wolfSSL main CMakeLists.txt") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + # `driver` component not available for ESP8266 + SET(THIS_PRIV_REQUIRES_DRIVER "") +else() + SET(THIS_PRIV_REQUIRES_DRIVER "driver") +endif() + if(WIN32) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") @@ -57,7 +64,9 @@ endif() idf_component_register(SRCS main.c INCLUDE_DIRS "." "./include" - PRIV_REQUIRES driver "${MAIN_WOLFSSL_COMPONENT_NAME}") + PRIV_REQUIRES "${THIS_PRIV_REQUIRES_DRIVER}" + "${MAIN_WOLFSSL_COMPONENT_NAME}" + ) # # LIBWOLFSSL_SAVE_INFO(VAR_OUPUT THIS_VAR VAR_RESULT) diff --git a/IDE/Espressif/ESP-IDF/examples/template/main/component.mk b/IDE/Espressif/ESP-IDF/examples/template/main/component.mk new file mode 100644 index 000000000..08f8fbe9b --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/template/main/component.mk @@ -0,0 +1,23 @@ +# +# Main component makefile. +# +# This Makefile can be left empty. By default, it will take the sources in the +# src/ directory, compile them and link them into lib(subdirectory_name).a +# in the build directory. This behavior is entirely configurable, +# please read the ESP-IDF documents if you need to do this. +# +# (Uses default behavior of compiling all source files in directory, adding 'include' to include path.) + +# We'll add the explicit lines only for old SDK requirements (e.h. ESP8266) + +ifeq ("$(VISUALGDB_DIR)","") + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL) ) +else + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL) ) + COMPONENT_SRCDIRS := . + COMPONENT_ADD_INCLUDEDIRS := . + COMPONENT_ADD_INCLUDEDIRS += include + + # Ensure main.c gets compiled + COMPONENT_OBJS := main.o +endif diff --git a/IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults b/IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults index 8b167b2d4..2a93afe05 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults +++ b/IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults @@ -1,5 +1,6 @@ # Set the known example app config to template example (see user_settings.h) CONFIG_WOLFSSL_EXAMPLE_NAME_TEMPLATE=y + # CONFIG_EXAMPLE_WIFI_SSID="myssid" # CONFIG_EXAMPLE_WIFI_PASSWORD="mypassword" @@ -23,6 +24,7 @@ CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y # When using RSA, assign at least 10500 bytes, otherwise 5500 usually works for others # We set this to 28672 for use in the "test everything possible" in the wolfssl_test app. CONFIG_ESP_MAIN_TASK_STACK_SIZE=10500 + # Legacy stack size name for older ESP-IDF versions CONFIG_MAIN_TASK_STACK_SIZE=10500 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/CMakeLists.txt index aa794e0b4..17437542e 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/CMakeLists.txt @@ -8,7 +8,11 @@ message(STATUS "Begin project ${CMAKE_PROJECT_NAME}") cmake_minimum_required(VERSION 3.16) # Optional no watchdog typically used for test & benchmark -add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESP_NO_WATCHDOG=1") +else() + add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +endif() # The wolfSSL CMake file should be able to find the source code. # Otherwise, assign an environment variable or set it here: @@ -52,6 +56,34 @@ if(APPLE) endif() # End optional WOLFSSL_CMAKE_SYSTEM_NAME +# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. +# set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) +string(REPLACE "\\" "/" PROTOCOL_EXAMPLES_DIR "$ENV{IDF_PATH}/examples/common_components/protocol_examples_common") + +if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") + message(STATUS "Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") +else() + message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") +endif() + +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER +message(STATUS "USERNAME = $ENV{USERNAME}") +if( "$ENV{USER}" STREQUAL "" ) # the bash user + if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user + message(STATUS "could not find USER or USERNAME") + else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USERNAME}") + endif() +else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USER}") +endif() +message(STATUS "THIS_USER = ${THIS_USER}") + # Check that there are not conflicting wolfSSL components # The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl # The local component wolfSSL directory will be in ./components/wolfssl @@ -95,8 +127,8 @@ endif() # Not only is a project-level "set(COMPONENTS" not needed here, this will cause # an unintuitive error about Unknown CMake command "esptool_py_flash_project_args". -message(STATUS "begin optional PROTOCOL_EXAMPLES_DIR include") if(0) + message(STATUS "Begin optional PROTOCOL_EXAMPLES_DIR include") # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) @@ -107,9 +139,10 @@ if(0) else() message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") endif() + message(STATUS "End optional PROTOCOL_EXAMPLES_DIR include") endif() + include($ENV{IDF_PATH}/tools/cmake/project.cmake) -message(STATUS "end optional include") project(wolfssl_benchmark) message(STATUS "end project") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/Makefile b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/Makefile index 27637c64d..5bdaf7fa9 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/Makefile +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/Makefile @@ -4,9 +4,11 @@ # CFLAGS += -DWOLFSSL_USER_SETTINGS + # Some of the tests are CPU intenstive, so we'll force the watchdog timer off. # There's an espressif NO_WATCHDOG; we don't use it, as it is reset by sdkconfig. -EXTRA_CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG +CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 PROJECT_NAME := wolfssl_benchmark + include $(IDF_PATH)/make/project.mk diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/CMakeLists.txt index 9d6b9f381..cc7ef0d47 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/CMakeLists.txt @@ -159,7 +159,8 @@ else() set(COMPONENT_REQUIRES lwip "${THIS_ESP_TLS}") # we typically don't need lwip directly in wolfssl component endif() -# find the user name to search for possible "wolfssl-username" +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER message(STATUS "USERNAME = $ENV{USERNAME}") if( "$ENV{USER}" STREQUAL "" ) # the bash user if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user @@ -407,17 +408,22 @@ endif() if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) # There's no esp_timer, no driver components for the ESP8266 - message(STATUS "Early expansion EXCLUDES esp_timer for esp8266: ${THIS_INCLUDE_TIMER}") - message(STATUS "Early expansion EXCLUDES driver for esp8266: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "") - set(THIS_INCLUDE_DRIVER "") - set(THIS_ESP_TLS "") + message(STATUS "Early expansion EXCLUDES for esp8266:") + message(STATUS "THIS_INCLUDE_DRIVER: '${THIS_INCLUDE_DRIVER}'") + message(STATUS "THIS_INCLUDE_TIMER: '${THIS_INCLUDE_TIMER}'") + message(STATUS "Early expansion INCLUDE for esp8266:") + message(STATUS "THIS_INCLUDE_PTHREAD: '${THIS_INCLUDE_PTHREAD}'") + set(THIS_ESP_TLS "") + set(THIS_INCLUDE_DRIVER "") + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_PTHREAD "pthread") else() message(STATUS "Early expansion includes esp_timer: ${THIS_INCLUDE_TIMER}") message(STATUS "Early expansion includes driver: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_ESP_TLS "esp-tls") set(THIS_INCLUDE_DRIVER "driver") - set(THIS_ESP_TLS "esp-tls") + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_PTHREAD "") # Let the app know that we've included the esp-tls component requirement. # This is critical for use the the esp-tls component. See wolfssl esp_crt_bundle.c file. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_REQUIRED_ESP_TLS=1") @@ -429,6 +435,7 @@ if(CMAKE_BUILD_EARLY_EXPANSION) REQUIRES "${COMPONENT_REQUIRES}" PRIV_REQUIRES # esp_hw_support "${THIS_ESP_TLS}" + "${THIS_INCLUDE_PTHREAD}" "${THIS_INCLUDE_TIMER}" "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark ) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/component.mk index 48aa28ed2..a7b5f3706 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/component.mk @@ -66,7 +66,19 @@ CFLAGS +=-DWOLFSSL_USER_SETTINGS # https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples # When this wolfssl component.mk makefile is in [project]/components/wolfssl # The root is 7 directories up from here (the location of of this component.mk): -WOLFSSL_ROOT := ../../../../../../.. +# +WOLFSSL_ROOT ?= ../../../../../../.. +THIS_DIR := $(shell pwd) +WOLFSSL_ROOT_OBJ := $(THIS_DIR) + +# When running make from commandline or VisualGDB, the current path varies: +ifeq ("$(VISUALGDB_DIR)","") + # current path is typically /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/wolfssl + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL)) +else + # current path is typically /C/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/Debug/wolfssl + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL)) +endif # To set the location of a different location, it is best to use relative paths. # @@ -92,14 +104,16 @@ WOLFSSL_ROOT := ../../../../../../.. # CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt # CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif -abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) +abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) # print-wolfssl-path-value: # @echo "WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)" # @echo "WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)" -$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) -$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info THIS_DIR defined: $(THIS_DIR)) +$(info WOLFSSL_ROOT_OBJ defined: $(WOLFSSL_ROOT_OBJ)) # NOTE: The wolfSSL include directory (e.g. user_settings.h) is # located HERE in THIS project, and *not* in the wolfSSL root. @@ -109,6 +123,7 @@ COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/. COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + # COMPONENT_ADD_INCLUDEDIRS += $ENV(IDF_PATH)/components/freertos/include/freertos # COMPONENT_ADD_INCLUDEDIRS += "$ENV(IDF_PATH)/soc/esp32s3/include/soc" @@ -122,27 +137,27 @@ COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/atmel -COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT)/wolfcrypt/src/aes_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/evp.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/misc.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/sha512_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_x25519_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/aes_gcm_x86_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/src/bio.o - +COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/evp.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/misc.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/sha512_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/fe_x25519_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_gcm_x86_asm.o ## ## wolfSSL ## -COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o -# COMPONENT_OBJS += src/conf.o +## reminder object files may end up in `./build` or `build/debug` or `build/release`, depending on build environment & settings. +## +# COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o # part of ssl.c, omitted to avoid "does not need to be compiled separately" +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/conf.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/crl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/internal.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/keys.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ocsp.o -# COMPONENT_OBJS += src/pk.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/pk.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/quic.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/sniffer.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o @@ -154,8 +169,8 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/wolfio.o -# COMPONENT_OBJS += src/x509.o -# COMPONENT_OBJS += src/x509_str.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509.o # part of ssl.c +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509_str.o # part of ssl.c ## ## wolfcrypt @@ -274,22 +289,18 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_time_lib. COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_wifi_lib.o ## -## wolfcrypt benchmark (optional) +## wolfcrypt benchmark (needed for this benchmark example) ## -COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark -COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark ## ## wolfcrypt test (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test +## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test/include -## -## wolfcrypt -## -# COMPONENT_PRIV_INCLUDEDIRS += $(PROJECT_PATH)/components/wolfssl/include -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src $(info ********** end wolfssl component **********) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/include/user_settings.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/include/user_settings.h index 0e02ca022..7349338aa 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/include/user_settings.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/components/wolfssl/include/user_settings.h @@ -20,6 +20,11 @@ */ #define WOLFSSL_ESPIDF_COMPONENT_VERSION 0x01 +/* Examples such as test and benchmark are known to cause watchdog timeouts. + * Note this is often set in project Makefile: + * CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 */ +#define WOLFSSL_ESP_NO_WATCHDOG 1 + /* The Espressif project config file. See also sdkconfig.defaults */ #include "sdkconfig.h" @@ -219,6 +224,17 @@ #endif #endif +/* Enable AES for all examples */ +#ifdef NO_AES + #warning "Found NO_AES, wolfSSL AES Cannot be enabled. Check config." +#else + #define WOLFSSL_AES + #define WOLFSSL_AES_COUNTER + + /* Typically only needed for wolfssl_test, see docs. */ + #define WOLFSSL_AES_DIRECT +#endif + /* Pick a cert buffer size: */ /* #define USE_CERT_BUFFERS_2048 */ /* #define USE_CERT_BUFFERS_1024 */ @@ -273,6 +289,10 @@ /* Optionally enable some wolfSSH settings */ #if defined(ESP_ENABLE_WOLFSSH) || defined(CONFIG_ESP_ENABLE_WOLFSSH) + /* Enable wolfSSH. Espressif examples need a few more settings, below */ + #undef WOLFSSL_WOLFSSH + #define WOLFSSL_WOLFSSH + /* The default SSH Windows size is massive for an embedded target. * Limit it: */ #define DEFAULT_WINDOW_SZ 2000 @@ -386,7 +406,10 @@ #if defined(CONFIG_IDF_TARGET_ESP32C2) || \ defined(CONFIG_IDF_TARGET_ESP8684) /* Optionally set smaller size here */ - #define HAVE_FFDHE_4096 + #ifdef HAVE_FFDHE_4096 + /* this size may be problematic on the C2 */ + #endif + #define HAVE_FFDHE_2048 #else #define HAVE_FFDHE_4096 #endif @@ -765,7 +788,7 @@ #define WOLFSSL_ESP8266 /* There's no hardware encryption on the ESP8266 */ - /* Consider using the ESP32-C2/C3/C6 */ + /* Consider using the ESP32-C2/C3/C6 */ #define NO_ESP32_CRYPT #define NO_WOLFSSL_ESP32_CRYPT_HASH #define NO_WOLFSSL_ESP32_CRYPT_AES diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/CMakeLists.txt index 7160bec7f..5166065a3 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/CMakeLists.txt @@ -1,12 +1,17 @@ # wolfSSL Espressif Example Project/main CMakeLists.txt -# v1.1 +# v1.2 # # wolfssl benchmark test # +message(STATUS "Begin wolfSSL main CMakeLists.txt") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") -set(COMPONENT_SRCS "main.c") -set(COMPONENT_ADD_INCLUDEDIRS ".") +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + # `driver` component not available for ESP8266 + SET(THIS_PRIV_REQUIRES_DRIVER "") +else() + SET(THIS_PRIV_REQUIRES_DRIVER "driver") +endif() if(WIN32) # Windows-specific configuration here @@ -59,7 +64,9 @@ endif() idf_component_register(SRCS main.c INCLUDE_DIRS "." "./include" - PRIV_REQUIRES driver "${MAIN_WOLFSSL_COMPONENT_NAME}") + PRIV_REQUIRES "${THIS_PRIV_REQUIRES_DRIVER}" + "${MAIN_WOLFSSL_COMPONENT_NAME}" + ) # # LIBWOLFSSL_SAVE_INFO(VAR_OUPUT THIS_VAR VAR_RESULT) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/Kconfig.projbuild b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/Kconfig.projbuild index 8fd12d389..264c80883 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/Kconfig.projbuild +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/Kconfig.projbuild @@ -22,7 +22,7 @@ config BENCH_ARGV -lng Display benchmark result by specified language. 0: English, 1: Japanese Size of block in bytes - + e.g -lng 1 e.g sha diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/component.mk index d9b752f16..08f8fbe9b 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/component.mk @@ -7,3 +7,17 @@ # please read the ESP-IDF documents if you need to do this. # # (Uses default behavior of compiling all source files in directory, adding 'include' to include path.) + +# We'll add the explicit lines only for old SDK requirements (e.h. ESP8266) + +ifeq ("$(VISUALGDB_DIR)","") + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL) ) +else + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL) ) + COMPONENT_SRCDIRS := . + COMPONENT_ADD_INCLUDEDIRS := . + COMPONENT_ADD_INCLUDEDIRS += include + + # Ensure main.c gets compiled + COMPONENT_OBJS := main.o +endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults index cd3798c80..7fac4476f 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults @@ -1,5 +1,6 @@ # Set the known example app config to template example (see user_settings.h) CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSL_BENCHMARK=y + # CONFIG_EXAMPLE_WIFI_SSID="myssid" # CONFIG_EXAMPLE_WIFI_PASSWORD="mypassword" @@ -7,6 +8,7 @@ CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSL_BENCHMARK=y CONFIG_USE_WOLFSSL_ESP_SDK_TIME=y # sdkconfig.defaults for ESP8266 + ESP32 +# See separate sdkconfig.defaults.esp8266 # Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. CONFIG_BENCH_ARGV="-lng 0" # FreeRTOS ticks at 1ms interval diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/CMakeLists.txt index c6c17911e..868b15d85 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/CMakeLists.txt @@ -8,7 +8,12 @@ message(STATUS "Begin project ${CMAKE_PROJECT_NAME}") cmake_minimum_required(VERSION 3.16) # Optional no watchdog typically used for test & benchmark -add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESP_NO_WATCHDOG=1") +else() + add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +endif() + # The wolfSSL CMake file should be able to find the source code. # Otherwise, assign an environment variable or set it here: @@ -124,7 +129,7 @@ endif() # an unintuitive error about Unknown CMake command "esptool_py_flash_project_args". if(0) - message(STATUS "begin optional PROTOCOL_EXAMPLES_DIR include") + message(STATUS "Begin optional PROTOCOL_EXAMPLES_DIR include") # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) @@ -135,8 +140,9 @@ if(0) else() message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") endif() - message(STATUS "end optional include") + message(STATUS "End optional PROTOCOL_EXAMPLES_DIR include") endif() + include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(wolfssl_client) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/CMakeLists.txt index 9d6b9f381..cc7ef0d47 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/CMakeLists.txt @@ -159,7 +159,8 @@ else() set(COMPONENT_REQUIRES lwip "${THIS_ESP_TLS}") # we typically don't need lwip directly in wolfssl component endif() -# find the user name to search for possible "wolfssl-username" +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER message(STATUS "USERNAME = $ENV{USERNAME}") if( "$ENV{USER}" STREQUAL "" ) # the bash user if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user @@ -407,17 +408,22 @@ endif() if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) # There's no esp_timer, no driver components for the ESP8266 - message(STATUS "Early expansion EXCLUDES esp_timer for esp8266: ${THIS_INCLUDE_TIMER}") - message(STATUS "Early expansion EXCLUDES driver for esp8266: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "") - set(THIS_INCLUDE_DRIVER "") - set(THIS_ESP_TLS "") + message(STATUS "Early expansion EXCLUDES for esp8266:") + message(STATUS "THIS_INCLUDE_DRIVER: '${THIS_INCLUDE_DRIVER}'") + message(STATUS "THIS_INCLUDE_TIMER: '${THIS_INCLUDE_TIMER}'") + message(STATUS "Early expansion INCLUDE for esp8266:") + message(STATUS "THIS_INCLUDE_PTHREAD: '${THIS_INCLUDE_PTHREAD}'") + set(THIS_ESP_TLS "") + set(THIS_INCLUDE_DRIVER "") + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_PTHREAD "pthread") else() message(STATUS "Early expansion includes esp_timer: ${THIS_INCLUDE_TIMER}") message(STATUS "Early expansion includes driver: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_ESP_TLS "esp-tls") set(THIS_INCLUDE_DRIVER "driver") - set(THIS_ESP_TLS "esp-tls") + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_PTHREAD "") # Let the app know that we've included the esp-tls component requirement. # This is critical for use the the esp-tls component. See wolfssl esp_crt_bundle.c file. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_REQUIRED_ESP_TLS=1") @@ -429,6 +435,7 @@ if(CMAKE_BUILD_EARLY_EXPANSION) REQUIRES "${COMPONENT_REQUIRES}" PRIV_REQUIRES # esp_hw_support "${THIS_ESP_TLS}" + "${THIS_INCLUDE_PTHREAD}" "${THIS_INCLUDE_TIMER}" "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark ) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/component.mk index 3292ae5eb..290563e69 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/component.mk @@ -66,7 +66,19 @@ CFLAGS +=-DWOLFSSL_USER_SETTINGS # https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples # When this wolfssl component.mk makefile is in [project]/components/wolfssl # The root is 7 directories up from here (the location of of this component.mk): -WOLFSSL_ROOT := ../../../../../../.. +# +WOLFSSL_ROOT ?= ../../../../../../.. +THIS_DIR := $(shell pwd) +WOLFSSL_ROOT_OBJ := $(THIS_DIR) + +# When running make from commandline or VisualGDB, the current path varies: +ifeq ("$(VISUALGDB_DIR)","") + # current path is typically /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/wolfssl + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL)) +else + # current path is typically /C/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/Debug/wolfssl + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL)) +endif # To set the location of a different location, it is best to use relative paths. # @@ -92,14 +104,16 @@ WOLFSSL_ROOT := ../../../../../../.. # CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt # CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif -abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) +abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) # print-wolfssl-path-value: # @echo "WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)" # @echo "WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)" -$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) -$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info THIS_DIR defined: $(THIS_DIR)) +$(info WOLFSSL_ROOT_OBJ defined: $(WOLFSSL_ROOT_OBJ)) # NOTE: The wolfSSL include directory (e.g. user_settings.h) is # located HERE in THIS project, and *not* in the wolfSSL root. @@ -109,6 +123,7 @@ COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/. COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + # COMPONENT_ADD_INCLUDEDIRS += $ENV(IDF_PATH)/components/freertos/include/freertos # COMPONENT_ADD_INCLUDEDIRS += "$ENV(IDF_PATH)/soc/esp32s3/include/soc" @@ -122,27 +137,27 @@ COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/atmel -COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT)/wolfcrypt/src/aes_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/evp.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/misc.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/sha512_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_x25519_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/aes_gcm_x86_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/src/bio.o - +COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/evp.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/misc.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/sha512_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/fe_x25519_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_gcm_x86_asm.o ## ## wolfSSL ## -COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o -# COMPONENT_OBJS += src/conf.o +## reminder object files may end up in `./build` or `build/debug` or `build/release`, depending on build environment & settings. +## +# COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o # part of ssl.c, omitted to avoid "does not need to be compiled separately" +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/conf.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/crl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/internal.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/keys.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ocsp.o -# COMPONENT_OBJS += src/pk.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/pk.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/quic.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/sniffer.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o @@ -154,8 +169,8 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/wolfio.o -# COMPONENT_OBJS += src/x509.o -# COMPONENT_OBJS += src/x509_str.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509.o # part of ssl.c +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509_str.o # part of ssl.c ## ## wolfcrypt @@ -276,21 +291,16 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_wifi_lib. ## ## wolfcrypt benchmark (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark ## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark ## ## wolfcrypt test (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test - -## -## wolfcrypt -## -## COMPONENT_PRIV_INCLUDEDIRS += $(PROJECT_PATH)/components/wolfssl/include -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test +## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test/include $(info ********** end wolfssl component **********) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include/user_settings.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include/user_settings.h index ec2021618..7349338aa 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include/user_settings.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include/user_settings.h @@ -20,6 +20,11 @@ */ #define WOLFSSL_ESPIDF_COMPONENT_VERSION 0x01 +/* Examples such as test and benchmark are known to cause watchdog timeouts. + * Note this is often set in project Makefile: + * CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 */ +#define WOLFSSL_ESP_NO_WATCHDOG 1 + /* The Espressif project config file. See also sdkconfig.defaults */ #include "sdkconfig.h" @@ -219,6 +224,17 @@ #endif #endif +/* Enable AES for all examples */ +#ifdef NO_AES + #warning "Found NO_AES, wolfSSL AES Cannot be enabled. Check config." +#else + #define WOLFSSL_AES + #define WOLFSSL_AES_COUNTER + + /* Typically only needed for wolfssl_test, see docs. */ + #define WOLFSSL_AES_DIRECT +#endif + /* Pick a cert buffer size: */ /* #define USE_CERT_BUFFERS_2048 */ /* #define USE_CERT_BUFFERS_1024 */ @@ -273,6 +289,10 @@ /* Optionally enable some wolfSSH settings */ #if defined(ESP_ENABLE_WOLFSSH) || defined(CONFIG_ESP_ENABLE_WOLFSSH) + /* Enable wolfSSH. Espressif examples need a few more settings, below */ + #undef WOLFSSL_WOLFSSH + #define WOLFSSL_WOLFSSH + /* The default SSH Windows size is massive for an embedded target. * Limit it: */ #define DEFAULT_WINDOW_SZ 2000 @@ -386,7 +406,10 @@ #if defined(CONFIG_IDF_TARGET_ESP32C2) || \ defined(CONFIG_IDF_TARGET_ESP8684) /* Optionally set smaller size here */ - #define HAVE_FFDHE_4096 + #ifdef HAVE_FFDHE_4096 + /* this size may be problematic on the C2 */ + #endif + #define HAVE_FFDHE_2048 #else #define HAVE_FFDHE_4096 #endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/CMakeLists.txt index 76b01c65b..80a89c25a 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/CMakeLists.txt @@ -1,11 +1,18 @@ # wolfSSL Espressif Example Project/main CMakeLists.txt -# v1.1 +# v1.2 # # wolfssl client test # message(STATUS "Begin wolfSSL main CMakeLists.txt") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + # `driver` component not available for ESP8266 + SET(THIS_PRIV_REQUIRES_DRIVER "") +else() + SET(THIS_PRIV_REQUIRES_DRIVER "driver") +endif() + if(WIN32) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") @@ -61,7 +68,7 @@ idf_component_register(SRCS main.c INCLUDE_DIRS "." "./include" PRIV_REQUIRES "${MAIN_WOLFSSL_COMPONENT_NAME}" - driver + "${THIS_PRIV_REQUIRES_DRIVER}" nvs_flash protocol_examples_common) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/Kconfig.projbuild b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/Kconfig.projbuild index 5c3880f30..ed9960248 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/Kconfig.projbuild +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/Kconfig.projbuild @@ -1,3 +1,26 @@ +# Kconfig main +# +# Copyright (C) 2006-2025 wolfSSL Inc. +# +# This file is part of wolfSSL. +# +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# + +# Kconfig File Version 5.7.2.001 for wolfssl_template + menu "Example wolfSSL Configuration" choice WOLFSSL_EXAMPLE_CHOOSE @@ -72,6 +95,12 @@ choice WOLFSSL_EXAMPLE_CHOOSE help See wolfSSL/wolfTPM on GitHub. + config WOLFSSL_APPLE_HOMEKIT + bool "Apple HomeKit for the ESP32" + help + See AchimPieters/esp32-homekit-demo on GitHub. + + config WOLFSSL_EXAMPLE_NAME_NONE bool "Other" help diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults index fc854cbc3..d2b0b890e 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults @@ -1,5 +1,6 @@ # Set the known example app config to TLS Client (see user_settings.h) CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_CLIENT=y + # CONFIG_EXAMPLE_WIFI_SSID="myssid" # CONFIG_EXAMPLE_WIFI_PASSWORD="mypassword" @@ -7,7 +8,7 @@ CONFIG_WOLFSSL_EXAMPLE_NAME_TLS_CLIENT=y CONFIG_USE_WOLFSSL_ESP_SDK_TIME=y # sdkconfig.defaults for ESP8266 + ESP32 - +# See separate sdkconfig.defaults.esp8266 # FreeRTOS ticks at 1ms interval CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_HZ=1000 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/CMakeLists.txt index 245a3dc2e..145129c46 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/CMakeLists.txt @@ -8,7 +8,12 @@ message(STATUS "Begin project ${CMAKE_PROJECT_NAME}") cmake_minimum_required(VERSION 3.16) # Optional no watchdog typically used for test & benchmark -add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESP_NO_WATCHDOG=1") +else() + add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +endif() + # The wolfSSL CMake file should be able to find the source code. # Otherwise, assign an environment variable or set it here: @@ -123,8 +128,8 @@ endif() # Not only is a project-level "set(COMPONENTS" not needed here, this will cause # an unintuitive error about Unknown CMake command "esptool_py_flash_project_args". -message(STATUS "begin optional PROTOCOL_EXAMPLES_DIR include") if(0) + message(STATUS "Begin optional PROTOCOL_EXAMPLES_DIR include") # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) @@ -135,9 +140,10 @@ if(0) else() message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") endif() + message(STATUS "End optional PROTOCOL_EXAMPLES_DIR include") endif() + include($ENV{IDF_PATH}/tools/cmake/project.cmake) -message(STATUS "end include") project(wolfssl_server) message(STATUS "end project") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/CMakeLists.txt index 9d6b9f381..cc7ef0d47 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/CMakeLists.txt @@ -159,7 +159,8 @@ else() set(COMPONENT_REQUIRES lwip "${THIS_ESP_TLS}") # we typically don't need lwip directly in wolfssl component endif() -# find the user name to search for possible "wolfssl-username" +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER message(STATUS "USERNAME = $ENV{USERNAME}") if( "$ENV{USER}" STREQUAL "" ) # the bash user if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user @@ -407,17 +408,22 @@ endif() if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) # There's no esp_timer, no driver components for the ESP8266 - message(STATUS "Early expansion EXCLUDES esp_timer for esp8266: ${THIS_INCLUDE_TIMER}") - message(STATUS "Early expansion EXCLUDES driver for esp8266: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "") - set(THIS_INCLUDE_DRIVER "") - set(THIS_ESP_TLS "") + message(STATUS "Early expansion EXCLUDES for esp8266:") + message(STATUS "THIS_INCLUDE_DRIVER: '${THIS_INCLUDE_DRIVER}'") + message(STATUS "THIS_INCLUDE_TIMER: '${THIS_INCLUDE_TIMER}'") + message(STATUS "Early expansion INCLUDE for esp8266:") + message(STATUS "THIS_INCLUDE_PTHREAD: '${THIS_INCLUDE_PTHREAD}'") + set(THIS_ESP_TLS "") + set(THIS_INCLUDE_DRIVER "") + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_PTHREAD "pthread") else() message(STATUS "Early expansion includes esp_timer: ${THIS_INCLUDE_TIMER}") message(STATUS "Early expansion includes driver: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_ESP_TLS "esp-tls") set(THIS_INCLUDE_DRIVER "driver") - set(THIS_ESP_TLS "esp-tls") + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_PTHREAD "") # Let the app know that we've included the esp-tls component requirement. # This is critical for use the the esp-tls component. See wolfssl esp_crt_bundle.c file. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_REQUIRED_ESP_TLS=1") @@ -429,6 +435,7 @@ if(CMAKE_BUILD_EARLY_EXPANSION) REQUIRES "${COMPONENT_REQUIRES}" PRIV_REQUIRES # esp_hw_support "${THIS_ESP_TLS}" + "${THIS_INCLUDE_PTHREAD}" "${THIS_INCLUDE_TIMER}" "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark ) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/component.mk index 3292ae5eb..290563e69 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/component.mk @@ -66,7 +66,19 @@ CFLAGS +=-DWOLFSSL_USER_SETTINGS # https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples # When this wolfssl component.mk makefile is in [project]/components/wolfssl # The root is 7 directories up from here (the location of of this component.mk): -WOLFSSL_ROOT := ../../../../../../.. +# +WOLFSSL_ROOT ?= ../../../../../../.. +THIS_DIR := $(shell pwd) +WOLFSSL_ROOT_OBJ := $(THIS_DIR) + +# When running make from commandline or VisualGDB, the current path varies: +ifeq ("$(VISUALGDB_DIR)","") + # current path is typically /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/wolfssl + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL)) +else + # current path is typically /C/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/Debug/wolfssl + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL)) +endif # To set the location of a different location, it is best to use relative paths. # @@ -92,14 +104,16 @@ WOLFSSL_ROOT := ../../../../../../.. # CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt # CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif -abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) +abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) # print-wolfssl-path-value: # @echo "WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)" # @echo "WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)" -$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) -$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info THIS_DIR defined: $(THIS_DIR)) +$(info WOLFSSL_ROOT_OBJ defined: $(WOLFSSL_ROOT_OBJ)) # NOTE: The wolfSSL include directory (e.g. user_settings.h) is # located HERE in THIS project, and *not* in the wolfSSL root. @@ -109,6 +123,7 @@ COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/. COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + # COMPONENT_ADD_INCLUDEDIRS += $ENV(IDF_PATH)/components/freertos/include/freertos # COMPONENT_ADD_INCLUDEDIRS += "$ENV(IDF_PATH)/soc/esp32s3/include/soc" @@ -122,27 +137,27 @@ COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/atmel -COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT)/wolfcrypt/src/aes_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/evp.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/misc.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/sha512_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_x25519_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/aes_gcm_x86_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/src/bio.o - +COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/evp.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/misc.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/sha512_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/fe_x25519_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_gcm_x86_asm.o ## ## wolfSSL ## -COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o -# COMPONENT_OBJS += src/conf.o +## reminder object files may end up in `./build` or `build/debug` or `build/release`, depending on build environment & settings. +## +# COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o # part of ssl.c, omitted to avoid "does not need to be compiled separately" +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/conf.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/crl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/internal.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/keys.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ocsp.o -# COMPONENT_OBJS += src/pk.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/pk.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/quic.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/sniffer.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o @@ -154,8 +169,8 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/wolfio.o -# COMPONENT_OBJS += src/x509.o -# COMPONENT_OBJS += src/x509_str.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509.o # part of ssl.c +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509_str.o # part of ssl.c ## ## wolfcrypt @@ -276,21 +291,16 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_wifi_lib. ## ## wolfcrypt benchmark (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark ## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark ## ## wolfcrypt test (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test - -## -## wolfcrypt -## -## COMPONENT_PRIV_INCLUDEDIRS += $(PROJECT_PATH)/components/wolfssl/include -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test +## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test/include $(info ********** end wolfssl component **********) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/include/user_settings.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/include/user_settings.h index ec2021618..7349338aa 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/include/user_settings.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/components/wolfssl/include/user_settings.h @@ -20,6 +20,11 @@ */ #define WOLFSSL_ESPIDF_COMPONENT_VERSION 0x01 +/* Examples such as test and benchmark are known to cause watchdog timeouts. + * Note this is often set in project Makefile: + * CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 */ +#define WOLFSSL_ESP_NO_WATCHDOG 1 + /* The Espressif project config file. See also sdkconfig.defaults */ #include "sdkconfig.h" @@ -219,6 +224,17 @@ #endif #endif +/* Enable AES for all examples */ +#ifdef NO_AES + #warning "Found NO_AES, wolfSSL AES Cannot be enabled. Check config." +#else + #define WOLFSSL_AES + #define WOLFSSL_AES_COUNTER + + /* Typically only needed for wolfssl_test, see docs. */ + #define WOLFSSL_AES_DIRECT +#endif + /* Pick a cert buffer size: */ /* #define USE_CERT_BUFFERS_2048 */ /* #define USE_CERT_BUFFERS_1024 */ @@ -273,6 +289,10 @@ /* Optionally enable some wolfSSH settings */ #if defined(ESP_ENABLE_WOLFSSH) || defined(CONFIG_ESP_ENABLE_WOLFSSH) + /* Enable wolfSSH. Espressif examples need a few more settings, below */ + #undef WOLFSSL_WOLFSSH + #define WOLFSSL_WOLFSSH + /* The default SSH Windows size is massive for an embedded target. * Limit it: */ #define DEFAULT_WINDOW_SZ 2000 @@ -386,7 +406,10 @@ #if defined(CONFIG_IDF_TARGET_ESP32C2) || \ defined(CONFIG_IDF_TARGET_ESP8684) /* Optionally set smaller size here */ - #define HAVE_FFDHE_4096 + #ifdef HAVE_FFDHE_4096 + /* this size may be problematic on the C2 */ + #endif + #define HAVE_FFDHE_2048 #else #define HAVE_FFDHE_4096 #endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/CMakeLists.txt index 0f991d909..4f5613953 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/CMakeLists.txt @@ -1,11 +1,18 @@ # wolfSSL Espressif Example Project/main CMakeLists.txt -# v1.1 +# v1.2 # # wolfssl server test # message(STATUS "Begin wolfSSL main CMakeLists.txt") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + # `driver` component not available for ESP8266 + SET(THIS_PRIV_REQUIRES_DRIVER "") +else() + SET(THIS_PRIV_REQUIRES_DRIVER "driver") +endif() + if(WIN32) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") @@ -61,7 +68,7 @@ idf_component_register(SRCS main.c INCLUDE_DIRS "." "./include" PRIV_REQUIRES "${MAIN_WOLFSSL_COMPONENT_NAME}" - driver + "${THIS_PRIV_REQUIRES_DRIVER}" nvs_flash protocol_examples_common) @@ -113,7 +120,7 @@ execute_process( if(NOT CMAKE_BUILD_EARLY_EXPANSION AND (IS_GIT_REPO STREQUAL "true")) # LIBWOLFSSL_VERSION_GIT_HASH execute_process(COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) - LIBWOLFSSL_SAVE_INFO(WOLFSSL_EXAMPLE_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") # LIBWOLFSSL_VERSION_GIT_SHORT_HASH execute_process(COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/Kconfig.projbuild b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/Kconfig.projbuild index 5c3880f30..ed9960248 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/Kconfig.projbuild +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/Kconfig.projbuild @@ -1,3 +1,26 @@ +# Kconfig main +# +# Copyright (C) 2006-2025 wolfSSL Inc. +# +# This file is part of wolfSSL. +# +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# + +# Kconfig File Version 5.7.2.001 for wolfssl_template + menu "Example wolfSSL Configuration" choice WOLFSSL_EXAMPLE_CHOOSE @@ -72,6 +95,12 @@ choice WOLFSSL_EXAMPLE_CHOOSE help See wolfSSL/wolfTPM on GitHub. + config WOLFSSL_APPLE_HOMEKIT + bool "Apple HomeKit for the ESP32" + help + See AchimPieters/esp32-homekit-demo on GitHub. + + config WOLFSSL_EXAMPLE_NAME_NONE bool "Other" help diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/main.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/main.h index 647b6fa39..6a7946d50 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/main.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/main.h @@ -18,7 +18,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ + #ifndef _MAIN_H_ #define _MAIN_H_ +void app_main(void); + #endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/wifi_connect.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/wifi_connect.h index a7cbebdc9..0fe2183c7 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/wifi_connect.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/wifi_connect.h @@ -109,7 +109,7 @@ ** the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid" */ #if defined(CONFIG_ESP_WIFI_SSID) - /* tyically from ESP32 with ESP-IDF v4 to v5 */ + /* typically from ESP32 with ESP-IDF v4 to v5 */ #define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID #elif defined(CONFIG_EXAMPLE_WIFI_SSID) /* typically from ESP8266 rtos-sdk/v3.4 */ diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults index ca304079c..ca33fd17b 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults @@ -24,7 +24,8 @@ CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y # When using RSA, assign at least 10500 bytes, otherwise 5500 usually works for others # We set this to 28672 for use in the "test everything possible" in the wolfssl_test app. CONFIG_ESP_MAIN_TASK_STACK_SIZE=10500 -# Legacy stack size for older ESP-IDF versions + +# Legacy stack size name for older ESP-IDF versions CONFIG_MAIN_TASK_STACK_SIZE=10500 # diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/wolfssl_server_ESP8266.vgdbproj b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/wolfssl_server_ESP8266.vgdbproj new file mode 100644 index 000000000..6181d50c7 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/wolfssl_server_ESP8266.vgdbproj @@ -0,0 +1,292 @@ + + + + + + Unknown + + true + + c9687472-a434-43a7-9026-7914f425b9b4 + true + true + SourceDirs + + + + + + com.visualgdb.xtensa-lx106-elf + + 8.4.0 + 8.1 + 1 + + + + release/v3.4 + rtos-sdk/v3.4 + RTOS_SDK + + 0 + + + + + + + + + + + + + Default + + false + + BuildMachine + BuiltinShortcut + + + + + + + COM70 + + 74880 + 8 + None + One + None + + + 0 + false + true + false + ASCII + + + 255 + 0 + 0 + 0 + + + 255 + 169 + 169 + 169 + + + 255 + 211 + 211 + 211 + + + 255 + 144 + 238 + 144 + + + 255 + 169 + 169 + 169 + + + + 16 + true + true + true + true + 0 + + LF + false + false + false + + + + true + + + + + True + + true + true + + Enabled + true + true + true + + true + + + + false + + apiModeling.google.GTest + core.builtin.BuiltinFunctions + core.builtin.NoReturnFunctions + core.CallAndMessage + core.DivideZero + core.DynamicTypePropagation + core.NonnilStringConstants + core.NonNullParamChecker + core.NullDereference + core.StackAddressEscape + core.UndefinedBinaryOperatorResult + core.uninitialized.ArraySubscript + core.uninitialized.Assign + core.uninitialized.Branch + core.uninitialized.CapturedBlockVariable + core.uninitialized.UndefReturn + core.VLASize + cplusplus.NewDelete + cplusplus.NewDeleteLeaks + cplusplus.SelfAssignment + deadcode.DeadStores + nullability.NullPassedToNonnull + nullability.NullReturnedFromNonnull + security.insecureAPI.getpw + security.insecureAPI.gets + security.insecureAPI.mkstemp + security.insecureAPI.mktemp + security.insecureAPI.UncheckedReturn + security.insecureAPI.vfork + unix.API + unix.cstring.BadSizeArg + unix.cstring.NullArg + unix.Malloc + unix.MallocSizeof + unix.MismatchedDeallocator + unix.StdCLibraryFunctions + unix.Vfork + + + -analyzer-store=region + -analyzer-opt-analyze-nested-blocks + -analyzer-eagerly-assume + + + + + + Debug + + build/Debug + sdkconfig-debug + false + + + + Release + + build/Release + sdkconfig-release + false + + + + + + + + + + + + + false + false + false + false + false + false + false + false + false + + false + false + false + false + false + false + true + false + None + false + false + + true + false + false + true + 0 + false + 0 + true + false + + + openocd + + -f interface/ftdi/tigard.cfg -f target/esp8266.cfg + + + + false + + 131072 + Enabled + + set remotetimeout 60 + target remote :$$SYS:GDB_PORT$$ + mon reset halt + load + mon xtensa_no_interrupts_during_steps on + mon esp8266_autofeed_watchdog on + + false + 0 + 0 + false + + 0 + Soft + 4096 + 4096 + + size4M + freq40M + QIO + + + + true + Disabled + 0 + false + false + true + false + false + + _estack + 0 + false + + true + + \ No newline at end of file diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/CMakeLists.txt index 49fea2475..05d74de93 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/CMakeLists.txt @@ -8,7 +8,12 @@ message(STATUS "Begin project ${CMAKE_PROJECT_NAME}") cmake_minimum_required(VERSION 3.16) # Optional no watchdog typically used for test & benchmark -add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_ESP_NO_WATCHDOG=1") +else() + add_compile_definitions(WOLFSSL_ESP_NO_WATCHDOG=1) +endif() + # The wolfSSL CMake file should be able to find the source code. # Otherwise, assign an environment variable or set it here: @@ -123,8 +128,8 @@ endif() # Not only is a project-level "set(COMPONENTS" not needed here, this will cause # an unintuitive error about Unknown CMake command "esptool_py_flash_project_args". -message(STATUS "begin optional PROTOCOL_EXAMPLES_DIR include") if(0) + message(STATUS "Begin optional PROTOCOL_EXAMPLES_DIR include") # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) @@ -135,9 +140,10 @@ if(0) else() message(STATUS "NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") endif() + message(STATUS "End optional PROTOCOL_EXAMPLES_DIR include") endif() + include($ENV{IDF_PATH}/tools/cmake/project.cmake) -message(STATUS "end optional include") project(wolfssl_test) message(STATUS "end project") diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/Makefile b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/Makefile index b110e86aa..0763d5ae6 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/Makefile +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/Makefile @@ -7,7 +7,7 @@ CFLAGS += -DWOLFSSL_USER_SETTINGS # Some of the tests are CPU intenstive, so we'll force the watchdog timer off. # There's an espressif NO_WATCHDOG; we don't use it, as it is reset by sdkconfig. -EXTRA_CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG +CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 PROJECT_NAME := wolfssl_test diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/README.md b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/README.md index 298ea015c..8b6735886 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/README.md +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/README.md @@ -1,6 +1,5 @@ # wolfSSL Crypt Test Example - This is the ESP32 Version of the [wolfSSL wolfcrypt test application](https://github.com/wolfSSL/wolfssl/tree/master/wolfcrypt/test). For general information on [wolfSSL examples for Espressif](../README.md), see the @@ -11,7 +10,7 @@ For general information on [wolfSSL examples for Espressif](../README.md), see t The easiest way to get started with wolfSSL is by using the [ESP Registry](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/) examples. -``` +```bash . ~/esp/esp-idf/export.sh idf.py create-project-from-example "wolfssl/wolfssl^5.6.0-stable:wolfssl_test" cd wolfssl_benchmark @@ -42,7 +41,7 @@ Reminder than when building on WSL in `/mnt/c` there will be a noticeable perfor Example build on WSL, assuming `git clone` from `c:\workspace`: -``` +```bash WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.2 # WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/master @@ -70,7 +69,7 @@ idf.py build flash -p /dev/ttyS24 -b 115200 monitor ## ESP-IDF Commandline (version 3.5 or earlier for the ESP8266) -``` +```bash WRK_IDF_PATH=/mnt/c/SysGCC/esp8266/rtos-sdk/v3.4 . $WRK_IDF_PATH/export.sh @@ -85,6 +84,31 @@ idf.py menuconfig idf.py build flash -p /dev/ttyS55 -b 115200 ``` +## Espressif ESP8266 RTOS SDK Make Commandline + +```bash +# Find the ESP8266 SDK directory, shown here for WSL (Windows C:\ESP8266\esp\ESP8266_RTOS_SDK) +cd /mnt/c/ESP8266/esp/ESP8266_RTOS_SDK + +# Optionally run install as needed +./install.sh + +# Setup SDK +. ./export.sh + +# Find example to build +cd /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test + +make clean + +make + +make flash + +# or: +python /mnt/c/ESP8266/esp/ESP8266_RTOS_SDK/components/esptool_py/esptool/esptool.py --chip esp8266 --port /dev/ttyUSB0 --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 2MB 0x0 /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/bootloader/bootloader.bin 0x10000 /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/wolfssl_test.bin 0x8000 /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/partitions_singleapp.bin +``` + ## Putty (via WSL) Define a non-blank value for `ESPIDF_PUTTY_MONITOR` to launch `testMonitor.sh` output in putty.exe sessions from Windows. @@ -103,7 +127,7 @@ for help in optimizing for your particular application, or see the Compiled and flashed with `idf.py build flash -p /dev/ttyS7 -b 115200 monitor`: -``` +```text ets Jun 8 2016 00:22:57 rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/CMakeLists.txt index 9d6b9f381..cc7ef0d47 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/CMakeLists.txt @@ -159,7 +159,8 @@ else() set(COMPONENT_REQUIRES lwip "${THIS_ESP_TLS}") # we typically don't need lwip directly in wolfssl component endif() -# find the user name to search for possible "wolfssl-username" +# Find the user name to search for possible "wolfssl-username" +# Reminder: Windows is %USERNAME%, Linux is $USER message(STATUS "USERNAME = $ENV{USERNAME}") if( "$ENV{USER}" STREQUAL "" ) # the bash user if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user @@ -407,17 +408,22 @@ endif() if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") ) # There's no esp_timer, no driver components for the ESP8266 - message(STATUS "Early expansion EXCLUDES esp_timer for esp8266: ${THIS_INCLUDE_TIMER}") - message(STATUS "Early expansion EXCLUDES driver for esp8266: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "") - set(THIS_INCLUDE_DRIVER "") - set(THIS_ESP_TLS "") + message(STATUS "Early expansion EXCLUDES for esp8266:") + message(STATUS "THIS_INCLUDE_DRIVER: '${THIS_INCLUDE_DRIVER}'") + message(STATUS "THIS_INCLUDE_TIMER: '${THIS_INCLUDE_TIMER}'") + message(STATUS "Early expansion INCLUDE for esp8266:") + message(STATUS "THIS_INCLUDE_PTHREAD: '${THIS_INCLUDE_PTHREAD}'") + set(THIS_ESP_TLS "") + set(THIS_INCLUDE_DRIVER "") + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_PTHREAD "pthread") else() message(STATUS "Early expansion includes esp_timer: ${THIS_INCLUDE_TIMER}") message(STATUS "Early expansion includes driver: ${THIS_INCLUDE_DRIVER}") - set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_ESP_TLS "esp-tls") set(THIS_INCLUDE_DRIVER "driver") - set(THIS_ESP_TLS "esp-tls") + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_PTHREAD "") # Let the app know that we've included the esp-tls component requirement. # This is critical for use the the esp-tls component. See wolfssl esp_crt_bundle.c file. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_REQUIRED_ESP_TLS=1") @@ -429,6 +435,7 @@ if(CMAKE_BUILD_EARLY_EXPANSION) REQUIRES "${COMPONENT_REQUIRES}" PRIV_REQUIRES # esp_hw_support "${THIS_ESP_TLS}" + "${THIS_INCLUDE_PTHREAD}" "${THIS_INCLUDE_TIMER}" "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark ) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/component.mk index 80fd1fc89..8865ec880 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/component.mk @@ -66,7 +66,19 @@ CFLAGS +=-DWOLFSSL_USER_SETTINGS # https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples # When this wolfssl component.mk makefile is in [project]/components/wolfssl # The root is 7 directories up from here (the location of of this component.mk): -WOLFSSL_ROOT := ../../../../../../.. +# +WOLFSSL_ROOT ?= ../../../../../../.. +THIS_DIR := $(shell pwd) +WOLFSSL_ROOT_OBJ := $(THIS_DIR) + +# When running make from commandline or VisualGDB, the current path varies: +ifeq ("$(VISUALGDB_DIR)","") + # current path is typically /mnt/c/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/wolfssl + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL)) +else + # current path is typically /C/workspace/wolfssl-gojimmypi/IDE/Espressif/ESP-IDF/examples/wolfssl_test/build/Debug/wolfssl + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL)) +endif # To set the location of a different location, it is best to use relative paths. # @@ -92,14 +104,16 @@ WOLFSSL_ROOT := ../../../../../../.. # CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt # CFLAGS += -I$(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif -abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) +abs_WOLFSSL_ROOT := $(shell realpath $(WOLFSSL_ROOT)) # print-wolfssl-path-value: # @echo "WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)" # @echo "WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)" -$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) -$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT defined: $(WOLFSSL_ROOT)) +$(info WOLFSSL_ROOT actual: $(abs_WOLFSSL_ROOT)) +$(info THIS_DIR defined: $(THIS_DIR)) +$(info WOLFSSL_ROOT_OBJ defined: $(WOLFSSL_ROOT_OBJ)) # NOTE: The wolfSSL include directory (e.g. user_settings.h) is # located HERE in THIS project, and *not* in the wolfSSL root. @@ -109,6 +123,7 @@ COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/. COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfssl/wolfcrypt/port/Espressif + # COMPONENT_ADD_INCLUDEDIRS += $ENV(IDF_PATH)/components/freertos/include/freertos # COMPONENT_ADD_INCLUDEDIRS += "$ENV(IDF_PATH)/soc/esp32s3/include/soc" @@ -122,27 +137,27 @@ COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/atmel -COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT)/wolfcrypt/src/aes_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/evp.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/misc.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/sha512_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/fe_x25519_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/wolfcrypt/src/aes_gcm_x86_asm.o -COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)/src/bio.o - +COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/evp.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/misc.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/sha512_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/fe_x25519_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT_OBJ)/wolfcrypt/src/aes_gcm_x86_asm.o ## ## wolfSSL ## -COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o -# COMPONENT_OBJS += src/conf.o +## reminder object files may end up in `./build` or `build/debug` or `build/release`, depending on build environment & settings. +## +# COMPONENT_OBJS := $(WOLFSSL_ROOT)/src/bio.o # part of ssl.c, omitted to avoid "does not need to be compiled separately" +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/conf.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/crl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/dtls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/internal.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/keys.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ocsp.o -# COMPONENT_OBJS += src/pk.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/pk.o # part of ssl.c COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/quic.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/sniffer.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o @@ -154,8 +169,8 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/ssl.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/tls13.o COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/wolfio.o -# COMPONENT_OBJS += src/x509.o -# COMPONENT_OBJS += src/x509_str.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509.o # part of ssl.c +# COMPONENT_OBJS += $(WOLFSSL_ROOT)/src/x509_str.o # part of ssl.c ## ## wolfcrypt @@ -276,20 +291,16 @@ COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/src/port/Espressif/esp_sdk_wifi_lib. ## ## wolfcrypt benchmark (optional) ## -## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o -## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark +## COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.o +## COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark ## COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/benchmark ## -## wolfcrypt test (optional) +## wolfcrypt test (needed for this test example) ## -COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test +COMPONENT_OBJS += $(WOLFSSL_ROOT)/wolfcrypt/test/test.o +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)/wolfcrypt/test/include -## -## wolfcrypt -## -# COMPONENT_PRIV_INCLUDEDIRS += $(PROJECT_PATH)/components/wolfssl/include -COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)/wolfcrypt/src $(info ********** end wolfssl component **********) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/include/user_settings.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/include/user_settings.h index ec2021618..7349338aa 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/include/user_settings.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl/include/user_settings.h @@ -20,6 +20,11 @@ */ #define WOLFSSL_ESPIDF_COMPONENT_VERSION 0x01 +/* Examples such as test and benchmark are known to cause watchdog timeouts. + * Note this is often set in project Makefile: + * CFLAGS += -DWOLFSSL_ESP_NO_WATCHDOG=1 */ +#define WOLFSSL_ESP_NO_WATCHDOG 1 + /* The Espressif project config file. See also sdkconfig.defaults */ #include "sdkconfig.h" @@ -219,6 +224,17 @@ #endif #endif +/* Enable AES for all examples */ +#ifdef NO_AES + #warning "Found NO_AES, wolfSSL AES Cannot be enabled. Check config." +#else + #define WOLFSSL_AES + #define WOLFSSL_AES_COUNTER + + /* Typically only needed for wolfssl_test, see docs. */ + #define WOLFSSL_AES_DIRECT +#endif + /* Pick a cert buffer size: */ /* #define USE_CERT_BUFFERS_2048 */ /* #define USE_CERT_BUFFERS_1024 */ @@ -273,6 +289,10 @@ /* Optionally enable some wolfSSH settings */ #if defined(ESP_ENABLE_WOLFSSH) || defined(CONFIG_ESP_ENABLE_WOLFSSH) + /* Enable wolfSSH. Espressif examples need a few more settings, below */ + #undef WOLFSSL_WOLFSSH + #define WOLFSSL_WOLFSSH + /* The default SSH Windows size is massive for an embedded target. * Limit it: */ #define DEFAULT_WINDOW_SZ 2000 @@ -386,7 +406,10 @@ #if defined(CONFIG_IDF_TARGET_ESP32C2) || \ defined(CONFIG_IDF_TARGET_ESP8684) /* Optionally set smaller size here */ - #define HAVE_FFDHE_4096 + #ifdef HAVE_FFDHE_4096 + /* this size may be problematic on the C2 */ + #endif + #define HAVE_FFDHE_2048 #else #define HAVE_FFDHE_4096 #endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/CMakeLists.txt b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/CMakeLists.txt index 07b8ff3cf..2998d8ee5 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/CMakeLists.txt @@ -1,11 +1,18 @@ # wolfSSL Espressif Example Project/main CMakeLists.txt -# v1.1 +# v1.2 # # wolfssl crypt test # message(STATUS "Begin wolfSSL main CMakeLists.txt") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +if (idf_target STREQUAL "esp8266" OR IDF_TARGET STREQUAL "esp8266" OR IDF_VERSION_MAJOR VERSION_LESS "5.0") + # `driver` component not available for ESP8266 + SET(THIS_PRIV_REQUIRES_DRIVER "") +else() + SET(THIS_PRIV_REQUIRES_DRIVER "driver") +endif() + if(WIN32) # Windows-specific configuration here set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") @@ -57,7 +64,9 @@ endif() idf_component_register(SRCS main.c INCLUDE_DIRS "." "./include" - PRIV_REQUIRES driver "${MAIN_WOLFSSL_COMPONENT_NAME}") + PRIV_REQUIRES "${THIS_PRIV_REQUIRES_DRIVER}" + "${MAIN_WOLFSSL_COMPONENT_NAME}" + ) # # LIBWOLFSSL_SAVE_INFO(VAR_OUPUT THIS_VAR VAR_RESULT) diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/component.mk index d9b752f16..08f8fbe9b 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/main/component.mk @@ -7,3 +7,17 @@ # please read the ESP-IDF documents if you need to do this. # # (Uses default behavior of compiling all source files in directory, adding 'include' to include path.) + +# We'll add the explicit lines only for old SDK requirements (e.h. ESP8266) + +ifeq ("$(VISUALGDB_DIR)","") + $(info VISUALGDB_DIR build not detected. shell: $(shell echo $$SHELL) ) +else + $(info Detected VisualGDB in: $(VISUALGDB_DIR) shell: $(shell echo $$SHELL) ) + COMPONENT_SRCDIRS := . + COMPONENT_ADD_INCLUDEDIRS := . + COMPONENT_ADD_INCLUDEDIRS += include + + # Ensure main.c gets compiled + COMPONENT_OBJS := main.o +endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/partitions_singleapp_large.csv b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/partitions_singleapp_large.csv index 52a403708..0b2fcd1a9 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/partitions_singleapp_large.csv +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/partitions_singleapp_large.csv @@ -1,34 +1,31 @@ -# This tag is used to include this file in the ESP Component Registry: -# __ESP_COMPONENT_SOURCE__ - -# to view: idf.py partition-table -# -# ESP-IDF Partition Table -# Name, Type, SubType, Offset, Size, Flags -nvs, data, nvs, 0x9000, 24K, -phy_init,data, phy, 0xf000, 4K, -factory, app, factory, 0x10000, 1500K, - - -# For other settings, see: -# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#creating-custom-tables -# -# Here is the summary printed for the "Single factory app, no OTA" configuration: -# -# # ESP-IDF Partition Table -# # Name, Type, SubType, Offset, Size, Flags -# nvs, data, nvs, 0x9000, 0x6000, -# phy_init, data, phy, 0xf000, 0x1000, -# factory, app, factory, 0x10000, 1M, -# -# -# Here is the summary printed for the "Factory app, two OTA definitions" configuration: -# -# # ESP-IDF Partition Table -# # Name, Type, SubType, Offset, Size, Flags -# nvs, data, nvs, 0x9000, 0x4000, -# otadata, data, ota, 0xd000, 0x2000, -# phy_init, data, phy, 0xf000, 0x1000, -# factory, app, factory, 0x10000, 1M, -# ota_0, app, ota_0, 0x110000, 1M, -# ota_1, app, ota_1, 0x210000, 1M, +# to view: idf.py partition-table +# +# ESP-IDF Partition Table +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 24K, +phy_init,data, phy, 0xf000, 4K, +factory, app, factory, 0x10000, 1500K, + + +# For other settings, see: +# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#creating-custom-tables +# +# Here is the summary printed for the "Single factory app, no OTA" configuration: +# +# # ESP-IDF Partition Table +# # Name, Type, SubType, Offset, Size, Flags +# nvs, data, nvs, 0x9000, 0x6000, +# phy_init, data, phy, 0xf000, 0x1000, +# factory, app, factory, 0x10000, 1M, +# +# +# Here is the summary printed for the "Factory app, two OTA definitions" configuration: +# +# # ESP-IDF Partition Table +# # Name, Type, SubType, Offset, Size, Flags +# nvs, data, nvs, 0x9000, 0x4000, +# otadata, data, ota, 0xd000, 0x2000, +# phy_init, data, phy, 0xf000, 0x1000, +# factory, app, factory, 0x10000, 1M, +# ota_0, app, ota_0, 0x110000, 1M, +# ota_1, app, ota_1, 0x210000, 1M, diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults index c84e96247..6fd9876d0 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults @@ -1,5 +1,6 @@ # Set the known example app config to template example (see user_settings.h) CONFIG_WOLFSSL_EXAMPLE_NAME_WOLFSSL_TEST=y + # CONFIG_EXAMPLE_WIFI_SSID="myssid" # CONFIG_EXAMPLE_WIFI_PASSWORD="mypassword" @@ -25,6 +26,7 @@ CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y # When using RSA, assign at least 10500 bytes, otherwise 5500 usually works for others # We set this to 28672 for use in the "test everything possible" in the wolfssl_test app. CONFIG_ESP_MAIN_TASK_STACK_SIZE=28672 + # Legacy stack size name for older ESP-IDF versions CONFIG_MAIN_TASK_STACK_SIZE=28672 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32 b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32 new file mode 100644 index 000000000..9d61e301d --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32 @@ -0,0 +1,4 @@ +# Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=28672 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32c3 b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32c3 new file mode 100644 index 000000000..a252c51ba --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32c3 @@ -0,0 +1,4 @@ +# Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=25500 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32c6 b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32c6 new file mode 100644 index 000000000..a252c51ba --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32c6 @@ -0,0 +1,4 @@ +# Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=25500 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32h2 b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32h2 new file mode 100644 index 000000000..a252c51ba --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32h2 @@ -0,0 +1,4 @@ +# Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=25500 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32s2 b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32s2 new file mode 100644 index 000000000..9d61e301d --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32s2 @@ -0,0 +1,4 @@ +# Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=28672 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32s3 b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32s3 new file mode 100644 index 000000000..9d61e301d --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults.esp32s3 @@ -0,0 +1,4 @@ +# Note that during the build process, settings from sdkconfig.defaults will not override those already in sdkconfig. +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=28672 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.sln b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.sln new file mode 100644 index 000000000..57fec6c39 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.sln @@ -0,0 +1,30 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34601.278 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{803FD0C6-D64E-4E16-9DC3-1DAEC859A3D2}") = "wolfssl_test_ESP8266", "wolfssl_test_ESP8266.vgdbproj", "{C9687472-A434-43A7-9026-7914F425B9B4}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D4A6F5E5-807B-4D51-ACD5-8493BCF2E7F0}" + ProjectSection(SolutionItems) = preProject + components\wolfssl\include\user_settings.h = components\wolfssl\include\user_settings.h + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|VisualGDB = Debug|VisualGDB + Release|VisualGDB = Release|VisualGDB + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C9687472-A434-43A7-9026-7914F425B9B4}.Debug|VisualGDB.ActiveCfg = Debug|VisualGDB + {C9687472-A434-43A7-9026-7914F425B9B4}.Debug|VisualGDB.Build.0 = Debug|VisualGDB + {C9687472-A434-43A7-9026-7914F425B9B4}.Release|VisualGDB.ActiveCfg = Release|VisualGDB + {C9687472-A434-43A7-9026-7914F425B9B4}.Release|VisualGDB.Build.0 = Release|VisualGDB + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {84F29237-2909-4E98-AD33-2624E2256EF8} + EndGlobalSection +EndGlobal diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.vgdbproj b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.vgdbproj index 41509e0fd..6181d50c7 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.vgdbproj +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/wolfssl_test_ESP8266.vgdbproj @@ -53,7 +53,7 @@ - COM80 + COM70 74880 8 @@ -110,7 +110,7 @@ LF false false - true + false diff --git a/IDE/Espressif/include.am b/IDE/Espressif/include.am index eea296f2c..3d356b767 100644 --- a/IDE/Espressif/include.am +++ b/IDE/Espressif/include.am @@ -30,17 +30,18 @@ EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/Kconfig EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/README.md EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/include/user_settings.h -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/Makefile +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/main.c EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/Kconfig.projbuild +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/component.mk +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/CMakeLists.txt +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/include +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/include/main.h EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/partitions_singleapp_large.csv EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/README.md EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/sdkconfig.defaults.esp8266 EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/VisualGDB -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/CMakeLists.txt -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/include -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/main.c -EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/main/include/main.h EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/template/VisualGDB/wolfssl_template_IDF_v5.1_ESP32.vgdbproj @@ -146,9 +147,10 @@ EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/README_server_sm.md EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults.esp32c2 EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/sdkconfig.defaults.esp8266 + +EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/wolfssl_server_ESP8266.vgdbproj EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/VisualGDB EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/VisualGDB/README.md - EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/VisualGDB/wolfssl_server_IDF_v5_ESP32.sln EXTRA_DIST+= IDE/Espressif/ESP-IDF/examples/wolfssl_server/VisualGDB/wolfssl_server_IDF_v5_ESP32.vgdbproj diff --git a/wolfcrypt/src/port/Espressif/esp32_util.c b/wolfcrypt/src/port/Espressif/esp32_util.c index aff2b694b..62f40a3d8 100644 --- a/wolfcrypt/src/port/Espressif/esp32_util.c +++ b/wolfcrypt/src/port/Espressif/esp32_util.c @@ -37,7 +37,9 @@ #if ESP_IDF_VERSION_MAJOR > 4 #include #include + #include #endif + /* wolfSSL */ #include /* needed to print MATH_INT_T value */ #include @@ -740,14 +742,23 @@ esp_err_t esp_DisableWatchdog(void) defined(CONFIG_IDF_TARGET_ESP32C3) || \ defined(CONFIG_IDF_TARGET_ESP32C6) || \ defined(CONFIG_IDF_TARGET_ESP32H2) - ESP_LOGW(TAG, "No known rtc_wdt_protect_off for this platform."); + #if ESP_IDF_VERSION_MINOR >= 3 + #if CONFIG_ESP_TASK_WDT + ret = esp_task_wdt_deinit(); + #else + /* CONFIG_ESP_TASK_WDT=y needed in sdkconfig */ + ESP_LOGW(TAG, "esp_task_wdt_deinit not available"); + #endif + #else + ESP_LOGW(TAG, "esp_task_wdt_deinit not implemented"); + #endif #else rtc_wdt_protect_off(); rtc_wdt_disable(); #endif } #else - ESP_LOGW(TAG, "esp_DisableWatchdog not implemented on ESP_OIDF v%d", + ESP_LOGW(TAG, "esp_DisableWatchdog not implemented on ESP_IDF v%d", ESP_IDF_VERSION_MAJOR); #endif #endif @@ -782,6 +793,14 @@ esp_err_t esp_EnabledWatchdog(void) defined(CONFIG_IDF_TARGET_ESP32C6) || \ defined(CONFIG_IDF_TARGET_ESP32H2) ESP_LOGW(TAG, "No known rtc_wdt_protect_off for this platform."); + esp_task_wdt_config_t twdt_config = { + .timeout_ms = 5000, /* Timeout in milliseconds */ + .trigger_panic = true, /* trigger panic on timeout */ + .idle_core_mask = (1 << 0), /* Enable on Core 0 */ + }; + ESP_LOGW(TAG, "No known rtc_wdt_protect_off for this platform."); + esp_task_wdt_init(&twdt_config); + esp_task_wdt_add(NULL); #else rtc_wdt_protect_on(); rtc_wdt_enable(); diff --git a/wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h b/wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h index 737781a8c..a74d796f1 100644 --- a/wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h +++ b/wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h @@ -330,7 +330,7 @@ enum { #include #endif - #if ESP_IDF_VERSION_MAJOR >= 4 + #if ESP_IDF_VERSION_MAJOR == 4 || (ESP_IDF_VERSION_MAJOR == 5 && ESP_IDF_VERSION_MINOR < 4) #include #else #include @@ -375,9 +375,7 @@ enum { #include #endif - #if ESP_IDF_VERSION_MAJOR >= 4 - /* #include */ - #else + #if ESP_IDF_VERSION_MAJOR < 4 #include #endif @@ -411,9 +409,7 @@ enum { #include #endif - #if ESP_IDF_VERSION_MAJOR >= 4 - /* #include */ - #else + #if ESP_IDF_VERSION_MAJOR < 4 #include #endif @@ -447,9 +443,7 @@ enum { #include #endif - #if ESP_IDF_VERSION_MAJOR >= 4 - /* #include */ - #else + #if ESP_IDF_VERSION_MAJOR < 4 #include #endif @@ -719,24 +713,16 @@ extern "C" */ #ifndef NO_AES - #if ESP_IDF_VERSION_MAJOR >= 4 - #include "esp32/rom/aes.h" - #elif defined(CONFIG_IDF_TARGET_ESP8266) - /* no hardware includes for ESP8266*/ - #else - /* TODO: Confirm for older versions: */ - /* #include "rom/aes.h" */ - #endif + /* wolfSSL does not use Espressif rom/aes.h */ + struct Aes; /* see wolcrypt/aes.h */ - typedef enum tagES32_AES_PROCESS /* TODO what's this ? */ + typedef enum tagES32_AES_PROCESS { ESP32_AES_LOCKHW = 1, ESP32_AES_UPDATEKEY_ENCRYPT = 2, ESP32_AES_UPDATEKEY_DECRYPT = 3, ESP32_AES_UNLOCKHW = 4 } ESP32_AESPROCESS; - - struct Aes; /* see aes.h */ #if defined(WOLFSSL_HW_METRICS) WOLFSSL_LOCAL int esp_hw_show_aes_metrics(void); WOLFSSL_LOCAL int wc_esp32AesUnupportedLengthCountAdd(void); @@ -780,7 +766,14 @@ extern "C" #define SHA_CTX ETS_SHAContext - #if ESP_IDF_VERSION_MAJOR >= 4 + #if ESP_IDF_VERSION_MAJOR > 5 || (ESP_IDF_VERSION_MAJOR == 5 && ESP_IDF_VERSION_MINOR >= 4) + #include "rom/sha.h" + #if defined(CONFIG_IDF_TARGET_ESP32) + #define WC_ESP_SHA_TYPE enum SHA_TYPE + #else + #define WC_ESP_SHA_TYPE SHA_TYPE + #endif + #elif ESP_IDF_VERSION_MAJOR >= 4 #if defined(CONFIG_IDF_TARGET_ESP32) #include "esp32/rom/sha.h" #define WC_ESP_SHA_TYPE enum SHA_TYPE