Skip to content

Commit 788c5c9

Browse files
committed
Update CTAP2 Info dataclass
1 parent ced6678 commit 788c5c9

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

fido2/ctap2/base.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,19 @@ def _get_field_key(cls, field: Field) -> int:
6464
class Info(_CborDataObject):
6565
"""Binary CBOR encoded response data returned by the CTAP2 GET_INFO command.
6666
67+
See:
68+
https://fidoalliance.org/specs/fido-v2.2-rd-20230321/fido-client-to-authenticator-protocol-v2.2-rd-20230321.html#authenticatorGetInfo
69+
for descriptions of these fields.
70+
71+
Note that while many fields are optional when returned by the authenticator,
72+
this dataclass uses defaults to represent a missing value such as empty lists
73+
or dicts, or the integer value 0. These are used rather than None for omitted
74+
values as long as this can be done without introducing any practical ambiguity.
75+
This also means that several of these fields may have a 0 value even if the
76+
specification states that they should be non-zero when returned from the
77+
authenticator.
78+
6779
:param _: The binary content of the Info data.
68-
:ivar versions: The versions supported by the authenticator.
69-
:ivar extensions: The extensions supported by the authenticator.
70-
:ivar aaguid: The AAGUID of the authenticator.
71-
:ivar options: The options supported by the authenticator.
72-
:ivar max_msg_size: The max message size supported by the authenticator.
73-
:ivar pin_uv_protocols: The PIN/UV protocol versions supported by the authenticator.
74-
:ivar max_creds_in_list: Max number of credentials supported in list at a time.
75-
:ivar max_cred_id_length: Max length of Credential ID supported.
76-
:ivar transports: List of supported transports.
77-
:ivar algorithms: List of supported algorithms for credential creation.
78-
:ivar data: The Info members, in the form of a dict.
7980
"""
8081

8182
versions: list[str]
@@ -84,21 +85,24 @@ class Info(_CborDataObject):
8485
options: dict[str, bool] = field(default_factory=dict)
8586
max_msg_size: int = 1024
8687
pin_uv_protocols: list[int] = field(default_factory=list)
87-
max_creds_in_list: int | None = None
88-
max_cred_id_length: int | None = None
88+
max_creds_in_list: int = 0
89+
max_cred_id_length: int = 0
8990
transports: list[str] = field(default_factory=list)
90-
algorithms: list[dict[str, Any]] | None = None
91-
max_large_blob: int | None = None
91+
algorithms: list[dict[str, Any]] = field(default_factory=list)
92+
max_large_blob: int = 0
9293
force_pin_change: bool = False
9394
min_pin_length: int = 4
94-
firmware_version: int | None = None
95-
max_cred_blob_length: int | None = None
95+
firmware_version: int = 0
96+
max_cred_blob_length: int = 0
9697
max_rpids_for_min_pin: int = 0
97-
preferred_platform_uv_attempts: int | None = None
98-
uv_modality: int | None = None
99-
certifications: dict | None = None
98+
preferred_platform_uv_attempts: int = 0
99+
uv_modality: int = 0
100+
certifications: dict = field(default_factory=dict)
100101
remaining_disc_creds: int | None = None
101-
vendor_prototype_config_commands: list[int] | None = None
102+
vendor_prototype_config_commands: list[int] = field(default_factory=list)
103+
attestation_formats: list[str] = field(default_factory=lambda: ["packed"])
104+
uv_count_since_pin: int | None = None
105+
long_touch_for_reset: bool = False
102106

103107

104108
@dataclass(eq=False, frozen=True)

0 commit comments

Comments
 (0)