2017-04-01 13:45:50 +00:00
|
|
|
#!/usr/bin/env python3
|
2020-01-03 15:43:44 +00:00
|
|
|
import json
|
2017-04-01 13:45:50 +00:00
|
|
|
|
2020-01-03 15:43:44 +00:00
|
|
|
import click
|
2018-07-31 09:35:09 +00:00
|
|
|
|
2020-01-03 15:43:44 +00:00
|
|
|
from trezorlib import firmware
|
2017-04-01 13:45:50 +00:00
|
|
|
|
2017-06-13 14:50:03 +00:00
|
|
|
|
2020-01-03 15:43:44 +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-04-01 13:45:50 +00:00
|
|
|
|
2017-06-13 14:50:03 +00:00
|
|
|
|
2020-01-03 15:43:44 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
build_vendorheader()
|