From: Thorsten Blum <blum@kernel.org>
To: Ryan Prinz <rc4d5a@protonmail.com>
Cc: 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: atmel-ecc - fix missing ECDH public key validation
Date: Sat, 28 Nov 2026 02:28:36 +0100 [thread overview]
Message-ID: <awouRON5Mgq6pbhf@kernel.org> (raw)
In-Reply-To: <20261125231745.1857056-1-rc4d5a@protonmail.com>
Hi Ryan,
Thanks for the patch.
Please shorten the commit message substantially and focus on the missing
software validation and how this patch adds it.
On Wed, Nov 25, 2026 at 11:18:08PM +0000, Ryan Prinz wrote:
> atmel_ecdh_compute_shared_secret() passes the peer's ECDH public point
> into the ATECC508A/608A/608B secure element over I2C without checking
> it first. The only check on req->src is on length
> (req->src_len != ATMEL_ECC_PUBKEY_SIZE); the coordinates themselves are
> never validated before atmel_i2c_init_ecdh_cmd() hands them to the
> device.
>
> crypto/ecc.c's ecc_is_pubkey_valid_partial() is the generic software
> check for this operation: it rejects a point that is zero, out of
> range, or not on the curve. crypto/ecdh.c's compute_shared_secret()
> calls it before computing the shared secret. This driver's hardware
> path has no equivalent check.
The function is ecdh_compute_value(). Validation then happens in
crypto_ecdh_shared_secret().
> Both the generic implementation and this driver register under the
> same crypto_kpp name, "ecdh-nist-p256". This driver registers at
> cra_priority 300 (ATMEL_ECC_PRIORITY) versus the generic
> implementation's 100, so any caller requesting "ecdh-nist-p256" gets
> this unvalidated path whenever an Atmel/Microchip ECC device is bound.
>
> net/bluetooth/smp.c allocates "ecdh-nist-p256" for LE Secure
> Connections pairing and performs no validation of the remote device's
> public key itself; it relies on the crypto_kpp backend
> (net/bluetooth/ecdh_helper.c's compute_ecdh_secret() converts the
> wire-format coordinates to the big-endian layout this backend expects,
> but does not check their validity). Unlike this driver's HPRE
> counterpart, nothing else in that path currently blocks the call from
> reaching the unvalidated code: on a device with an Atmel/Microchip
> secure element bound as its ECDH backend, a BLE peer can send an
> invalid public key during pairing and force the resulting DHKey to
> one of a small number of predictable values in a single pairing
> attempt.
Please drop this claim unless supported by testing or documentation.
Also, wolfSSL's public-key validation code [1] assumes that the devices
validate keys internally:
/* consider key check success on HW crypto
* ex: ATECC508/608A, CryptoCell and Silabs which validate the key
* internally
*/
Thanks,
Thorsten
[1] https://github.com/wolfSSL/wolfssl/blob/master/wolfcrypt/src/ecc.c#L12012-L12015
prev parent reply other threads:[~2026-11-28 1:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 23:18 [PATCH] crypto: atmel-ecc - fix missing ECDH public key validation Ryan Prinz
2026-11-28 1:28 ` Thorsten Blum [this message]
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=awouRON5Mgq6pbhf@kernel.org \
--to=blum@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rc4d5a@protonmail.com \
/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