Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ impl Yubico {
Err(YubicoError::DeviceNotFound)
}

/// Finds all the YubiKeys currently connected to the system
pub fn find_yubikeys(&mut self) -> Result<Vec<Device>> {
let mut yubikeys: Vec<Device> = vec![];

for device in self.context.devices().unwrap().iter() {
let descr = device.device_descriptor().unwrap();
if descr.vendor_id() == VENDOR_ID {
let device = Device {
product_id: descr.product_id(),
vendor_id: descr.vendor_id(),
};
yubikeys.push(device);
}
}
Ok(yubikeys)
}

pub fn write_config(&mut self, conf: Config, device_config: &mut DeviceModeConfig) -> Result<()> {
let d = device_config.to_frame(conf.command);
let mut buf = [0; 8];
Expand Down Expand Up @@ -194,4 +211,4 @@ impl Yubico {
Err(error) => Err(error)
}
}
}
}