From: Eric Biggers <ebiggers@kernel.org>
To: David Howells <dhowells@redhat.com>
Cc: "Jason A . Donenfeld" <Jason@zx2c4.com>,
Ard Biesheuvel <ardb@kernel.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
Stephan Mueller <smueller@chronox.de>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 7/8] crypto/sha3: Add SHAKE128/256 support
Date: Wed, 1 Oct 2025 08:25:28 -0700 [thread overview]
Message-ID: <20251001152528.GA1592@sol> (raw)
In-Reply-To: <2284488.1759323746@warthog.procyon.org.uk>
On Wed, Oct 01, 2025 at 02:02:26PM +0100, David Howells wrote:
> Eric Biggers <ebiggers@kernel.org> wrote:
>
> > I recommend holding off on this part until you have a try at using the
> > SHAKE library API directly. The dispatch to different algorithms could
> > be done in the calling code. This patch would also limit the ML-DSA
> > code to fixed-size SHAKE outputs; is that really going to be enough?
>
> Actually, ML-DSA also allows SHA2 hashes for the prehash, so if I use
> crypto_shash for that, then I maintain the flexibility through that.
>
> > When there's only a small number of supported algorithms, just doing the
> > dispatch in the calling code tends to be simpler than using
> > crypto_shash. For example, see the recent conversion of fs/verity/ to
> > use the SHA-2 library API instead of crypto_shash.
>
> That's reinventing the wheel.
Not really. As I said, in fs/verity/ it was simpler to use the library
APIs, even with multiple algorithms. I got similar results in net/sctp/
too. The library APIs are also faster, due to eliminating overhead such
as algorithm lookup by name and indirect calls.
With the library it's also much easier to implement things that don't
fit into the existing paradigm well, such as XOFs. Case in this point:
this patch adds "shake128" and "shake256" to crypto_shash, but only
offers fixed-size digests. Which kind of defeats the point of SHAKE.
> Why have crypto_shash at all if we're going to
> encourage people to ignore that and use a union and an enum/ops table.
Mainly because some subsystems accept an arbitrary string in "Crypto API
algorithm syntax" from userspace, and they have to continue supporting
that for backwards compatibility.
Anyway, I'm not saying that you *can't* use crypto_shash. Just the way
you described it, where using crypto_shash is *required* as soon as
there are two possible algorithms, is not correct. It's an option.
- Eric
next prev parent reply other threads:[~2025-10-01 15:26 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-26 14:19 [PATCH v3 0/8] crypto, lib/crypto: Add SHAKE128/256 support and move SHA3 to lib/crypto David Howells
2025-09-26 14:19 ` [PATCH v3 1/8] s390/sha3: Rename conflicting functions David Howells
2025-09-29 11:39 ` Harald Freudenberger
2025-09-26 14:19 ` [PATCH v3 2/8] arm64/sha3: " David Howells
2025-09-26 14:19 ` [PATCH v3 3/8] lib/crypto: Add SHA3-224, SHA3-256, SHA3-384, SHA-512, SHAKE128, SHAKE256 David Howells
2025-09-26 21:09 ` Eric Biggers
2025-09-26 14:19 ` [PATCH v3 4/8] lib/crypto: Move the SHA3 Iota transform into the single round function David Howells
2025-09-26 14:19 ` [PATCH v3 5/8] lib/crypto: Add SHA3 kunit tests David Howells
2025-10-01 16:04 ` Eric Biggers
2025-10-01 16:08 ` Eric Biggers
2025-10-02 13:05 ` David Howells
2025-10-02 16:07 ` Eric Biggers
2025-09-26 14:19 ` [PATCH v3 6/8] crypto/sha3: Use lib/crypto/sha3 David Howells
2025-09-26 21:25 ` Eric Biggers
2025-09-26 14:19 ` [PATCH v3 7/8] crypto/sha3: Add SHAKE128/256 support David Howells
2025-09-26 21:14 ` Eric Biggers
2025-10-01 13:02 ` David Howells
2025-10-01 15:25 ` Eric Biggers [this message]
2025-09-26 14:19 ` [PATCH v3 8/8] crypto: SHAKE tests David Howells
2025-09-26 19:59 ` [PATCH v3 0/8] crypto, lib/crypto: Add SHAKE128/256 support and move SHA3 to lib/crypto Eric Biggers
2025-10-01 15:28 ` Eric Biggers
2025-10-02 13:14 ` David Howells
2025-10-02 16:27 ` Eric Biggers
2025-10-11 0:26 ` Eric Biggers
2025-10-16 12:35 ` David Howells
2025-10-16 14:34 ` David Howells
2025-10-16 14:56 ` Stephan Mueller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251001152528.GA1592@sol \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=dhowells@redhat.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=smueller@chronox.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox