Implement reset command for HID authenticator

dev
Nick Zana 1 year ago
parent 1daffb7db7
commit ce905e422d

@ -1,4 +1,5 @@
/// Possible errors for the [`Ctap2Device::reset`] command. /// Possible errors for the [`Ctap2Device::reset`] command.
#[derive(Debug)]
pub enum Error { pub enum Error {
/// Returned if the `reset` operation is disabled for the transport used or /// Returned if the `reset` operation is disabled for the transport used or
/// if user precense is explicitly denied. /// if user precense is explicitly denied.

@ -48,7 +48,7 @@ pub trait Ctap2_2Authenticator {
#[allow(clippy::missing_errors_doc)] #[allow(clippy::missing_errors_doc)]
/// > This method is used by the client to reset an authenticator back to a /// > This method is used by the client to reset an authenticator back to a
/// > factory default state. /// > factory default state.
fn reset() -> Result<(), reset::Error>; fn reset(&mut self) -> Result<(), reset::Error>;
// fn bio_enrollment( // fn bio_enrollment(
// request: bio_enrollment::Request, // request: bio_enrollment::Request,

@ -28,8 +28,9 @@ impl<D: ctaphid::HidDevice> Ctap2_2Authenticator for HidAuthenticator<D> {
todo!() todo!()
} }
fn reset() -> Result<(), reset::Error> { fn reset(&mut self) -> Result<(), reset::Error> {
todo!() let _: () = self.send(Command::AuthenticatorReset, ()).unwrap();
Ok(())
} }
fn selection() -> Result<(), ctap2_proto::authenticator::selection::Error> { fn selection() -> Result<(), ctap2_proto::authenticator::selection::Error> {
@ -67,6 +68,16 @@ mod tests {
None None
} }
// #[test]
fn reset() {
init();
let mut guard = AUTHENTICATOR.lock().unwrap();
let authenticator = guard.as_mut().unwrap();
authenticator.reset().unwrap();
}
#[test] #[test]
fn test_get_info() { fn test_get_info() {
init(); init();

Loading…
Cancel
Save