feat(trezorlib): run a bootloader firmware update in the background [no changelog]
What changed, and why it matters
This commit is a small internal test-utility change. It adds a configurable timeout and a background-thread helper to the Python test library that emulates a Trezor bootloader during firmware updates. There is no indication it fixes a security bug or introduces a vulnerability; it appears to be a test-infrastructure convenience feature.
No security action required. Treat as routine test-infrastructure maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In python/src/trezorlib/_internal/bootloader_emulator.py, the firmware_update method gains a timeout parameter (default 60 s) that is passed to each wire.call() for FirmwareErase and FirmwareUpload. A new firmware_update_in_background method submits the update to an existing thread pool so tests can continue while waiting for on-screen confirmation. The change is localized to test/emulation code and does not alter device firmware, cryptographic checks, or the bootloader protocol.
Changed components
python/src/trezorlib/_internal/bootloader_emulator.pyInspect captured patch +16 / −3
### python/src/trezorlib/_internal/bootloader_emulator.py
@@ -273,22 +273,35 @@ def sync_responses(self) -> None:
pass
def firmware_update(
- self, data: bytes, progress_update: t.Callable[[int], t.Any] = lambda _: None
+ self,
+ data: bytes,
+ progress_update: t.Callable[[int], t.Any] = lambda _: None,
+ timeout: float = 60,
) -> None:
"""Upload `data` the way `trezorlib.firmware.update()` does.
The bootloader answers FirmwareErase with the first FirmwareRequest
only after the user confirmed on screen, if a confirmation is due.
+ `timeout` limits the wait for each response, not the whole upload.
"""
- resp = self.wire.call(messages.FirmwareErase(length=len(data)))
+ resp = self.wire.call(messages.FirmwareErase(length=len(data)), timeout=timeout)
while isinstance(resp, messages.FirmwareRequest):
payload = data[resp.offset : resp.offset + resp.length]
resp = self.wire.call(
- messages.FirmwareUpload(payload=payload, hash=blake2s(payload).digest())
+ messages.FirmwareUpload(
+ payload=payload, hash=blake2s(payload).digest()
+ ),
+ timeout=timeout,
)
progress_update(len(payload))
messages.Success.ensure_isinstance(resp)
+ def firmware_update_in_background(
+ self, data: bytes, timeout: float = 60
+ ) -> Future[None]:
+ """Start an update that the bootloader will ask to confirm on screen."""
+ return self.wire._pool.submit(self.firmware_update, data, timeout=timeout)
+
def close(self) -> None:
self.wire.close()
self.debug.close()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.