diff --git a/core/src/trezor/wire/thp/thp_messages.py b/core/src/trezor/wire/thp/thp_messages.py index a06706059..2322d6b15 100644 --- a/core/src/trezor/wire/thp/thp_messages.py +++ b/core/src/trezor/wire/thp/thp_messages.py @@ -12,8 +12,9 @@ CONTINUATION_PACKET = 0x80 ENCRYPTED_TRANSPORT = 0x02 HANDSHAKE_INIT = 0x00 ACK_MESSAGE = 0x20 -_ERROR = 0x41 -_CHANNEL_ALLOCATION_RES = 0x40 +_ERROR = 0x42 +CHANNEL_ALLOCATION_REQ = 0x40 +_CHANNEL_ALLOCATION_RES = 0x41 TREZOR_STATE_UNPAIRED = b"\x00" TREZOR_STATE_PAIRED = b"\x01" diff --git a/core/src/trezor/wire/thp_v1.py b/core/src/trezor/wire/thp_v1.py index ea0aa9a95..d2069f930 100644 --- a/core/src/trezor/wire/thp_v1.py +++ b/core/src/trezor/wire/thp_v1.py @@ -16,14 +16,13 @@ from .thp.channel import ( load_cached_channels, ) from .thp.checksum import CHECKSUM_LENGTH -from .thp.thp_messages import CODEC_V1, InitHeader +from .thp.thp_messages import CHANNEL_ALLOCATION_REQ, CODEC_V1, InitHeader from .thp.thp_session import ThpError if TYPE_CHECKING: from trezorio import WireInterface # pyright: ignore[reportMissingImports] _MAX_CID_REQ_PAYLOAD_LENGTH = const(12) # TODO set to reasonable value -_CHANNEL_ALLOCATION_REQ = 0x40 _BUFFER: bytearray @@ -137,7 +136,7 @@ async def _handle_broadcast( iface: WireInterface, ctrl_byte, packet ) -> MessageWithId | None: global _BUFFER - if ctrl_byte != _CHANNEL_ALLOCATION_REQ: + if ctrl_byte != CHANNEL_ALLOCATION_REQ: raise ThpError("Unexpected ctrl_byte in broadcast channel packet") if __debug__: log.debug(__name__, "Received valid message on broadcast channel ")