mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
tests: add test for firmware dumping and hashing
This commit is contained in:
parent
e47bcee4a4
commit
c9b521a8b0
27
tests/device_tests/test_firmware_dump.py
Normal file
27
tests/device_tests/test_firmware_dump.py
Normal file
@ -0,0 +1,27 @@
|
||||
from hashlib import blake2s
|
||||
|
||||
from trezorlib import firmware
|
||||
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
||||
|
||||
FIRMWARE_LENGTHS = {
|
||||
"1": 7 * 128 * 1024 + 64 * 1024,
|
||||
"T": 13 * 128 * 1024,
|
||||
}
|
||||
|
||||
|
||||
def test_firmware_dump_hash(client: Client) -> None:
|
||||
data = firmware.get_firmware(client)
|
||||
assert len(data) == FIRMWARE_LENGTHS[client.features.model]
|
||||
|
||||
if client.features.fw_vendor != "EMULATOR":
|
||||
# check that the dumped data is not empty
|
||||
assert not all(byte == 0xFF for byte in data)
|
||||
|
||||
expected_hash = blake2s(data).digest()
|
||||
hash = firmware.get_hash(client, None)
|
||||
assert hash == expected_hash
|
||||
|
||||
challenge = b"Hello Trezor"
|
||||
expected_hash = blake2s(data, key=challenge).digest()
|
||||
hash = firmware.get_hash(client, challenge)
|
||||
assert hash == expected_hash
|
@ -527,6 +527,7 @@
|
||||
"T1_test_debuglink.py::test_layout": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"T1_test_debuglink.py::test_mnemonic": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"T1_test_debuglink.py::test_pin": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"T1_test_firmware_dump.py::test_firmware_dump_hash": "cb42c7f21adc31e70ee62c7581245260705dd38f743bbe41161deb5471b9e5f6",
|
||||
"T1_test_msg_applysettings.py::test_apply_homescreen": "d85a5591a0a433741fcc897fa6941bf0b8475de957375e3811fe710b3d40a053",
|
||||
"T1_test_msg_applysettings.py::test_apply_settings": "fb962820965916d494e44bd5aebd25c4f80095ca3d468d3ed212e04a9e0ef9e0",
|
||||
"T1_test_msg_applysettings.py::test_apply_settings_passphrase": "1f948e87ea82a0224190d3e552e506d5d4579503905526160c7a527c5a88b729",
|
||||
@ -1507,6 +1508,7 @@
|
||||
"TT_test_cancel.py::test_cancel_message_via_initialize[message1]": "b014449cbf1a45739d64a370b30af75df2228f48c090a02227bac8ed20c7b2dc",
|
||||
"TT_test_cancel.py::test_cancel_on_paginated": "6b8a80b8e81a14c0183805fac48a36f9cc61daa290d04d295032ab76ec83300f",
|
||||
"TT_test_debuglink.py::test_softlock_instability": "9750df55cb4716f1d497d57de57257a0c5188fb652fcdb66a9d436d9c396c62b",
|
||||
"TT_test_firmware_dump.py::test_firmware_dump_hash": "5bd19a3b684eb5160270266f1900dc1e0e216901a64f6ed1e91dc65f7d88d82f",
|
||||
"TT_test_msg_applysettings.py::test_apply_homescreen_toif": "7e7fb6223f2113a592c848cd8e57aa22eb002e6472abb5045814f7fe958b2818",
|
||||
"TT_test_msg_applysettings.py::test_apply_homescreen_toif_fail[TOIf\\x80\\x00\\x80\\x00~\\x00\\x00\\x0-ba464b0c": "d81ff1a197803cfda9180cad05dad5c1912a064da957d036c1311fa3eeef4b70",
|
||||
"TT_test_msg_applysettings.py::test_apply_homescreen_toif_fail[TOIf\\x90\\x00\\x90\\x00~XXXf\\x90\\x0-cb3c88da": "d81ff1a197803cfda9180cad05dad5c1912a064da957d036c1311fa3eeef4b70",
|
||||
|
Loading…
Reference in New Issue
Block a user