Struct FidoDevice

Source
pub struct FidoDevice {
    pub guest_key: Arc<Mutex<FidoGuestKey>>,
    pub transaction_manager: Arc<Mutex<TransactionManager>>,
    pub is_active: bool,
    pub is_device_lost: bool,
    event_loop: Arc<EventLoop>,
    pub transfer_timer: PollTimer,
    pub fd: Arc<Mutex<File>>,
}
Expand description

A virtual representation of a FidoDevice emulated on the Host.

Fields§

§guest_key: Arc<Mutex<FidoGuestKey>>

Guest representation of the virtual security key device

§transaction_manager: Arc<Mutex<TransactionManager>>

The TransactionManager which handles starting and stopping u2f transactions

§is_active: bool

Marks whether the current device is active in a transaction. If it is not active, the fd polling event loop does not handle the device fd monitoring.

§is_device_lost: bool

Marks whether the device has been lost. In case the FD stops being responsive we signal that the device is lost and any further transaction will return a failure.

§event_loop: Arc<EventLoop>

Backend provider event loop to attach/detach the monitored fd.

§transfer_timer: PollTimer

Timer to poll for active USB transfers

§fd: Arc<Mutex<File>>

fd of the actual hidraw device

Implementations§

Source§

impl FidoDevice

Source

pub fn new(hidraw: File, event_loop: Arc<EventLoop>) -> Result<FidoDevice>

Source

pub fn set_active(&mut self, active: bool)

Sets the device active state. If the device becomes active, it toggles polling on the file descriptor for the host hid device. If the devices becomes inactive, it stops polling. In case of error, it’s not possible to recover so we just log the warning and continue.

Source

pub fn start_transaction(&mut self, packet: &InitPacket) -> Result<()>

Starts a new transaction from a given init packet.

Source

pub fn recv_from_host(&mut self, packet: &[u8; 64]) -> Result<()>

Receives a low-level request from the host device. It means we read data from the actual key on the host.

Source

pub fn recv_from_guest(&mut self, packet: &[u8; 64]) -> Result<usize>

Receives a request from the guest device to write into the actual device on the host.

Trait Implementations§

Source§

impl AsRawDescriptor for FidoDevice

Source§

fn as_raw_descriptor(&self) -> RawDescriptor

Returns the underlying raw descriptor. Read more

Auto Trait Implementations§

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> AsRawDescriptors for T
where T: AsRawDescriptor,

Source§

fn as_raw_descriptors(&self) -> Vec<i32>

Returns the underlying raw descriptors. 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, 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.
§

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

§

fn vzip(self) -> V