From 86a46933b5175daee9dfe88462d8928483829097 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Thu, 6 Nov 2014 19:09:53 -0500 Subject: [PATCH] Use getpass('') and confirm passphrase Added getpass as a dependency Switched pin entry from raw_input() to getpass.getpass('') Switch passphrase entry from raw_input() to getpass.getpass('') Ask user to confirm passphrase --- trezorlib/client.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/trezorlib/client.py b/trezorlib/client.py index 589fdbaee..af451965a 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -6,6 +6,7 @@ import hashlib import unicodedata import mapping import json +import getpass import tools import messages_pb2 as proto @@ -165,15 +166,19 @@ class TextUIMixin(object): desc = 'PIN' log("Please enter %s: " % desc) - pin = raw_input() + pin = getpass.getpass('') return proto.PinMatrixAck(pin=pin) def callback_PassphraseRequest(self, msg): log("Passphrase required: ") - passphrase = raw_input() - passphrase = unicode(str(bytearray(passphrase, 'utf-8')), 'utf-8') - - return proto.PassphraseAck(passphrase=passphrase) + passphrase = getpass.getpass('') + log("Confirm your Passphrase: ") + if passphrase == getpass(''): + passphrase = unicode(str(bytearray(passphrase, 'utf-8')), 'utf-8') + return proto.PassphraseAck(passphrase=passphrase) + else: + log("Passphrase did not match! ") + exit() def callback_WordRequest(self, msg): log("Enter one word of mnemonic: ")