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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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>,

§

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>,

§

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