From 96ead03e03c878b07a28a1105ba3b0389f1ba0e1 Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Sat, 17 Dec 2016 13:20:57 +0100 Subject: [PATCH] apps: fix for change_pin and debug --- src/apps/debug/__init__.py | 22 +++++++++++++++------- src/apps/management/change_pin.py | 2 ++ tests/run_tests_python_trezor.sh | 2 ++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/apps/debug/__init__.py b/src/apps/debug/__init__.py index 14fca7d5b1..59251ce364 100644 --- a/src/apps/debug/__init__.py +++ b/src/apps/debug/__init__.py @@ -6,24 +6,32 @@ from trezor.messages.wire_types import \ async def dispatch_DebugLinkDecision(session_id, msg): from trezor.ui.confirm import CONFIRMED, CANCELLED - from ..common.confirm import signal + from apps.common.confirm import signal signal.send(CONFIRMED if msg.yes_no else CANCELLED) async def dispatch_DebugLinkGetState(session_id, msg): from trezor.messages.DebugLinkState import DebugLinkState - from ..common import storage, request_pin + from apps.common import storage, request_pin if request_pin.matrix: matrix = ''.join([str(d) for d in request_pin.matrix.digits]) else: matrix = None - m = DebugLinkState() - m.pin = storage.get_pin() - m.mnemonic = storage.get_mnemonic() - m.passphrase_protection = storage.is_protected_by_passphrase() - m.matrix = matrix + # TODO: do this differently + locked = storage.is_locked() + try: + if locked: + storage.unlock(storage.get_pin()) + m = DebugLinkState() + m.pin = storage.get_pin() + m.mnemonic = storage.get_mnemonic() + m.passphrase_protection = storage.is_protected_by_passphrase() + m.matrix = matrix + finally: + if locked: + storage.lock() # TODO: handle other fields: # f.reset_entropy = reset_get_internal_entropy() diff --git a/src/apps/management/change_pin.py b/src/apps/management/change_pin.py index e29cc3fc58..ed4f14c431 100644 --- a/src/apps/management/change_pin.py +++ b/src/apps/management/change_pin.py @@ -50,4 +50,6 @@ async def layout_change_pin(session_id, msg): await confirm_set_pin(session_id) pin = await request_pin_twice(session_id) storage.load_settings(pin=pin) + if pin: + storage.lock() return Success(message='PIN changed') diff --git a/tests/run_tests_python_trezor.sh b/tests/run_tests_python_trezor.sh index 6a5cb6f3cd..644c66ebe4 100755 --- a/tests/run_tests_python_trezor.sh +++ b/tests/run_tests_python_trezor.sh @@ -30,6 +30,8 @@ for i in \ test_msg_signmessage.py \ test_msg_signtx.py \ test_msg_verifymessage.py \ + test_msg_wipedevice.py \ + test_msg_changepin.py \ ; do if ! $PYTHON $i ; then error=1