mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-17 01:52:02 +00:00
use Mnemonic.normalize_string where possible
This commit is contained in:
parent
9e068ce903
commit
0d9ee4376d
@ -173,7 +173,6 @@ def normalize_nfc(txt):
|
|||||||
return unicodedata.normalize('NFC', txt.decode('utf-8'))
|
return unicodedata.normalize('NFC', txt.decode('utf-8'))
|
||||||
if isinstance(txt, str):
|
if isinstance(txt, str):
|
||||||
return unicodedata.normalize('NFC', txt)
|
return unicodedata.normalize('NFC', txt)
|
||||||
|
|
||||||
raise ValueError('unicode/str or bytes/str expected')
|
raise ValueError('unicode/str or bytes/str expected')
|
||||||
|
|
||||||
|
|
||||||
@ -285,7 +284,7 @@ class TextUIMixin(object):
|
|||||||
passphrase = getpass.getpass('')
|
passphrase = getpass.getpass('')
|
||||||
log("Confirm your Passphrase: ")
|
log("Confirm your Passphrase: ")
|
||||||
if passphrase == getpass.getpass(''):
|
if passphrase == getpass.getpass(''):
|
||||||
passphrase = normalize_nfc(passphrase)
|
passphrase = Mnemonic.normalize_string(passphrase)
|
||||||
return proto.PassphraseAck(passphrase=passphrase)
|
return proto.PassphraseAck(passphrase=passphrase)
|
||||||
else:
|
else:
|
||||||
log("Passphrase did not match! ")
|
log("Passphrase did not match! ")
|
||||||
@ -372,10 +371,10 @@ class DebugLinkMixin(object):
|
|||||||
self.pin_correct = pin_correct
|
self.pin_correct = pin_correct
|
||||||
|
|
||||||
def set_passphrase(self, passphrase):
|
def set_passphrase(self, passphrase):
|
||||||
self.passphrase = normalize_nfc(passphrase)
|
self.passphrase = Mnemonic.normalize_string(passphrase)
|
||||||
|
|
||||||
def set_mnemonic(self, mnemonic):
|
def set_mnemonic(self, mnemonic):
|
||||||
self.mnemonic = normalize_nfc(mnemonic).split(' ')
|
self.mnemonic = Mnemonic.normalize_string(mnemonic).split(' ')
|
||||||
|
|
||||||
def call_raw(self, msg):
|
def call_raw(self, msg):
|
||||||
|
|
||||||
@ -1036,7 +1035,7 @@ class ProtocolMixin(object):
|
|||||||
raise RuntimeError("Invalid response, expected EntropyRequest")
|
raise RuntimeError("Invalid response, expected EntropyRequest")
|
||||||
|
|
||||||
external_entropy = self._get_local_entropy()
|
external_entropy = self._get_local_entropy()
|
||||||
log("Computer generated entropy: " + binascii.hexlify(external_entropy).decode('ascii'))
|
log("Computer generated entropy: " + binascii.hexlify(external_entropy).decode())
|
||||||
ret = self.call(proto.EntropyAck(entropy=external_entropy))
|
ret = self.call(proto.EntropyAck(entropy=external_entropy))
|
||||||
self.init_device()
|
self.init_device()
|
||||||
return ret
|
return ret
|
||||||
@ -1054,7 +1053,7 @@ class ProtocolMixin(object):
|
|||||||
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 = mnemonic.decode()
|
||||||
|
|
||||||
m = Mnemonic('english')
|
m = Mnemonic('english')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user