Skip to content

Commit

Permalink
Fix large blob support
Browse files Browse the repository at this point in the history
This patch fixes some issues that we missed in
#18:
- largeBlobs request deserialization
- largeBlobKey in credential management
- empty response for largeBlobs command with set
  • Loading branch information
robin-nitrokey committed Nov 21, 2023
1 parent 2a563c8 commit 785bcc5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/ctap2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,14 @@ impl<'a> Request<'a> {
Request::ClientPin(cbor_deserialize(data).map_err(CtapMappingError::ParsingError)?)
}

Operation::LargeBlobs => {
Request::LargeBlobs(cbor_deserialize(data).map_err(CtapMappingError::ParsingError)?)
}

// NB: FIDO Alliance "stole" 0x40 and 0x41, so these are not available
Operation::Vendor(vendor_operation) => Request::Vendor(vendor_operation),

Operation::BioEnrollment
| Operation::PreviewBioEnrollment
| Operation::Config
| Operation::LargeBlobs => {
Operation::BioEnrollment | Operation::PreviewBioEnrollment | Operation::Config => {
debug_now!("unhandled CBOR operation {:?}", operation);
return Err(CtapMappingError::InvalidCommand(op).into());
}
Expand Down
3 changes: 3 additions & 0 deletions src/ctap2/credential_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,7 @@ pub struct Response {
// 0x0A
#[serde(skip_serializing_if = "Option::is_none")]
pub cred_protect: Option<CredentialProtectionPolicy>,
// 0x0B
#[serde(skip_serializing_if = "Option::is_none")]
pub large_blob_key: Option<Bytes<32>>,
}
5 changes: 3 additions & 2 deletions src/ctap2/large_blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ pub struct Request<'a> {
pub pin_uv_auth_protocol: Option<u32>,
}

#[derive(Clone, Debug, Eq, PartialEq, SerializeIndexed, DeserializeIndexed)]
#[derive(Clone, Debug, Default, Eq, PartialEq, SerializeIndexed, DeserializeIndexed)]
#[serde_indexed(offset = 1)]
pub struct Response {
// 0x01
pub config: Bytes<LARGE_BLOB_MAX_FRAGMENT_LENGTH>,
#[serde(skip_serializing_if = "Option::is_none")]
pub config: Option<Bytes<LARGE_BLOB_MAX_FRAGMENT_LENGTH>>,
}

0 comments on commit 785bcc5

Please sign in to comment.