On Mon, Jul 20, 2026 at 12:22 PM Simon Glass <[email protected]> wrote:
>
> 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?

Yeah, I can add something like that.

>
> > 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?

I figured people were passing the full keyfile rather than the key
directory for ecdsa, if that's the case(since binman is kinda broken
with the current naming) then I figure should be safe enough to just
fix this. I don't think ecdsa signing is particularly common in general
so this would be a fairly rare issue. I can re-spin with fallback or
warning if you think that really is necessary but since the failure isn't
silent it should be easy/obvious enough to fix if someone does run
into the error. Let me know what 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