From e51fb2078fe17742d4cfd5e2b4161999689fa96f Mon Sep 17 00:00:00 2001 From: Jochen Hoenicke Date: Sun, 12 Jun 2016 23:49:52 +0200 Subject: [PATCH] new message SetU2FCounter --- trezorctl | 9 +++++++++ trezorlib/client.py | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/trezorctl b/trezorctl index 644e85802..0e84e0ed5 100755 --- a/trezorctl +++ b/trezorctl @@ -288,6 +288,10 @@ class Commands(object): ret = self.client.decrypt_keyvalue(address_n, args.key, args.value.decode("hex")) return ret + def set_u2f_counter(self, args): + ret = self.client.set_u2f_counter(args.counter) + return ret + def firmware_update(self, args): import requests if args.file: @@ -343,6 +347,7 @@ class Commands(object): decrypt_message.help = 'Decrypt message' encrypt_keyvalue.help = 'Encrypt value by given key and path' decrypt_keyvalue.help = 'Decrypt value by given key and path' + set_u2f_counter.help = 'Set U2F counter' firmware_update.help = 'Upload new firmware to device (must be in bootloader mode)' get_address.arguments = ( @@ -460,6 +465,10 @@ class Commands(object): (('-d', '--show-display'), {'action': 'store_true', 'default': False}), ) + set_u2f_counter.arguments = ( + (('counter',), {'type': int}), + ) + firmware_update.arguments = ( (('-f', '--file'), {'type': str}), (('-u', '--url'), {'type': str}), diff --git a/trezorlib/client.py b/trezorlib/client.py index a06fdc58d..9bf1c5daf 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -512,6 +512,12 @@ class ProtocolMixin(object): def get_ecdh_session_key(self, identity, peer_public_key, ecdsa_curve_name=DEFAULT_CURVE): return self.call(proto.GetECDHSessionKey(identity=identity, peer_public_key=peer_public_key, ecdsa_curve_name=ecdsa_curve_name)) + @field('message') + @expect(proto.Success) + def set_u2f_counter(self, u2f_counter): + ret = self.call(proto.SetU2FCounter(u2f_counter = u2f_counter)) + return ret + def verify_message(self, address, signature, message): # Convert message to UTF8 NFC (seems to be a bitcoin-qt standard) message = normalize_nfc(message)