mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 06:18:07 +00:00
trezorctl: Validate PIN digits and length.
This commit is contained in:
parent
77bb6deb66
commit
ac78d1e2f3
@ -169,9 +169,9 @@ class TrezorClient:
|
||||
self.call_raw(messages.Cancel())
|
||||
raise
|
||||
|
||||
if not pin.isdigit():
|
||||
if any(d not in "123456789" for d in pin) or not (1 <= len(pin) <= 9):
|
||||
self.call_raw(messages.Cancel())
|
||||
raise ValueError("Non-numeric PIN provided")
|
||||
raise ValueError("Invalid PIN provided")
|
||||
|
||||
resp = self.call_raw(messages.PinMatrixAck(pin=pin))
|
||||
if isinstance(resp, messages.Failure) and resp.code in (
|
||||
|
@ -95,8 +95,10 @@ class ClickUI:
|
||||
pin = prompt("Please enter {}".format(desc), hide_input=True)
|
||||
except click.Abort:
|
||||
raise Cancelled from None
|
||||
if not pin.isdigit():
|
||||
echo("Non-numerical value provided, please try again")
|
||||
if any(d not in "123456789" for d in pin):
|
||||
echo("The value may only consist of digits 1 to 9.")
|
||||
elif len(pin) > 9:
|
||||
echo("The value must be at most 9 digits in length.")
|
||||
else:
|
||||
return pin
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user