diff --git a/tools/pwd_reader.py b/tools/pwd_reader.py index 87416d05da..d962ceb81a 100755 --- a/tools/pwd_reader.py +++ b/tools/pwd_reader.py @@ -7,6 +7,7 @@ import json import os from urllib.parse import urlparse +from trezorlib import misc, ui from trezorlib.client import TrezorClient from trezorlib.transport import get_transport from trezorlib.tools import parse_path @@ -21,7 +22,8 @@ def getMasterKey(client): bip32_path = BIP32_PATH ENC_KEY = 'Activate TREZOR Password Manager?' ENC_VALUE = bytes.fromhex('2d650551248d792eabf628f451200d7f51cb63e46aadcbb1038aacb05e8c8aee2d650551248d792eabf628f451200d7f51cb63e46aadcbb1038aacb05e8c8aee') - key = client.encrypt_keyvalue( + key = misc.encrypt_keyvalue( + client, bip32_path, ENC_KEY, ENC_VALUE, @@ -35,7 +37,7 @@ def getMasterKey(client): def getFileEncKey(key): filekey, enckey = key[:len(key) // 2], key[len(key) // 2:] FILENAME_MESS = b'5f91add3fa1c3c76e90c90a3bd0999e2bd7833d06a483fe884ee60397aca277a' - digest = hmac.new(filekey, FILENAME_MESS, hashlib.sha256).hexdigest() + digest = hmac.new(str.encode(filekey), FILENAME_MESS, hashlib.sha256).hexdigest() filename = digest + '.pswd' return [filename, filekey, enckey] @@ -97,7 +99,8 @@ def getDecryptedNonce(client, entry): ENC_KEY = 'Unlock %s for user %s?' % (item, entry['username']) ENC_VALUE = entry['nonce'] - decrypted_nonce = client.decrypt_keyvalue( + decrypted_nonce = misc.decrypt_keyvalue( + client, BIP32_PATH, ENC_KEY, bytes.fromhex(ENC_VALUE), @@ -130,7 +133,7 @@ def main(): print(e) return - client = TrezorClient(transport) + client = TrezorClient(transport=transport, ui=ui.ClickUI()) print() print('Confirm operation on TREZOR') @@ -142,13 +145,14 @@ def main(): fileName = getFileEncKey(masterKey)[0] # print('file name:', fileName) - path = os.path.expanduser('~/Dropbox/Apps/TREZOR Password Manager/') + home = os.path.expanduser('~') + path = os.path.join(home, 'Dropbox', 'Apps', 'TREZOR Password Manager') # print('path to file:', path) encKey = getFileEncKey(masterKey)[2] # print('enckey:', encKey) - full_path = path + fileName + full_path = os.path.join(path, fileName) parsed_json = decryptStorage(full_path, encKey) # list entries diff --git a/tools/rng_entropy_collector.py b/tools/rng_entropy_collector.py index 421ecd59c9..31ec8528bd 100755 --- a/tools/rng_entropy_collector.py +++ b/tools/rng_entropy_collector.py @@ -6,13 +6,14 @@ import io import sys +from trezorlib import misc, ui from trezorlib.client import TrezorClient from trezorlib.transport import get_transport def main(): try: - client = TrezorClient(get_transport()) + client = TrezorClient(get_transport(), ui=ui.ClickUI()) except Exception as e: print(e) return @@ -23,7 +24,7 @@ def main(): with io.open(arg1, 'wb') as f: for i in range(0, arg2, step): - entropy = client.get_entropy(step) + entropy = misc.get_entropy(client, step) f.write(entropy) client.close()