common/fido: change FIDO icon checking logic

pull/748/head
matejcik 5 years ago committed by matejcik
parent ac6e23fb87
commit 6225fa6193

@ -7,12 +7,14 @@ This directory hosts JSON definitions of recognized coins, tokens, and FIDO/U2F
The [`fido/`](fido) subdirectory contains definitons of apps whose logos and The [`fido/`](fido) subdirectory contains definitons of apps whose logos and
names are shown on Trezor T screen for FIDO/U2F authentication. names are shown on Trezor T screen for FIDO/U2F authentication.
Each app must have a single JSON file in the `fido/` subdirectory, and a corresponding Each app must have a single JSON file in the `fido/` subdirectory. Every app must have
PNG image with the same name. The PNG must be 128x128 pixels RGBA. its `label` set to the user-recognizable application name. The `u2f` field is a list of
U2F origin hashes, and the `webauthn` field is a list of FIDO2/WebAuthn hostnames for
Every app must have its `label` set to the user-recognizable application name. The `u2f` the app. At least one must be present.
field is a list of U2F origin hashes, and the `webauthn` field is a list of
FIDO2/WebAuthn hostnames for the app. At least one must be present. Each app can have an icon. If present, it must be a 128x128 pixels RGBA PNG of the same
name as the corresponding JSON name. If the app does not have an icon, it must instead
have a field `no_icon` set to `true` in the JSON.
## Coins ## Coins

@ -1,5 +1,5 @@
{ {
"label": "u2f.bin.coffee", "label": "u2f.bin.coffee",
"u2f": ["1b3c16dd2f7c46e2b4c289dc16746bcc60dfcf0fb818e13215526e1408e7f468"], "u2f": ["1b3c16dd2f7c46e2b4c289dc16746bcc60dfcf0fb818e13215526e1408e7f468"],
"demo": true "no_icon": true
} }

@ -1,5 +1,5 @@
{ {
"label": "webauthn.bin.coffee", "label": "webauthn.bin.coffee",
"webauthn": ["webauthn.bin.coffee"], "webauthn": ["webauthn.bin.coffee"],
"demo": true "no_icon": true
} }

@ -1,5 +1,5 @@
{ {
"label": "WebAuthn.io", "label": "WebAuthn.io",
"webauthn": ["webauthn.io"], "webauthn": ["webauthn.io"],
"demo": true "no_icon": true
} }

@ -1,5 +1,5 @@
{ {
"label": "WebAuthn.me", "label": "WebAuthn.me",
"webauthn": ["webauthn.me"], "webauthn": ["webauthn.me"],
"demo": true "no_icon": true
} }

@ -1,5 +1,5 @@
{ {
"label": "demo.yubico.com", "label": "demo.yubico.com",
"webauthn": ["demo.yubico.com"], "webauthn": ["demo.yubico.com"],
"demo": true "no_icon": true
} }

@ -477,7 +477,7 @@ def check_segwit(coins):
FIDO_KNOWN_KEYS = frozenset( FIDO_KNOWN_KEYS = frozenset(
("key", "u2f", "webauthn", "label", "use_sign_count", "demo", "icon") ("key", "u2f", "webauthn", "label", "use_sign_count", "no_icon", "icon")
) )
@ -514,18 +514,23 @@ def check_fido(apps):
# check icons # check icons
if app["icon"] is None: if app["icon"] is None:
if app.get("demo"): if app.get("no_icon"):
log_level = logging.WARNING continue
else:
log_level = logging.ERROR print_log(logging.ERROR, app["key"], ": missing icon")
check_passed = False check_passed = False
print_log(log_level, app["key"], ": missing icon")
continue continue
elif app.get("no_icon"):
print_log(logging.ERROR, app["key"], ": icon present for 'no_icon' app")
check_passed = False
try: try:
icon = Image.open(app["icon"]) icon = Image.open(app["icon"])
except Exception: except Exception:
print_log(log_level, app["key"], ": failed to open icon file", app["icon"]) print_log(
logging.ERROR, app["key"], ": failed to open icon file", app["icon"]
)
check_passed = False check_passed = False
continue continue
@ -534,6 +539,7 @@ def check_fido(apps):
logging.ERROR, app["key"], ": bad icon format (must be RGBA 128x128)" logging.ERROR, app["key"], ": bad icon format (must be RGBA 128x128)"
) )
check_passed = False check_passed = False
return check_passed return check_passed

Loading…
Cancel
Save