Packet handlers, first draft

M1nd3r/thp5
M1nd3r 2 months ago
parent 8723babd83
commit 9510aaef3a

@ -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

@ -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

@ -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:

@ -0,0 +1,13 @@
from .channel_context import ChannelContext
from . import ChannelState
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
def handler_TH_1(packet):
pass
Loading…
Cancel
Save