mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-08 14:31:06 +00:00
make flake8 happy (#225)
This commit is contained in:
parent
b24550c72f
commit
55641dd8b5
@ -18,10 +18,12 @@ except:
|
|||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClient
|
||||||
from trezorlib.transport_hid import HidTransport
|
from trezorlib.transport_hid import HidTransport
|
||||||
|
|
||||||
|
|
||||||
# Return path by BIP-32
|
# Return path by BIP-32
|
||||||
def getPath(client):
|
def getPath(client):
|
||||||
return client.expand_path("10016'/0")
|
return client.expand_path("10016'/0")
|
||||||
|
|
||||||
|
|
||||||
# Deriving master key
|
# Deriving master key
|
||||||
def getMasterKey(client):
|
def getMasterKey(client):
|
||||||
bip32_path = getPath(client)
|
bip32_path = getPath(client)
|
||||||
@ -36,6 +38,7 @@ def getMasterKey(client):
|
|||||||
))
|
))
|
||||||
return key
|
return key
|
||||||
|
|
||||||
|
|
||||||
# Deriving file name and encryption key
|
# Deriving file name and encryption key
|
||||||
def getFileEncKey(key):
|
def getFileEncKey(key):
|
||||||
filekey, enckey = key[:len(key) // 2], key[len(key) // 2:]
|
filekey, enckey = key[:len(key) // 2], key[len(key) // 2:]
|
||||||
@ -44,6 +47,7 @@ def getFileEncKey(key):
|
|||||||
filename = digest + '.pswd'
|
filename = digest + '.pswd'
|
||||||
return [filename, filekey, enckey]
|
return [filename, filekey, enckey]
|
||||||
|
|
||||||
|
|
||||||
# File level decryption and file reading
|
# File level decryption and file reading
|
||||||
def decryptStorage(path, key):
|
def decryptStorage(path, key):
|
||||||
cipherkey = unhexlify(key)
|
cipherkey = unhexlify(key)
|
||||||
@ -64,6 +68,7 @@ def decryptStorage(path, key):
|
|||||||
data = data + decryptor.finalize().decode()
|
data = data + decryptor.finalize().decode()
|
||||||
return json.loads(data)
|
return json.loads(data)
|
||||||
|
|
||||||
|
|
||||||
def decryptEntryValue(nonce, val):
|
def decryptEntryValue(nonce, val):
|
||||||
cipherkey = unhexlify(nonce)
|
cipherkey = unhexlify(nonce)
|
||||||
iv = val[:12]
|
iv = val[:12]
|
||||||
@ -83,6 +88,7 @@ def decryptEntryValue(nonce, val):
|
|||||||
data = data + decryptor.finalize().decode()
|
data = data + decryptor.finalize().decode()
|
||||||
return json.loads(data)
|
return json.loads(data)
|
||||||
|
|
||||||
|
|
||||||
# Decrypt give entry nonce
|
# Decrypt give entry nonce
|
||||||
def getDecryptedNonce(client, entry):
|
def getDecryptedNonce(client, entry):
|
||||||
print()
|
print()
|
||||||
@ -108,6 +114,7 @@ def getDecryptedNonce(client, entry):
|
|||||||
))
|
))
|
||||||
return decrypted_nonce
|
return decrypted_nonce
|
||||||
|
|
||||||
|
|
||||||
# Pretty print of list
|
# Pretty print of list
|
||||||
def printEntries(entries):
|
def printEntries(entries):
|
||||||
print('Password entries')
|
print('Password entries')
|
||||||
@ -117,7 +124,8 @@ def printEntries(entries):
|
|||||||
print('Entry id: #%s' % k)
|
print('Entry id: #%s' % k)
|
||||||
print('-------------')
|
print('-------------')
|
||||||
for kk, vv in v.items():
|
for kk, vv in v.items():
|
||||||
if kk in ['nonce', 'safe_note', 'password']: continue # skip these fields
|
if kk in ['nonce', 'safe_note', 'password']:
|
||||||
|
continue # skip these fields
|
||||||
print('*', kk, ': ', vv)
|
print('*', kk, ': ', vv)
|
||||||
print()
|
print()
|
||||||
return
|
return
|
||||||
@ -169,5 +177,6 @@ def main():
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -187,7 +187,6 @@ class TestMsgSigntxBch(TrezorTest):
|
|||||||
else:
|
else:
|
||||||
assert False # exception expected
|
assert False # exception expected
|
||||||
|
|
||||||
|
|
||||||
def test_attack_change_input(self):
|
def test_attack_change_input(self):
|
||||||
self.setup_mnemonic_allallall()
|
self.setup_mnemonic_allallall()
|
||||||
self.client.set_tx_api(TxApiBcash)
|
self.client.set_tx_api(TxApiBcash)
|
||||||
|
Loading…
Reference in New Issue
Block a user