feat(trezorctl): Add firmware get-hash command.

pull/2251/head
Andrew Kozlik 2 years ago committed by Martin Milata
parent 106ab65e21
commit e43c14f448

@ -0,0 +1 @@
Add firmware get-hash command.

@ -590,3 +590,12 @@ def update(
click.echo("Dry run. Not uploading firmware to device.")
else:
upload_firmware_into_device(client=client, firmware_data=firmware_data)
@cli.command()
@click.argument("hex_challenge", required=False)
@with_client
def get_hash(client: "TrezorClient", hex_challenge: Optional[str]) -> str:
"""Get a hash of the installed firmware combined with the optional challenge."""
challenge = bytes.fromhex(hex_challenge) if hex_challenge else None
return firmware.get_hash(client, challenge).hex()

@ -23,7 +23,7 @@ import construct as c
import ecdsa
from . import cosi, messages
from .tools import session
from .tools import expect, session
if TYPE_CHECKING:
from .client import TrezorClient
@ -518,3 +518,8 @@ def update(
return
else:
raise RuntimeError(f"Unexpected message {resp}")
@expect(messages.FirmwareHash, field="hash", ret_type=bytes)
def get_hash(client: "TrezorClient", challenge: Optional[bytes]):
return client.call(messages.GetFirmwareHash(challenge=challenge))

Loading…
Cancel
Save