1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-04-23 02:29:10 +00:00

wip public credential

This commit is contained in:
M1nd3r 2025-03-25 15:36:11 +01:00
parent 6c012f3f4d
commit 317a8cb3cf

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 = 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: