From: David Gall <david.ccm.gall@googlemail.com>
To: Ignat Korchagin <ignat@linux.win>
Cc: Greg KH <gregkh@linuxfoundation.org>,
Eric Biggers <ebiggers@kernel.org>,
Lukas Wunner <lukas@wunner.de>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] crypto: rsassa-pkcs1: use constant-time comparison for digest and signature verification
Date: Sat, 11 Jul 2026 13:23:36 +0200 [thread overview]
Message-ID: <alInuM5TquLTv5QE@fudgebox> (raw)
In-Reply-To: <CAOs+rJUPQq88D7YwHyrbTFF-G9Lw7cJ9pcaZBpACP89ES9z00w@mail.gmail.com>
On Sat, Jul 11, 2026 at 09:00:23AM +0100, Ignat Korchagin wrote:
> On Sat, Jul 11, 2026 at 6:19 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > On Fri, Jul 10, 2026 at 05:37:18PM -0400, Eric Biggers wrote:
> > > On Fri, Jul 10, 2026 at 07:29:33PM +0200, David C.C.M. Gall wrote:
> > > > Replace memcmp() with crypto_memneq() for cryptographic digest and
> > > > signature comparisons to prevent timing side-channel attacks.
> > > >
> > > > crypto/rsassa-pkcs1.c: RSA signature digest verification used memcmp
> > > > which can leak valid prefix length via timing analysis, user data
> > > > could reach the leaky comparison via the digest argument to verify.
> > > >
> > > > Assisted-by: gregkh_clanker_t1000
> > > > Signed-off-by: David C.C.M. Gall <david.ccm.gall@googlemail.com>
> > >
> > > While we should use crypto_memneq() on MACs, auth tags, and other secret
> > > data, I don't think we should let it creep into domains where it is
> > > clearly not needed, like public key signature verification.
> >
> > But isn't this user-controlled data and so a user could use it to figure
> > out the key?
>
> This is signature verification with a public key. So the user knows
> the key already.
>
> > thanks,
> >
> > greg k-h
> >
>
> Ignat
Nevermind, my reasoning on how this method is used was faulty. The
crypto_memneq call does not protect against digest forgery, the
public key is already available to anyone attempting verification,
so an attacker can compute the padding/digest offline without needing
the kernel's comparison at all, timing or otherwise.
That said, this function already uses crypto_memneq for the hash-prefix
check a few lines above. I'd argue for consistency it's worth using it
for the digest comparison too.
David
next prev parent reply other threads:[~2026-07-11 11:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 17:29 [PATCH] crypto: rsassa-pkcs1: use constant-time comparison for digest and signature verification David C.C.M. Gall
2026-07-10 21:37 ` Eric Biggers
2026-07-11 5:19 ` Greg KH
2026-07-11 8:00 ` Ignat Korchagin
2026-07-11 11:23 ` David Gall [this message]
2026-07-11 15:17 ` Lukas Wunner
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=alInuM5TquLTv5QE@fudgebox \
--to=david.ccm.gall@googlemail.com \
--cc=davem@davemloft.net \
--cc=ebiggers@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=herbert@gondor.apana.org.au \
--cc=ignat@linux.win \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas@wunner.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