From fffb80d2214b6d050d2d033c629e4bec4cff9dda Mon Sep 17 00:00:00 2001 From: Zackery Backman Date: Mon, 13 Apr 2026 17:12:49 -0600 Subject: [PATCH] Clear sha3->hashType in InitSha3 so Final fully resets the struct for cross sha3 reuse. --- wolfcrypt/src/sha3.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wolfcrypt/src/sha3.c b/wolfcrypt/src/sha3.c index 7a6faffe56..3cf78ebf3e 100644 --- a/wolfcrypt/src/sha3.c +++ b/wolfcrypt/src/sha3.c @@ -646,6 +646,12 @@ static int InitSha3(wc_Sha3* sha3) #ifdef WOLFSSL_HASH_FLAGS sha3->flags = 0; #endif +#ifdef WOLF_CRYPTO_CB + /* Cached hash variant is tied to sponge state; clear it whenever the + * state is reset so reuse for a different SHA3 variant dispatches + * correctly through the crypto callback. */ + sha3->hashType = WC_HASH_TYPE_NONE; +#endif #ifdef USE_INTEL_SPEEDUP {