Re: [PATCH v3 0/8] crypto, lib/crypto: Add SHAKE128/256 support and move SHA3 to lib/crypto
From: David Howells
Date: Thu Oct 02 2025 - 09:15:06 EST
Eric Biggers <ebiggers@xxxxxxxxxx> wrote:
> Have you had a chance to read this reply?
I have.
You held up your implementation of sha256 and sha224 as an example of how it
perhaps should be implemented:
It would be worth considering separating the APIs for the different
algorithms that are part of SHA-3, similar to what I did with SHA-224
and SHA-256.
so I have followed that. That defines a type for each, so I'll leave it at
that.
> All I'm really requesting is that we don't create footguns, like the
> following that the API in the v2 patch permitted:
The way you did a separate type for each removed one more footgun - and
arguably a more important one - as the *type* enforces[1] the output buffer
size and the sha3_*_final() function has the same sized-array as the
convenience wrappers.
It also eliminates the need to store the digest size as this is only needed at
the final step for the digest variant algorithms.
David
[1] Inasmuch as this is effective in C.