mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-15 20:19:23 +00:00
fido_u2f: unify handling of bogus app ids
This commit is contained in:
parent
934b32707c
commit
a932816a25
@ -382,18 +382,20 @@ class ConfirmState:
|
|||||||
from trezor.ui.confirm import ConfirmDialog, CONFIRMED
|
from trezor.ui.confirm import ConfirmDialog, CONFIRMED
|
||||||
from trezor.ui.text import Text
|
from trezor.ui.text import Text
|
||||||
|
|
||||||
if bytes(self.app_id) == _BOGUS_APPID:
|
app_id = bytes(self.app_id) # could be bytearray, which doesn't have __hash__
|
||||||
text = Text("U2F mismatch", ui.ICON_WRONG, icon_color=ui.RED)
|
|
||||||
|
if app_id == _BOGUS_APPID and self.action == _CONFIRM_REGISTER:
|
||||||
|
text = Text("U2F", ui.ICON_WRONG, icon_color=ui.RED)
|
||||||
text.normal(
|
text.normal(
|
||||||
"Another U2F device", "was used to register", "in this application."
|
"Another U2F device", "was used to register", "in this application."
|
||||||
)
|
)
|
||||||
text.render()
|
text.render()
|
||||||
await loop.sleep(3 * 1000 * 1000)
|
dialog = ConfirmDialog(text)
|
||||||
self.confirmed = True
|
|
||||||
else:
|
else:
|
||||||
content = ConfirmContent(self.action, self.app_id)
|
content = ConfirmContent(self.action, app_id)
|
||||||
dialog = ConfirmDialog(content)
|
dialog = ConfirmDialog(content)
|
||||||
self.confirmed = await dialog == CONFIRMED
|
|
||||||
|
self.confirmed = await dialog == CONFIRMED
|
||||||
|
|
||||||
|
|
||||||
class ConfirmContent(ui.Widget):
|
class ConfirmContent(ui.Widget):
|
||||||
@ -409,24 +411,17 @@ class ConfirmContent(ui.Widget):
|
|||||||
from trezor import res
|
from trezor import res
|
||||||
from apps.fido_u2f import knownapps
|
from apps.fido_u2f import knownapps
|
||||||
|
|
||||||
app_id = bytes(self.app_id) # could be bytearray, which doesn't have __hash__
|
if self.app_id in knownapps.knownapps:
|
||||||
|
name = knownapps.knownapps[self.app_id]
|
||||||
if app_id == _BOGUS_APPID:
|
|
||||||
# TODO: display a warning dialog for bogus app ids
|
|
||||||
name = "Another U2F device"
|
|
||||||
icon = res.load("apps/fido_u2f/res/u2f_generic.toif") # TODO: warning icon
|
|
||||||
elif app_id in knownapps.knownapps:
|
|
||||||
name = knownapps.knownapps[app_id]
|
|
||||||
try:
|
try:
|
||||||
icon = res.load(
|
namepart = name.lower().replace(" ", "_")
|
||||||
"apps/fido_u2f/res/u2f_%s.toif" % name.lower().replace(" ", "_")
|
icon = res.load("apps/fido_u2f/res/u2f_%s.toif" % namepart)
|
||||||
)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
icon = res.load("apps/fido_u2f/res/u2f_generic.toif")
|
icon = res.load("apps/fido_u2f/res/u2f_generic.toif")
|
||||||
else:
|
else:
|
||||||
name = "%s...%s" % (
|
name = "%s...%s" % (
|
||||||
hexlify(app_id[:4]).decode(),
|
hexlify(self.app_id[:4]).decode(),
|
||||||
hexlify(app_id[-4:]).decode(),
|
hexlify(self.app_id[-4:]).decode(),
|
||||||
)
|
)
|
||||||
icon = res.load("apps/fido_u2f/res/u2f_generic.toif")
|
icon = res.load("apps/fido_u2f/res/u2f_generic.toif")
|
||||||
self.app_name = name
|
self.app_name = name
|
||||||
|
Loading…
Reference in New Issue
Block a user