]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add xof state handing for generic sha3 absorb.
authorHolger Dengler <dengler@linux.ibm.com>
Wed, 27 Sep 2023 19:54:34 +0000 (21:54 +0200)
committerHolger Dengler <dengler@linux.ibm.com>
Fri, 10 Nov 2023 13:25:44 +0000 (14:25 +0100)
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 <dengler@linux.ibm.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22221)

providers/implementations/digests/sha3_prov.c

index 19576c71909b00aa8bb75328a383e89d4329928e..13735153f2daa4464b142f2b4a92a6540db79d86 100644 (file)
@@ -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);
 }