mirror of
https://github.com/trussed-dev/fido-authenticator.git
synced 2026-06-20 04:16:16 -07:00
Support attestation in get_assertion
This commit is contained in:
@@ -1063,6 +1063,7 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
|
||||
up_performed,
|
||||
multiple_credentials,
|
||||
extensions: parameters.extensions.clone(),
|
||||
attestation_formats_preference: parameters.attestation_formats_preference.clone(),
|
||||
});
|
||||
|
||||
let num_credentials = match num_credentials {
|
||||
@@ -1677,6 +1678,46 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {
|
||||
.to_bytes()
|
||||
.unwrap();
|
||||
|
||||
let att_stmt_fmt =
|
||||
SupportedAttestationFormat::select(data.attestation_formats_preference.as_ref());
|
||||
let att_stmt = if let Some(format) = att_stmt_fmt {
|
||||
match format {
|
||||
SupportedAttestationFormat::None => {
|
||||
Some(AttestationStatement::None(NoneAttestationStatement {}))
|
||||
}
|
||||
SupportedAttestationFormat::Packed => {
|
||||
let (attestation_maybe, _) = self.state.identity.attestation(&mut self.trussed);
|
||||
let (signature, attestation_algorithm) = {
|
||||
if let Some(attestation) = attestation_maybe.as_ref() {
|
||||
let signature = syscall!(self.trussed.sign_p256(
|
||||
attestation.0,
|
||||
&commitment,
|
||||
SignatureSerialization::Asn1Der,
|
||||
))
|
||||
.signature;
|
||||
(signature.to_bytes().map_err(|_| Error::Other)?, -7)
|
||||
} else {
|
||||
(signature.clone(), credential.algorithm())
|
||||
}
|
||||
};
|
||||
let packed = PackedAttestationStatement {
|
||||
alg: attestation_algorithm,
|
||||
sig: signature,
|
||||
x5c: attestation_maybe.as_ref().map(|attestation| {
|
||||
// See: https://www.w3.org/TR/webauthn-2/#sctn-packed-attestation-cert-requirements
|
||||
let cert = attestation.1.clone();
|
||||
let mut x5c = Vec::new();
|
||||
x5c.push(cert).ok();
|
||||
x5c
|
||||
}),
|
||||
};
|
||||
Some(AttestationStatement::Packed(packed))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
if !is_rk {
|
||||
syscall!(self.trussed.delete(key));
|
||||
}
|
||||
@@ -1688,6 +1729,7 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {
|
||||
}
|
||||
.build();
|
||||
response.number_of_credentials = num_credentials;
|
||||
response.att_stmt = att_stmt;
|
||||
|
||||
// User with empty IDs are ignored for compatibility
|
||||
if is_rk {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//! Needs cleanup.
|
||||
|
||||
use ctap_types::{
|
||||
ctap2::AttestationFormatsPreference,
|
||||
// 2022-02-27: 10 credentials
|
||||
sizes::MAX_CREDENTIAL_COUNT_IN_LIST, // U8 currently
|
||||
Error,
|
||||
@@ -216,6 +217,7 @@ pub struct ActiveGetAssertionData {
|
||||
pub up_performed: bool,
|
||||
pub multiple_credentials: bool,
|
||||
pub extensions: Option<ctap_types::ctap2::get_assertion::ExtensionsInput>,
|
||||
pub attestation_formats_preference: Option<AttestationFormatsPreference>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
||||
Reference in New Issue
Block a user