1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-25 01:18:54 +00:00

chore(python): allow PASSPHRASE_ON_DEVICE with ProtocolV2

This commit is contained in:
M1nd3r 2025-04-22 16:26:51 +02:00
parent 1afccbbdc2
commit ca696a84cd
2 changed files with 11 additions and 4 deletions

View File

@ -164,7 +164,7 @@ class TrezorClient:
if self._session_id_counter >= 255:
self._session_id_counter = 0
assert isinstance(passphrase, str) or passphrase is None
self._session_id_counter += 1
return SessionV2.new(

View File

@ -4,7 +4,7 @@ import logging
import typing as t
from .. import exceptions, messages, models
from ..client import MAX_PIN_LENGTH
from ..client import MAX_PIN_LENGTH, PASSPHRASE_ON_DEVICE
from ..protobuf import MessageType
from .thp.protocol_v1 import ProtocolV1Channel
from .thp.protocol_v2 import ProtocolV2Channel
@ -246,15 +246,22 @@ class SessionV2(Session):
def new(
cls,
client: TrezorClient,
passphrase: str | None,
passphrase: str | object | None,
derive_cardano: bool,
session_id: int = 0,
) -> SessionV2:
assert isinstance(client.protocol, ProtocolV2Channel)
session = cls(client, session_id.to_bytes(1, "big"))
if passphrase is PASSPHRASE_ON_DEVICE:
passphrase = None
on_device = True
else:
on_device = False
session.call(
messages.ThpCreateNewSession(
passphrase=passphrase, derive_cardano=derive_cardano
passphrase=passphrase,
on_device=on_device,
derive_cardano=derive_cardano,
),
expect=messages.Success,
)