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