Re: [PATCH] crypto: atmel-ecc - fix missing ECDH public key validation
From: Thorsten Blum
Date: Fri Nov 27 2026 - 20:28:47 EST
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