Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions ledgerblue/hostOnboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def enter_if_none_and_normalize(hint, strg):
if strg is None: # or len(string) == 0: len 0 is accepted, to specify without being bothered by a message
strg = getpass.getpass(hint)
if len(strg) != 0 :
strg = unicodedata.normalize('NFKD', u''+strg)
if isinstance(strg, bytes):
strg = strg.decode(sys.stdin.encoding)
strg = unicodedata.normalize('NFKD', strg)
return strg

if (args.id < 2):
Expand All @@ -73,22 +75,26 @@ def enter_if_none_and_normalize(hint, strg):
args.words = enter_if_none_and_normalize("Derivation phrase: ", args.words)

if args.pin:
apdudata = bytearray([len(args.pin)]) + bytearray(args.pin, 'utf8')
pin_ba = bytearray(args.pin, 'utf8')
apdudata = bytearray([len(pin_ba)]) + pin_ba
else:
apdudata = bytearray([0])

if args.prefix:
apdudata += bytearray([len(args.prefix)]) + bytearray(args.prefix, 'utf8')
prefix_ba = bytearray(args.prefix, 'utf8')
apdudata += bytearray([len(prefix_ba)]) + prefix_ba
else:
apdudata += bytearray([0])

if args.passphrase:
apdudata += bytearray([len(args.passphrase)]) + bytearray(args.passphrase, 'utf8')
passphrase_ba = bytearray(args.passphrase, 'utf8')
apdudata += bytearray([len(passphrase_ba)]) + passphrase_ba
else:
apdudata += bytearray([0])

if args.words:
apdudata += bytearray([len(args.words)]) + bytearray(args.words, 'utf8')
words_ba = bytearray(args.words, 'utf8')
apdudata += bytearray([len(words_ba)]) + words_ba
else:
apdudata += bytearray([0])

Expand Down