mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 20:38:10 +00:00
src/apps/common: refactor new_device_id function
This commit is contained in:
parent
cda9ae3be7
commit
6cf9bb1d93
@ -21,10 +21,14 @@ _FLAGS = const(0x08) # int
|
|||||||
_U2F_COUNTER = const(0x09) # int
|
_U2F_COUNTER = const(0x09) # int
|
||||||
|
|
||||||
|
|
||||||
|
def _new_device_id() -> str:
|
||||||
|
return hexlify(random.bytes(12)).decode().upper()
|
||||||
|
|
||||||
|
|
||||||
def get_device_id() -> str:
|
def get_device_id() -> str:
|
||||||
dev_id = config.get(_APP, _DEVICE_ID, True).decode() # public
|
dev_id = config.get(_APP, _DEVICE_ID, True).decode() # public
|
||||||
if not dev_id:
|
if not dev_id:
|
||||||
dev_id = new_device_id()
|
dev_id = _new_device_id()
|
||||||
config.set(_APP, _DEVICE_ID, dev_id.encode(), True) # public
|
config.set(_APP, _DEVICE_ID, dev_id.encode(), True) # public
|
||||||
return dev_id
|
return dev_id
|
||||||
|
|
||||||
@ -117,7 +121,3 @@ def set_u2f_counter(cntr: int):
|
|||||||
def wipe():
|
def wipe():
|
||||||
config.wipe()
|
config.wipe()
|
||||||
cache.clear()
|
cache.clear()
|
||||||
|
|
||||||
|
|
||||||
def new_device_id() -> str:
|
|
||||||
return hexlify(random.bytes(12)).decode().upper()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user