mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-29 08:40:57 +00:00
feat(trezorctl): Add firmware get-hash command.
This commit is contained in:
parent
106ab65e21
commit
e43c14f448
1
python/.changelog.d/2239.added
Normal file
1
python/.changelog.d/2239.added
Normal file
@ -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…
Reference in New Issue
Block a user