mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 03:50:58 +00:00
Convert U2F counter from private to public to take advantage of the more efficient implementation.
This commit is contained in:
parent
fa339bbe06
commit
8be3896038
@ -8,7 +8,7 @@ from apps.common import cache
|
|||||||
|
|
||||||
HOMESCREEN_MAXSIZE = 16384
|
HOMESCREEN_MAXSIZE = 16384
|
||||||
|
|
||||||
_STORAGE_VERSION = b"\x01"
|
_STORAGE_VERSION = b"\x02"
|
||||||
_FALSE_BYTE = b"\x00"
|
_FALSE_BYTE = b"\x00"
|
||||||
_TRUE_BYTE = b"\x01"
|
_TRUE_BYTE = b"\x01"
|
||||||
_COUNTER_HEAD_LEN = 4
|
_COUNTER_HEAD_LEN = 4
|
||||||
@ -223,3 +223,15 @@ def set_u2f_counter(cntr: int) -> None:
|
|||||||
def wipe():
|
def wipe():
|
||||||
config.wipe()
|
config.wipe()
|
||||||
cache.clear()
|
cache.clear()
|
||||||
|
|
||||||
|
|
||||||
|
def init_unlocked():
|
||||||
|
# Check for storage version upgrade.
|
||||||
|
version = config.get(_APP, _VERSION)
|
||||||
|
if version == b"\x01":
|
||||||
|
# Make the U2F counter public.
|
||||||
|
counter = config.get(_APP, _U2F_COUNTER)
|
||||||
|
if counter is not None:
|
||||||
|
_set_counter(_APP, _U2F_COUNTER, counter, True)
|
||||||
|
config.delete(_APP, _U2F_COUNTER)
|
||||||
|
config.set(_APP, _VERSION, _STORAGE_VERSION)
|
||||||
|
@ -2,6 +2,7 @@ from trezor import config, log, loop, res, ui
|
|||||||
from trezor.pin import pin_to_int, show_pin_timeout
|
from trezor.pin import pin_to_int, show_pin_timeout
|
||||||
|
|
||||||
from apps.common.request_pin import request_pin
|
from apps.common.request_pin import request_pin
|
||||||
|
from apps.common import storage
|
||||||
|
|
||||||
|
|
||||||
async def bootscreen():
|
async def bootscreen():
|
||||||
@ -9,12 +10,14 @@ async def bootscreen():
|
|||||||
try:
|
try:
|
||||||
if not config.has_pin():
|
if not config.has_pin():
|
||||||
config.unlock(pin_to_int(""))
|
config.unlock(pin_to_int(""))
|
||||||
|
storage.init_unlocked()
|
||||||
return
|
return
|
||||||
await lockscreen()
|
await lockscreen()
|
||||||
label = None
|
label = None
|
||||||
while True:
|
while True:
|
||||||
pin = await request_pin(label, config.get_pin_rem())
|
pin = await request_pin(label, config.get_pin_rem())
|
||||||
if config.unlock(pin_to_int(pin)):
|
if config.unlock(pin_to_int(pin)):
|
||||||
|
storage.init_unlocked()
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
label = "Wrong PIN, enter again"
|
label = "Wrong PIN, enter again"
|
||||||
@ -24,8 +27,6 @@ async def bootscreen():
|
|||||||
|
|
||||||
|
|
||||||
async def lockscreen():
|
async def lockscreen():
|
||||||
from apps.common import storage
|
|
||||||
|
|
||||||
label = storage.get_label()
|
label = storage.get_label()
|
||||||
image = storage.get_homescreen()
|
image = storage.get_homescreen()
|
||||||
if not label:
|
if not label:
|
||||||
|
Loading…
Reference in New Issue
Block a user