Add mkimage secp521r1 ECDSA curve support
Adds support for the secp521r1 ECDSA algorithm to mkimage.
Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/include/u-boot/ecdsa.h b/include/u-boot/ecdsa.h
index 53490c6..8f9f5e7 100644
--- a/include/u-boot/ecdsa.h
+++ b/include/u-boot/ecdsa.h
@@ -65,5 +65,6 @@
/** @} */
#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 5fa9be1..403dfe0 100644
--- a/lib/ecdsa/ecdsa-libcrypto.c
+++ b/lib/ecdsa/ecdsa-libcrypto.c
@@ -108,7 +108,7 @@
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 default_password(char *buf, int size, int rwflag, void *u)
diff --git a/tools/image-sig-host.c b/tools/image-sig-host.c
index d0133ae..21b4fa5 100644
--- a/tools/image-sig-host.c
+++ b/tools/image-sig-host.c
@@ -76,6 +76,13 @@
.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[] = {