1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 12:28:09 +00:00

feat(python): add possibility to enter PIN via letters (#1496)

This commit is contained in:
Pavol Rusnak 2021-02-23 10:39:26 +01:00 committed by GitHub
parent 8f33220865
commit f780cbdb17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View File

@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Enabled session management via `EndSession` [#1227] - Enabled session management via `EndSession` [#1227]
- Support for temporary or permanent `safety-checks` setting - Support for temporary or permanent `safety-checks` setting
- Support for Output Descriptors export [#1363] - Support for Output Descriptors export [#1363]
- PIN entry via letters [#1496]
### Changed ### Changed
@ -514,3 +515,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#1232]: https://github.com/trezor/trezor-firmware/issues/1232 [#1232]: https://github.com/trezor/trezor-firmware/issues/1232
[#1266]: https://github.com/trezor/trezor-firmware/issues/1266 [#1266]: https://github.com/trezor/trezor-firmware/issues/1266
[#1363]: https://github.com/trezor/trezor-firmware/pull/1363 [#1363]: https://github.com/trezor/trezor-firmware/pull/1363
[#1496]: https://github.com/trezor/trezor-firmware/pull/1496

View File

@ -25,10 +25,13 @@ from .exceptions import Cancelled
from .messages import PinMatrixRequestType, WordRequestType from .messages import PinMatrixRequestType, WordRequestType
PIN_MATRIX_DESCRIPTION = """ PIN_MATRIX_DESCRIPTION = """
Use the numeric keypad to describe number positions. The layout is: Use the numeric keypad or lowercase letters to describe number positions.
7 8 9
4 5 6 The layout is:
1 2 3
7 8 9 e r t
4 5 6 -or- d f g
1 2 3 c v b
""".strip() """.strip()
RECOVERY_MATRIX_DESCRIPTION = """ RECOVERY_MATRIX_DESCRIPTION = """
@ -95,8 +98,15 @@ class ClickUI:
pin = prompt("Please enter {}".format(desc), hide_input=True) pin = prompt("Please enter {}".format(desc), hide_input=True)
except click.Abort: except click.Abort:
raise Cancelled from None raise Cancelled from None
# translate letters to numbers if letters were used
if all(d in "cvbdfgert" for d in pin):
pin = pin.translate(str.maketrans("cvbdfgert", "123456789"))
if any(d not in "123456789" for d in pin): if any(d not in "123456789" for d in pin):
echo("The value may only consist of digits 1 to 9.") echo(
"The value may only consist of digits 1 to 9 or letters cvbdfgert."
)
elif len(pin) > 9: elif len(pin) > 9:
echo("The value must be at most 9 digits in length.") echo("The value must be at most 9 digits in length.")
else: else: