diff --git a/CHANGELOG.md b/CHANGELOG.md index b72fcea..401939f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Implement PIN protocol 2 ([#63][]) - Implement PIN token permissions ([#63][]) - Implement UpdateUserInformation subcommand for CredentialManagement +- Support CTAP 2.1 [#26]: https://github.com/solokeys/fido-authenticator/issues/26 [#28]: https://github.com/solokeys/fido-authenticator/issues/28 diff --git a/Cargo.toml b/Cargo.toml index daf1090..eb815fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,6 @@ iso7816 = { version = "0.1", optional = true } [features] dispatch = ["apdu-dispatch", "ctaphid-dispatch", "iso7816"] disable-reset-time-window = [] -enable-fido-pre = [] # enables support for a large-blob array longer than 1024 bytes chunked = ["trussed-staging/chunked"] diff --git a/src/ctap2.rs b/src/ctap2.rs index 5adf984..c84365e 100644 --- a/src/ctap2.rs +++ b/src/ctap2.rs @@ -49,13 +49,11 @@ impl Authenticator for crate::Authenti versions .push(String::from_str("FIDO_2_0").unwrap()) .unwrap(); - // #[cfg(feature = "enable-fido-pre")] versions - .push(String::from_str("FIDO_2_1_PRE").unwrap()) + .push(String::from_str("FIDO_2_1").unwrap()) .unwrap(); let mut extensions = Vec::, 4>::new(); - // extensions.push(String::from_str("credProtect").unwrap()).unwrap(); extensions .push(String::from_str("credProtect").unwrap()) .unwrap(); @@ -84,25 +82,15 @@ impl Authenticator for crate::Authenti true => Some(true), false => Some(false), }, - credential_mgmt_preview: Some(true), large_blobs: Some(self.config.supports_large_blobs()), pin_uv_auth_token: Some(true), ..Default::default() }; - // options.rk = true; - // options.up = true; - // options.uv = None; // "uv" here refers to "in itself", e.g. biometric - // options.plat = Some(false); - // options.cred_mgmt = Some(true); - // options.credential_mgmt_preview = Some(true); - // // options.client_pin = None; // not capable of PIN - // options.client_pin = match self.state.persistent.pin_is_set() { - // true => Some(true), - // false => Some(false), - // }; let mut transports = Vec::new(); - transports.push(String::from("nfc")).unwrap(); + if self.config.nfc_transport { + transports.push(String::from("nfc")).unwrap(); + } transports.push(String::from("usb")).unwrap(); let (_, aaguid) = self.state.identity.attestation(&mut self.trussed); @@ -170,6 +158,9 @@ impl Authenticator for crate::Authenti return Err(Error::InvalidOption); } } + if parameters.enterprise_attestation.is_some() { + return Err(Error::InvalidParameter); + } let uv_performed = self.pin_prechecks( ¶meters.options, parameters.pin_auth.map(AsRef::as_ref), @@ -1553,18 +1544,16 @@ impl crate::Authenticator { &hmac_secret.salt_auth, )?; - if hmac_secret.salt_enc.len() != 32 - && (hmac_secret.salt_enc.len() != 64 || hmac_secret.salt_enc.len() == 80) - { - debug_now!("invalid hmac-secret length"); - return Err(Error::InvalidLength); - } - // decrypt input salt_enc to get salt1 or (salt1 || salt2) let salts = shared_secret .decrypt(&mut self.trussed, &hmac_secret.salt_enc) .ok_or(Error::InvalidOption)?; + if salts.len() != 32 && salts.len() != 64 { + debug_now!("invalid hmac-secret length"); + return Err(Error::InvalidLength); + } + let mut salt_output: Bytes<64> = Bytes::new(); // output1 = hmac_sha256(credRandom, salt1) diff --git a/src/ctap2/pin.rs b/src/ctap2/pin.rs index 0ef9cd1..443c255 100644 --- a/src/ctap2/pin.rs +++ b/src/ctap2/pin.rs @@ -406,7 +406,7 @@ impl SharedSecret { data.split_at(16) } }; - try_syscall!(trussed.decrypt(Mechanism::Aes256Cbc, key_id, data, iv, b"", b"")) + try_syscall!(trussed.decrypt(Mechanism::Aes256Cbc, key_id, data, b"", iv, b"")) .ok() .and_then(|response| response.plaintext) } diff --git a/src/lib.rs b/src/lib.rs index 2351556..139ae1c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -103,6 +103,8 @@ pub struct Config { /// /// If this is `None`, the extension and the command are disabled. pub large_blobs: Option, + /// Whether the authenticator supports the NFC transport. + pub nfc_transport: bool, } impl Config {