mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-29 10:58:21 +00:00
Fix PIN handling
This commit is contained in:
parent
cb594df790
commit
6fe26c26e4
@ -17,9 +17,6 @@ class CallException(Exception):
|
||||
class PinException(CallException):
|
||||
pass
|
||||
|
||||
class OtpException(CallException):
|
||||
pass
|
||||
|
||||
class BitkeyClient(object):
|
||||
|
||||
def __init__(self, transport, debuglink=None,
|
||||
@ -80,10 +77,10 @@ class BitkeyClient(object):
|
||||
if isinstance(resp, proto.PinMatrixRequest):
|
||||
if self.debuglink:
|
||||
if self.debug_pin:
|
||||
pin = self.debuglink.read_pin()
|
||||
pin = self.debuglink.read_pin_encoded()
|
||||
msg2 = proto.PinMatrixAck(pin=pin)
|
||||
else:
|
||||
msg2 = proto.PinMatrixAck(pin='__42__')
|
||||
msg2 = proto.PinMatrixAck(pin='444444222222')
|
||||
else:
|
||||
pin = self.input_func("PIN required: ", resp.message)
|
||||
msg2 = proto.PinMatrixAck(pin=pin)
|
||||
@ -106,6 +103,9 @@ class BitkeyClient(object):
|
||||
|
||||
return resp
|
||||
|
||||
def ping(self, msg):
|
||||
return self.call(proto.Ping(message=msg)).message
|
||||
|
||||
def get_uuid(self):
|
||||
return self.call(proto.GetUUID()).UUID
|
||||
|
||||
|
@ -20,11 +20,16 @@ class DebugLink(object):
|
||||
print "Read PIN:", obj.pin
|
||||
print "Read matrix:", obj.matrix
|
||||
|
||||
return (obj.pin, obj.matrix)
|
||||
|
||||
def read_pin_encoded(self):
|
||||
pin, matrix = self.read_pin()
|
||||
|
||||
# Now we have real PIN and PIN matrix.
|
||||
# We have to encode that into encoded pin,
|
||||
# because application must send back positions
|
||||
# on keypad, not a real PIN.
|
||||
pin_encoded = ''.join([ str(obj.matrix.index(p) + 1) for p in obj.pin])
|
||||
pin_encoded = ''.join([ str(matrix.index(p) + 1) for p in pin])
|
||||
|
||||
print "Encoded PIN:", pin_encoded
|
||||
self.pin_func(pin_encoded)
|
||||
|
Loading…
Reference in New Issue
Block a user