1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-23 15:08:19 +00:00

wip public credential

This commit is contained in:
M1nd3r 2025-03-25 15:36:11 +01:00
parent 64e27ec534
commit 15adb681fa

View File

@ -364,21 +364,23 @@ if utils.USE_THP:
""" """
Device secret is used to derive keys that are independent of the seed. 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: if not device_secret:
from trezor.crypto import random from trezor.crypto import random
device_secret = random.bytes(16, True) device_secret = random.bytes(16, True)
common.set(_NAMESPACE, _DEVICE_SECRET, device_secret) common.set(_NAMESPACE, _DEVICE_SECRET, device_secret, True)
return device_secret return device_secret
def get_cred_auth_key_counter() -> bytes: 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: def increment_cred_auth_key_counter() -> None:
counter = int.from_bytes(get_cred_auth_key_counter(), "big") counter = int.from_bytes(get_cred_auth_key_counter(), "big")
utils.ensure(counter < 0xFFFFFFFF, "Overflow of cred_auth_key_counter") 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: def set_haptic_feedback(enable: bool) -> None: