mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-17 01:52:02 +00:00
core/slip39: do not populate MnemonicError's message; do not throw exceptions with mnemonic inside the message
This commit is contained in:
parent
4f8022c5cd
commit
c205acd3e1
@ -77,7 +77,7 @@ async def recovery_device(ctx, msg):
|
|||||||
try:
|
try:
|
||||||
secret = mnemonic_module.process_all(mnemonics)
|
secret = mnemonic_module.process_all(mnemonics)
|
||||||
except slip39.MnemonicError as e:
|
except slip39.MnemonicError as e:
|
||||||
raise wire.ProcessError("Mnemonic is not valid: " + str(e))
|
raise wire.ProcessError("Mnemonic is not valid")
|
||||||
# show a number of remaining mnemonics for SLIP39
|
# show a number of remaining mnemonics for SLIP39
|
||||||
if secret is None and mnemonic_module == mnemonic.slip39:
|
if secret is None and mnemonic_module == mnemonic.slip39:
|
||||||
await show_remaining_slip39_mnemonics(ctx, title, remaining)
|
await show_remaining_slip39_mnemonics(ctx, title, remaining)
|
||||||
|
@ -365,11 +365,7 @@ def decode_mnemonic(mnemonic):
|
|||||||
raise MnemonicError("Invalid mnemonic length.")
|
raise MnemonicError("Invalid mnemonic length.")
|
||||||
|
|
||||||
if not rs1024_verify_checksum(mnemonic_data):
|
if not rs1024_verify_checksum(mnemonic_data):
|
||||||
raise MnemonicError(
|
raise MnemonicError("Invalid mnemonic checksum.")
|
||||||
'Invalid mnemonic checksum for "{} ...".'.format(
|
|
||||||
" ".join(mnemonic.split()[: _ID_EXP_LENGTH_WORDS + 2])
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
id_exp_int = _int_from_indices(mnemonic_data[:_ID_EXP_LENGTH_WORDS])
|
id_exp_int = _int_from_indices(mnemonic_data[:_ID_EXP_LENGTH_WORDS])
|
||||||
identifier = id_exp_int >> _ITERATION_EXP_LENGTH_BITS
|
identifier = id_exp_int >> _ITERATION_EXP_LENGTH_BITS
|
||||||
@ -384,19 +380,13 @@ def decode_mnemonic(mnemonic):
|
|||||||
|
|
||||||
if group_count < group_threshold:
|
if group_count < group_threshold:
|
||||||
raise MnemonicError(
|
raise MnemonicError(
|
||||||
'Invalid mnemonic "{} ...". Group threshold cannot be greater than group count.'.format(
|
"Invalid mnemonic. Group threshold cannot be greater than group count."
|
||||||
" ".join(mnemonic.split()[: _ID_EXP_LENGTH_WORDS + 2])
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
value_byte_count = bits_to_bytes(_RADIX_BITS * len(value_data) - padding_len)
|
value_byte_count = bits_to_bytes(_RADIX_BITS * len(value_data) - padding_len)
|
||||||
value_int = _int_from_indices(value_data)
|
value_int = _int_from_indices(value_data)
|
||||||
if value_data[0] >= 1 << (_RADIX_BITS - padding_len):
|
if value_data[0] >= 1 << (_RADIX_BITS - padding_len):
|
||||||
raise MnemonicError(
|
raise MnemonicError("Invalid mnemonic padding")
|
||||||
'Invalid mnemonic padding for "{} ...".'.format(
|
|
||||||
" ".join(mnemonic.split()[: _ID_EXP_LENGTH_WORDS + 2])
|
|
||||||
)
|
|
||||||
)
|
|
||||||
value = value_int.to_bytes(value_byte_count, "big")
|
value = value_int.to_bytes(value_byte_count, "big")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -612,8 +602,8 @@ def combine_mnemonics(mnemonics):
|
|||||||
group_count,
|
group_count,
|
||||||
)
|
)
|
||||||
raise MnemonicError(
|
raise MnemonicError(
|
||||||
'Wrong number of mnemonics. Expected {} mnemonics starting with "{} ...", but {} were provided.'.format(
|
"Wrong number of mnemonics. Expected {} mnemonics, but {} were provided.".format(
|
||||||
group[0], mnemonic_from_indices(prefix), len(group[1])
|
group[0], len(group[1])
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user