Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions wolfcrypt/src/port/Espressif/esp32_sha.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@

#include <hal/sha_ll.h>
#include <hal/clk_gate_ll.h>
#if ESP_IDF_VERSION_MAJOR >= 6
#include "sha/sha_core.h"
#endif
#elif defined(CONFIG_IDF_TARGET_ESP32) || \
defined(CONFIG_IDF_TARGET_ESP32S2) || \
defined(CONFIG_IDF_TARGET_ESP32S3)
Expand Down Expand Up @@ -1928,6 +1931,24 @@ static int wc_esp_process_block(WC_ESP32SHA* ctx, /* see ctx->sha_type */
}
if (ctx->isfirstblock) {
ets_sha_enable(); /* will clear initial digest */
#if ESP_IDF_VERSION_MAJOR >= 6
/* Beginning ESP-IDF v6, the mode needs to be explicitly set. */
sha_hal_wait_idle();
switch (ctx->sha_type) {
case SHA1:
sha_hal_set_mode(SHA1);
break;
case SHA2_224:
esp_sha_set_mode(SHA2_224);
break;
case SHA2_256:
esp_sha_set_mode(SHA2_256);
break;
default:
/* Unsupported SHA mode. */
ESP_LOGW(TAG, "Unexpected sha_type", ctx->sha_type);
}
#endif
#if defined(DEBUG_WOLFSSL)
{
this_block_num = 1; /* one-based counter, just for debug info */
Expand Down
Loading