mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-09 06:50:58 +00:00
chore(core): remove management session code from handle_ThpCreateNewSession
[no changelog]
This commit is contained in:
parent
e2e811e072
commit
5a65b5b1f3
@ -225,10 +225,7 @@ if utils.USE_THP:
|
|||||||
from trezor.wire.context import get_context
|
from trezor.wire.context import get_context
|
||||||
from trezor.wire.errors import ActionCancelled, DataError
|
from trezor.wire.errors import ActionCancelled, DataError
|
||||||
from trezor.wire.thp.session_context import GenericSessionContext
|
from trezor.wire.thp.session_context import GenericSessionContext
|
||||||
from trezor.wire.thp.session_manager import (
|
from trezor.wire.thp.session_manager import get_new_session_context
|
||||||
get_new_management_session_ctx,
|
|
||||||
get_new_session_context,
|
|
||||||
)
|
|
||||||
|
|
||||||
from apps.common.seed import derive_and_store_roots
|
from apps.common.seed import derive_and_store_roots
|
||||||
|
|
||||||
@ -243,30 +240,12 @@ if utils.USE_THP:
|
|||||||
# Do not use `ctx` beyond this point, as it is techically
|
# Do not use `ctx` beyond this point, as it is techically
|
||||||
# allowed to change in between await statements
|
# allowed to change in between await statements
|
||||||
|
|
||||||
is_management = (
|
|
||||||
message.passphrase is None
|
|
||||||
and message.on_device is not True
|
|
||||||
and message.derive_cardano is not True
|
|
||||||
)
|
|
||||||
|
|
||||||
if not 0 <= session_id <= 255:
|
if not 0 <= session_id <= 255:
|
||||||
return Failure(
|
return Failure(
|
||||||
code=FailureType.DataError,
|
code=FailureType.DataError,
|
||||||
message="Invalid session_id for session creation.",
|
message="Invalid session_id for session creation.",
|
||||||
)
|
)
|
||||||
|
|
||||||
if is_management:
|
|
||||||
# TODO this block is completely useless and will be removed - or will result in session.clear
|
|
||||||
new_session = get_new_management_session_ctx(
|
|
||||||
channel_ctx=channel, session_id=session_id
|
|
||||||
)
|
|
||||||
succ_message = "New management session created."
|
|
||||||
|
|
||||||
if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
|
|
||||||
log.debug(
|
|
||||||
__name__, "New management session with sid %d created.", session_id
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
new_session = get_new_session_context(
|
new_session = get_new_session_context(
|
||||||
channel_ctx=channel, session_id=session_id
|
channel_ctx=channel, session_id=session_id
|
||||||
)
|
)
|
||||||
@ -281,8 +260,6 @@ if utils.USE_THP:
|
|||||||
return Failure(code=FailureType.NotInitialized, message=e.message)
|
return Failure(code=FailureType.NotInitialized, message=e.message)
|
||||||
# TODO handle other errors (`Exception` when "Cardano icarus secret is already set!")
|
# TODO handle other errors (`Exception` when "Cardano icarus secret is already set!")
|
||||||
|
|
||||||
succ_message = "New session created."
|
|
||||||
|
|
||||||
if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
|
if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
|
||||||
log.debug(
|
log.debug(
|
||||||
__name__,
|
__name__,
|
||||||
@ -294,7 +271,7 @@ if utils.USE_THP:
|
|||||||
channel.sessions[new_session.session_id] = new_session
|
channel.sessions[new_session.session_id] = new_session
|
||||||
loop.schedule(new_session.handle())
|
loop.schedule(new_session.handle())
|
||||||
|
|
||||||
return Success(message=succ_message)
|
return Success(message="New session created.")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user