load_device moved to debuglink

This commit is contained in:
slush 2013-02-18 18:45:33 +01:00
parent 235aaf7768
commit 43c2d9b042
2 changed files with 13 additions and 3 deletions

View File

@ -235,11 +235,16 @@ class BitkeyClient(object):
'''
def reset_device(self):
# Begin with device reset workflow
resp = self.call(proto.ResetDevice(random=self._get_local_entropy()))
self.init_device()
return isinstance(resp, proto.Success)
def load_device(self, seed, otp, pin, spv):
resp = self.call(proto.LoadDevice(seed=seed, otp=otp, pin=pin, spv=spv))
if not self.debuglink:
raise Exception("DebugLink not available")
if not self.debuglink.load_device(seed, otp, pin, spv):
return False
self.init_device()
return isinstance(resp, proto.Success)
return True

View File

@ -21,7 +21,12 @@ class DebugLink(object):
def get_state(self, otp=False, pin=False):
self.transport.write(proto.DebugLinkGetState(otp=otp, pin=pin))
return self.transport.read_blocking()
def load_device(self, seed, otp, pin, spv):
self.transport.write(proto.LoadDevice(seed=seed, otp=otp, pin=pin, spv=spv))
resp = self.transport.read_blocking()
return isinstance(resp, proto.Success)
def read_otp(self):
obj = self.get_state(otp=True).otp
print "Read OTP:", obj.otp