binman: etype: fit: raise ValueError if key-name-hint is a path
authorQuentin Schulz <quentin.schulz@cherry.de>
Fri, 18 Apr 2025 11:26:07 +0000 (13:26 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 1 Jul 2025 16:52:01 +0000 (10:52 -0600)
commit2ddc47f9aa0581a907dd07cb4468ef6d4f3519dc
tree48f7a8432c0c1c0471cb6805e4fcf64988c07127
parentcb7555e93075114fe4af0adb806877ac4d4ef80d
binman: etype: fit: raise ValueError if key-name-hint is a path

mkimage doesn't fail if it cannot find the public key but it prints to
stderr. Considering that btool.run() discards stderr, it means binman
happily returns an unsigned FIT and doesn't tell you something went
wrong.

Binman will actually find the file if there's a path in the
key-name-hint property but the current logic expects key-name-hint to be
a filename and thus returns the dirname of the found path for the key,
but with the original key-name-hint appended. This means we can have the
following:

- key-name-hint = "keys/dev"
- name = "/home/qschulz/work/upstream/u-boot/keys/"

so we pass /home/qschulz/work/upstream/u-boot/keys/ to the -k option of
mkimage but the FIT still contains "keys/dev" in key-name-hint which
means mkimage will try to find the key at
/home/qschulz/work/upstream/u-boot/keys/keys/, which doesn't exist.

Let's assume paths are simply not supported (it is named key-name-hint
and not key-path-hint after all) and raise an error if the property
contains a path so that the build fails and not quietly.

Fixes: 133c000ca334 ("binman: implement signing FIT images during image build")
Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
tools/binman/etype/fit.py
tools/binman/ftest.py
tools/binman/test/347_key_name_hint_dir_fit_signature.dts [new file with mode: 0644]