mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-12 01:28:10 +00:00
35 lines
571 B
Python
35 lines
571 B
Python
import typing as t
|
|
from dataclasses import dataclass
|
|
|
|
from typing_extensions import Protocol
|
|
|
|
|
|
class FirmwareIntegrityError(Exception):
|
|
pass
|
|
|
|
|
|
class InvalidSignatureError(FirmwareIntegrityError):
|
|
pass
|
|
|
|
|
|
class Unsigned(FirmwareIntegrityError):
|
|
pass
|
|
|
|
|
|
class DigestCalculator(Protocol):
|
|
def update(self, __data: bytes) -> None:
|
|
...
|
|
|
|
def digest(self) -> bytes:
|
|
...
|
|
|
|
|
|
Hasher = t.Callable[[bytes], DigestCalculator]
|
|
|
|
|
|
@dataclass
|
|
class FirmwareHashParameters:
|
|
hash_function: Hasher
|
|
chunk_size: int
|
|
padding_byte: t.Optional[bytes]
|