From ab82382b1e7bdbc5c3db427e64f23d362733e037 Mon Sep 17 00:00:00 2001 From: matejcik Date: Wed, 18 Dec 2019 13:15:16 +0100 Subject: [PATCH] python/firmware: make header digest function public --- python/src/trezorlib/firmware.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/src/trezorlib/firmware.py b/python/src/trezorlib/firmware.py index b25e778947..c72631b704 100644 --- a/python/src/trezorlib/firmware.py +++ b/python/src/trezorlib/firmware.py @@ -298,7 +298,7 @@ def check_sig_v1( raise InvalidSignatureError("Invalid signature in slot {}".format(i)) from e -def _header_digest( +def header_digest( header: c.Container, header_type: c.Construct, hash_function: Callable = blake2s ) -> bytes: stripped_header = header.copy() @@ -311,11 +311,11 @@ def _header_digest( def digest_v2(fw: FirmwareType) -> bytes: - return _header_digest(fw.firmware_header, FirmwareHeader, blake2s) + return header_digest(fw.image.header, FirmwareHeader, blake2s) def digest_onev2(fw: FirmwareType) -> bytes: - return _header_digest(fw.firmware_header, FirmwareHeader, hashlib.sha256) + return header_digest(fw.header, FirmwareHeader, hashlib.sha256) def validate_code_hashes( @@ -374,7 +374,7 @@ def validate_onev1(fw: FirmwareType, allow_unsigned: bool = False) -> None: def validate_v2(fw: FirmwareType, skip_vendor_header: bool = False) -> None: - vendor_fingerprint = _header_digest(fw.vendor_header, VendorHeader) + vendor_fingerprint = header_digest(fw.vendor_header, VendorHeader) fingerprint = digest_v2(fw) if not skip_vendor_header: