implement fido 2.1

This commit is contained in:
2020-04-10 20:55:53 +02:00
parent 80c175077f
commit bb202c8a54
3 changed files with 64 additions and 9 deletions

View File

@@ -274,6 +274,12 @@ pub struct GetInfoResponse {
pub options: OptionsInfo,
pub max_msg_size: u16,
pub pin_protocols: Vec<u8>,
pub max_credential_count_in_list: Option<u32>,
pub max_credential_id_len: Option<u32>,
pub transports: Vec<String>,
pub algorithms: Vec<CoseKey>,
pub max_authenticator_config_len: Option<u32>,
pub default_cred_protect: Option<u8>,
}
impl GetInfoResponse {
@@ -282,28 +288,49 @@ impl GetInfoResponse {
if status != 0 {
Err(FidoErrorKind::CborError(CborErrorCode::from(status)))?
}
let mut decoder = Decoder::new(Config::default(), reader);
let mut generic = GenericDecoder::new(Config::default(), reader);
let mut response = GetInfoResponse::default();
for _ in 0..decoder.object()? {
match decoder.u8()? {
for _ in 0..generic.borrow_mut().object()? {
match generic.borrow_mut().u8()? {
0x01 => {
let decoder = generic.borrow_mut();
for _ in 0..decoder.array()? {
response.versions.push(decoder.text()?);
}
}
0x02 => {
let decoder = generic.borrow_mut();
for _ in 0..decoder.array()? {
response.extensions.push(decoder.text()?);
}
}
0x03 => response.aaguid.copy_from_slice(&decoder.bytes()?[..]),
0x04 => response.options = OptionsInfo::decode(&mut decoder)?,
0x05 => response.max_msg_size = decoder.u16()?,
0x03 => response
.aaguid
.copy_from_slice(&generic.borrow_mut().bytes()?[..]),
0x04 => response.options = OptionsInfo::decode(&mut generic.borrow_mut())?,
0x05 => response.max_msg_size = generic.borrow_mut().u16()?,
0x06 => {
let decoder = generic.borrow_mut();
for _ in 0..decoder.array()? {
response.pin_protocols.push(decoder.u8()?);
}
}
0x07 => response.max_credential_count_in_list = Some(generic.borrow_mut().u32()?),
0x08 => response.max_credential_id_len = Some(generic.borrow_mut().u32()?),
0x09 => {
let decoder = generic.borrow_mut();
for _ in 0..decoder.array()? {
response.transports.push(decoder.text()?);
}
}
0x0A => {
for _ in 0..generic.borrow_mut().array()? {
response.algorithms.push(CoseKey::decode(&mut generic)?);
}
}
0x0B => response.max_authenticator_config_len = Some(generic.borrow_mut().u32()?),
0x0C => response.default_cred_protect = Some(generic.borrow_mut().u8()?),
_ => continue,
}
}