From 317a8cb3cfe807d413319a239e51e036e28cac75 Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Tue, 25 Mar 2025 15:36:11 +0100 Subject: [PATCH] wip public credential --- core/src/storage/device.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/storage/device.py b/core/src/storage/device.py index 3d91616e87..5769592627 100644 --- a/core/src/storage/device.py +++ b/core/src/storage/device.py @@ -364,21 +364,23 @@ if utils.USE_THP: """ Device secret is used to derive keys that are independent of the seed. """ - device_secret = common.get(_NAMESPACE, _DEVICE_SECRET) + device_secret = common.get(_NAMESPACE, _DEVICE_SECRET, True) if not device_secret: from trezor.crypto import random device_secret = random.bytes(16, True) - common.set(_NAMESPACE, _DEVICE_SECRET, device_secret) + common.set(_NAMESPACE, _DEVICE_SECRET, device_secret, True) return device_secret def get_cred_auth_key_counter() -> bytes: - return common.get(_NAMESPACE, _CRED_AUTH_KEY_COUNTER) or bytes(4) + return common.get(_NAMESPACE, _CRED_AUTH_KEY_COUNTER, True) or bytes(4) def increment_cred_auth_key_counter() -> None: counter = int.from_bytes(get_cred_auth_key_counter(), "big") utils.ensure(counter < 0xFFFFFFFF, "Overflow of cred_auth_key_counter") - common.set(_NAMESPACE, _CRED_AUTH_KEY_COUNTER, (counter + 1).to_bytes(4, "big")) + common.set( + _NAMESPACE, _CRED_AUTH_KEY_COUNTER, (counter + 1).to_bytes(4, "big"), True + ) def set_haptic_feedback(enable: bool) -> None: