1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 07:18:09 +00:00
trezor-firmware/core/tools/build_vendorheader

24 lines
617 B
Plaintext
Raw Normal View History

#!/usr/bin/env python3
import json
import click
2018-07-31 09:35:09 +00:00
from trezorlib import firmware
2017-06-13 14:50:03 +00:00
@click.command()
@click.argument("specfile", type=click.File("r"))
@click.argument("image", type=click.File("rb"))
@click.argument("outfile", type=click.File("wb"))
def build_vendorheader(specfile, image, outfile):
spec = json.load(specfile)
spec["pubkeys"] = [bytes.fromhex(k) for k in spec["pubkeys"]]
spec["image"] = firmware.Toif.parse(image.read())
spec["sigmask"] = 0
spec["signature"] = b"\x00" * 64
outfile.write(firmware.VendorHeader.build(spec))
2017-06-13 14:50:03 +00:00
if __name__ == "__main__":
build_vendorheader()