diff --git a/crates/fido-common/src/attestation.rs b/crates/fido-common/src/attestation.rs index 5b76fe6..5dc3d5f 100644 --- a/crates/fido-common/src/attestation.rs +++ b/crates/fido-common/src/attestation.rs @@ -1,5 +1,10 @@ #[cfg(feature = "serde")] +use crate::credential::public_key::algorithm; +#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; +#[cfg(feature = "serde")] +use serde_with::{serde_as, Bytes}; + pub mod enterprise; /// > Attestation statement formats are identified by a string, called an @@ -71,6 +76,31 @@ pub enum FormatIdentifier { None, } +#[cfg_eval] +#[derive(Debug)] +#[cfg_attr( + feature = "serde", + serde_as, + derive(Serialize, Deserialize), + // TODO: Workaround until serde can use integer keys as tag, since "fmt" is CBOR key 0x01. + serde(untagged) +)] +pub enum Statement { + #[cfg_attr(feature = "serde", serde(rename = "packed"))] + Packed { + #[cfg_attr(feature = "serde", serde(rename = "alg", with = "algorithm"))] + algorithm: coset::iana::Algorithm, + #[cfg_attr(feature = "serde", serde_as(as = "Bytes"), serde(rename = "sig"))] + signature: Vec, + #[cfg_attr(feature = "serde", serde_as(as = "Vec"), serde(rename = "x5c"))] + attestation_certificate_chain: Vec>, // TODO: Parse X.509 certs + }, + Unregistered { + identifier: String, + data: Vec, + }, +} + /// > Attested credential data is a variable-length byte array added to the /// > authenticator data when generating an attestation object for a given /// > credential.