Hi James,

On 2026-07-03T21:40:03, James Hilliard <[email protected]> wrote:
> lib: ecdsa: use .key extension for keydir keys
>
> The keydir/keyname path should follow the FIT signing key convention and
> read <key-name-hint>.key. Using .pem here is incorrect and does not match
> the filenames used by mkimage and binman key-directory flows.
>
> Signed-off-by: James Hilliard <[email protected]>
>
> lib/ecdsa/ecdsa-libcrypto.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

> Using .pem here is incorrect and does not match
> the filenames used by mkimage and binman key-directory flows.

Not quite - this has been the ECDSA behaviour since 2021 (commit
eb22759e2be). It is inconsistent with the RSA path in
rsa_get_priv_key() and binman's fit etype (which look for
'<hint>.key'), but not incorrect as such. Anyone signing with 'mkimage
-k <keydir>' and ECDSA today has keys named '<hint>.pem' and this
patch silently breaks them. Please can you mention the compatibility
impact in the commit message, rather than describing it as a straight
bug fix?

> diff --git a/lib/ecdsa/ecdsa-libcrypto.c b/lib/ecdsa/ecdsa-libcrypto.c
> @@ -338,7 +338,7 @@ static int prepare_ctx(struct signer *ctx, const struct 
> image_sign_info *info)
> -             snprintf(kname, sizeof(kname), "%s/%s.pem", info->keydir,
> +             snprintf(kname, sizeof(kname), "%s/%s.key", info->keydir,
>                        info->keyname);

Given the existing users, I suspect this should try
'<keydir>/<keyname>.key' first and fall back to .pem if the file does
not exist, perhaps with a deprecation warning. That gives people a
migration path instead of an abrupt failure. What do you think?

BTW test/py/tests/test_fit_ecdsa.py only exercises the keyfile path,
so neither extension is covered by tests - it would be good to extend
it to use keydir so this does not regress again.

Regards,
Simon

Reply via email to