wolfSSL / wolfssl

The wolfSSL library is a small, fast, portable implementation of TLS/SSL for embedded devices to the cloud. wolfSSL supports up to TLS 1.3 and DTLS 1.3!

Home Page:https://www.wolfssl.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: Forcing FreeRTOS Espressif to SINGLE_THREADED causes SHA256 test failure

gojimmypi opened this issue · comments

Contact Details

No response

Version

latest master

Description

Related to #7528 and #7533 the SHA256 test (only) fails on the ESP32 when #define SINGLE_THREADED is included in the user_settings.h.

Even though the ESP32 is already a multi-task FreeRTOS environment, forcing the SINGLE_THREADED mode should not cause a SHA256 failure.

Additionally, I discovered there's a macro logic problem when surgically disabling only SHA256 and/or SHA224:

    #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256
    #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA224

Reproduction steps

Add above noted settings to respective user_settings.h for the wolfssl_test example.

Relevant log output

The SHA256 failuee looks like this:


I (642) esp32_util: LIBWOLFSSL_VERSION_STRING = 5.7.0
I (648) esp32_util: LIBWOLFSSL_VERSION_HEX = 5007000
I (653) esp32_util: Stack HWM: 9212
I (657) esp32_util: 
I (660) esp32_util: Macro Name                 Defined   Not Defined
I (667) esp32_util: ------------------------- --------- -------------
I (674) esp32_util: NO_ESPIDF_DEFAULT........                 X
I (681) esp32_util: HW_MATH_ENABLED..........     X
I (687) esp32_util: WOLFSSL_SHA224...........     X
I (692) esp32_util: WOLFSSL_SHA384...........     X
I (698) esp32_util: WOLFSSL_SHA512...........     X
I (703) esp32_util: WOLFSSL_SHA3.............     X
I (709) esp32_util: HAVE_ED25519.............     X
I (714) esp32_util: HAVE_AES_ECB.............                 X
I (721) esp32_util: HAVE_AES_DIRECT..........                 X
I (728) esp32_util: USE_FAST_MATH............     X
I (733) esp32_util: WOLFSSL_SP_MATH_ALL......                 X
I (740) esp32_util: SP_MATH..................                 X
I (746) esp32_util: WOLFSSL_HW_METRICS.......     X
I (752) esp32_util: RSA_LOW_MEM..............     X
I (757) esp32_util: SMALL_SESSION_CACHE......                 X
I (764) esp32_util: WC_NO_HARDEN.............                 X
I (771) esp32_util: TFM_TIMING_RESISTANT.....     X
I (776) esp32_util: ECC_TIMING_RESISTANT.....     X
I (782) esp32_util: WC_NO_CACHE_RESISTANT....     X
I (787) esp32_util: WC_AES_BITSLICED.........                 X
I (794) esp32_util: WOLFSSL_AES_NO_UNROLL....                 X
I (800) esp32_util: TFM_TIMING_RESISTANT.....     X
I (806) esp32_util: ECC_TIMING_RESISTANT.....     X
I (812) esp32_util: WC_RSA_BLINDING..........     X
I (817) esp32_util: NO_WRITEV................     X
I (823) esp32_util: FREERTOS.................     X
I (828) esp32_util: NO_WOLFSSL_DIR...........     X
I (834) esp32_util: WOLFSSL_NO_CURRDIR.......     X
I (839) esp32_util: WOLFSSL_LWIP.............     X
I (845) esp32_util:
I (848) esp32_util: Compiler Optimization: Default
I (853) esp32_util:
I (856) esp32_util: CONFIG_IDF_TARGET = esp32
W (861) esp32_util: Watchdog active; missing WOLFSSL_ESP_NO_WATCHDOG definition.
I (869) esp32_util: CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: 240 MHz
I (876) esp32_util: Xthal_have_ccount: 1
I (880) esp32_util: CONFIG_MAIN_TASK_STACK_SIZE: 10500
I (886) esp32_util: CONFIG_ESP_MAIN_TASK_STACK_SIZE: 10500
I (892) esp32_util: CONFIG_TIMER_TASK_STACK_SIZE: 3584
I (898) esp32_util: CONFIG_TIMER_TASK_STACK_DEPTH: 2048
I (904) esp32_util: Stack HWM: 3ffb65af
I (908) esp32_util: ESP32_CRYPT is enabled for ESP32.
I (914) esp32_util: SINGLE_THREADED
I (918) esp32_util: Boot count: 1
------------------------------------------------------------------------------
 wolfSSL version 5.7.0
------------------------------------------------------------------------------
error    test passed!
MEMORY   test passed!
base64   test passed!
base16   test passed!
asn      test passed!
RANDOM   test passed!
MD5      test passed!
MD2      test passed!
MD4      test passed!
SHA      test passed!
SHA-224  test passed!
E (969) wc_test: Failed: Error = -1610916146 during sha256_test, line 3410

Attempting to disable HW SHA256 (only) and forcing SINGLE_THREADED causes this compile-time error:

-- wolfSSL @ 5.7.0-test.rev02
Building in release mode
Compiling .pio\build\esp32dev\libb61\wolfSSL\wolfcrypt\src\sha256.o
.pio/libdeps/esp32dev/wolfSSL/src/wolfcrypt/src/sha256.c: In function 'wc_Sha224Update':
.pio/libdeps/esp32dev/wolfSSL/src/wolfcrypt/src/sha256.c:2090:15: error: 'wc_Sha224' {aka 'struct wc_Sha256'} has no member named 'ctx'
 2090 |         sha224->ctx.mode = ESP32_SHA_SW; /* no SHA224 HW, so always SW */
      |               ^~
*** [.pio\build\esp32dev\libb61\wolfSSL\wolfcrypt\src\sha256.o] Error 1
=================================================================== [FAILED] Took 20.16 seconds ===================================================================

 *  The terminal process "C:\Users\gojimmypi\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 

False alarm, my mistake. I was testing with stale code published to staging version of wolfSSL on PlatformIO. Any related issues were likely fixed with the merge of #7505 yesterday.

See https://registry.platformio.org/libraries/wolfssl-staging/wolfSSL/versions

I'm still testing, but I believe 5.7.0-test.rev03 is working properly with the latest master version of wolfSSL as of today, along with minor changes in my gojimmypi:PR-PlatformIO-FreeRTOS branch for #7528.