Esempio n. 1
0
async def bootscreen() -> None:
    ui.display.orientation(storage_device.get_rotation())
    salt_auth_key = storage_device.get_sd_salt_auth_key()

    while True:
        try:
            if salt_auth_key is not None or config.has_pin():
                await lockscreen()

            if salt_auth_key is not None:
                salt = await request_sd_salt(None, salt_auth_key
                                             )  # type: Optional[bytearray]
            else:
                salt = None

            if not config.has_pin():
                config.unlock(pin_to_int(""), salt)
                storage.init_unlocked()
                return

            label = "Enter your PIN"
            while True:
                pin = await request_pin(label, config.get_pin_rem())
                if config.unlock(pin_to_int(pin), salt):
                    storage.init_unlocked()
                    return
                else:
                    label = "Wrong PIN, enter again"
        except (OSError, PinCancelled, SdProtectCancelled) as e:
            if __debug__:
                log.exception(__name__, e)
        except BaseException as e:
            utils.halt(e.__class__.__name__)
Esempio n. 2
0
async def bootscreen() -> None:
    ui.display.orientation(storage.device.get_rotation())

    while True:
        try:
            if storage.sd_salt.is_enabled() or config.has_pin():
                await lockscreen()

            salt = await request_sd_salt()

            if not config.has_pin():
                config.unlock(pin_to_int(""), salt)
                storage.init_unlocked()
                return

            label = "Enter your PIN"
            while True:
                pin = await request_pin(label, config.get_pin_rem())
                if config.unlock(pin_to_int(pin), salt):
                    storage.init_unlocked()
                    return
                else:
                    label = "Wrong PIN, enter again"
        except (OSError, PinCancelled, SdCardUnavailable) as e:
            if __debug__:
                log.exception(__name__, e)
        except BaseException as e:
            if __debug__:
                log.exception(__name__, e)
            utils.halt(e.__class__.__name__)
Esempio n. 3
0
async def bootscreen() -> None:
    lockscreen = Lockscreen(bootscreen=True)
    ui.display.orientation(storage.device.get_rotation())
    while True:
        try:
            if can_lock_device():
                await lockscreen
            await verify_user_pin()
            storage.init_unlocked()
            return
        except wire.PinCancelled:
            # verify_user_pin will convert a SdCardUnavailable (in case of sd salt)
            # to PinCancelled exception.
            # Ignore exception, retry loop.
            pass
        except BaseException as e:
            # other exceptions here are unexpected and should halt the device
            if __debug__:
                log.exception(__name__, e)
            utils.halt(e.__class__.__name__)
Esempio n. 4
0
async def bootscreen() -> None:
    ui.display.orientation(storage.device.get_rotation())
    while True:
        try:
            if storage.sd_salt.is_enabled() or config.has_pin():
                await lockscreen()
            await verify_user_pin()
            storage.init_unlocked()
            return
        except PinCancelled as e:
            # verify_user_pin will convert a SdCardUnavailable (in case of sd salt)
            # to PinCancelled exception.
            # log the exception and retry loop
            if __debug__:
                log.exception(__name__, e)
        except BaseException as e:
            # other exceptions here are unexpected and should halt the device
            if __debug__:
                log.exception(__name__, e)
            utils.halt(e.__class__.__name__)
Esempio n. 5
0
if not __debug__:
    from trezor.utils import halt

    halt("debug mode inactive")

if __debug__:
    from trezor import io, ui, wire
    from trezor.messages import MessageType, DebugSwipeDirection
    from trezor.messages.DebugLinkLayout import DebugLinkLayout
    from trezor import config, crypto, log, loop, utils
    from trezor.messages.Success import Success

    if False:
        from typing import List, Optional
        from trezor.messages.DebugLinkDecision import DebugLinkDecision
        from trezor.messages.DebugLinkGetState import DebugLinkGetState
        from trezor.messages.DebugLinkRecordScreen import DebugLinkRecordScreen
        from trezor.messages.DebugLinkReseedRandom import DebugLinkReseedRandom
        from trezor.messages.DebugLinkState import DebugLinkState
        from trezor.messages.DebugLinkEraseSdCard import DebugLinkEraseSdCard

    save_screen = False
    save_screen_directory = "."

    reset_internal_entropy = None  # type: Optional[bytes]
    reset_current_words = loop.chan()
    reset_word_index = loop.chan()

    confirm_chan = loop.chan()
    swipe_chan = loop.chan()
    input_chan = loop.chan()
