From 1022131d16e30cfbf896e02419019de48e8e1149 Mon Sep 17 00:00:00 2001 From: Holger Dengler Date: Wed, 27 Sep 2023 15:43:18 +0200 Subject: [PATCH] Fix state handling of keccak_final for s390x. The digest life-cycle state diagram has been updated for XOF. Fix the state handling in s390x_keccac_final() according to the updated state diagram. Signed-off-by: Holger Dengler Reviewed-by: Shane Lontis Reviewed-by: Todd Short Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/22221) --- providers/implementations/digests/sha3_prov.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/providers/implementations/digests/sha3_prov.c b/providers/implementations/digests/sha3_prov.c index 34620cf95a6..f691273bafd 100644 --- a/providers/implementations/digests/sha3_prov.c +++ b/providers/implementations/digests/sha3_prov.c @@ -235,6 +235,10 @@ static int s390x_keccakc_final(void *vctx, unsigned char *out, size_t outlen, if (!ossl_prov_is_running()) return 0; + if (!(ctx->xof_state == XOF_STATE_INIT || + ctx->xof_state == XOF_STATE_ABSORB)) + return 0; + ctx->xof_state = XOF_STATE_FINAL; if (outlen == 0) return 1; memset(ctx->buf + num, 0, bsz - num); -- 2.47.2