fix: tolerate newer versions
This commit is contained in:
parent
3a6dd90ec4
commit
718c9c93e6
@ -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"
|
||||
|
@ -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<R: ReadBytesExt>(&self, reader: R) -> FidoResult<Response> {
|
||||
pub fn decode<R: ReadBytesExt + Skip>(&self, reader: R) -> FidoResult<Response> {
|
||||
Ok(match self {
|
||||
Request::MakeCredential(_) => {
|
||||
Response::MakeCredential(MakeCredentialResponse::decode(reader)?)
|
||||
@ -277,7 +278,7 @@ pub struct GetInfoResponse {
|
||||
}
|
||||
|
||||
impl GetInfoResponse {
|
||||
pub fn decode<R: ReadBytesExt>(mut reader: R) -> FidoResult<Self> {
|
||||
pub fn decode<R: ReadBytesExt + Skip>(mut reader: R) -> FidoResult<Self> {
|
||||
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)
|
||||
|
@ -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)?
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user