mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-02 19:40:57 +00:00
feat(core): Implement storage.cache.get_int_all_sessions().
This commit is contained in:
parent
0fb55553b7
commit
9bb1d1cf8b
@ -46,6 +46,12 @@ def get() -> protobuf.MessageType | None:
|
|||||||
return protobuf.load_message_buffer(buffer, msg_wire_type)
|
return protobuf.load_message_buffer(buffer, msg_wire_type)
|
||||||
|
|
||||||
|
|
||||||
|
def is_set_any_session(auth_type: MessageType) -> bool:
|
||||||
|
return auth_type in storage_cache.get_int_all_sessions(
|
||||||
|
APP_COMMON_AUTHORIZATION_TYPE
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_wire_types() -> Iterable[int]:
|
def get_wire_types() -> Iterable[int]:
|
||||||
stored_auth_type = storage_cache.get(APP_COMMON_AUTHORIZATION_TYPE)
|
stored_auth_type = storage_cache.get(APP_COMMON_AUTHORIZATION_TYPE)
|
||||||
if stored_auth_type is None:
|
if stored_auth_type is None:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import builtins
|
||||||
import gc
|
import gc
|
||||||
from micropython import const
|
from micropython import const
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
@ -273,6 +274,16 @@ def get_int(key: int, default: T | None = None) -> int | T | None: # noqa: F811
|
|||||||
return int.from_bytes(encoded, "big")
|
return int.from_bytes(encoded, "big")
|
||||||
|
|
||||||
|
|
||||||
|
def get_int_all_sessions(key: int) -> builtins.set[int]:
|
||||||
|
sessions = [_SESSIONLESS_CACHE] if key & _SESSIONLESS_FLAG else _SESSIONS
|
||||||
|
values = builtins.set()
|
||||||
|
for session in sessions:
|
||||||
|
encoded = session.get(key)
|
||||||
|
if encoded is not None:
|
||||||
|
values.add(int.from_bytes(encoded, "big"))
|
||||||
|
return values
|
||||||
|
|
||||||
|
|
||||||
def is_set(key: int) -> bool:
|
def is_set(key: int) -> bool:
|
||||||
if key & _SESSIONLESS_FLAG:
|
if key & _SESSIONLESS_FLAG:
|
||||||
return _SESSIONLESS_CACHE.is_set(key ^ _SESSIONLESS_FLAG)
|
return _SESSIONLESS_CACHE.is_set(key ^ _SESSIONLESS_FLAG)
|
||||||
|
Loading…
Reference in New Issue
Block a user