* [PATCH] fixup! public-keys: move list out of struct public_key
@ 2025-10-28 15:01 Jonas Rebmann
0 siblings, 0 replies; only message in thread
From: Jonas Rebmann @ 2025-10-28 15:01 UTC (permalink / raw)
To: Sascha Hauer, BAREBOX; +Cc: Jonas Rebmann
After not invoking ecdsa_key_dup() on keys before first use anymore,
key->size bits remains uninitialized, breaking ecdsa_verify() and
thereby ECDSA at large.
- Drop the unused ecdsa_key_dup
- Drop the uninitialized size_bits field in struct ecdsa_public_key
- Invoke ecdsa_key_size() in ecdsa_verify() instead
Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
---
crypto/ecdsa.c | 22 ++++------------------
include/crypto/ecdsa.h | 1 -
2 files changed, 4 insertions(+), 19 deletions(-)
diff --git a/crypto/ecdsa.c b/crypto/ecdsa.c
index 6aaeff5c14..6bc4da2cdd 100644
--- a/crypto/ecdsa.c
+++ b/crypto/ecdsa.c
@@ -78,7 +78,10 @@ int ecdsa_verify(const struct ecdsa_public_key *key, const uint8_t *sig,
const void *r, *s;
u64 rh[4], sh[4];
u64 mhash[ECC_MAX_DIGITS];
- int key_size_bytes = key->size_bits / 8;
+ int key_size_bits, key_size_bytes;
+
+ key_size_bits = ecdsa_key_size(key->curve_name);
+ key_size_bytes = key_size_bits / 8;
ctx->curve_id = curve_id;
ctx->curve = ecc_get_curve(curve_id);
@@ -103,20 +106,3 @@ int ecdsa_verify(const struct ecdsa_public_key *key, const uint8_t *sig,
return _ecdsa_verify(ctx, (void *)mhash, rh, sh);
}
-
-struct ecdsa_public_key *ecdsa_key_dup(const struct ecdsa_public_key *key)
-{
- struct ecdsa_public_key *new;
- int key_size_bits;
-
- key_size_bits = ecdsa_key_size(key->curve_name);
- if (!key_size_bits)
- return NULL;
-
- new = xmemdup(key, sizeof(*key));
- new->x = xmemdup(key->x, key_size_bits / 8);
- new->y = xmemdup(key->y, key_size_bits / 8);
- new->size_bits = key_size_bits;
-
- return new;
-}
diff --git a/include/crypto/ecdsa.h b/include/crypto/ecdsa.h
index 3b6bb394d9..7c8aeadc25 100644
--- a/include/crypto/ecdsa.h
+++ b/include/crypto/ecdsa.h
@@ -10,7 +10,6 @@ struct ecdsa_public_key {
const char *curve_name; /* Name of curve, e.g. "prime256v1" */
const uint64_t *x; /* x coordinate of public key */
const uint64_t *y; /* y coordinate of public key */
- unsigned int size_bits; /* key size in bits, derived from curve name */
};
#ifdef CONFIG_CRYPTO_ECDSA
---
base-commit: 946cf6bbbe2bdaac56b17185af673a1fa3288635
change-id: 20251028-fixup-ecdsa-8af6dc75f31b
Best regards,
--
Jonas Rebmann <jre@pengutronix.de>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-10-28 15:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-28 15:01 [PATCH] fixup! public-keys: move list out of struct public_key Jonas Rebmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox