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 v3] crypto: atmel-ecc - fix missing ECDH public key validation
Date: Sat, 28 Nov 2026 18:25:24 +0100 [thread overview]
Message-ID: <awsOhD7tlH1YZPdr@kernel.org> (raw)
In-Reply-To: <20261128084418.2057984-1-rc4d5a@protonmail.com>
Hi Ryan,
This should probably have been submitted as v2, not v3, but let's
continue with v4.
Please post each revision as a new thread to the list and not as a reply
to a review.
On Sat, Nov 28, 2026 at 08:46:06AM +0000, Ryan Prinz wrote:
> atmel_ecdh_compute_shared_secret() passes the peer's ECDH public point
> to the ATECC508A/608A/608B secure element without validating it; only
> req->src_len is checked.
Please clarify that this refers to software validation, as the device
may perform its own hardware validation.
> Add the same check to this driver's path, before the point reaches the
> I2C command, reusing ecc_is_pubkey_valid_partial().
Which same check? Somebody reading this later in the git history will
have no idea what you're referring to without the context of earlier
revisions.
[...]
> drivers/crypto/atmel-ecc.c | 34 ++++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
> --- a/drivers/crypto/atmel-ecc.c
> +++ b/drivers/crypto/atmel-ecc.c
> @@ -19,7 +19,9 @@
> #include <linux/slab.h>
> #include <linux/workqueue.h>
> #include <crypto/internal/kpp.h>
> +#include <crypto/ecc_curve.h>
> #include <crypto/ecdh.h>
> +#include <crypto/internal/ecc.h>
Please keep the crypto includes in alphabetical order.
> #include <crypto/kpp.h>
> #include "atmel-i2c.h"
>
> @@ -146,6 +148,34 @@ static int atmel_ecdh_generate_public_key(struct kpp_request *req)
> return 0;
> }
>
> +static int atmel_ecdh_peer_pubkey_valid(struct scatterlist *src,
> + unsigned int src_len)
> +{
> + const struct ecc_curve *curve = ecc_get_curve(ECC_CURVE_NIST_P256);
> + u8 pubkey_buf[ATMEL_ECC_PUBKEY_SIZE];
> + u64 x[ECC_CURVE_NIST_P256_DIGITS], y[ECC_CURVE_NIST_P256_DIGITS];
> + struct ecc_point pk;
> + size_t copied;
> +
> + if (!curve)
> + return -EINVAL;
This check can be dropped as ecc_get_curve(ECC_CURVE_NIST_P256) always
returns a valid pointer.
> + if (src_len != ATMEL_ECC_PUBKEY_SIZE)
> + return -EINVAL;
The caller already checks the length, so this check is also redundant.
> + copied = sg_copy_to_buffer(src, sg_nents_for_len(src, src_len),
> + pubkey_buf, src_len);
Could we validate work_data->cmd.data after atmel_i2c_init_ecdh_cmd()
and before enqueueing? That would avoid an extra copy.
Thanks,
Thorsten
prev parent reply other threads:[~2026-11-28 17:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 23:18 [PATCH] " Ryan Prinz
2026-11-28 1:28 ` Thorsten Blum
2026-11-28 8:46 ` [PATCH v3] " Ryan Prinz
2026-11-28 17:25 ` 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=awsOhD7tlH1YZPdr@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
all inboxes | Powered by JetHome®