Hi Yan,

On 2026-10-23T09:06:06, yan wang <[email protected]> wrote:
> binman: pre_load: Validate file signing key
>
> Use integer division when calculating RSA and ECDSA signature sizes
> and reject file-based signing without a key-name property.

Please can you start with the motivation? Without key-name,
os.path.join() is called with None and binman fails with a TypeError
traceback rather than a useful message. For the division, as far as I
can tell the float values still compare equal to the integer key
sizes, so say that this is a tidy-up ahead of the signature-length
check in the next patch. The subject also only covers half of the
change.

> diff --git a/tools/binman/etype/pre_load.py b/tools/binman/etype/pre_load.py
> @@ -199,6 +199,10 @@ class Entry_pre_load(Entry_collection):
> +
> +        # File-based path: dispatch on signing algorithm
> +        if not self.key_name:
> +            self.Raise('key-name is required for file-based signing')

The 'File-based path' comment only makes sense once patch 3 adds the
HSM branch, so please move it there, and drop the blank line after the
docstring. Also, patch 3 checks the HSM settings in ReadNode() so that
a bad devicetree fails early. Doing the key-name check there too (when
hsm-key is not set) would be more consistent. What do you think?

>
> Signed-off-by: yan wang <[email protected]>
>
>  tools/binman/etype/pre_load.py                       | 16 ++++++++++------
>  tools/binman/ftest.py                                | 11 +++++++++++
>  .../test/security/pre_load_missing_key_name.dts      | 20 
> ++++++++++++++++++++
>  3 files changed, 41 insertions(+), 6 deletions(-)

Regards,
Simon

Reply via email to