From: Holger Dengler Date: Wed, 27 Sep 2023 19:54:34 +0000 (+0200) Subject: Add xof state handing for generic sha3 absorb. X-Git-Tag: openssl-3.3.0-alpha1~638 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1337b50936ed190a98af1ee6601d857b42a3d296;p=thirdparty%2Fopenssl.git Add xof state handing for generic sha3 absorb. The digest life-cycle diagram specifies state transitions to `updated` (aka XOF_STATE_ABSORB) only from `initialised` and `updated`. Add this checking to the generic sha3 absorb implementation. 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) --- diff --git a/providers/implementations/digests/sha3_prov.c b/providers/implementations/digests/sha3_prov.c index 19576c71909..13735153f2d 100644 --- a/providers/implementations/digests/sha3_prov.c +++ b/providers/implementations/digests/sha3_prov.c @@ -143,6 +143,10 @@ static size_t generic_sha3_absorb(void *vctx, const void *inp, size_t len) { KECCAK1600_CTX *ctx = vctx; + if (!(ctx->xof_state == XOF_STATE_INIT || + ctx->xof_state == XOF_STATE_ABSORB)) + return 0; + ctx->xof_state = XOF_STATE_ABSORB; return SHA3_absorb(ctx->A, inp, len, ctx->block_size); }