mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-08-04 12:56:25 +00:00
fix(python/internal): fix key index handling in firmware_headers.py
[no changelog]
This commit is contained in:
parent
e778ec4af4
commit
1cbe96c6e5
@ -45,12 +45,6 @@ VHASH_DEVEL = bytes.fromhex(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ImageType(Enum):
|
|
||||||
VENDOR_HEADER = 0
|
|
||||||
BOOTLOADER = 1
|
|
||||||
FIRMWARE = 2
|
|
||||||
|
|
||||||
|
|
||||||
def _make_dev_keys(*key_bytes: bytes) -> t.Sequence[bytes]:
|
def _make_dev_keys(*key_bytes: bytes) -> t.Sequence[bytes]:
|
||||||
return [k * 32 for k in key_bytes]
|
return [k * 32 for k in key_bytes]
|
||||||
|
|
||||||
@ -359,7 +353,7 @@ class LegacyFirmware(firmware.LegacyFirmware):
|
|||||||
def insert_signature(self, slot: int, key_index: int, signature: bytes) -> None:
|
def insert_signature(self, slot: int, key_index: int, signature: bytes) -> None:
|
||||||
if not 0 <= slot < firmware.V1_SIGNATURE_SLOTS:
|
if not 0 <= slot < firmware.V1_SIGNATURE_SLOTS:
|
||||||
raise ValueError("Invalid slot number")
|
raise ValueError("Invalid slot number")
|
||||||
if not 0 <= key_index < len(firmware.V1_BOOTLOADER_KEYS):
|
if not 0 < key_index <= len(firmware.V1_BOOTLOADER_KEYS):
|
||||||
raise ValueError("Invalid key index")
|
raise ValueError("Invalid key index")
|
||||||
self.key_indexes[slot] = key_index
|
self.key_indexes[slot] = key_index
|
||||||
self.signatures[slot] = signature
|
self.signatures[slot] = signature
|
||||||
@ -396,7 +390,7 @@ class LegacyV2Firmware(firmware.LegacyV2Firmware):
|
|||||||
def insert_signature(self, slot: int, key_index: int, signature: bytes) -> None:
|
def insert_signature(self, slot: int, key_index: int, signature: bytes) -> None:
|
||||||
if not 0 <= slot < firmware.V1_SIGNATURE_SLOTS:
|
if not 0 <= slot < firmware.V1_SIGNATURE_SLOTS:
|
||||||
raise ValueError("Invalid slot number")
|
raise ValueError("Invalid slot number")
|
||||||
if not 0 <= key_index < len(firmware.V1_BOOTLOADER_KEYS):
|
if not 0 < key_index <= len(firmware.V1_BOOTLOADER_KEYS):
|
||||||
raise ValueError("Invalid key index")
|
raise ValueError("Invalid key index")
|
||||||
if not isinstance(self.header.v1_key_indexes, list):
|
if not isinstance(self.header.v1_key_indexes, list):
|
||||||
self.header.v1_key_indexes = list(self.header.v1_key_indexes)
|
self.header.v1_key_indexes = list(self.header.v1_key_indexes)
|
||||||
|
Loading…
Reference in New Issue
Block a user