1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 03:30:02 +00:00

feat(core): add packet handlers

This commit is contained in:
M1nd3r 2024-03-21 09:42:02 +01:00
parent 4f9b3944ab
commit ef1b429c62
4 changed files with 35 additions and 3 deletions

View File

@ -215,6 +215,8 @@ trezor.wire.thp.channel_context
import trezor.wire.thp.channel_context
trezor.wire.thp.checksum
import trezor.wire.thp.checksum
trezor.wire.thp.packet_handlers
import trezor.wire.thp.packet_handlers
trezor.wire.thp.session_context
import trezor.wire.thp.session_context
trezor.wire.thp.thp_messages

View File

@ -0,0 +1,18 @@
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from enum import IntEnum
else:
IntEnum = object
class ChannelState(IntEnum):
UNALLOCATED = 0
TH1 = 1
TH2 = 2
TP1 = 3
TP2 = 4
TP3 = 5
TP4 = 6
TP5 = 7
ENCRYPTED_TRANSPORT = 8

View File

@ -93,9 +93,7 @@ class ChannelContext(Context):
passphrase="",
) -> None: # TODO change it to output session data
pass
# TODO check, wheter a session with this passphrase already exists
# if not, create a new session with this passphrase
# if yes, what TODO TODO ???
# create a new session with this passphrase
def _is_ctrl_byte_continuation(ctrl_byte: int) -> bool:

View File

@ -0,0 +1,14 @@
from . import ChannelState
from .channel_context import ChannelContext
def getPacketHandler(
channel: ChannelContext, packet: bytes
): # TODO is the packet bytes or BufferType?
if channel.get_management_session_state is ChannelState.TH1: # TODO is correct
# return handler_TH_1
pass
def handler_TH_1(packet):
pass