Ignore key parameters with unsupported type

As required by the Webauthn spec, we now ignore public key credential
parameters with a type other than "public-key".

Fixes: https://github.com/Nitrokey/fido-authenticator/issues/20
This commit is contained in:
Robin Krahl
2023-07-10 13:18:33 +02:00
parent 08c21a222b
commit 2ef8446d56
2 changed files with 11 additions and 9 deletions
+4
View File
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
- Add config option for setting a maximum number of resident credentials.
- Ignore public key credential paramters with an unknown type, as required by
the Webauthn spec ([#28][])
[#28]: https://github.com/solokeys/fido-authenticator/issues/28
## [0.1.1] - 2022-08-22
- Fix bug that treated U2F payloads as APDU over APDU in NFC transport @conorpp
+7 -9
View File
@@ -197,6 +197,11 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
let mut algorithm: Option<SigningAlgorithm> = None;
for param in parameters.pub_key_cred_params.iter() {
// Ignore unknown key types
if param.key_type != "public-key" {
continue;
}
match param.alg {
-7 => {
if algorithm.is_none() {
@@ -210,15 +215,8 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
_ => {}
}
}
let algorithm = match algorithm {
Some(algorithm) => {
info_now!("algo: {:?}", algorithm as i32);
algorithm
}
None => {
return Err(Error::UnsupportedAlgorithm);
}
};
let algorithm = algorithm.ok_or(Error::UnsupportedAlgorithm)?;
info_now!("algo: {:?}", algorithm as i32);
// 8. process options; on known but unsupported error UnsupportedOption