implements the AuthenticatorSelection command
This commit is contained in:
@@ -37,6 +37,8 @@ pub enum Command {
|
|||||||
AuthenticatorClientPin(AuthenticatorClientPinParameters),
|
AuthenticatorClientPin(AuthenticatorClientPinParameters),
|
||||||
AuthenticatorReset,
|
AuthenticatorReset,
|
||||||
AuthenticatorGetNextAssertion,
|
AuthenticatorGetNextAssertion,
|
||||||
|
#[cfg(feature = "with_ctap2_1")]
|
||||||
|
AuthenticatorSelection,
|
||||||
// TODO(kaczmarczyck) implement FIDO 2.1 commands (see below consts)
|
// TODO(kaczmarczyck) implement FIDO 2.1 commands (see below consts)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +103,11 @@ impl Command {
|
|||||||
// Parameters are ignored.
|
// Parameters are ignored.
|
||||||
Ok(Command::AuthenticatorGetNextAssertion)
|
Ok(Command::AuthenticatorGetNextAssertion)
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "with_ctap2_1")]
|
||||||
|
Command::AUTHENTICATOR_SELECTION => {
|
||||||
|
// Parameters are ignored.
|
||||||
|
Ok(Command::AuthenticatorSelection)
|
||||||
|
}
|
||||||
_ => Err(Ctap2StatusCode::CTAP1_ERR_INVALID_COMMAND),
|
_ => Err(Ctap2StatusCode::CTAP1_ERR_INVALID_COMMAND),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -484,4 +491,12 @@ mod test {
|
|||||||
let command = Command::deserialize(&cbor_bytes);
|
let command = Command::deserialize(&cbor_bytes);
|
||||||
assert_eq!(command, Ok(Command::AuthenticatorGetNextAssertion));
|
assert_eq!(command, Ok(Command::AuthenticatorGetNextAssertion));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "with_ctap2_1")]
|
||||||
|
#[test]
|
||||||
|
fn test_deserialize_selection() {
|
||||||
|
let cbor_bytes = [Command::AUTHENTICATOR_SELECTION];
|
||||||
|
let command = Command::deserialize(&cbor_bytes);
|
||||||
|
assert_eq!(command, Ok(Command::AuthenticatorSelection));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -368,8 +368,10 @@ where
|
|||||||
Command::AuthenticatorGetInfo => self.process_get_info(),
|
Command::AuthenticatorGetInfo => self.process_get_info(),
|
||||||
Command::AuthenticatorClientPin(params) => self.process_client_pin(params),
|
Command::AuthenticatorClientPin(params) => self.process_client_pin(params),
|
||||||
Command::AuthenticatorReset => self.process_reset(cid),
|
Command::AuthenticatorReset => self.process_reset(cid),
|
||||||
|
#[cfg(feature = "with_ctap2_1")]
|
||||||
|
Command::AuthenticatorSelection => self.process_selection(cid),
|
||||||
// TODO(kaczmarczyck) implement GetNextAssertion and FIDO 2.1 commands
|
// TODO(kaczmarczyck) implement GetNextAssertion and FIDO 2.1 commands
|
||||||
_ => unimplemented!(),
|
_ => self.process_unknown_command(),
|
||||||
};
|
};
|
||||||
#[cfg(feature = "debug_ctap")]
|
#[cfg(feature = "debug_ctap")]
|
||||||
writeln!(&mut Console::new(), "Sending response: {:#?}", response).unwrap();
|
writeln!(&mut Console::new(), "Sending response: {:#?}", response).unwrap();
|
||||||
@@ -1094,6 +1096,16 @@ where
|
|||||||
Ok(ResponseData::AuthenticatorReset)
|
Ok(ResponseData::AuthenticatorReset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "with_ctap2_1")]
|
||||||
|
fn process_selection(&self, cid: ChannelID) -> Result<ResponseData, Ctap2StatusCode> {
|
||||||
|
(self.check_user_presence)(cid)?;
|
||||||
|
Ok(ResponseData::AuthenticatorSelection)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn process_unknown_command(&self) -> Result<ResponseData, Ctap2StatusCode> {
|
||||||
|
Err(Ctap2StatusCode::CTAP1_ERR_INVALID_COMMAND)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn generate_auth_data(&self, rp_id_hash: &[u8], flag_byte: u8) -> Vec<u8> {
|
pub fn generate_auth_data(&self, rp_id_hash: &[u8], flag_byte: u8) -> Vec<u8> {
|
||||||
let mut auth_data = vec![];
|
let mut auth_data = vec![];
|
||||||
auth_data.extend(rp_id_hash);
|
auth_data.extend(rp_id_hash);
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ pub enum ResponseData {
|
|||||||
AuthenticatorGetInfo(AuthenticatorGetInfoResponse),
|
AuthenticatorGetInfo(AuthenticatorGetInfoResponse),
|
||||||
AuthenticatorClientPin(Option<AuthenticatorClientPinResponse>),
|
AuthenticatorClientPin(Option<AuthenticatorClientPinResponse>),
|
||||||
AuthenticatorReset,
|
AuthenticatorReset,
|
||||||
|
#[cfg(feature = "with_ctap2_1")]
|
||||||
|
AuthenticatorSelection,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ResponseData> for Option<cbor::Value> {
|
impl From<ResponseData> for Option<cbor::Value> {
|
||||||
@@ -43,6 +45,8 @@ impl From<ResponseData> for Option<cbor::Value> {
|
|||||||
ResponseData::AuthenticatorClientPin(Some(data)) => Some(data.into()),
|
ResponseData::AuthenticatorClientPin(Some(data)) => Some(data.into()),
|
||||||
ResponseData::AuthenticatorClientPin(None) => None,
|
ResponseData::AuthenticatorClientPin(None) => None,
|
||||||
ResponseData::AuthenticatorReset => None,
|
ResponseData::AuthenticatorReset => None,
|
||||||
|
#[cfg(feature = "with_ctap2_1")]
|
||||||
|
ResponseData::AuthenticatorSelection => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -372,4 +376,11 @@ mod test {
|
|||||||
let response_cbor: Option<cbor::Value> = ResponseData::AuthenticatorReset.into();
|
let response_cbor: Option<cbor::Value> = ResponseData::AuthenticatorReset.into();
|
||||||
assert_eq!(response_cbor, None);
|
assert_eq!(response_cbor, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "with_ctap2_1")]
|
||||||
|
#[test]
|
||||||
|
fn test_selection_into_cbor() {
|
||||||
|
let response_cbor: Option<cbor::Value> = ResponseData::AuthenticatorSelection.into();
|
||||||
|
assert_eq!(response_cbor, None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user