diff mbox series

ICEXMSW-2822: Add mkimage secp521r1 ECDSA curve support

Message ID 20240920161114.916381-1-joakim.tjernlund@infinera.com
State Changes Requested
Delegated to: Fabio Estevam
Headers show
Series ICEXMSW-2822: Add mkimage secp521r1 ECDSA curve support | expand

Commit Message

Joakim Tjernlund Sept. 20, 2024, 4:10 p.m. UTC
From: Mykyta Iziumtsev <miziumtsev@infinera.com>

Adds support for secp521r1 ECDSA in mkimgage
---
 include/u-boot/ecdsa.h      | 1 +
 lib/ecdsa/ecdsa-libcrypto.c | 2 +-
 tools/image-sig-host.c      | 7 +++++++
 3 files changed, 9 insertions(+), 1 deletion(-)

Comments

Fabio Estevam Sept. 20, 2024, 4:53 p.m. UTC | #1
Hi Joakim,

Please replace ICEXMSW-2822 with ecdsa-libcrypto in the Subject line.

On Fri, Sep 20, 2024 at 1:11 PM Joakim Tjernlund
<joakim.tjernlund@infinera.com> wrote:
>
> From: Mykyta Iziumtsev <miziumtsev@infinera.com>
>
> Adds support for secp521r1 ECDSA in mkimgage

Mykyta and your Signed-off-by are missing.

checkpatch should have warned you about it.
diff mbox series

Patch

diff --git a/include/u-boot/ecdsa.h b/include/u-boot/ecdsa.h
index 6e0269e3ae..ea37217d86 100644
--- a/include/u-boot/ecdsa.h
+++ b/include/u-boot/ecdsa.h
@@ -66,5 +66,6 @@  int ecdsa_verify(struct image_sign_info *info,
 /** @} */
 
 #define ECDSA256_BYTES	(256 / 8)
+#define ECDSA521_BYTES	((521 + 7) / 8)
 
 #endif
diff --git a/lib/ecdsa/ecdsa-libcrypto.c b/lib/ecdsa/ecdsa-libcrypto.c
index d5939af2c5..6cbbdb6680 100644
--- a/lib/ecdsa/ecdsa-libcrypto.c
+++ b/lib/ecdsa/ecdsa-libcrypto.c
@@ -108,7 +108,7 @@  static size_t ecdsa_key_size_bytes(const EC_KEY *key)
 	const EC_GROUP *group;
 
 	group = EC_KEY_get0_group(key);
-	return EC_GROUP_order_bits(group) / 8;
+	return (EC_GROUP_order_bits(group) + 7) / 8;
 }
 
 static int read_key(struct signer *ctx, const char *key_name)
diff --git a/tools/image-sig-host.c b/tools/image-sig-host.c
index d0133aec4c..21b4fa5d39 100644
--- a/tools/image-sig-host.c
+++ b/tools/image-sig-host.c
@@ -76,6 +76,13 @@  struct crypto_algo crypto_algos[] = {
 		.add_verify_data = ecdsa_add_verify_data,
 		.verify = ecdsa_verify,
 	},
+	{
+		.name = "secp521r1",
+		.key_len = ECDSA521_BYTES,
+		.sign = ecdsa_sign,
+		.add_verify_data = ecdsa_add_verify_data,
+		.verify = ecdsa_verify,
+	},
 };
 
 struct padding_algo padding_algos[] = {