Authenticator

Struct Authenticator 

Source
pub struct Authenticator<C: AuthenticatorCallbacks> { /* private fields */ }
Expand description

High-level FIDO2 authenticator

Provides a thread-safe authenticator that processes CTAP commands via callbacks.

Implementations§

Source§

impl<C: AuthenticatorCallbacks> Authenticator<C>

Source

pub fn set_pin_hash(pin_hash: &[u8])

Set the PIN hash for the authenticator (must be called before creating instance)

The PIN hash will be applied to the next authenticator instance created. This is useful for testing scenarios where you want to simulate a PIN being set.

§Arguments
  • pin_hash - SHA-256 hash of the PIN (32 bytes)
Source

pub fn new(callbacks: C) -> Result<Self>
where C: 'static,

Create a new authenticator with default configuration

Source

pub fn with_config(callbacks: C, config: AuthenticatorConfig) -> Result<Self>
where C: 'static,

Create a new authenticator with custom configuration

Source

pub fn with_config_and_pin_storage<P>( callbacks: C, config: AuthenticatorConfig, pin_storage: P, ) -> Result<Self>
where C: 'static, P: PinStorageCallbacks + Send + Sync + 'static,

Create a new authenticator with custom configuration and persistent PIN storage

Source

pub fn handle( &mut self, request: &[u8], response: &mut Vec<u8>, ) -> Result<usize>

Handle a CTAP request

§Arguments
  • request - CTAP command bytes (command code + CBOR parameters)
  • response - Buffer for response (will be resized as needed)
§Returns

Number of bytes written to response buffer

Source

pub fn register_custom_command<F>(&mut self, command: u8, handler: F)
where F: Fn(&[u8]) -> Result<Vec<u8>, StatusCode> + Send + Sync + 'static,

Register a custom CTAP command handler

This allows registering vendor-specific commands in the 0x40-0xFF range.

§Example
let callbacks = MyCallbacks;
let mut auth = Authenticator::new(callbacks).unwrap();

// Register custom command 0x41
auth.register_custom_command(0x41, |request| {
    // Process custom command
    Ok(vec![0x01, 0x02, 0x03])
});

Auto Trait Implementations§

§

impl<C> Freeze for Authenticator<C>

§

impl<C> RefUnwindSafe for Authenticator<C>

§

impl<C> Send for Authenticator<C>

§

impl<C> Sync for Authenticator<C>

§

impl<C> Unpin for Authenticator<C>

§

impl<C> UnwindSafe for Authenticator<C>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V