From afeeafd5cded1a293867019ad09c1d704b09788a Mon Sep 17 00:00:00 2001 From: matejcik Date: Mon, 27 Apr 2020 13:15:56 +0200 Subject: [PATCH] core: hide some fields when softlocked --- core/src/apps/base.py | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/core/src/apps/base.py b/core/src/apps/base.py index ac2fa3b791..d15a486605 100644 --- a/core/src/apps/base.py +++ b/core/src/apps/base.py @@ -32,16 +32,10 @@ def get_features() -> Features: f.model = utils.MODEL f.device_id = storage.device.get_device_id() f.label = storage.device.get_label() - f.initialized = storage.is_initialized() f.pin_protection = config.has_pin() f.pin_cached = config.is_unlocked() f.passphrase_protection = storage.device.is_passphrase_enabled() - f.needs_backup = storage.device.needs_backup() - f.unfinished_backup = storage.device.unfinished_backup() - f.no_backup = storage.device.no_backup() - f.flags = storage.device.get_flags() - f.recovery_mode = storage.recovery.is_in_progress() - f.backup_type = mnemonic.get_type() + if utils.BITCOIN_ONLY: f.capabilities = [ Capability.Bitcoin, @@ -71,9 +65,23 @@ def get_features() -> Features: Capability.PassphraseEntry, ] f.sd_card_present = sdcard.is_present() - f.sd_protection = storage.sd_salt.is_enabled() - f.wipe_code_protection = config.has_wipe_code() - f.passphrase_always_on_device = storage.device.get_passphrase_always_on_device() + + # private fields: + if config.is_unlocked(): + # While this is technically not private, we can't reliably find the value while + # locked. Instead of sending always False, we choose to not send it. + f.initialized = storage.is_initialized() + + f.needs_backup = storage.device.needs_backup() + f.unfinished_backup = storage.device.unfinished_backup() + f.no_backup = storage.device.no_backup() + f.flags = storage.device.get_flags() + f.recovery_mode = storage.recovery.is_in_progress() + f.backup_type = mnemonic.get_type() + f.sd_protection = storage.sd_salt.is_enabled() + f.wipe_code_protection = config.has_wipe_code() + f.passphrase_always_on_device = storage.device.get_passphrase_always_on_device() + return f @@ -109,7 +117,11 @@ async def handle_Ping(ctx: wire.Context, msg: Ping) -> Success: return Success(message=msg.message) -ALLOW_WHILE_LOCKED = (MessageType.Initialize, MessageType.GetFeatures) +ALLOW_WHILE_LOCKED = ( + MessageType.Initialize, + MessageType.GetFeatures, + MessageType.WipeDevice, +) def set_homescreen() -> None: