2017-06-14 17:27:02 +00:00
|
|
|
from typing import *
|
2017-06-14 15:41:45 +00:00
|
|
|
|
2019-05-17 12:22:36 +00:00
|
|
|
|
2020-06-17 12:24:57 +00:00
|
|
|
# extmod/modtrezorutils/modtrezorutils-meminfo.h
|
|
|
|
def meminfo(filename: str) -> None:
|
|
|
|
"""Dumps map of micropython GC arena to a file.
|
|
|
|
The JSON file can be decoded by analyze.py
|
|
|
|
Only available in the emulator.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2018-01-26 13:28:49 +00:00
|
|
|
# extmod/modtrezorutils/modtrezorutils.c
|
|
|
|
def consteq(sec: bytes, pub: bytes) -> bool:
|
2019-05-17 12:22:36 +00:00
|
|
|
"""
|
2018-01-26 13:28:49 +00:00
|
|
|
Compares the private information in `sec` with public, user-provided
|
|
|
|
information in `pub`. Runs in constant time, corresponding to a length
|
|
|
|
of `pub`. Can access memory behind valid length of `sec`, caller is
|
|
|
|
expected to avoid any invalid memory access.
|
2019-05-17 12:22:36 +00:00
|
|
|
"""
|
|
|
|
|
2018-01-26 13:28:49 +00:00
|
|
|
|
2017-06-14 15:41:45 +00:00
|
|
|
# extmod/modtrezorutils/modtrezorutils.c
|
2019-05-17 12:22:36 +00:00
|
|
|
def memcpy(
|
2021-03-18 09:48:50 +00:00
|
|
|
dst: bytearray | memoryview,
|
2020-06-30 13:10:11 +00:00
|
|
|
dst_ofs: int,
|
|
|
|
src: bytes,
|
|
|
|
src_ofs: int,
|
2021-03-18 09:48:50 +00:00
|
|
|
n: int | None = None,
|
2019-05-17 12:22:36 +00:00
|
|
|
) -> int:
|
|
|
|
"""
|
2017-06-14 15:41:45 +00:00
|
|
|
Copies at most `n` bytes from `src` at offset `src_ofs` to
|
2020-06-26 10:30:12 +00:00
|
|
|
`dst` at offset `dst_ofs`. Returns the number of actually
|
|
|
|
copied bytes. If `n` is not specified, tries to copy
|
|
|
|
as much as possible.
|
2019-05-17 12:22:36 +00:00
|
|
|
"""
|
|
|
|
|
2017-06-14 15:41:45 +00:00
|
|
|
|
|
|
|
# extmod/modtrezorutils/modtrezorutils.c
|
2021-03-18 09:48:50 +00:00
|
|
|
def halt(msg: str | None = None) -> None:
|
2019-05-17 12:22:36 +00:00
|
|
|
"""
|
2017-06-14 15:41:45 +00:00
|
|
|
Halts execution.
|
2019-05-17 12:22:36 +00:00
|
|
|
"""
|
2022-04-22 22:18:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
# extmod/modtrezorutils/modtrezorutils.c
|
2022-05-02 22:55:49 +00:00
|
|
|
def firmware_hash(
|
|
|
|
challenge: bytes | None = None,
|
|
|
|
callback: Callable[[int, int], None] | None = None,
|
|
|
|
) -> bytes:
|
2022-04-22 22:18:13 +00:00
|
|
|
"""
|
|
|
|
Computes the Blake2s hash of the firmware with an optional challenge as
|
|
|
|
the key.
|
|
|
|
"""
|
2022-05-02 22:16:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
# extmod/modtrezorutils/modtrezorutils.c
|
|
|
|
def firmware_vendor() -> str:
|
|
|
|
"""
|
|
|
|
Returns the firmware vendor string from the vendor header.
|
|
|
|
"""
|
2022-05-03 09:34:34 +00:00
|
|
|
|
|
|
|
|
2022-04-11 11:27:48 +00:00
|
|
|
# extmod/modtrezorutils/modtrezorutils.c
|
|
|
|
def reboot_to_bootloader() -> None:
|
|
|
|
"""
|
|
|
|
Reboots to bootloader.
|
|
|
|
"""
|
2021-05-21 09:35:43 +00:00
|
|
|
SCM_REVISION: bytes
|
2019-06-09 09:24:06 +00:00
|
|
|
VERSION_MAJOR: int
|
|
|
|
VERSION_MINOR: int
|
|
|
|
VERSION_PATCH: int
|
|
|
|
MODEL: str
|
|
|
|
EMULATOR: bool
|
2020-04-20 14:38:50 +00:00
|
|
|
BITCOIN_ONLY: bool
|