diff --git a/common/defs/README.md b/common/defs/README.md index c1d05db34..d924c3ffc 100644 --- a/common/defs/README.md +++ b/common/defs/README.md @@ -1,4 +1,20 @@ -# Coin Definitions +# Coin and FIDO Definitions + +This directory hosts JSON definitions of recognized coins, tokens, and FIDO/U2F apps. + +## FIDO + +The [`fido/`](fido) subdirectory contains definitons of apps whose logos and +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 +PNG image with the same name. The PNG must be 128x128 pixels RGBA. + +Every app must have 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 the app. At least one must be present. + +## Coins We currently recognize five categories of coins. diff --git a/common/defs/webauthn/apps/binance.json b/common/defs/fido/binance.json similarity index 100% rename from common/defs/webauthn/apps/binance.json rename to common/defs/fido/binance.json diff --git a/common/defs/webauthn/apps/binance.png b/common/defs/fido/binance.png similarity index 100% rename from common/defs/webauthn/apps/binance.png rename to common/defs/fido/binance.png diff --git a/common/defs/webauthn/apps/bitbucket.json b/common/defs/fido/bitbucket.json similarity index 100% rename from common/defs/webauthn/apps/bitbucket.json rename to common/defs/fido/bitbucket.json diff --git a/common/defs/webauthn/apps/bitbucket.png b/common/defs/fido/bitbucket.png similarity index 100% rename from common/defs/webauthn/apps/bitbucket.png rename to common/defs/fido/bitbucket.png diff --git a/common/defs/webauthn/apps/bitfinex.json b/common/defs/fido/bitfinex.json similarity index 100% rename from common/defs/webauthn/apps/bitfinex.json rename to common/defs/fido/bitfinex.json diff --git a/common/defs/webauthn/apps/bitfinex.png b/common/defs/fido/bitfinex.png similarity index 100% rename from common/defs/webauthn/apps/bitfinex.png rename to common/defs/fido/bitfinex.png diff --git a/common/defs/webauthn/apps/bitwarden.json b/common/defs/fido/bitwarden.json similarity index 100% rename from common/defs/webauthn/apps/bitwarden.json rename to common/defs/fido/bitwarden.json diff --git a/common/defs/webauthn/apps/bitwarden.png b/common/defs/fido/bitwarden.png similarity index 100% rename from common/defs/webauthn/apps/bitwarden.png rename to common/defs/fido/bitwarden.png diff --git a/common/defs/webauthn/apps/dashlane.json b/common/defs/fido/dashlane.json similarity index 100% rename from common/defs/webauthn/apps/dashlane.json rename to common/defs/fido/dashlane.json diff --git a/common/defs/webauthn/apps/dashlane.png b/common/defs/fido/dashlane.png similarity index 100% rename from common/defs/webauthn/apps/dashlane.png rename to common/defs/fido/dashlane.png diff --git a/common/defs/webauthn/apps/dropbox.json b/common/defs/fido/dropbox.json similarity index 100% rename from common/defs/webauthn/apps/dropbox.json rename to common/defs/fido/dropbox.json diff --git a/common/defs/webauthn/apps/dropbox.png b/common/defs/fido/dropbox.png similarity index 100% rename from common/defs/webauthn/apps/dropbox.png rename to common/defs/fido/dropbox.png diff --git a/common/defs/webauthn/apps/duo.json b/common/defs/fido/duo.json similarity index 100% rename from common/defs/webauthn/apps/duo.json rename to common/defs/fido/duo.json diff --git a/common/defs/webauthn/apps/duo.png b/common/defs/fido/duo.png similarity index 100% rename from common/defs/webauthn/apps/duo.png rename to common/defs/fido/duo.png diff --git a/common/defs/webauthn/apps/fastmail.json b/common/defs/fido/fastmail.json similarity index 100% rename from common/defs/webauthn/apps/fastmail.json rename to common/defs/fido/fastmail.json diff --git a/common/defs/webauthn/apps/fastmail.png b/common/defs/fido/fastmail.png similarity index 100% rename from common/defs/webauthn/apps/fastmail.png rename to common/defs/fido/fastmail.png diff --git a/common/defs/webauthn/apps/fedora.json b/common/defs/fido/fedora.json similarity index 100% rename from common/defs/webauthn/apps/fedora.json rename to common/defs/fido/fedora.json diff --git a/common/defs/webauthn/apps/fedora.png b/common/defs/fido/fedora.png similarity index 100% rename from common/defs/webauthn/apps/fedora.png rename to common/defs/fido/fedora.png diff --git a/common/defs/webauthn/apps/gandi.json b/common/defs/fido/gandi.json similarity index 100% rename from common/defs/webauthn/apps/gandi.json rename to common/defs/fido/gandi.json diff --git a/common/defs/webauthn/apps/gandi.png b/common/defs/fido/gandi.png similarity index 100% rename from common/defs/webauthn/apps/gandi.png rename to common/defs/fido/gandi.png diff --git a/common/defs/webauthn/apps/github.json b/common/defs/fido/github.json similarity index 100% rename from common/defs/webauthn/apps/github.json rename to common/defs/fido/github.json diff --git a/common/defs/webauthn/apps/github.png b/common/defs/fido/github.png similarity index 100% rename from common/defs/webauthn/apps/github.png rename to common/defs/fido/github.png diff --git a/common/defs/webauthn/apps/gitlab.json b/common/defs/fido/gitlab.json similarity index 100% rename from common/defs/webauthn/apps/gitlab.json rename to common/defs/fido/gitlab.json diff --git a/common/defs/webauthn/apps/gitlab.png b/common/defs/fido/gitlab.png similarity index 100% rename from common/defs/webauthn/apps/gitlab.png rename to common/defs/fido/gitlab.png diff --git a/common/defs/webauthn/apps/google.json b/common/defs/fido/google.json similarity index 100% rename from common/defs/webauthn/apps/google.json rename to common/defs/fido/google.json diff --git a/common/defs/webauthn/apps/google.png b/common/defs/fido/google.png similarity index 100% rename from common/defs/webauthn/apps/google.png rename to common/defs/fido/google.png diff --git a/common/defs/webauthn/apps/keeper.json b/common/defs/fido/keeper.json similarity index 100% rename from common/defs/webauthn/apps/keeper.json rename to common/defs/fido/keeper.json diff --git a/common/defs/webauthn/apps/keeper.png b/common/defs/fido/keeper.png similarity index 100% rename from common/defs/webauthn/apps/keeper.png rename to common/defs/fido/keeper.png diff --git a/common/defs/webauthn/apps/lastpass.json b/common/defs/fido/lastpass.json similarity index 100% rename from common/defs/webauthn/apps/lastpass.json rename to common/defs/fido/lastpass.json diff --git a/common/defs/webauthn/apps/lastpass.png b/common/defs/fido/lastpass.png similarity index 100% rename from common/defs/webauthn/apps/lastpass.png rename to common/defs/fido/lastpass.png diff --git a/common/defs/webauthn/apps/login.gov.json b/common/defs/fido/login.gov.json similarity index 100% rename from common/defs/webauthn/apps/login.gov.json rename to common/defs/fido/login.gov.json diff --git a/common/defs/webauthn/apps/login.gov.png b/common/defs/fido/login.gov.png similarity index 100% rename from common/defs/webauthn/apps/login.gov.png rename to common/defs/fido/login.gov.png diff --git a/common/defs/webauthn/apps/microsoft.json b/common/defs/fido/microsoft.json similarity index 100% rename from common/defs/webauthn/apps/microsoft.json rename to common/defs/fido/microsoft.json diff --git a/common/defs/webauthn/apps/microsoft.png b/common/defs/fido/microsoft.png similarity index 100% rename from common/defs/webauthn/apps/microsoft.png rename to common/defs/fido/microsoft.png diff --git a/common/defs/webauthn/apps/mojeid.json b/common/defs/fido/mojeid.json similarity index 100% rename from common/defs/webauthn/apps/mojeid.json rename to common/defs/fido/mojeid.json diff --git a/common/defs/webauthn/apps/mojeid.png b/common/defs/fido/mojeid.png similarity index 100% rename from common/defs/webauthn/apps/mojeid.png rename to common/defs/fido/mojeid.png diff --git a/common/defs/webauthn/apps/slushpool.json b/common/defs/fido/slushpool.json similarity index 100% rename from common/defs/webauthn/apps/slushpool.json rename to common/defs/fido/slushpool.json diff --git a/common/defs/webauthn/apps/slushpool.png b/common/defs/fido/slushpool.png similarity index 100% rename from common/defs/webauthn/apps/slushpool.png rename to common/defs/fido/slushpool.png diff --git a/common/defs/webauthn/apps/stripe.json b/common/defs/fido/stripe.json similarity index 100% rename from common/defs/webauthn/apps/stripe.json rename to common/defs/fido/stripe.json diff --git a/common/defs/webauthn/apps/stripe.png b/common/defs/fido/stripe.png similarity index 100% rename from common/defs/webauthn/apps/stripe.png rename to common/defs/fido/stripe.png diff --git a/common/defs/webauthn/apps/u2f.bin.coffee.json b/common/defs/fido/u2f.bin.coffee.json similarity index 100% rename from common/defs/webauthn/apps/u2f.bin.coffee.json rename to common/defs/fido/u2f.bin.coffee.json diff --git a/common/defs/webauthn/apps/webauthn.bin.coffee.json b/common/defs/fido/webauthn.bin.coffee.json similarity index 100% rename from common/defs/webauthn/apps/webauthn.bin.coffee.json rename to common/defs/fido/webauthn.bin.coffee.json diff --git a/common/defs/webauthn/apps/webauthn.io.json b/common/defs/fido/webauthn.io.json similarity index 100% rename from common/defs/webauthn/apps/webauthn.io.json rename to common/defs/fido/webauthn.io.json diff --git a/common/defs/webauthn/apps/webauthn.me.json b/common/defs/fido/webauthn.me.json similarity index 100% rename from common/defs/webauthn/apps/webauthn.me.json rename to common/defs/fido/webauthn.me.json diff --git a/common/defs/webauthn/apps/yubico-demo.json b/common/defs/fido/yubico-demo.json similarity index 100% rename from common/defs/webauthn/apps/yubico-demo.json rename to common/defs/fido/yubico-demo.json diff --git a/common/defs/webauthn/gen.py b/common/defs/webauthn/gen.py deleted file mode 100755 index e1cba7157..000000000 --- a/common/defs/webauthn/gen.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python3 -import json -import sys -from glob import glob -from hashlib import sha256 - -try: - opt = sys.argv[1] -except IndexError: - print("Usage: gen.py [core|mcu|check])") - sys.exit(1) - - -def c_bytes(h): - return "{ " + ", ".join(["0x%02x" % x for x in h]) + " }" - - -def gen_core(data): - print("# contents generated via script in") - print("# trezor-common/defs/webauthn/gen.py") - print("# do not edit manually") - print() - print("knownapps = {") - print(" # U2F") - for d in data: - for appid in d.get("u2f", []): - label = d["label"] - h = bytes.fromhex(appid) - print(" %s: {" % h) - print(' "label": "%s",' % label) - print(' "use_sign_count": True,') - print(" },") - print(" # WebAuthn") - for d in data: - for origin in d.get("webauthn", []): - h = sha256(origin.encode()).digest() - label, use_sign_count = (d["label"], d.get("use_sign_count", None)) - print(" %s: {" % h) - print(' "label": "%s",' % label) - if use_sign_count is not None: - print(' "use_sign_count": %s,' % use_sign_count) - print(" },") - print("} # type: dict") - - -def gen_mcu(data): - for d in data: - for appid in d.get("u2f", []): - label = d["label"] - h = bytes.fromhex(appid) - print('\t{\n\t\t// U2F\n\t\t%s,\n\t\t"%s"\n\t},' % (c_bytes(h), label)) - for origin in d.get("webauthn", []): - label = d["label"] - h = sha256(origin.encode()).digest() - print( - '\t{\n\t\t// WebAuthn: %s\n\t\t%s,\n\t\t"%s"\n\t},' - % (origin, c_bytes(h), label) - ) - - -data = [] -for fn in sorted(glob("apps/*.json")): - d = json.load(open(fn, "rt")) - data.append(d) - -if opt == "core": - gen_core(data) -elif opt == "mcu": - gen_mcu(data) diff --git a/common/tools/coin_info.py b/common/tools/coin_info.py index 8fade47b4..357aa70d7 100755 --- a/common/tools/coin_info.py +++ b/common/tools/coin_info.py @@ -262,16 +262,14 @@ def _load_misc(): def _load_fido_apps(): """Load btc-like coins from `coins/*.json`""" apps = [] - for filename in sorted( - glob.glob(os.path.join(DEFS_DIR, "webauthn", "apps", "*.json")) - ): + for filename in sorted(glob.glob(os.path.join(DEFS_DIR, "fido", "*.json"))): app_name = os.path.basename(filename)[:-5].lower() app = load_json(filename) app.setdefault("use_sign_count", None) app.setdefault("u2f", []) app.setdefault("webauthn", []) - icon_path = os.path.join(DEFS_DIR, "webauthn", "apps", app_name + ".png") + icon_path = os.path.join(DEFS_DIR, "fido", app_name + ".png") if not os.path.exists(icon_path): icon_path = None