From 7386c1b15ddf6c02172c9273322ff08fee2fcb20 Mon Sep 17 00:00:00 2001 From: manastasova Date: Fri, 3 Jan 2025 15:54:55 -0800 Subject: [PATCH] Update Keccak state flag in SHA3 functions --- crypto/fipsmodule/sha/sha3.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crypto/fipsmodule/sha/sha3.c b/crypto/fipsmodule/sha/sha3.c index aabf8a043e..1db9e9d61b 100644 --- a/crypto/fipsmodule/sha/sha3.c +++ b/crypto/fipsmodule/sha/sha3.c @@ -234,11 +234,17 @@ int SHA3_Final(uint8_t *md, KECCAK1600_CTX *ctx) { return 1; } + if (ctx->state == KECCAK1600_STATE_SQUEEZE || + ctx->state == KECCAK1600_STATE_FINAL) { + return 0; + } + if (FIPS202_Finalize(md, ctx) == 0) { return 0; } Keccak1600_Squeeze(ctx->A, md, ctx->md_size, ctx->block_size, ctx->state); + ctx->state = KECCAK1600_STATE_FINAL; FIPS_service_indicator_update_state(); return 1;