1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-16 04:29:08 +00:00
trezor-firmware/legacy/bootloader/firmware_align.py
Ondrej Mikle e2abd2a9ad feat(legacy): bootloader with v3 SignMessage signatures + signatures debug
Removed oldest v1 style of firmware signature and presence checks.
Added debug helpers for T1 signatures.
Support for v2 and v3 signatures, but can only update FW to v3-style signed.
Support for debugging T1 signatures.
Scripts and README for debugging v2/v3 FW signing scheme.
Firmware in GetFeatures counts only v3 signatures as signed.
Add documentation and comments about signing schemes like a sane person
2022-11-22 15:00:19 +01:00

20 lines
481 B
Python
Executable File

#!/usr/bin/env python3
import os
import sys
TOTALSIZE = 32768
MAXSIZE = TOTALSIZE - 32
infile = sys.argv[1]
outfile = sys.argv[2]
fs = os.stat(infile).st_size
print(f"Current bootloader size before align is {fs} bytes")
if fs > MAXSIZE:
raise Exception(
f"bootloader has to be smaller than {MAXSIZE} bytes (current size is {fs})"
)
with open(outfile, "wb") as f:
with open(infile, "rb") as i:
f.write(i.read())
f.write(b"\x00" * (TOTALSIZE - fs))