You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.0 KiB
76 lines
2.0 KiB
6 years ago
|
#!/usr/bin/env python3
|
||
|
|
||
|
# This file is part of the Trezor project.
|
||
|
#
|
||
5 years ago
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
||
6 years ago
|
#
|
||
|
# This library is free software: you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU Lesser General Public License version 3
|
||
|
# as published by the Free Software Foundation.
|
||
|
#
|
||
|
# This library is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU Lesser General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the License along with this library.
|
||
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||
|
|
||
|
import os
|
||
|
import random
|
||
|
import string
|
||
|
|
||
6 years ago
|
from trezorlib import device
|
||
6 years ago
|
from trezorlib.debuglink import TrezorClientDebugLink
|
||
|
from trezorlib.transport import enumerate_devices, get_transport
|
||
|
|
||
|
|
||
|
def get_device():
|
||
|
path = os.environ.get("TREZOR_PATH")
|
||
|
if path:
|
||
|
return get_transport(path)
|
||
|
else:
|
||
|
devices = enumerate_devices()
|
||
6 years ago
|
for d in devices:
|
||
|
if hasattr(d, "find_debug"):
|
||
|
return d
|
||
6 years ago
|
raise RuntimeError("No debuggable device found")
|
||
|
|
||
|
|
||
6 years ago
|
def pin_input_flow(client, old_pin, new_pin):
|
||
|
# do you want to change pin?
|
||
|
yield
|
||
|
client.debug.press_yes()
|
||
|
if old_pin is not None:
|
||
|
# enter old pin
|
||
|
yield
|
||
|
client.debug.input(old_pin)
|
||
|
# enter new pin
|
||
|
yield
|
||
|
client.debug.input(new_pin)
|
||
|
# repeat new pin
|
||
|
yield
|
||
|
client.debug.input(new_pin)
|
||
|
|
||
|
|
||
6 years ago
|
if __name__ == "__main__":
|
||
|
wirelink = get_device()
|
||
|
client = TrezorClientDebugLink(wirelink)
|
||
|
client.open()
|
||
|
|
||
|
i = 0
|
||
|
|
||
6 years ago
|
last_pin = None
|
||
|
|
||
6 years ago
|
while True:
|
||
|
# set private field
|
||
6 years ago
|
device.apply_settings(client, auto_lock_delay_ms=(i % 10 + 10) * 1000)
|
||
6 years ago
|
|
||
|
# set public field
|
||
|
label = "".join(random.choices(string.ascii_uppercase + string.digits, k=17))
|
||
|
device.apply_settings(client, label=label)
|
||
|
assert client.features.label == label
|
||
|
|
||
|
print("iteration %d" % i)
|
||
|
i = i + 1
|