From 7963cb12c3bf435597debe5830c807731348bc86 Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Mon, 29 Apr 2024 11:11:56 +0200 Subject: [PATCH] feat(core): create pairing state if branch --- core/src/trezor/wire/thp/channel.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/src/trezor/wire/thp/channel.py b/core/src/trezor/wire/thp/channel.py index 3cbedf778..191998d1a 100644 --- a/core/src/trezor/wire/thp/channel.py +++ b/core/src/trezor/wire/thp/channel.py @@ -211,6 +211,10 @@ class Channel(Context): if state is ChannelState.TH2: await self._handle_state_TH2(message_length, sync_bit) return + if is_channel_state_pairing(state): + await self._handle_pairing(message_length) + return + raise ThpError("Unimplemented channel state") async def _handle_state_TH1( self, payload_length: int, message_length: int, sync_bit: int @@ -279,6 +283,9 @@ class Channel(Context): ) ) + async def _handle_pairing(self, message_length: int) -> None: + pass + def _handle_channel_message(self, message_length: int, message_type: int) -> None: buf = self.buffer[INIT_DATA_OFFSET + 3 : message_length - CHECKSUM_LENGTH] @@ -580,6 +587,18 @@ def _is_ctrl_byte_ack(ctrl_byte: int) -> bool: return ctrl_byte & 0xEF == ACK_MESSAGE +def is_channel_state_pairing(state: int) -> bool: + if state in ( + ChannelState.TP1, + ChannelState.TP2, + ChannelState.TP3, + ChannelState.TP4, + ChannelState.TP5, + ): + return True + return False + + def _state_to_str(state: int) -> str: if state == ChannelState.ENCRYPTED_TRANSPORT: return "state: encrypted transport"