mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-06 14:52:33 +00:00
load_device_by_mnemonic: normalize mnemonic before validation (#95)
This commit is contained in:
parent
03272b6170
commit
de94bf2247
@ -859,16 +859,16 @@ class ProtocolMixin(object):
|
|||||||
@field('message')
|
@field('message')
|
||||||
@expect(proto.Success)
|
@expect(proto.Success)
|
||||||
def load_device_by_mnemonic(self, mnemonic, pin, passphrase_protection, label, language, skip_checksum=False):
|
def load_device_by_mnemonic(self, mnemonic, pin, passphrase_protection, label, language, skip_checksum=False):
|
||||||
m = Mnemonic('english')
|
|
||||||
if not skip_checksum and not m.check(mnemonic):
|
|
||||||
raise Exception("Invalid mnemonic checksum")
|
|
||||||
|
|
||||||
# Convert mnemonic to UTF8 NKFD
|
# Convert mnemonic to UTF8 NKFD
|
||||||
mnemonic = Mnemonic.normalize_string(mnemonic)
|
mnemonic = Mnemonic.normalize_string(mnemonic)
|
||||||
|
|
||||||
# Convert mnemonic to ASCII stream
|
# Convert mnemonic to ASCII stream
|
||||||
mnemonic = normalize_nfc(mnemonic)
|
mnemonic = normalize_nfc(mnemonic)
|
||||||
|
|
||||||
|
m = Mnemonic('english')
|
||||||
|
if not skip_checksum and not m.check(mnemonic):
|
||||||
|
raise Exception("Invalid mnemonic checksum")
|
||||||
|
|
||||||
if self.features.initialized:
|
if self.features.initialized:
|
||||||
raise Exception("Device is initialized already. Call wipe_device() and try again.")
|
raise Exception("Device is initialized already. Call wipe_device() and try again.")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user