From: Eric Biggers <ebiggers@kernel.org>
To: "Elliott, Robert (Servers)" <elliott@hpe.com>
Cc: "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
David Howells <dhowells@redhat.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
Ard Biesheuvel <ardb@kernel.org>,
Stephan Mueller <smueller@chronox.de>,
Lukas Wunner <lukas@wunner.de>,
Ignat Korchagin <ignat@cloudflare.com>,
"keyrings@vger.kernel.org" <keyrings@vger.kernel.org>,
"linux-modules@vger.kernel.org" <linux-modules@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] lib/crypto: Add ML-DSA verification support
Date: Wed, 26 Nov 2025 13:42:09 -0800 [thread overview]
Message-ID: <20251126214209.GA1697@quark> (raw)
In-Reply-To: <IA4PR84MB4011F4D5B7EF52901829AD94ABDEA@IA4PR84MB4011.NAMPRD84.PROD.OUTLOOK.COM>
On Wed, Nov 26, 2025 at 09:29:10PM +0000, Elliott, Robert (Servers) wrote:
>
>
> > -----Original Message-----
> > From: Eric Biggers <ebiggers@kernel.org>
> > Subject: [PATCH v2 1/2] lib/crypto: Add ML-DSA verification support
> ...
>
> > +++ b/lib/crypto/mldsa.c
>
> > +} mldsa_parameter_sets[] = {
> > + [MLDSA44] = {
> > + .ctilde_len = 32,
> > + .pk_len = MLDSA44_PUBLIC_KEY_SIZE,
> > + .sig_len = MLDSA44_SIGNATURE_SIZE,
> > + },
> > + [MLDSA65] = {
> > + .ctilde_len = 48,
> > + .pk_len = MLDSA65_PUBLIC_KEY_SIZE,
> > + .sig_len = MLDSA65_SIGNATURE_SIZE,
> > + },
> > + [MLDSA87] = {
> > + .ctilde_len = 64,
> > + .pk_len = MLDSA87_PUBLIC_KEY_SIZE,
> > + .sig_len = MLDSA87_SIGNATURE_SIZE,
> > + },
> ...
> > + union {
> ...
> > + /* The commitment hash. Real length is params->ctilde_len */
> > + u8 ctildeprime[64];
> > + };
> ...
> > + /* Recreate the challenge c from the signer's commitment hash. */
> > + sample_in_ball(&ws->c, ctilde, params->ctilde_len, params->tau,
> > + &ws->shake);
> ...
> > + /* Finish computing ctildeprime. */
> > + shake_squeeze(&ws->shake, ws->ctildeprime, params->ctilde_len);
> ...
> > + /* Verify that ctilde == ctildeprime. */
> > + if (memcmp(ws->ctildeprime, ctilde, params->ctilde_len) != 0)
> > + return -EKEYREJECTED;
>
> Is there any way to ensure that each ctilde_len value is <= 64
> and <= the corresponding .sig_size value at compile time so there's
> no risk of overflowing any buffers?
Not at compile time, unless we do some fancy validation of each of the
three ctilde_len values against the max3() of the signature lengths
using macros. It could be checked at runtime in a module_init function.
Seems pointless though, given that these parameters are fixed in the
ML-DSA specification. The specification uses parameters that make sense
and are consistent with each other.
- Eric
next prev parent reply other threads:[~2025-11-26 21:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 20:35 [PATCH v2 0/2] lib/crypto: ML-DSA verification support Eric Biggers
2025-11-26 20:35 ` [PATCH v2 1/2] lib/crypto: Add " Eric Biggers
2025-11-26 21:29 ` Elliott, Robert (Servers)
2025-11-26 21:42 ` Eric Biggers [this message]
2025-11-26 20:35 ` [PATCH v2 2/2] lib/crypto: tests: Add KUnit tests for ML-DSA verification Eric Biggers
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=20251126214209.GA1697@quark \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=da.gomez@kernel.org \
--cc=dhowells@redhat.com \
--cc=elliott@hpe.com \
--cc=herbert@gondor.apana.org.au \
--cc=ignat@cloudflare.com \
--cc=keyrings@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=mcgrof@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.com \
--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;
as well as URLs for NNTP newsgroup(s).