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:
parent
4f9b3944ab
commit
ef1b429c62
2
core/src/all_modules.py
generated
2
core/src/all_modules.py
generated
@ -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:
|
||||
|
14
core/src/trezor/wire/thp/packet_handlers.py
Normal file
14
core/src/trezor/wire/thp/packet_handlers.py
Normal 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
|
Loading…
Reference in New Issue
Block a user