Exemplo n.º 1
0
def require_confirm_change_pin(ctx: wire.Context, msg: ChangePin) -> None:
    has_pin = config.has_pin()

    if msg.remove and has_pin:  # removing pin
        return confirm_action(
            ctx,
            "set_pin",
            "Remove PIN",
            description="Do you really want to",
            action="disable PIN protection?",
            reverse=True,
        )

    if not msg.remove and has_pin:  # changing pin
        return confirm_action(
            ctx,
            "set_pin",
            "Change PIN",
            description="Do you really want to",
            action="change your PIN?",
            reverse=True,
        )

    if not msg.remove and not has_pin:  # setting new pin
        return confirm_action(
            ctx,
            "set_pin",
            "Enable PIN",
            description="Do you really want to",
            action="enable PIN protection?",
            reverse=True,
        )

    # removing non-existing PIN
    raise wire.ProcessError("PIN protection already disabled")
Exemplo n.º 2
0
async def handle_Ping(ctx: wire.Context, msg: Ping) -> Success:
    if msg.button_protection:
        from trezor.ui.layouts import require, confirm_action
        from trezor.messages.ButtonRequestType import ProtectCall

        await require(
            confirm_action(ctx, "ping", "Confirm", "ping",
                           br_code=ProtectCall))
    return Success(message=msg.message)
Exemplo n.º 3
0
async def _warn(ctx: wire.Context):
    await require(
        confirm_action(
            ctx,
            "warn_loading_seed",
            "Loading seed",
            "Loading private seed\nis not recommended.",
            "Continue only if you\nknow what you are doing!",
        ))
Exemplo n.º 4
0
def _require_confirm_action(
    ctx: wire.Context, msg: ChangeWipeCode, has_wipe_code: bool
) -> Awaitable[None]:
    if msg.remove and has_wipe_code:
        return confirm_action(
            ctx,
            "disable_wipe_code",
            title="Disable wipe code",
            description="Do you really want to",
            action="disable wipe code protection?",
            reverse=True,
            icon=ui.ICON_CONFIG,
        )

    if not msg.remove and has_wipe_code:
        return confirm_action(
            ctx,
            "change_wipe_code",
            title="Change wipe code",
            description="Do you really want to",
            action="change the wipe code?",
            reverse=True,
            icon=ui.ICON_CONFIG,
        )

    if not msg.remove and not has_wipe_code:
        return confirm_action(
            ctx,
            "set_wipe_code",
            title="Set wipe code",
            description="Do you really want to",
            action="set the wipe code?",
            reverse=True,
            icon=ui.ICON_CONFIG,
        )

    # Removing non-existing wipe code.
    raise wire.ProcessError("Wipe code protection is already disabled")
Exemplo n.º 5
0
def require_confirm_sd_protect(ctx: wire.Context,
                               msg: SdProtect) -> Awaitable[None]:
    if msg.operation == SdProtectOperationType.ENABLE:
        text = "Do you really want to secure your device with SD card protection?"
    elif msg.operation == SdProtectOperationType.DISABLE:
        text = "Do you really want to remove SD card protection from your device?"
    elif msg.operation == SdProtectOperationType.REFRESH:
        text = "Do you really want to replace the current\nSD card secret with a newly generated one?"
    else:
        raise wire.ProcessError("Unknown operation")

    return confirm_action(ctx,
                          "set_sd",
                          "SD card protection",
                          description=text)