[v3,12/15] boot: pre-load: add support of ecdsa

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


Hi Philippe,

On 2026-03-31T10:00:34, Philippe Reynes <philippe.reynes at softathome.com> wrote:
> diff --git a/boot/image-pre-load.c b/boot/image-pre-load.c
> @@ -70,6 +70,18 @@ static int image_pre_load_sig_setup(struct image_sig_info *info)
> +static int is_ecdsa(const void *algo_name)
> +{
> +     struct crypto_algo *crypto = image_get_crypto_algo(algo_name);
> +     int ret = 0;
> +
> +     if (crypto && !strncmp(crypto->name, "ecdsa", strlen("ecdsa")))
> +             return 1;
> +
> +     return ret;
> +}

This function is called three times in image_pre_load_sig_setup(),
calling image_get_crypto_algo() each time.

Coudl we call image_get_crypto_algo() once early in
image_pre_load_sig_setup() and then check crypto->name directly in the
conditional blocks? This also avoids looking up the algorithm
repeatedly.

Also, the return value pattern is a bit awkward - you initialise ret
to 0 but never use it since you return 1 directly. Please can you
simplify to just return the strncmp result (using !! to get 0/1), or
use a simpler pattern like:

if (crypto && !strncmp(crypto->name, "ecdsa", 5))
   return 1;
return 0;

Regards,
Simon


More information about the U-Boot mailing list