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

trezorctl: Add set wipe-code command.

This commit is contained in:
Andrew Kozlik 2019-10-18 15:59:12 +02:00
parent 4381511930
commit 83fab3c220
4 changed files with 28 additions and 1 deletions

View File

@ -362,6 +362,7 @@ Device settings.
label Set new device label.
passphrase Enable, disable or configure passphrase protection.
pin Set, change or remove PIN.
wipe-code Set or remove the wipe code.
Stellar commands.
~~~~~~~~~~~~~~~~~

View File

@ -41,6 +41,19 @@ def pin(connect, remove):
return device.change_pin(connect(), remove)
@cli.command()
@click.option("-r", "--remove", is_flag=True)
@click.pass_obj
def wipe_code(connect, remove):
"""Set or remove the wipe code.
The wipe code functions as a "self-destruct PIN". If the wipe code is ever
entered into any PIN entry dialog, then all private data will be immediately
removed and the device will be reset to factory defaults.
"""
return device.change_wipe_code(connect(), remove)
@cli.command()
# keep the deprecated -l/--label option, make it do nothing
@click.option("-l", "--label", "_ignore", is_flag=True, hidden=True, expose_value=False)

View File

@ -90,6 +90,13 @@ def change_pin(client, remove=False):
return ret
@expect(messages.Success, field="message")
def change_wipe_code(client, remove=False):
ret = client.call(messages.ChangeWipeCode(remove=remove))
client.init_device() # Re-read features
return ret
@expect(messages.Success, field="message")
def sd_protect(client, operation):
ret = client.call(messages.SdProtect(operation=operation))

View File

@ -45,6 +45,8 @@ PIN_GENERIC = None
PIN_CURRENT = PinMatrixRequestType.Current
PIN_NEW = PinMatrixRequestType.NewFirst
PIN_CONFIRM = PinMatrixRequestType.NewSecond
WIPE_CODE_NEW = PinMatrixRequestType.WipeCodeFirst
WIPE_CODE_CONFIRM = PinMatrixRequestType.WipeCodeSecond
def echo(*args, **kwargs):
@ -74,6 +76,10 @@ class ClickUI:
desc = "new PIN"
elif code == PIN_CONFIRM:
desc = "new PIN again"
elif code == WIPE_CODE_NEW:
desc = "new wipe code"
elif code == WIPE_CODE_CONFIRM:
desc = "new wipe code again"
else:
desc = "PIN"
@ -88,7 +94,7 @@ class ClickUI:
except click.Abort:
raise Cancelled from None
if not pin.isdigit():
echo("Non-numerical PIN provided, please try again")
echo("Non-numerical value provided, please try again")
else:
return pin