From e60914e30f4d948008dda911844e6084d21195a6 Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Sat, 23 Feb 2019 01:56:56 +0100 Subject: [PATCH] pin: avoid changing PIN unnecessarily --- src/apps/management/recovery_device.py | 4 +++- src/apps/management/reset_device.py | 5 +++-- vendor/trezor-storage | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/apps/management/recovery_device.py b/src/apps/management/recovery_device.py index 07772b085..271fc8de3 100644 --- a/src/apps/management/recovery_device.py +++ b/src/apps/management/recovery_device.py @@ -57,6 +57,8 @@ async def recovery_device(ctx, msg): # ask for pin repeatedly if msg.pin_protection: newpin = await request_pin_confirm(ctx, cancellable=False) + else: + newpin = "" # dry run if msg.dry_run: @@ -72,7 +74,7 @@ async def recovery_device(ctx, msg): ) # save into storage - if msg.pin_protection: + if newpin: config.change_pin(pin_to_int(""), pin_to_int(newpin)) storage.set_u2f_counter(msg.u2f_counter) storage.load_settings(label=msg.label, use_passphrase=msg.passphrase_protection) diff --git a/src/apps/management/reset_device.py b/src/apps/management/reset_device.py index d711a7342..becc2c27f 100644 --- a/src/apps/management/reset_device.py +++ b/src/apps/management/reset_device.py @@ -73,8 +73,9 @@ async def reset_device(ctx, msg): await show_wrong_entry(ctx) # write PIN into storage - if not config.change_pin(pin_to_int(""), pin_to_int(newpin)): - raise wire.ProcessError("Could not change PIN") + if newpin: + if not config.change_pin(pin_to_int(""), pin_to_int(newpin)): + raise wire.ProcessError("Could not change PIN") # write settings and mnemonic into storage storage.load_settings(label=msg.label, use_passphrase=msg.passphrase_protection) diff --git a/vendor/trezor-storage b/vendor/trezor-storage index 0e897f673..511fc205b 160000 --- a/vendor/trezor-storage +++ b/vendor/trezor-storage @@ -1 +1 @@ -Subproject commit 0e897f673a2150607bae553e21604b253352644e +Subproject commit 511fc205b284605651348512c5c5c2c95a642fa1