diff --git a/libwebauthn-tests/tests/signature_roundtrip.rs b/libwebauthn-tests/tests/signature_roundtrip.rs index 87107d66..87002c04 100644 --- a/libwebauthn-tests/tests/signature_roundtrip.rs +++ b/libwebauthn-tests/tests/signature_roundtrip.rs @@ -133,7 +133,7 @@ async fn test_ctap2_signature_roundtrip() { ); let (attestation_signature, x5c) = match ®istration.attestation_statement { - Ctap2AttestationStatement::PackedOrAndroid(stmt) => ( + Some(Ctap2AttestationStatement::PackedOrAndroid(stmt)) => ( stmt.signature.as_ref(), stmt.certificates .first() diff --git a/libwebauthn/src/ops/u2f.rs b/libwebauthn/src/ops/u2f.rs index 84b124b9..65d8b7d3 100644 --- a/libwebauthn/src/ops/u2f.rs +++ b/libwebauthn/src/ops/u2f.rs @@ -163,7 +163,7 @@ impl UpgradableResponse for Regis let resp = Ctap2MakeCredentialResponse { format: String::from("fido-u2f"), authenticator_data, - attestation_statement, + attestation_statement: Some(attestation_statement), enterprise_attestation: None, large_blob_key: None, unsigned_extension_outputs: None, diff --git a/libwebauthn/src/ops/webauthn/make_credential.rs b/libwebauthn/src/ops/webauthn/make_credential.rs index b1b2bb9e..6e9f8ba0 100644 --- a/libwebauthn/src/ops/webauthn/make_credential.rs +++ b/libwebauthn/src/ops/webauthn/make_credential.rs @@ -48,7 +48,7 @@ use super::{ pub struct MakeCredentialResponse { pub format: String, pub authenticator_data: AuthenticatorData, - pub attestation_statement: Ctap2AttestationStatement, + pub attestation_statement: Option, pub enterprise_attestation: Option, pub large_blob_key: Option>, pub unsigned_extensions_output: MakeCredentialsResponseUnsignedExtensions, @@ -144,7 +144,12 @@ impl WebAuthnIDLResponse for MakeCredentialResponse { let (format, attestation_statement) = if scrub_attestation { ("none", &none_statement) } else { - (self.format.as_str(), &self.attestation_statement) + ( + self.format.as_str(), + self.attestation_statement + .as_ref() + .unwrap_or(&none_statement), + ) }; let attestation_object_bytes = build_attestation_object(format, attestation_statement, &authenticator_data_bytes)?; @@ -1796,7 +1801,7 @@ mod tests { MakeCredentialResponse { format: "none".to_string(), authenticator_data, - attestation_statement: Ctap2AttestationStatement::None(BTreeMap::new()), + attestation_statement: Some(Ctap2AttestationStatement::None(BTreeMap::new())), enterprise_attestation: None, large_blob_key: None, unsigned_extensions_output: MakeCredentialsResponseUnsignedExtensions::default(), @@ -2104,10 +2109,12 @@ mod tests { MakeCredentialResponse { format: "fido-u2f".to_string(), authenticator_data, - attestation_statement: Ctap2AttestationStatement::FidoU2F(FidoU2fAttestationStmt { - signature: ByteBuf::from(vec![0xAA; 16]), - certificates: vec![ByteBuf::from(vec![0xBB; 8])], - }), + attestation_statement: Some(Ctap2AttestationStatement::FidoU2F( + FidoU2fAttestationStmt { + signature: ByteBuf::from(vec![0xAA; 16]), + certificates: vec![ByteBuf::from(vec![0xBB; 8])], + }, + )), enterprise_attestation: None, large_blob_key: None, unsigned_extensions_output: MakeCredentialsResponseUnsignedExtensions::default(), diff --git a/libwebauthn/src/proto/ctap2/model/make_credential.rs b/libwebauthn/src/proto/ctap2/model/make_credential.rs index 2a50b12c..a1e7d27f 100644 --- a/libwebauthn/src/proto/ctap2/model/make_credential.rs +++ b/libwebauthn/src/proto/ctap2/model/make_credential.rs @@ -411,8 +411,9 @@ pub struct Ctap2MakeCredentialResponse { #[serde(index = 0x02)] pub authenticator_data: AuthenticatorData, + #[serde(skip_serializing_if = "Option::is_none")] #[serde(index = 0x03)] - pub attestation_statement: Ctap2AttestationStatement, + pub attestation_statement: Option, #[serde(skip_serializing_if = "Option::is_none")] #[serde(index = 0x04)]