From 785bcc52720ce2e2054ae32034a2a24c500e1043 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 21 Nov 2023 11:41:02 +0100 Subject: [PATCH] Fix large blob support This patch fixes some issues that we missed in https://github.com/trussed-dev/ctap-types/pull/18: - largeBlobs request deserialization - largeBlobKey in credential management - empty response for largeBlobs command with set --- src/ctap2.rs | 9 +++++---- src/ctap2/credential_management.rs | 3 +++ src/ctap2/large_blobs.rs | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ctap2.rs b/src/ctap2.rs index ec836c6..5395a60 100644 --- a/src/ctap2.rs +++ b/src/ctap2.rs @@ -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()); } diff --git a/src/ctap2/credential_management.rs b/src/ctap2/credential_management.rs index 2eeeff3..fcfd77f 100644 --- a/src/ctap2/credential_management.rs +++ b/src/ctap2/credential_management.rs @@ -107,4 +107,7 @@ pub struct Response { // 0x0A #[serde(skip_serializing_if = "Option::is_none")] pub cred_protect: Option, + // 0x0B + #[serde(skip_serializing_if = "Option::is_none")] + pub large_blob_key: Option>, } diff --git a/src/ctap2/large_blobs.rs b/src/ctap2/large_blobs.rs index dba57dd..438b44e 100644 --- a/src/ctap2/large_blobs.rs +++ b/src/ctap2/large_blobs.rs @@ -25,9 +25,10 @@ pub struct Request<'a> { pub pin_uv_auth_protocol: Option, } -#[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, + #[serde(skip_serializing_if = "Option::is_none")] + pub config: Option>, }