mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-22 18:19:03 +00:00
wip public credential
This commit is contained in:
parent
64e27ec534
commit
15adb681fa
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user