Skip to content

Commit 925b9b8

Browse files
committed
Remove support for credProps for CTAP 2.0 devices
1 parent c9a6692 commit 925b9b8

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/ctap2/commands/make_credentials.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::get_info::AuthenticatorInfo;
1+
use super::get_info::{AuthenticatorInfo, AuthenticatorVersion};
22
use super::{
33
Command, CommandError, PinUvAuthCommand, RequestCtap1, RequestCtap2, Retryable, StatusCode,
44
};
@@ -300,18 +300,31 @@ impl MakeCredentials {
300300
}
301301
}
302302

303-
pub fn finalize_result<Dev: FidoDevice>(&self, _dev: &Dev, result: &mut MakeCredentialsResult) {
303+
pub fn finalize_result<Dev: FidoDevice>(&self, dev: &Dev, result: &mut MakeCredentialsResult) {
304+
let maybe_info = dev.get_authenticator_info();
305+
304306
// Handle extensions whose outputs are not encoded in the authenticator data.
305307
// 1. credProps
306308
// "set clientExtensionResults["credProps"]["rk"] to the value of the
307309
// requireResidentKey parameter that was used in the invocation of the
308310
// authenticatorMakeCredential operation."
309-
if self.extensions.cred_props == Some(true) {
311+
// Note: a CTAP 2.0 authenticator is allowed to create a discoverable credential even
312+
// if one was not requested, so there is a case in which we cannot confidently
313+
// return `rk=false` here. We omit the response entirely in this case.
314+
let dev_supports_rk = maybe_info.map_or(false, |info| info.options.resident_key);
315+
let requested_rk = self.options.resident_key.unwrap_or(false);
316+
let max_supported_version = maybe_info.map_or(AuthenticatorVersion::U2F_V2, |info| {
317+
info.max_supported_version()
318+
});
319+
let rk_uncertain = max_supported_version == AuthenticatorVersion::FIDO_2_0
320+
&& dev_supports_rk
321+
&& !requested_rk;
322+
if self.extensions.cred_props == Some(true) && !rk_uncertain {
310323
result
311324
.extensions
312325
.cred_props
313326
.get_or_insert(Default::default())
314-
.rk = self.options.resident_key.unwrap_or(false);
327+
.rk = requested_rk;
315328
}
316329

317330
// 2. hmac-secret

0 commit comments

Comments
 (0)