[PATCH v2 0/3] crypto: ecc - Fix P-521 public key generation

From: Arun Iyengar via B4 Relay

Date: Sat Nov 28 2026 - 12:38:57 EST


Two P-521 fixes for crypto/ecc.c and a KUnit test. Patch 1 keeps the
random initial Z from commit cd65eaf17841 below 2^521: with 576 bits,
every P-521 ecc_make_pub_key() call fails with -EAGAIN. Patch 2 fixes
the scalar multiplication for scalars below about 2^259.5. Patch 3,
suggested by Laveesh Bansal, tests P-521 key generation. No in-tree
caller is affected yet.

This series was developed with Claude (Anthropic) as a coding assistant:
it wrote the code and the commit messages. I reviewed it and tested it
as described in each patch.

---
Changes in v2:
- Add Tested-by from Laveesh Bansal to patches 1 and 2.
- Patch 2: note that k = n now runs the ladder on 2n.
- New patch 3: KUnit test for P-521 key generation.
- Link to v1: https://patch.msgid.link/20261114-ecc-p521-small-scalars-v1-0-7b114f076b33@xxxxxxxxx

---
Arun Iyengar (3):
crypto: ecc - Keep the random initial Z below 2^521 on P-521
crypto: ecc - Fix P-521 scalar multiplication for small scalars
crypto: ecc - Add KUnit test for P-521 public key generation

crypto/Kconfig | 11 +++++++
crypto/Makefile | 1 +
crypto/ecc.c | 31 +++++++++++-------
crypto/ecc_test.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 125 insertions(+), 12 deletions(-)
---
base-commit: 9fb9278d13dca54ce7ecd3254c7df8839e59f03d
change-id: 20261114-ecc-p521-small-scalars-601dd880c8bb

Best regards,
--
Arun Iyengar <aiyengar1990@xxxxxxxxx>