Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions core/src/apps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ def get_pinlocked_handler(

async def wrapper(ctx: wire.Context, msg: wire.Msg) -> protobuf.MessageType:
await unlock_device(ctx)
storage.cache.start_session()
return await orig_handler(ctx, msg)

return wrapper
Expand Down Expand Up @@ -696,13 +697,8 @@ async def handle_GetPassphraseState(
from trezor.messages import PassphraseState
from apps.common import passphrase, paths

# Check if client supports attach pin
(
hasattr(msg, "allow_create_attach_pin")
and msg.allow_create_attach_pin is not None
)
if not device_is_unlocked():
await unlock_device(ctx, pin_use_type=2)
await unlock_device(ctx, pin_use_type=PinType.USER_AND_PASSPHRASE_PIN)
session_id = storage.cache.start_session()

from trezor.lvglui.scrs import fingerprints
Expand Down Expand Up @@ -759,13 +755,15 @@ async def handle_UnLockDevice(
) -> UnLockDeviceResponse:
"""Handle UnLockDevice message to unlock the device if needed."""
if not config.is_unlocked():
await unlock_device(ctx, pin_use_type=2)
await unlock_device(ctx, pin_use_type=PinType.USER_AND_PASSPHRASE_PIN)
storage.cache.start_session()

# Get current device state after unlock attempt
from apps.common import passphrase

unlocked = config.is_unlocked()
unlocked_attach_pin = passphrase.is_passphrase_pin_enabled() if unlocked else False

passphrase_protection = (
storage.device.is_passphrase_enabled() if unlocked else False
)
Expand Down
1 change: 1 addition & 0 deletions core/src/apps/homescreen/lockscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ async def lockscreen() -> None:
# to an unlocked state.
try:
await unlock_device()
storage.cache.start_session()
except wire.PinCancelled:
pass

Expand Down
4 changes: 3 additions & 1 deletion core/src/apps/management/change_pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ async def change_pin(ctx: wire.Context, msg: ChangePin) -> Success:
newpin = ""

if newpin:
verified, usertype = config.check_pin(newpin, salt, PinType.PASSPHRASE_PIN)
verified, usertype = config.check_pin(
newpin, salt, PinType.PASSPHRASE_PIN_CHECK
)
if usertype == PinResult.PASSPHRASE_PIN_ENTERED:
return await error_pin_used(ctx)

Expand Down
4 changes: 3 additions & 1 deletion core/src/apps/management/change_wipe_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ async def change_wipe_code(ctx: wire.Context, msg: ChangeWipeCode) -> Success:

if not msg.remove:
# Pre-check the entered PIN.
if config.has_pin() and not config.check_pin(pin, salt)[0]:
from apps.common.pin_constants import PinType

if config.has_pin() and not config.check_pin(pin, salt, PinType.USER_CHECK)[0]:
await error_pin_invalid(ctx)

# Get new wipe code.
Expand Down
6 changes: 6 additions & 0 deletions core/src/apps/webauthn/fido2.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,9 @@ async def verify_user(keepalive_callback: KeepaliveCallback) -> bool:
trezor.pin.keepalive_callback = keepalive_callback

await unlock_device()
import storage.cache

storage.cache.start_session()
return True
except Exception:
return False
Expand Down Expand Up @@ -806,6 +809,9 @@ async def confirm_dialog(self) -> bool:

try:
await unlock_device()
import storage.cache

storage.cache.start_session()
return True
except Exception:
return False
Expand Down
1 change: 1 addition & 0 deletions core/src/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async def bootscreen() -> None:
from apps.common.pin_constants import PinType

await verify_user_pin(pin_use_type=PinType.USER_AND_PASSPHRASE_PIN)
storage.cache.start_session()
storage.init_unlocked()
loop.close(lvgl_task)
return
Expand Down
6 changes: 6 additions & 0 deletions core/src/trezor/lvglui/scrs/lockscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ def eventhandler(self, event_obj: lv.event_t):
from apps.base import unlock_device

workflow.spawn(unlock_device())
import storage.cache

storage.cache.start_session()

def on_slide_up(self, event_obj: lv.event_t):
code = event_obj.code
Expand All @@ -203,6 +206,9 @@ def on_slide_up(self, event_obj: lv.event_t):
from apps.base import unlock_device

workflow.spawn(unlock_device())
import storage.cache

storage.cache.start_session()

def _load_scr(self, scr: "Screen", back: bool = False) -> None:
lv.scr_load(scr)
7 changes: 7 additions & 0 deletions core/src/trezor/uart.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ async def handle_fingerprint():
if __debug__:
print(f"fingerprint unlock result {res}")
await base.unlock_device()
import storage.cache

storage.cache.start_session()

# await loop.sleep(2000)
return
else:
Expand Down Expand Up @@ -331,6 +335,9 @@ async def _deal_ble_pair(value):
if not base.device_is_unlocked():
try:
await base.unlock_device()
import storage.cache

storage.cache.start_session()
except Exception:
await safe_reloop()
workflow.spawn(utils.internal_reloop())
Expand Down
14 changes: 0 additions & 14 deletions core/src/trezor/ui/layouts/lvgl/attach_to_pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,6 @@ async def show_attach_to_pin_window(ctx):
if not save_result:
return False

# Convert passphrase pin to string if needed
passphrase_pin_str = (
str(passphrase_pin)
if not isinstance(passphrase_pin, str)
else passphrase_pin
)

# Verify the pin
pinstatus, result = config.check_pin(
passphrase_pin_str,
None,
PinType.USER_AND_PASSPHRASE_PIN,
)

# Show success message
await show_passphrase_set_and_attached_to_pin_window(
ctx
Expand Down
Loading