Skip to content

Conversation

@m-iwanicki
Copy link
Contributor

@m-iwanicki m-iwanicki commented Dec 18, 2025

Manual usage of btg_key_validator. Error paths on QEMU:

  • Hash not defined in dts-configs

    image
  • Failed to read flash:

    Reading flash...
    Failed to read flash : (1)
    
  • Failed to export key manifest:

    Extracting key manifest...
    Failed to export key manifest. : (1)
    
  • Hashes don't match:

    image

Happy path:

image

Usage:

btg_key_validator [OPTION]...

Script that allows for verification whether firmware binary is signed with correct keys.
Options:
  -f|--file <file>          Path to firmware file for which to check key hash.
  -k|--key-hash <hash>      Expected key hash
  -v|--verbose              Enable trace output
  -h|--help                 Print this help

Fuse workflow on QEMU (emulated NovaCustom) with correctly signed binary:

image

Fuse workflow on QEMU (emulated NovaCustom) with update binary signed with wrong key:

image

ref: zhs-397

@m-iwanicki m-iwanicki force-pushed the fuse-key-verification branch 5 times, most recently from 4a286a7 to a22ed0b Compare December 18, 2025 16:32
@m-iwanicki m-iwanicki marked this pull request as ready for review December 18, 2025 16:44
@m-iwanicki m-iwanicki self-assigned this Dec 18, 2025
Copy link
Contributor

@3mkusiak 3mkusiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two nitpicks, LGTM otherwise.

I still need to test it on qemu.

@m-iwanicki m-iwanicki force-pushed the fuse-key-verification branch from a42c68e to 32fcecd Compare December 22, 2025 08:57
Copy link
Contributor

@3mkusiak 3mkusiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, verified in qemu.

Not merging since there are more reviewers assigned.

Copy link
Member

@SergiiDmytruk SergiiDmytruk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bash doesn't allow using '-' in function names

It does, even in POSIX-compliance mode (bash --posix). Maybe you got the error from a fake bash of busybox or something. man bash:

When in posix mode, fname must be a valid shell name and may not be the name of one of the POSIX
special builtins. In default mode, a function name can be any unquoted shell word that does not contain $.

That way there won't be duplication which we might forgot to update.
Before this change, sourcing "$DTS_ENV" in shell connected to via ssh
wasn't possible as "$DTS_HAL" was empty, which resulted in ssh session
ending.

Signed-off-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
This is to allow using some functions in source `$DTS_FUNCTIONS`
without entering dts-boot first e.g. board_config.

Signed-off-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
* Add argument parsing
* allow passing expected key hash and firmware file to check.
* Add error checks
* Download expected key hash from dts-configs repository instead of
  hardcoding

Signed-off-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
Signed-off-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
Signed-off-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
Signed-off-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
@m-iwanicki m-iwanicki force-pushed the fuse-key-verification branch from 443fc82 to db6ad78 Compare December 22, 2025 15:28
@m-iwanicki
Copy link
Contributor Author

@SergiiDmytruk you are right, I checked again and got no error this time. Reverted. Not sure where I got this error from. I can reproduce it by entering sh and then trying to define function with - in the name so probably related to that.
I removed this commit. Thanks for noticing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants