feat(trezorlib): improve terse firmware header output
What changed, and why it matters
This commit is a minor user-interface improvement for a developer/debugging tool. It adds a 'verbose' mode to the text output shown when inspecting a Trezor firmware file header. In non-verbose mode it now prints a shorter summary (device model, version, fingerprint, signature/hash status) instead of dumping every header field. There is no change to security checks, cryptography, firmware loading, or device behavior.
No security action required. Treat as a normal feature/UI commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change is confined to python/src/trezorlib/_internal/firmware_headers.py. It adds a verbose: bool parameter to format_header() and threads the existing verbose argument from FirmwareFormat.format() into it. When verbose is False, the output is condensed to model, version, fingerprint, and signature/hash status. The underlying check_signature_any(), digest computation, and hash verification logic are untouched. No security-sensitive code paths are modified.
Changed components
python/src/trezorlib/_internal/firmware_headers.pyInspect captured patch +18 / −5
### python/src/trezorlib/_internal/firmware_headers.py
@@ -163,6 +163,7 @@ def format_header(
code_hashes: t.Sequence[bytes],
digest: bytes,
sig_status: Status,
+ verbose: bool,
) -> str:
header_dict = asdict(header)
header_out = header_dict.copy()
@@ -187,11 +188,20 @@ def format_header(
all_ok = SYM_OK if hash_status.is_ok() and sig_status.is_ok() else SYM_FAIL
- output = [
- "Firmware Header " + format_container(header_out),
- f"Fingerprint: {click.style(chunkify(digest), bold=True)}",
- f"{all_ok} Signature is {sig_status.value}, hashes are {hash_status.value}",
- ]
+ if verbose:
+ output = ["Firmware Header " + format_container(header_out)]
+ else:
+ model = str(header_out["hw_model"])
+ version = header_out["version"]
+ output = [
+ f"Firmware Header for {click.style(model, bold=True)} "
+ f"version {click.style(version, bold=True)}"
+ ]
+
+ output.append(f"Fingerprint: {click.style(chunkify(digest), bold=True)}")
+ output.append(
+ f"{all_ok} Signature is {sig_status.value}, hashes are {hash_status.value}"
+ )
return "\n".join(output)
@@ -374,6 +384,7 @@ def format(self, verbose: bool = False) -> str:
self.firmware.code_hashes(),
self.digest(),
check_signature_any(self, is_devel),
+ verbose,
)
)
@@ -400,6 +411,7 @@ def format(self, verbose: bool = False) -> str:
self.code_hashes(),
self.digest(),
check_signature_any(self),
+ verbose,
)
def verify(self, dev_keys: bool = False) -> None:
@@ -611,6 +623,7 @@ def format(self, verbose: bool = False) -> str:
self.code_hashes(),
self.digest(),
check_signature_any(self),
+ verbose,
)
def public_keys(Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.