mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-12 08:20:56 +00:00
tools: loop on error in keyctl-proxy
This commit is contained in:
parent
81ff60c3e1
commit
132660c378
@ -30,26 +30,37 @@ def get_path(index):
|
|||||||
@Pyro4.expose
|
@Pyro4.expose
|
||||||
class KeyctlProxy(object):
|
class KeyctlProxy(object):
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(KeyctlProxy, self).__init__()
|
|
||||||
|
|
||||||
def get_commit(self, index, digest):
|
def get_commit(self, index, digest):
|
||||||
digest = serpent.tobytes(digest)
|
digest = serpent.tobytes(digest)
|
||||||
t = get_trezor()
|
|
||||||
path = get_path(index)
|
path = get_path(index)
|
||||||
print('commiting to hash %s with path %s' % (binascii.hexlify(digest).decode(), path))
|
commit = None
|
||||||
|
while commit is None:
|
||||||
|
try:
|
||||||
|
t = get_trezor()
|
||||||
|
print('\n\n\nCommiting to hash %s with path %s:' % (binascii.hexlify(digest).decode(), path))
|
||||||
commit = t.cosi_commit(t.expand_path(path), digest)
|
commit = t.cosi_commit(t.expand_path(path), digest)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
print('Trying again ...')
|
||||||
pk = commit.pubkey
|
pk = commit.pubkey
|
||||||
R = commit.commitment
|
R = commit.commitment
|
||||||
|
print('Commitment sent!')
|
||||||
return (pk, R)
|
return (pk, R)
|
||||||
|
|
||||||
def get_signature(self, index, digest, global_R, global_pk):
|
def get_signature(self, index, digest, global_R, global_pk):
|
||||||
digest, global_R, global_pk = serpent.tobytes(digest), serpent.tobytes(global_R), serpent.tobytes(global_pk)
|
digest, global_R, global_pk = serpent.tobytes(digest), serpent.tobytes(global_R), serpent.tobytes(global_pk)
|
||||||
t = get_trezor()
|
|
||||||
path = get_path(index)
|
path = get_path(index)
|
||||||
print('signing hash %s with path %s' % (binascii.hexlify(digest).decode(), path))
|
signature = None
|
||||||
|
while signature is None:
|
||||||
|
try:
|
||||||
|
t = get_trezor()
|
||||||
|
print('\n\n\nSigning hash %s with path %s:' % (binascii.hexlify(digest).decode(), path))
|
||||||
signature = t.cosi_sign(t.expand_path(path), digest, global_R, global_pk)
|
signature = t.cosi_sign(t.expand_path(path), digest, global_R, global_pk)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
print('Trying again ...')
|
||||||
sig = signature.signature
|
sig = signature.signature
|
||||||
|
print('Signature sent!')
|
||||||
return sig
|
return sig
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user