mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
feat(core): Show path warning for SignMessage.
This commit is contained in:
parent
e559c5688b
commit
03b1b3bc6b
1
core/.changelog.d/1656.added.5
Normal file
1
core/.changelog.d/1656.added.5
Normal file
@ -0,0 +1 @@
|
||||
Show warning dialog in SignMessage if a non-standard path is used.
|
@ -8,7 +8,7 @@ from apps.common.paths import validate_path
|
||||
from apps.common.signverify import decode_message, message_digest
|
||||
|
||||
from .addresses import address_short, get_address
|
||||
from .keychain import with_keychain
|
||||
from .keychain import validate_path_against_script_type, with_keychain
|
||||
|
||||
if False:
|
||||
from trezor.messages import SignMessage
|
||||
@ -25,7 +25,9 @@ async def sign_message(
|
||||
address_n = msg.address_n
|
||||
script_type = msg.script_type or InputScriptType.SPENDADDRESS
|
||||
|
||||
await validate_path(ctx, keychain, address_n)
|
||||
await validate_path(
|
||||
ctx, keychain, address_n, validate_path_against_script_type(coin, msg)
|
||||
)
|
||||
|
||||
node = keychain.derive(address_n)
|
||||
address = get_address(script_type, coin, node)
|
||||
|
@ -350,3 +350,28 @@ def test_signmessage_pagination_trailing_newline(client):
|
||||
n=parse_path("m/44h/0h/0h/0/0"),
|
||||
message=message,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_signmessage_path_warning(client):
|
||||
message = "This is an example of a signed message."
|
||||
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
# expect a path warning
|
||||
message_filters.ButtonRequest(
|
||||
code=messages.ButtonRequestType.UnknownDerivationPath
|
||||
),
|
||||
message_filters.ButtonRequest(code=messages.ButtonRequestType.Other),
|
||||
message_filters.ButtonRequest(code=messages.ButtonRequestType.Other),
|
||||
messages.MessageSignature,
|
||||
]
|
||||
)
|
||||
btc.sign_message(
|
||||
client,
|
||||
coin_name="Bitcoin",
|
||||
n=parse_path("m/86h/0h/0h/0/0"),
|
||||
message=message,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
)
|
||||
|
@ -576,6 +576,7 @@
|
||||
"test_msg_signmessage.py::test_signmessage_pagination[utf_nospace]": "9a36cae6e21029e403b4f30ec88fc6da92ac8643b2c63ad7da7b7bc57ecc106b",
|
||||
"test_msg_signmessage.py::test_signmessage_pagination[utf_text]": "4ac1d8e2491164d442b700ea65e430867d74a941ac0d0dc8d4f51f4494fd0bb0",
|
||||
"test_msg_signmessage.py::test_signmessage_pagination_trailing_newline": "3ecd60468981b8c59cae21ae1189ad42b9d69b87e86c17e51b40185e31a5c52d",
|
||||
"test_msg_signmessage.py::test_signmessage_path_warning": "2c8369a05493ccdd6a368f3428050f22fc5aa42cf5c34e4995c47c3c7bf764fc",
|
||||
"test_msg_signtx.py-test_attack_change_input_address": "5f230e46301f0af85b5c40944cae1a8e4d3fc576fb19d7b7374decb463c8be62",
|
||||
"test_msg_signtx.py-test_attack_change_outputs": "2e8e05aa366da0ce2990a2b8b76f13973af8eaa11ec0cb5591412a9a5ba48da4",
|
||||
"test_msg_signtx.py-test_attack_modify_change_address": "72b96c639ac76ecccbe5d710a1c84eba6711879c329952b18ffab385ca79bafd",
|
||||
@ -789,8 +790,8 @@
|
||||
"test_nonstandard_paths.py::test_getpublicnode[m-3'-100'-4-255-script_types1]": "c09de07fbbf1e047442180e2facb5482d06a1a428891b875b7dd93c9e4704ae1",
|
||||
"test_nonstandard_paths.py::test_getpublicnode[m-4-255-script_types0]": "c09de07fbbf1e047442180e2facb5482d06a1a428891b875b7dd93c9e4704ae1",
|
||||
"test_nonstandard_paths.py::test_getpublicnode[m-49-0-63-0-255-script_types4]": "c09de07fbbf1e047442180e2facb5482d06a1a428891b875b7dd93c9e4704ae1",
|
||||
"test_nonstandard_paths.py::test_signmessage[m-1195487518-6-255-script_types3]": "da9682c495ea2cdc7513404ed533461de199d5abde5e2d269acb99c013debfb3",
|
||||
"test_nonstandard_paths.py::test_signmessage[m-1195487518-script_types2]": "4a625dc911357f101240d0a39c8e7091a0f0ae684ff3796ef32a36021f5c9d45",
|
||||
"test_nonstandard_paths.py::test_signmessage[m-1195487518-6-255-script_types3]": "7ac64354602a89c0a47419e224db81a059dd103a66959c94789fd787dd4c69ee",
|
||||
"test_nonstandard_paths.py::test_signmessage[m-1195487518-script_types2]": "976f9c147269fc68beef182cd8efeb35422147f30fe24369b43021c1e68b9d8e",
|
||||
"test_nonstandard_paths.py::test_signmessage[m-3'-100'-4-255-script_types1]": "4f73135d2ec9add695e0a22d855816558b4ba9329a2828f9c9930be6245bdc2d",
|
||||
"test_nonstandard_paths.py::test_signmessage[m-4-255-script_types0]": "0988cc8bdc5879744bd33190fddc5b5aa137fdd7214abb003c8000a871d98f14",
|
||||
"test_nonstandard_paths.py::test_signmessage[m-49-0-63-0-255-script_types4]": "540df94c73a4eed8fe88cdb475e2b31df752dca9e47b102792c01064ee432752",
|
||||
|
Loading…
Reference in New Issue
Block a user