1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 20:19:23 +00:00

load_device_by_mnemonic: normalize mnemonic before validation (#95)

This commit is contained in:
mruddy 2017-02-09 08:25:32 -05:00 committed by Pavol Rusnak
parent 03272b6170
commit de94bf2247

View File

@ -859,16 +859,16 @@ class ProtocolMixin(object):
@field('message')
@expect(proto.Success)
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
mnemonic = Mnemonic.normalize_string(mnemonic)
# Convert mnemonic to ASCII stream
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:
raise Exception("Device is initialized already. Call wipe_device() and try again.")