From: "David C.C.M. Gall" <david.ccm.gall@googlemail.com>
To: Lukas Wunner <lukas@wunner.de>, Ignat Korchagin <ignat@linux.win>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: gregkh@linuxfoundation.org
Subject: [PATCH] crypto: rsassa-pkcs1: use constant-time comparison for digest and signature verification
Date: Fri, 10 Jul 2026 19:29:33 +0200 [thread overview]
Message-ID: <alEr_e-G0L2nxxv-@fudgebox> (raw)
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>
---
crypto/rsassa-pkcs1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/crypto/rsassa-pkcs1.c b/crypto/rsassa-pkcs1.c
index 94fa5e9600e7..a612a9eef2dd 100644
--- a/crypto/rsassa-pkcs1.c
+++ b/crypto/rsassa-pkcs1.c
@@ -291,7 +291,7 @@ static int rsassa_pkcs1_verify(struct crypto_sig *tfm,
/* RFC 8017 sec 8.2.2 step 4 - comparison of digest with out_buf */
if (dlen != dst_len - pos)
return -EKEYREJECTED;
- if (memcmp(digest, out_buf + pos, dlen) != 0)
+ if (crypto_memneq(digest, out_buf + pos, dlen))
return -EKEYREJECTED;
return 0;
--
2.43.0
next reply other threads:[~2026-07-10 17:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 17:29 David C.C.M. Gall [this message]
2026-07-10 21:37 ` [PATCH] crypto: rsassa-pkcs1: use constant-time comparison for digest and signature verification Eric Biggers
2026-07-11 5:19 ` Greg KH
2026-07-11 8:00 ` Ignat Korchagin
2026-07-11 11:23 ` David Gall
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=alEr_e-G0L2nxxv-@fudgebox \
--to=david.ccm.gall@googlemail.com \
--cc=davem@davemloft.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.