2017-06-14 17:27:02 +00:00
|
|
|
from typing import *
|
2017-06-14 15:41:45 +00:00
|
|
|
|
|
|
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
2019-02-27 10:30:58 +00:00
|
|
|
def init(ui_wait_callback: (int, int -> None)=None) -> None:
|
2017-06-14 15:41:45 +00:00
|
|
|
'''
|
2018-01-26 13:28:49 +00:00
|
|
|
Initializes the storage. Must be called before any other method is
|
|
|
|
called from this module!
|
2017-06-14 15:41:45 +00:00
|
|
|
'''
|
|
|
|
|
2017-06-20 11:24:12 +00:00
|
|
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
2019-02-27 10:30:58 +00:00
|
|
|
def check_pin(pin: int) -> bool:
|
2018-03-09 10:37:06 +00:00
|
|
|
'''
|
|
|
|
Check the given PIN. Returns True on success, False on failure.
|
|
|
|
'''
|
|
|
|
|
|
|
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
2019-02-27 10:30:58 +00:00
|
|
|
def unlock(pin: int) -> bool:
|
2018-01-26 13:28:49 +00:00
|
|
|
'''
|
|
|
|
Attempts to unlock the storage with given PIN. Returns True on
|
|
|
|
success, False on failure.
|
|
|
|
'''
|
|
|
|
|
2019-02-27 10:30:58 +00:00
|
|
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
|
|
|
def lock() -> None:
|
|
|
|
'''
|
|
|
|
Locks the storage.
|
|
|
|
'''
|
|
|
|
|
2018-01-26 13:28:49 +00:00
|
|
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
|
|
|
def has_pin() -> bool:
|
|
|
|
'''
|
|
|
|
Returns True if storage has a configured PIN, False otherwise.
|
|
|
|
'''
|
|
|
|
|
|
|
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
2019-02-27 10:30:58 +00:00
|
|
|
def get_pin_rem() -> int:
|
|
|
|
'''
|
|
|
|
Returns the number of remaining PIN entry attempts.
|
|
|
|
'''
|
|
|
|
|
|
|
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
|
|
|
def change_pin(pin: int, newpin: int) -> bool:
|
2018-01-26 13:28:49 +00:00
|
|
|
'''
|
|
|
|
Change PIN. Returns True on success, False on failure.
|
|
|
|
'''
|
|
|
|
|
|
|
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
|
|
|
def get(app: int, key: int, public: bool=False) -> bytes:
|
2017-06-20 11:24:12 +00:00
|
|
|
'''
|
2019-02-27 10:30:58 +00:00
|
|
|
Gets the value of the given key for the given app (or None if not set).
|
|
|
|
Raises a RuntimeError if decryption or authentication of the stored value fails.
|
2017-06-20 11:24:12 +00:00
|
|
|
'''
|
2017-06-14 15:41:45 +00:00
|
|
|
|
2017-06-20 11:24:12 +00:00
|
|
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
2018-01-26 13:28:49 +00:00
|
|
|
def set(app: int, key: int, value: bytes, public: bool=False) -> None:
|
2017-06-20 11:24:12 +00:00
|
|
|
'''
|
|
|
|
Sets a value of given key for given app.
|
|
|
|
'''
|
2017-06-14 15:41:45 +00:00
|
|
|
|
2019-02-27 10:30:58 +00:00
|
|
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
|
|
|
def delete(app: int, key: int, public: bool=False) -> bool:
|
|
|
|
'''
|
|
|
|
Deletes the given key of the given app.
|
|
|
|
'''
|
|
|
|
|
|
|
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
|
|
|
def set_counter(app: int, key: int, count: int, writable_locked: bool=False) -> bool:
|
|
|
|
'''
|
|
|
|
Sets the given key of the given app as a counter with the given value.
|
|
|
|
'''
|
|
|
|
|
|
|
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
|
|
|
def next_counter(app: int, key: int, writable_locked: bool=False) -> bool:
|
|
|
|
'''
|
|
|
|
Increments the counter stored under the given key of the given app and returns the new value.
|
|
|
|
'''
|
|
|
|
|
2017-06-20 11:24:12 +00:00
|
|
|
# extmod/modtrezorconfig/modtrezorconfig.c
|
2018-01-26 13:28:49 +00:00
|
|
|
def wipe() -> None:
|
2017-06-20 11:24:12 +00:00
|
|
|
'''
|
|
|
|
Erases the whole config. Use with caution!
|
|
|
|
'''
|