mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-24 15:28:10 +00:00
common: add support for FIDO data to template rendering
This commit is contained in:
parent
6a3910b8ff
commit
04c34fb4b0
@ -262,12 +262,20 @@ def _load_misc():
|
|||||||
def _load_fido_apps():
|
def _load_fido_apps():
|
||||||
"""Load btc-like coins from `coins/*.json`"""
|
"""Load btc-like coins from `coins/*.json`"""
|
||||||
apps = []
|
apps = []
|
||||||
for filename in glob.glob(os.path.join(DEFS_DIR, "webauthn", "apps", "*.json")):
|
for filename in sorted(
|
||||||
app_name = os.path.basename(filename)[:-5]
|
glob.glob(os.path.join(DEFS_DIR, "webauthn", "apps", "*.json"))
|
||||||
|
):
|
||||||
|
app_name = os.path.basename(filename)[:-5].lower()
|
||||||
app = load_json(filename)
|
app = load_json(filename)
|
||||||
app.update(
|
app.setdefault("use_sign_count", None)
|
||||||
key=app_name,
|
app.setdefault("u2f", [])
|
||||||
)
|
app.setdefault("webauthn", [])
|
||||||
|
|
||||||
|
icon_path = os.path.join(DEFS_DIR, "webauthn", "apps", app_name + ".png")
|
||||||
|
if not os.path.exists(icon_path):
|
||||||
|
icon_path = None
|
||||||
|
|
||||||
|
app.update(key=app_name, icon=icon_path)
|
||||||
apps.append(app)
|
apps.append(app)
|
||||||
|
|
||||||
return apps
|
return apps
|
||||||
|
@ -477,7 +477,7 @@ def check_segwit(coins):
|
|||||||
|
|
||||||
|
|
||||||
FIDO_KNOWN_KEYS = frozenset(
|
FIDO_KNOWN_KEYS = frozenset(
|
||||||
("key", "u2f", "webauthn", "label", "use_sign_count", "demo")
|
("key", "u2f", "webauthn", "label", "use_sign_count", "demo", "icon")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -510,20 +510,23 @@ def check_fido(apps):
|
|||||||
unknown_keys = set(app.keys()) - FIDO_KNOWN_KEYS
|
unknown_keys = set(app.keys()) - FIDO_KNOWN_KEYS
|
||||||
if unknown_keys:
|
if unknown_keys:
|
||||||
print_log(logging.ERROR, app["key"], ": unrecognized keys:", unknown_keys)
|
print_log(logging.ERROR, app["key"], ": unrecognized keys:", unknown_keys)
|
||||||
|
check_passed = False
|
||||||
|
|
||||||
# check icons
|
# check icons
|
||||||
icon_file = app["key"].lower() + ".png"
|
if app["icon"] is None:
|
||||||
try:
|
|
||||||
icon = Image.open(
|
|
||||||
os.path.join(coin_info.DEFS_DIR, "webauthn", "apps", icon_file)
|
|
||||||
)
|
|
||||||
except Exception:
|
|
||||||
if app.get("demo"):
|
if app.get("demo"):
|
||||||
log_level = logging.WARNING
|
log_level = logging.WARNING
|
||||||
else:
|
else:
|
||||||
log_level = logging.ERROR
|
log_level = logging.ERROR
|
||||||
check_passed = False
|
check_passed = False
|
||||||
print_log(log_level, app["key"], ": failed to open icon file", icon_file)
|
print_log(log_level, app["key"], ": missing icon")
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
icon = Image.open(app["icon"])
|
||||||
|
except Exception:
|
||||||
|
print_log(log_level, app["key"], ": failed to open icon file", app["icon"])
|
||||||
|
check_passed = False
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if icon.size != (128, 128) or icon.mode != "RGBA":
|
if icon.size != (128, 128) or icon.mode != "RGBA":
|
||||||
@ -887,6 +890,7 @@ def render(paths, outfile, verbose, bitcoin_only):
|
|||||||
|
|
||||||
# prepare defs
|
# prepare defs
|
||||||
defs = coin_info.coin_info()
|
defs = coin_info.coin_info()
|
||||||
|
defs["fido"] = coin_info.fido_info()
|
||||||
support_info = coin_info.support_info(defs)
|
support_info = coin_info.support_info(defs)
|
||||||
|
|
||||||
if bitcoin_only:
|
if bitcoin_only:
|
||||||
|
Loading…
Reference in New Issue
Block a user