1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-21 23:18:13 +00:00

pin: avoid changing PIN unnecessarily

This commit is contained in:
Andrew Kozlik 2019-02-23 01:56:56 +01:00 committed by Pavol Rusnak
parent 456a2c68d6
commit e60914e30f
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 7 additions and 4 deletions

View File

@ -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)

View File

@ -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)

@ -1 +1 @@
Subproject commit 0e897f673a2150607bae553e21604b253352644e
Subproject commit 511fc205b284605651348512c5c5c2c95a642fa1