diff --git a/common/defs/webauthn/gen.py b/common/defs/webauthn/gen.py index c6ca8805c6..e1cba71575 100755 --- a/common/defs/webauthn/gen.py +++ b/common/defs/webauthn/gen.py @@ -40,7 +40,7 @@ def gen_core(data): if use_sign_count is not None: print(' "use_sign_count": %s,' % use_sign_count) print(" },") - print("}") + print("} # type: dict") def gen_mcu(data): diff --git a/core/src/apps/webauthn/credential.py b/core/src/apps/webauthn/credential.py index 13effcf3f1..31b0f142cd 100644 --- a/core/src/apps/webauthn/credential.py +++ b/core/src/apps/webauthn/credential.py @@ -264,7 +264,9 @@ class U2fCredential(Credential): def app_name(self) -> str: from apps.webauthn.knownapps import knownapps - app_name = knownapps.get(self.rp_id_hash, {}).get("label", None) + app_name = knownapps.get(self.rp_id_hash, {}).get( + "label", None + ) # type: Optional[str] if app_name is None: app_name = "%s...%s" % ( hexlify(self.rp_id_hash[:4]).decode(), diff --git a/core/src/apps/webauthn/fido2.py b/core/src/apps/webauthn/fido2.py index facfc6aa1c..a62f215855 100644 --- a/core/src/apps/webauthn/fido2.py +++ b/core/src/apps/webauthn/fido2.py @@ -23,7 +23,7 @@ if __debug__: from apps.debug import confirm_signal if False: - from typing import Any, Coroutine, List, Optional + from typing import Any, Coroutine, List, Optional, Tuple _CID_BROADCAST = const(0xFFFFFFFF) # broadcast channel id @@ -319,15 +319,15 @@ def resp_cmd_authenticate(siglen: int) -> dict: } -def overlay_struct(buf, desc): - desc_size = uctypes.sizeof(desc, uctypes.BIG_ENDIAN) +def overlay_struct(buf: bytes, desc: dict) -> Any: + desc_size = uctypes.sizeof(desc, uctypes.BIG_ENDIAN) # type: ignore if desc_size > len(buf): raise ValueError("desc is too big (%d > %d)" % (desc_size, len(buf))) return uctypes.struct(uctypes.addressof(buf), desc, uctypes.BIG_ENDIAN) -def make_struct(desc): - desc_size = uctypes.sizeof(desc, uctypes.BIG_ENDIAN) +def make_struct(desc: dict) -> Tuple[bytearray, Any]: + desc_size = uctypes.sizeof(desc, uctypes.BIG_ENDIAN) # type: ignore buf = bytearray(desc_size) return buf, uctypes.struct(uctypes.addressof(buf), desc, uctypes.BIG_ENDIAN) diff --git a/core/src/apps/webauthn/knownapps.py b/core/src/apps/webauthn/knownapps.py index 81b63aeb98..df092d629b 100644 --- a/core/src/apps/webauthn/knownapps.py +++ b/core/src/apps/webauthn/knownapps.py @@ -117,4 +117,4 @@ knownapps = { b"\xc4l\xef\x82\xad\x1bTdwY\x1d\x00\x8b\x08u\x9e\xc3\xe6\xd2\xec\xb4\xf3\x94t\xbf\xeaii\x92]\x03\xb7": { "label": "demo.yubico.com" }, -} +} # type: dict