From e534ae3ad7781bee7ef09b551a32e9a96a7b6e4d Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Fri, 19 Jun 2020 14:04:24 +0000 Subject: [PATCH] legacy, core: rename Features.pin_cached to unlocked and unify --- common/protob/messages-management.proto | 2 +- core/src/apps/base.py | 2 +- core/src/trezor/messages/Features.py | 6 +++--- legacy/firmware/fsm_msg_common.h | 4 ++-- python/src/trezorlib/messages/Features.py | 6 +++--- tests/device_tests/test_msg_changepin_t2.py | 2 +- tests/device_tests/test_protection_levels.py | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/common/protob/messages-management.proto b/common/protob/messages-management.proto index cb0abf368..015b8e97d 100644 --- a/common/protob/messages-management.proto +++ b/common/protob/messages-management.proto @@ -50,7 +50,7 @@ message Features { optional bytes revision = 13; // SCM revision of firmware optional bytes bootloader_hash = 14; // hash of the bootloader optional bool imported = 15; // was storage imported from an external source? - optional bool pin_cached = 16; // is PIN already cached in session? + optional bool unlocked = 16; // is the device unlocked? called "pin_cached" previously // optional bool passphrase_cached = 17; // is passphrase already cached in session? DEPRECATED optional bool firmware_present = 18; // is valid firmware loaded? optional bool needs_backup = 19; // does storage need backup? (equals to Storage.needs_backup) diff --git a/core/src/apps/base.py b/core/src/apps/base.py index ae05cf044..18d96e717 100644 --- a/core/src/apps/base.py +++ b/core/src/apps/base.py @@ -33,7 +33,7 @@ def get_features() -> Features: f.device_id = storage.device.get_device_id() f.label = storage.device.get_label() f.pin_protection = config.has_pin() - f.pin_cached = config.is_unlocked() + f.unlocked = config.is_unlocked() f.passphrase_protection = storage.device.is_passphrase_enabled() if utils.BITCOIN_ONLY: diff --git a/core/src/trezor/messages/Features.py b/core/src/trezor/messages/Features.py index ce5462e2c..6ba3c39e6 100644 --- a/core/src/trezor/messages/Features.py +++ b/core/src/trezor/messages/Features.py @@ -31,7 +31,7 @@ class Features(p.MessageType): revision: bytes = None, bootloader_hash: bytes = None, imported: bool = None, - pin_cached: bool = None, + unlocked: bool = None, firmware_present: bool = None, needs_backup: bool = None, flags: int = None, @@ -66,7 +66,7 @@ class Features(p.MessageType): self.revision = revision self.bootloader_hash = bootloader_hash self.imported = imported - self.pin_cached = pin_cached + self.unlocked = unlocked self.firmware_present = firmware_present self.needs_backup = needs_backup self.flags = flags @@ -104,7 +104,7 @@ class Features(p.MessageType): 13: ('revision', p.BytesType, 0), 14: ('bootloader_hash', p.BytesType, 0), 15: ('imported', p.BoolType, 0), - 16: ('pin_cached', p.BoolType, 0), + 16: ('unlocked', p.BoolType, 0), 18: ('firmware_present', p.BoolType, 0), 19: ('needs_backup', p.BoolType, 0), 20: ('flags', p.UVarintType, 0), diff --git a/legacy/firmware/fsm_msg_common.h b/legacy/firmware/fsm_msg_common.h index 32b959417..7a65d59c4 100644 --- a/legacy/firmware/fsm_msg_common.h +++ b/legacy/firmware/fsm_msg_common.h @@ -48,8 +48,8 @@ bool get_features(Features *resp) { resp->has_initialized = true; resp->initialized = config_isInitialized(); resp->has_imported = config_getImported(&(resp->imported)); - resp->has_pin_cached = true; - resp->pin_cached = session_isUnlocked() && config_hasPin(); + resp->has_unlocked = true; + resp->unlocked = session_isUnlocked(); resp->has_needs_backup = true; config_getNeedsBackup(&(resp->needs_backup)); resp->has_unfinished_backup = true; diff --git a/python/src/trezorlib/messages/Features.py b/python/src/trezorlib/messages/Features.py index 5a2390b02..47d1c9a40 100644 --- a/python/src/trezorlib/messages/Features.py +++ b/python/src/trezorlib/messages/Features.py @@ -31,7 +31,7 @@ class Features(p.MessageType): revision: bytes = None, bootloader_hash: bytes = None, imported: bool = None, - pin_cached: bool = None, + unlocked: bool = None, firmware_present: bool = None, needs_backup: bool = None, flags: int = None, @@ -66,7 +66,7 @@ class Features(p.MessageType): self.revision = revision self.bootloader_hash = bootloader_hash self.imported = imported - self.pin_cached = pin_cached + self.unlocked = unlocked self.firmware_present = firmware_present self.needs_backup = needs_backup self.flags = flags @@ -104,7 +104,7 @@ class Features(p.MessageType): 13: ('revision', p.BytesType, 0), 14: ('bootloader_hash', p.BytesType, 0), 15: ('imported', p.BoolType, 0), - 16: ('pin_cached', p.BoolType, 0), + 16: ('unlocked', p.BoolType, 0), 18: ('firmware_present', p.BoolType, 0), 19: ('needs_backup', p.BoolType, 0), 20: ('flags', p.UVarintType, 0), diff --git a/tests/device_tests/test_msg_changepin_t2.py b/tests/device_tests/test_msg_changepin_t2.py index 908df2395..61b3f665f 100644 --- a/tests/device_tests/test_msg_changepin_t2.py +++ b/tests/device_tests/test_msg_changepin_t2.py @@ -29,7 +29,7 @@ pytestmark = pytest.mark.skip_t1 def _check_pin(client, pin): client.clear_session() assert client.features.pin_protection is True - assert client.features.pin_cached is False + assert client.features.unlocked is False with client: client.use_pin_sequence([pin]) diff --git a/tests/device_tests/test_protection_levels.py b/tests/device_tests/test_protection_levels.py index 5a5696e6d..746140f97 100644 --- a/tests/device_tests/test_protection_levels.py +++ b/tests/device_tests/test_protection_levels.py @@ -233,8 +233,8 @@ class TestProtectionLevels: # pass @pytest.mark.setup_client(pin=PIN4) - def test_pin_cached(self, client): - assert client.features.pin_cached is False + def test_unlocked(self, client): + assert client.features.unlocked is False with client: client.use_pin_sequence([PIN4]) @@ -242,7 +242,7 @@ class TestProtectionLevels: btc.get_address(client, "Testnet", [0]) client.init_device() - assert client.features.pin_cached is True + assert client.features.unlocked is True with client: client.set_expected_responses([proto.Address()]) btc.get_address(client, "Testnet", [0])