Beispiel #1
0
def load_settings(
    label: str = None,
    use_passphrase: bool = None,
    homescreen: bytes = None,
    passphrase_always_on_device: bool = None,
    display_rotation: int = None,
) -> None:
    if label is not None:
        common.set(_NAMESPACE, _LABEL, label.encode(), True)  # public
    if use_passphrase is not None:
        common.set_bool(_NAMESPACE, _USE_PASSPHRASE, use_passphrase)
    if homescreen is not None:
        if homescreen[:8] == b"TOIf\x90\x00\x90\x00":
            if len(homescreen) <= HOMESCREEN_MAXSIZE:
                common.set(_NAMESPACE, _HOMESCREEN, homescreen, True)  # public
        else:
            common.set(_NAMESPACE, _HOMESCREEN, b"", True)  # public
    if passphrase_always_on_device is not None:
        common.set_bool(_NAMESPACE, _PASSPHRASE_ALWAYS_ON_DEVICE,
                        passphrase_always_on_device)
    if display_rotation is not None:
        if display_rotation not in (0, 90, 180, 270):
            raise ValueError("Unsupported display rotation degrees: %d" %
                             display_rotation)
        else:
            common.set(_NAMESPACE, _ROTATION,
                       display_rotation.to_bytes(2, "big"), True)  # public
Beispiel #2
0
def init_unlocked() -> None:
    # Check for storage version upgrade.
    version = device.get_version()
    if version == common.STORAGE_VERSION_01:
        _migrate_from_version_01()

    # In FWs <= 2.3.1 'version' denoted whether the device is initialized or not.
    # In 2.3.2 we have introduced a new field 'initialized' for that.
    if device.is_version_stored() and not device.is_initialized():
        common.set_bool(common.APP_DEVICE, device.INITIALIZED, True, public=True)
Beispiel #3
0
def store_mnemonic_secret(
    secret: bytes,
    backup_type: BackupType,
    needs_backup: bool = False,
    no_backup: bool = False,
) -> None:
    set_version(common.STORAGE_VERSION_CURRENT)
    common.set(_NAMESPACE, _MNEMONIC_SECRET, secret)
    common.set_uint8(_NAMESPACE, _BACKUP_TYPE, backup_type)
    common.set_true_or_delete(_NAMESPACE, _NO_BACKUP, no_backup)
    common.set_bool(_NAMESPACE, INITIALIZED, True, public=True)
    if not no_backup:
        common.set_true_or_delete(_NAMESPACE, _NEEDS_BACKUP, needs_backup)
Beispiel #4
0
def set_passphrase_always_on_device(enable: bool) -> None:
    common.set_bool(_NAMESPACE, _PASSPHRASE_ALWAYS_ON_DEVICE, enable)
Beispiel #5
0
def set_unfinished_backup(state: bool) -> None:
    common.set_bool(_NAMESPACE, _UNFINISHED_BACKUP, state)
Beispiel #6
0
def set_passphrase_enabled(enable: bool) -> None:
    common.set_bool(_NAMESPACE, _USE_PASSPHRASE, enable)
    if not enable:
        set_passphrase_always_on_device(False)
Beispiel #7
0
def set_dry_run(val: bool) -> None:
    _require_progress()
    common.set_bool(_NAMESPACE, _DRY_RUN, val)
Beispiel #8
0
def set_in_progress(val: bool) -> None:
    common.set_bool(_NAMESPACE, _IN_PROGRESS, val)
Beispiel #9
0
def set_unsafe_prompts_allowed(allowed: bool) -> None:
    common.set_bool(_NAMESPACE, _UNSAFE_PROMPTS_ALLOWED, allowed)