diff --git a/Cargo.toml b/Cargo.toml index 1813630..732bb2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ctap_hmac" description = "A Rust implementation of the FIDO2 CTAP protocol, including the HMAC extension" -version = "0.4.4" +version = "0.4.5" license = "Apache-2.0/MIT" homepage = "https://github.com/shimunn/ctap" repository = "https://github.com/shimunn/ctap" diff --git a/src/cbor.rs b/src/cbor.rs index 068f485..9f175a8 100644 --- a/src/cbor.rs +++ b/src/cbor.rs @@ -7,6 +7,7 @@ use cbor_codec::value; use cbor_codec::value::Value; use cbor_codec::{Config, Decoder, Encoder, GenericDecoder, GenericEncoder}; +use cbor::skip::Skip; use byteorder::{BigEndian, ByteOrder, ReadBytesExt, WriteBytesExt}; use failure::ResultExt; @@ -38,7 +39,7 @@ impl<'a> Request<'a> { } } - pub fn decode(&self, reader: R) -> FidoResult { + pub fn decode(&self, reader: R) -> FidoResult { Ok(match self { Request::MakeCredential(_) => { Response::MakeCredential(MakeCredentialResponse::decode(reader)?) @@ -277,7 +278,7 @@ pub struct GetInfoResponse { } impl GetInfoResponse { - pub fn decode(mut reader: R) -> FidoResult { + pub fn decode(mut reader: R) -> FidoResult { let status = reader.read_u8().context(FidoErrorKind::CborDecode)?; if status != 0 { Err(FidoErrorKind::CborError(CborErrorCode::from(status)))? @@ -304,7 +305,7 @@ impl GetInfoResponse { response.pin_protocols.push(decoder.u8()?); } } - _ => continue, + _ => decoder.skip()?, } } Ok(response) diff --git a/src/lib.rs b/src/lib.rs index e057576..c823e69 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -287,14 +287,14 @@ impl FidoDevice { cbor::Response::GetInfo(resp) => resp, _ => Err(FidoErrorKind::CborDecode)?, }; - if !response.versions.iter().any(|ver| ver == "FIDO_2_0") { + if !response.versions.iter().any(|ver| ["FIDO_2_0", "FIDO_2_1_PRE"].contains(&ver.as_str())) { Err(FidoErrorKind::DeviceUnsupported)? } // Require pin protocol version 1, only if pin-protocol is supported at all if !response .pin_protocols .iter() - .fold(true, |supported, ver| *ver == 1 && supported) + .any(|ver| *ver == 1) && response.pin_protocols.len() > 0 { Err(FidoErrorKind::DeviceUnsupported)? }