2019-11-28 14:51:41 +00:00
|
|
|
# generated from knownapps.py.mako
|
2022-04-28 10:22:53 +00:00
|
|
|
# (by running `make templates` in `core`)
|
2019-11-28 14:51:41 +00:00
|
|
|
# do not edit manually!
|
|
|
|
|
|
|
|
|
|
|
|
class FIDOApp:
|
|
|
|
def __init__(
|
2019-12-11 10:47:02 +00:00
|
|
|
self,
|
|
|
|
label: str,
|
2021-03-18 09:48:50 +00:00
|
|
|
icon: str | None,
|
|
|
|
use_sign_count: bool | None,
|
|
|
|
use_self_attestation: bool | None,
|
2019-11-28 14:51:41 +00:00
|
|
|
) -> None:
|
|
|
|
self.label = label
|
|
|
|
self.icon = icon
|
|
|
|
self.use_sign_count = use_sign_count
|
2019-12-11 10:47:02 +00:00
|
|
|
self.use_self_attestation = use_self_attestation
|
2019-11-28 14:51:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
<%
|
|
|
|
from hashlib import sha256
|
|
|
|
|
|
|
|
fido_entries = []
|
|
|
|
for app in fido:
|
2020-07-30 10:11:26 +00:00
|
|
|
for u2f in app.u2f:
|
|
|
|
fido_entries.append((u2f["label"], bytes.fromhex(u2f["app_id"]), "U2F", app))
|
2019-11-28 14:51:41 +00:00
|
|
|
for origin in app.webauthn:
|
|
|
|
rp_id_hash = sha256(origin.encode()).digest()
|
2020-07-30 10:11:26 +00:00
|
|
|
fido_entries.append((origin, rp_id_hash, "WebAuthn", app))
|
2019-11-28 14:51:41 +00:00
|
|
|
if app.icon is not None:
|
|
|
|
app.icon_res = f"apps/webauthn/res/icon_{app.key}.toif"
|
|
|
|
else:
|
|
|
|
app.icon_res = None
|
|
|
|
%>\
|
|
|
|
# fmt: off
|
2021-03-18 09:48:50 +00:00
|
|
|
def by_rp_id_hash(rp_id_hash: bytes) -> FIDOApp | None:
|
2020-07-30 10:11:26 +00:00
|
|
|
% for label, rp_id_hash, type, app in fido_entries:
|
2021-12-08 09:16:19 +00:00
|
|
|
if rp_id_hash == ${black_repr(rp_id_hash)}:
|
2020-07-30 10:11:26 +00:00
|
|
|
# ${type} key for ${app.name}
|
2019-11-28 14:51:41 +00:00
|
|
|
return FIDOApp(
|
2020-07-30 10:11:26 +00:00
|
|
|
label=${black_repr(label)},
|
2019-11-28 14:51:41 +00:00
|
|
|
icon=${black_repr(app.icon_res)},
|
|
|
|
use_sign_count=${black_repr(app.use_sign_count)},
|
2019-12-11 10:47:02 +00:00
|
|
|
use_self_attestation=${black_repr(app.use_self_attestation)},
|
2019-11-28 14:51:41 +00:00
|
|
|
)
|
|
|
|
% endfor
|
2021-12-08 09:16:19 +00:00
|
|
|
|
|
|
|
return None
|