Skip to content

Commit

Permalink
get_info: Add fields for CTAP 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-nitrokey committed Jun 20, 2024
1 parent 114efe5 commit 62ad40a
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Mark `get_assertion::{ExtensionsInput, ExtensionsOutput}` and `make_credential::Extensions` as non-exhaustive and implement `Default`
- Mark CTAP2 request and response types as non-exhaustive where possible
- Use references where possible
- Put uncommon fields in `get_info` behind `get-info-full` feature flag
- Put uncommon fields in `get_info` behind `get-info-full` feature flag and add fields for CTAP 2.1

[#8]: https://github.com/trussed-dev/ctap-types/pull/8
[#9]: https://github.com/solokeys/ctap-types/issues/9
Expand Down
125 changes: 114 additions & 11 deletions src/ctap2/get_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,66 @@ pub struct Response {
// FIDO_2_1
#[serde(skip_serializing_if = "Option::is_none")]
pub max_serialized_large_blob_array: Option<usize>,

// 0x0C
// FIDO_2_1
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub force_pin_change: Option<bool>,

// 0x0D
// FIDO_2_1
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub min_pin_length: Option<usize>,

// 0x0E
// FIDO_2_1
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firmware_version: Option<usize>,

// 0x0F
// FIDO_2_1
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_cred_blob_length: Option<usize>,

// 0x10
// FIDO_2_1
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_rpids_for_set_min_pin_length: Option<usize>,

// 0x11
// FIDO_2_1
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_platform_uv_attempts: Option<usize>,

// 0x12
// FIDO_2_1
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub uv_modality: Option<usize>,

// 0x13
// FIDO_2_1
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certifications: Option<Certifications>,

// 0x14
// FIDO_2_1
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remaining_discoverable_credentials: Option<usize>,

// 0x15
// FIDO_2_1
#[cfg(feature = "get-info-full")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vendor_prototype_config_commands: Option<usize>,
}

impl Default for Response {
Expand All @@ -63,19 +123,13 @@ impl Default for Response {
zero_aaguid.resize_default(16).unwrap();
let aaguid = Bytes::<16>::from(zero_aaguid);

Self {
versions: Vec::new(),
extensions: None,
let mut response = ResponseBuilder {
aaguid,
options: Some(CtapOptions::default()),
max_msg_size: None, //Some(MESSAGE_SIZE),
pin_protocols: None,
max_creds_in_list: None,
max_cred_id_length: None,
transports: None,
algorithms: None,
max_serialized_large_blob_array: None,
versions: Vec::new(),
}
.build();
response.options = Some(CtapOptions::default());
response
}
}

Expand All @@ -100,6 +154,26 @@ impl ResponseBuilder {
transports: None,
algorithms: None,
max_serialized_large_blob_array: None,
#[cfg(feature = "get-info-full")]
force_pin_change: None,
#[cfg(feature = "get-info-full")]
min_pin_length: None,
#[cfg(feature = "get-info-full")]
firmware_version: None,
#[cfg(feature = "get-info-full")]
max_cred_blob_length: None,
#[cfg(feature = "get-info-full")]
max_rpids_for_set_min_pin_length: None,
#[cfg(feature = "get-info-full")]
preferred_platform_uv_attempts: None,
#[cfg(feature = "get-info-full")]
uv_modality: None,
#[cfg(feature = "get-info-full")]
certifications: None,
#[cfg(feature = "get-info-full")]
remaining_discoverable_credentials: None,
#[cfg(feature = "get-info-full")]
vendor_prototype_config_commands: None,
}
}
}
Expand Down Expand Up @@ -196,3 +270,32 @@ impl Default for CtapOptions {
}
}
}

#[cfg(feature = "get-info-full")]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Certifications {
#[serde(rename = "FIPS-CMVP-2")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fips_cmpv2: Option<u8>,

#[serde(rename = "FIPS-CMVP-3")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fips_cmpv3: Option<u8>,

#[serde(rename = "FIPS-CMVP-2-PHY")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fips_cmpv2_phy: Option<u8>,

#[serde(rename = "FIPS-CMVP-3-PHY")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fips_cmpv3_phy: Option<u8>,

#[serde(rename = "CC-EAL")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cc_eal: Option<u8>,

#[serde(rename = "FIDO")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fido: Option<u8>,
}

0 comments on commit 62ad40a

Please sign in to comment.