feat(python): Support 50 digit PIN and wipe code in trezorctl.

pull/1546/head
Andrew Kozlik 4 years ago committed by Andrew Kozlik
parent cbb0d82999
commit 885b6f7214

@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- protobuf is aware of `required` fields and default values - protobuf is aware of `required` fields and default values
- `btc.sign_tx()` accepts keyword arguments for transaction metadata [#1266] - `btc.sign_tx()` accepts keyword arguments for transaction metadata [#1266]
- Support long PIN of up to 50 digits. [#1167]
### Deprecated ### Deprecated
@ -509,6 +510,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#948]: https://github.com/trezor/trezor-firmware/issues/948 [#948]: https://github.com/trezor/trezor-firmware/issues/948
[#1052]: https://github.com/trezor/trezor-firmware/issues/1052 [#1052]: https://github.com/trezor/trezor-firmware/issues/1052
[#1126]: https://github.com/trezor/trezor-firmware/issues/1126 [#1126]: https://github.com/trezor/trezor-firmware/issues/1126
[#1167]: https://github.com/trezor/trezor-firmware/issues/1167
[#1179]: https://github.com/trezor/trezor-firmware/issues/1179 [#1179]: https://github.com/trezor/trezor-firmware/issues/1179
[#1196]: https://github.com/trezor/trezor-firmware/issues/1196 [#1196]: https://github.com/trezor/trezor-firmware/issues/1196
[#1210]: https://github.com/trezor/trezor-firmware/issues/1210 [#1210]: https://github.com/trezor/trezor-firmware/issues/1210

@ -29,6 +29,7 @@ LOG = logging.getLogger(__name__)
VENDORS = ("bitcointrezor.com", "trezor.io") VENDORS = ("bitcointrezor.com", "trezor.io")
MAX_PASSPHRASE_LENGTH = 50 MAX_PASSPHRASE_LENGTH = 50
MAX_PIN_LENGTH = 50
PASSPHRASE_ON_DEVICE = object() PASSPHRASE_ON_DEVICE = object()
PASSPHRASE_TEST_PATH = tools.parse_path("44h/1h/0h/0/0") PASSPHRASE_TEST_PATH = tools.parse_path("44h/1h/0h/0/0")
@ -152,7 +153,9 @@ class TrezorClient:
self.call_raw(messages.Cancel()) self.call_raw(messages.Cancel())
raise raise
if any(d not in "123456789" for d in pin) or not (1 <= len(pin) <= 9): if any(d not in "123456789" for d in pin) or not (
1 <= len(pin) <= MAX_PIN_LENGTH
):
self.call_raw(messages.Cancel()) self.call_raw(messages.Cancel())
raise ValueError("Invalid PIN provided") raise ValueError("Invalid PIN provided")

@ -20,7 +20,7 @@ import click
from mnemonic import Mnemonic from mnemonic import Mnemonic
from . import device from . import device
from .client import PASSPHRASE_ON_DEVICE from .client import MAX_PIN_LENGTH, PASSPHRASE_ON_DEVICE
from .exceptions import Cancelled from .exceptions import Cancelled
from .messages import PinMatrixRequestType, WordRequestType from .messages import PinMatrixRequestType, WordRequestType
@ -107,8 +107,12 @@ class ClickUI:
echo( echo(
"The value may only consist of digits 1 to 9 or letters cvbdfgert." "The value may only consist of digits 1 to 9 or letters cvbdfgert."
) )
elif len(pin) > 9: elif len(pin) > MAX_PIN_LENGTH:
echo("The value must be at most 9 digits in length.") echo(
"The value must be at most {} digits in length.".format(
MAX_PIN_LENGTH
)
)
else: else:
return pin return pin

Loading…
Cancel
Save