1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

common: move FIDO defs to "fido" subdirectory

This commit is contained in:
matejcik 2019-11-28 17:02:25 +01:00 committed by matejcik
parent 61e4f79c90
commit 0320a6f23b
48 changed files with 19 additions and 74 deletions

View File

@ -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. We currently recognize five categories of coins.

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 830 B

After

Width:  |  Height:  |  Size: 830 B

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -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)

View File

@ -262,16 +262,14 @@ 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 sorted( for filename in sorted(glob.glob(os.path.join(DEFS_DIR, "fido", "*.json"))):
glob.glob(os.path.join(DEFS_DIR, "webauthn", "apps", "*.json"))
):
app_name = os.path.basename(filename)[:-5].lower() app_name = os.path.basename(filename)[:-5].lower()
app = load_json(filename) app = load_json(filename)
app.setdefault("use_sign_count", None) app.setdefault("use_sign_count", None)
app.setdefault("u2f", []) app.setdefault("u2f", [])
app.setdefault("webauthn", []) 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): if not os.path.exists(icon_path):
icon_path = None icon_path = None