[v3,02/15] ecdsa: initial support of ecdsa using mbedtls

Simon Glass sjg at chromium.org
Thu Apr 2 00:00:54 CEST 2026


Hi Philippe,

On 2026-03-31T10:00:34, Philippe Reynes <philippe.reynes at softathome.com> wrote:
> diff --git a/lib/mbedtls/ecdsa.c b/lib/mbedtls/ecdsa.c
> @@ -0,0 +1,141 @@
> +int ecdsa_hash_verify(const struct ecdsa_public_key *pubkey,
> +                   const void *hash, size_t hash_len,
> +                   const void *signature, size_t sig_len)
> +{
> +     mbedtls_ecp_group_id grp_id;
> +     mbedtls_ecp_group grp;
> +     const unsigned char *buf = hash;
> +     size_t blen = hash_len;

The buf and blen variables are not needed - you can pass hash and
hash_len directly to mbedtls_ecdsa_verify()

> diff --git a/lib/mbedtls/ecdsa.c b/lib/mbedtls/ecdsa.c
> @@ -0,0 +1,141 @@
> +     /* check the signature len */
> +     if (sig_len != 2 * key_len) {
> +             debug("%s: sig len should be twice the key len (sig len = %ld, key len = %d)\n",
> +                   __func__, sig_len, key_len);

The format specifier %ld is not portable for size_t, please use %zu instead.

You can use log_debug() and then don't need __func__

Regards,
Simon


More information about the U-Boot mailing list