From 07e51279e2a87af12b3ec1fe47196d963770921f Mon Sep 17 00:00:00 2001 From: grdddj Date: Wed, 15 Feb 2023 15:43:20 +0100 Subject: [PATCH] feat(python): ability to not show passphrase coming from host [no changelog] --- python/src/trezorlib/cli/settings.py | 11 +++++++++++ python/src/trezorlib/device.py | 2 ++ python/src/trezorlib/messages.py | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/python/src/trezorlib/cli/settings.py b/python/src/trezorlib/cli/settings.py index e5414293b0..eb23398db1 100644 --- a/python/src/trezorlib/cli/settings.py +++ b/python/src/trezorlib/cli/settings.py @@ -337,3 +337,14 @@ passphrase.aliases = { "enabled": passphrase_on, "disabled": passphrase_off, } + + +@passphrase.command(name="hide") +@click.argument("hide", type=ChoiceType({"on": True, "off": False})) +@with_client +def hide_passphrase_from_host(client: "TrezorClient", hide: bool) -> str: + """Enable or disable hiding passphrase coming from host. + + This is a developer feature. Use with caution. + """ + return device.apply_settings(client, hide_passphrase_from_host=hide) diff --git a/python/src/trezorlib/device.py b/python/src/trezorlib/device.py index cea79deb24..79c75eff82 100644 --- a/python/src/trezorlib/device.py +++ b/python/src/trezorlib/device.py @@ -43,6 +43,7 @@ def apply_settings( display_rotation: Optional[int] = None, safety_checks: Optional[messages.SafetyCheckLevel] = None, experimental_features: Optional[bool] = None, + hide_passphrase_from_host: Optional[bool] = None, ) -> "MessageType": settings = messages.ApplySettings( label=label, @@ -54,6 +55,7 @@ def apply_settings( display_rotation=display_rotation, safety_checks=safety_checks, experimental_features=experimental_features, + hide_passphrase_from_host=hide_passphrase_from_host, ) out = client.call(settings) diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index 0ffb7a296b..2178610400 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -3143,6 +3143,7 @@ class Features(protobuf.MessageType): 40: protobuf.Field("experimental_features", "bool", repeated=False, required=False, default=None), 41: protobuf.Field("busy", "bool", repeated=False, required=False, default=None), 42: protobuf.Field("homescreen_format", "HomescreenFormat", repeated=False, required=False, default=None), + 43: protobuf.Field("hide_passphrase_from_host", "bool", repeated=False, required=False, default=None), } def __init__( @@ -3188,6 +3189,7 @@ class Features(protobuf.MessageType): experimental_features: Optional["bool"] = None, busy: Optional["bool"] = None, homescreen_format: Optional["HomescreenFormat"] = None, + hide_passphrase_from_host: Optional["bool"] = None, ) -> None: self.capabilities: Sequence["Capability"] = capabilities if capabilities is not None else [] self.major_version = major_version @@ -3229,6 +3231,7 @@ class Features(protobuf.MessageType): self.experimental_features = experimental_features self.busy = busy self.homescreen_format = homescreen_format + self.hide_passphrase_from_host = hide_passphrase_from_host class LockDevice(protobuf.MessageType): @@ -3266,6 +3269,7 @@ class ApplySettings(protobuf.MessageType): 8: protobuf.Field("passphrase_always_on_device", "bool", repeated=False, required=False, default=None), 9: protobuf.Field("safety_checks", "SafetyCheckLevel", repeated=False, required=False, default=None), 10: protobuf.Field("experimental_features", "bool", repeated=False, required=False, default=None), + 11: protobuf.Field("hide_passphrase_from_host", "bool", repeated=False, required=False, default=None), } def __init__( @@ -3281,6 +3285,7 @@ class ApplySettings(protobuf.MessageType): passphrase_always_on_device: Optional["bool"] = None, safety_checks: Optional["SafetyCheckLevel"] = None, experimental_features: Optional["bool"] = None, + hide_passphrase_from_host: Optional["bool"] = None, ) -> None: self.language = language self.label = label @@ -3292,6 +3297,7 @@ class ApplySettings(protobuf.MessageType): self.passphrase_always_on_device = passphrase_always_on_device self.safety_checks = safety_checks self.experimental_features = experimental_features + self.hide_passphrase_from_host = hide_passphrase_from_host class ApplyFlags(protobuf.MessageType):