mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-18 10:32:02 +00:00
flake8: fix complaints
This commit is contained in:
parent
46307cc4ba
commit
23b58cc0cb
4
.flake8
4
.flake8
@ -19,4 +19,6 @@ ignore =
|
|||||||
# E722: do not use bare except
|
# E722: do not use bare except
|
||||||
E722,
|
E722,
|
||||||
# E741: ambiguous variable name
|
# E741: ambiguous variable name
|
||||||
E741
|
E741,
|
||||||
|
##### E266: too many leading '#' for block comment
|
||||||
|
E266,
|
||||||
|
@ -460,7 +460,6 @@ class ProtocolMixin(object):
|
|||||||
def clear_session(self):
|
def clear_session(self):
|
||||||
return self.call(proto.ClearSession())
|
return self.call(proto.ClearSession())
|
||||||
|
|
||||||
|
|
||||||
# Device functionality
|
# Device functionality
|
||||||
self_test = MovedTo(device.self_test)
|
self_test = MovedTo(device.self_test)
|
||||||
|
|
||||||
@ -516,7 +515,7 @@ class ProtocolMixin(object):
|
|||||||
stellar_get_address = MovedTo(stellar.get_address)
|
stellar_get_address = MovedTo(stellar.get_address)
|
||||||
stellar_sign_transaction = MovedTo(stellar.sign_tx)
|
stellar_sign_transaction = MovedTo(stellar.sign_tx)
|
||||||
|
|
||||||
# Miscellaneous cryptography
|
# Miscellaneous cryptographic functionality
|
||||||
get_entropy = MovedTo(misc.get_entropy)
|
get_entropy = MovedTo(misc.get_entropy)
|
||||||
sign_identity = MovedTo(misc.sign_identity)
|
sign_identity = MovedTo(misc.sign_identity)
|
||||||
get_ecdh_session_key = MovedTo(misc.get_ecdh_session_key)
|
get_ecdh_session_key = MovedTo(misc.get_ecdh_session_key)
|
||||||
|
@ -183,10 +183,10 @@ def load_device_by_mnemonic(client, mnemonic, pin, passphrase_protection, label,
|
|||||||
raise RuntimeError("Device is initialized already. Call wipe_device() and try again.")
|
raise RuntimeError("Device is initialized already. Call wipe_device() and try again.")
|
||||||
|
|
||||||
resp = client.call(proto.LoadDevice(mnemonic=mnemonic, pin=pin,
|
resp = client.call(proto.LoadDevice(mnemonic=mnemonic, pin=pin,
|
||||||
passphrase_protection=passphrase_protection,
|
passphrase_protection=passphrase_protection,
|
||||||
language=language,
|
language=language,
|
||||||
label=label,
|
label=label,
|
||||||
skip_checksum=skip_checksum))
|
skip_checksum=skip_checksum))
|
||||||
client.init_device()
|
client.init_device()
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@ -228,10 +228,10 @@ def load_device_by_xprv(client, xprv, pin, passphrase_protection, label, languag
|
|||||||
node.private_key = binascii.unhexlify(data[92:156]) # skip 0x00 indicating privkey
|
node.private_key = binascii.unhexlify(data[92:156]) # skip 0x00 indicating privkey
|
||||||
|
|
||||||
resp = client.call(proto.LoadDevice(node=node,
|
resp = client.call(proto.LoadDevice(node=node,
|
||||||
pin=pin,
|
pin=pin,
|
||||||
passphrase_protection=passphrase_protection,
|
passphrase_protection=passphrase_protection,
|
||||||
language=language,
|
language=language,
|
||||||
label=label))
|
label=label))
|
||||||
client.init_device()
|
client.init_device()
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ def update(client, fp):
|
|||||||
|
|
||||||
# TREZORv1 method
|
# TREZORv1 method
|
||||||
if isinstance(resp, proto.Success):
|
if isinstance(resp, proto.Success):
|
||||||
fingerprint = hashlib.sha256(data[256:]).hexdigest()
|
# fingerprint = hashlib.sha256(data[256:]).hexdigest()
|
||||||
# LOG.debug("Firmware fingerprint: " + fingerprint)
|
# LOG.debug("Firmware fingerprint: " + fingerprint)
|
||||||
resp = client.call(proto.FirmwareUpload(payload=data))
|
resp = client.call(proto.FirmwareUpload(payload=data))
|
||||||
if isinstance(resp, proto.Success):
|
if isinstance(resp, proto.Success):
|
||||||
|
@ -12,6 +12,7 @@ def get_entropy(client, size):
|
|||||||
def sign_identity(client, identity, challenge_hidden, challenge_visual, ecdsa_curve_name=None):
|
def sign_identity(client, identity, challenge_hidden, challenge_visual, ecdsa_curve_name=None):
|
||||||
return client.call(proto.SignIdentity(identity=identity, challenge_hidden=challenge_hidden, challenge_visual=challenge_visual, ecdsa_curve_name=ecdsa_curve_name))
|
return client.call(proto.SignIdentity(identity=identity, challenge_hidden=challenge_hidden, challenge_visual=challenge_visual, ecdsa_curve_name=ecdsa_curve_name))
|
||||||
|
|
||||||
|
|
||||||
@expect(proto.ECDHSessionKey)
|
@expect(proto.ECDHSessionKey)
|
||||||
def get_ecdh_session_key(client, identity, peer_public_key, ecdsa_curve_name=None):
|
def get_ecdh_session_key(client, identity, peer_public_key, ecdsa_curve_name=None):
|
||||||
return client.call(proto.GetECDHSessionKey(identity=identity, peer_public_key=peer_public_key, ecdsa_curve_name=ecdsa_curve_name))
|
return client.call(proto.GetECDHSessionKey(identity=identity, peer_public_key=peer_public_key, ecdsa_curve_name=ecdsa_curve_name))
|
||||||
@ -22,22 +23,22 @@ def get_ecdh_session_key(client, identity, peer_public_key, ecdsa_curve_name=Non
|
|||||||
def encrypt_keyvalue(client, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=b''):
|
def encrypt_keyvalue(client, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=b''):
|
||||||
n = client._convert_prime(n)
|
n = client._convert_prime(n)
|
||||||
return client.call(proto.CipherKeyValue(address_n=n,
|
return client.call(proto.CipherKeyValue(address_n=n,
|
||||||
key=key,
|
key=key,
|
||||||
value=value,
|
value=value,
|
||||||
encrypt=True,
|
encrypt=True,
|
||||||
ask_on_encrypt=ask_on_encrypt,
|
ask_on_encrypt=ask_on_encrypt,
|
||||||
ask_on_decrypt=ask_on_decrypt,
|
ask_on_decrypt=ask_on_decrypt,
|
||||||
iv=iv))
|
iv=iv))
|
||||||
|
|
||||||
|
|
||||||
@field('value')
|
@field('value')
|
||||||
@expect(proto.CipheredKeyValue)
|
@expect(proto.CipheredKeyValue)
|
||||||
def decrypt_keyvalue(client, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=b''):
|
def decrypt_keyvalue(client, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=b''):
|
||||||
n = client._convert_prime(n)
|
n = client._convert_prime(n)
|
||||||
return client.call(proto.CipherKeyValue(address_n=n,
|
return client.call(proto.CipherKeyValue(address_n=n,
|
||||||
key=key,
|
key=key,
|
||||||
value=value,
|
value=value,
|
||||||
encrypt=False,
|
encrypt=False,
|
||||||
ask_on_encrypt=ask_on_encrypt,
|
ask_on_encrypt=ask_on_encrypt,
|
||||||
ask_on_decrypt=ask_on_decrypt,
|
ask_on_decrypt=ask_on_decrypt,
|
||||||
iv=iv))
|
iv=iv))
|
||||||
|
|
||||||
|
@ -188,4 +188,3 @@ def sign_tx(client, n, transaction):
|
|||||||
assert msg.transaction is not None
|
assert msg.transaction is not None
|
||||||
msg.transaction.address_n = n
|
msg.transaction.address_n = n
|
||||||
return client.call(msg)
|
return client.call(msg)
|
||||||
|
|
||||||
|
@ -162,7 +162,6 @@ def parse_path(nstr: str) -> Address:
|
|||||||
raise ValueError('Invalid BIP32 path', nstr)
|
raise ValueError('Invalid BIP32 path', nstr)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def normalize_nfc(txt):
|
def normalize_nfc(txt):
|
||||||
'''
|
'''
|
||||||
Normalize message to NFC and return bytes suitable for protobuf.
|
Normalize message to NFC and return bytes suitable for protobuf.
|
||||||
|
Loading…
Reference in New Issue
Block a user