Esempio n. 6
0
        apps.monero.boot()
        apps.nem.boot()
        apps.stellar.boot()
        apps.ripple.boot()
        apps.cardano.boot()
        apps.tezos.boot()
        apps.eos.boot()
        apps.binance.boot()
        apps.webauthn.boot()
        apps.polis.boot()

    if __debug__:
        apps.debug.boot()

    # run main event loop and specify which screen is the default
    apps.base.set_homescreen()
    workflow.start_default()


_boot_apps()

# initialize the wire codec
wire.setup(usb.iface_wire)
if __debug__:
    wire.setup(usb.iface_debug, use_workflow=False)

loop.run()

# loop is empty. That should not happen
utils.halt("All tasks have died.")
Esempio n. 7
0
if not __debug__:
    from trezor.utils import halt
    halt('debug mode inactive')

if __debug__:
    from trezor import loop
    from trezor.messages import MessageType
    from trezor.messages.DebugLinkState import DebugLinkState
    from trezor.ui import confirm, swipe
    from trezor.wire import register, protobuf_workflow
    from apps.common import storage

    reset_internal_entropy = None
    reset_current_words = None
    reset_word_index = None

    confirm_signal = loop.signal()
    swipe_signal = loop.signal()
    input_signal = loop.signal()

    async def dispatch_DebugLinkDecision(ctx, msg):
        if msg.yes_no is not None:
            confirm_signal.send(
                confirm.CONFIRMED if msg.yes_no else confirm.CANCELLED)
        if msg.up_down is not None:
            swipe_signal.send(
                swipe.SWIPE_DOWN if msg.up_down else swipe.SWIPE_UP)
        if msg.input is not None:
            input_signal.send(msg.input)

    async def dispatch_DebugLinkGetState(ctx, msg):
Esempio n. 8
0
from trezor import loop, utils
from trezor.messages import wire_types
from trezor.messages.DebugLinkState import DebugLinkState
from trezor.ui import confirm, swipe
from trezor.wire import register, protobuf_workflow
from apps.common import storage

if not __debug__:
    utils.halt("debug mode inactive")

reset_internal_entropy = None
reset_current_words = None
reset_word_index = None

confirm_signal = loop.signal()
swipe_signal = loop.signal()
input_signal = loop.signal()


async def dispatch_DebugLinkDecision(ctx, msg):
    if msg.yes_no is not None:
        confirm_signal.send(
            confirm.CONFIRMED if msg.yes_no else confirm.CANCELLED)
    if msg.up_down is not None:
        swipe_signal.send(swipe.SWIPE_DOWN if msg.up_down else swipe.SWIPE_UP)
    if msg.input is not None:
        input_signal.send(msg.input)


async def dispatch_DebugLinkGetState(ctx, msg):
    m = DebugLinkState()
Esempio n. 9
0
# generated from all_modules.py.mako
# do not edit manually!
# flake8: noqa
# fmt: off
# isort:skip_file
from trezor.utils import halt

# this module should not be part of the build, its purpose is only to add missed Qstrings
halt("Tried to import excluded module.")

# explanation:
# uPy collects string literals and symbol names from all frozen modules, and converts
# them to qstrings for certain usages. In particular, it appears that qualified names
# of modules in sys.modules must be qstrings. However, the collection process is
# imperfect. If `apps.common.mnemonic` is always imported as `from ..common import mnemonic`,
# the string "apps.common.mnemonic" never appears in source code, is never collected,
# but then is generated and interned at runtime.
# A similar thing happens in reverse: if module `storage.cache` is always imported as
# this name, then "storage.cache" is collected but neither "storage" nor "cache" alone.
# Which is a problem, because "cache" is a symbol that is added to `storage`'s dict.
#
# We need to avoid run-time interning as much as possible, because it creates
# uncollectable garbage in the GC arena.
#
# Below, every module is listed both as import (which collects the qualified name)
# and as a symbol (which collects each individual component).
# In addition, we list the alphabet, because apparently one-character strings are always
# interned, and some operation somewhere (rendering?) is reading strings character by
# character.

all_modules
Esempio n. 10
0
def config_set_checked(key, value: bytes):
    config_set(key, value)
    check = config_get(key)
    if check != value:
        utils.halt('config.set failed')