@@ -38,8 +38,8 @@ type Result<T> = ::std::result::Result<T, YubicoError>;
3838
3939#[ derive( Clone , Debug , PartialEq ) ]
4040pub struct Yubikey {
41- pub name : String ,
42- pub serial : u32 ,
41+ pub name : Option < String > ,
42+ pub serial : Option < u32 > ,
4343 pub product_id : u16 ,
4444 pub vendor_id : u16 ,
4545 pub bus_id : u8 ,
@@ -95,8 +95,14 @@ impl Yubico {
9595 for device in self . context . devices ( ) . unwrap ( ) . iter ( ) {
9696 let descr = device. device_descriptor ( ) . unwrap ( ) ;
9797 if descr. vendor_id ( ) == VENDOR_ID {
98- let name = device. open ( ) ?. read_product_string_ascii ( & descr) ?;
99- let serial = self . read_serial_from_device ( device. clone ( ) ) ?;
98+ let name = match device. open ( ) ?. read_product_string_ascii ( & descr) {
99+ Ok ( name) => Some ( name) ,
100+ Err ( _) => None ,
101+ } ;
102+ let serial = match self . read_serial_from_device ( device. clone ( ) ) {
103+ Ok ( serial) => Some ( serial) ,
104+ Err ( _) => None ,
105+ } ;
100106 let yubikey = Yubikey {
101107 name : name,
102108 serial : serial,
@@ -118,8 +124,8 @@ impl Yubico {
118124 for device in self . context . devices ( ) . unwrap ( ) . iter ( ) {
119125 let descr = device. device_descriptor ( ) . unwrap ( ) ;
120126 if descr. vendor_id ( ) == VENDOR_ID {
121- let name = device. open ( ) ?. read_product_string_ascii ( & descr) ? ;
122- let serial = self . read_serial_from_device ( device. clone ( ) ) ? ;
127+ let name = device. open ( ) ?. read_product_string_ascii ( & descr) . ok ( ) ;
128+ let serial = self . read_serial_from_device ( device. clone ( ) ) . ok ( ) ;
123129 let yubikey = Yubikey {
124130 name : name,
125131 serial : serial,
@@ -284,16 +290,20 @@ impl Yubico {
284290 ( & mut challenge[ ..chall. len ( ) ] ) . copy_from_slice ( chall) ;
285291 let d = Frame :: new ( challenge, command) ;
286292 let mut buf = [ 0 ; 8 ] ;
287-
293+ eprintln ! ( "Step 1 done" ) ;
288294 let mut response = [ 0 ; 36 ] ;
289295 manager:: wait (
290296 & mut handle,
291297 |f| !f. contains ( manager:: Flags :: SLOT_WRITE_FLAG ) ,
292298 & mut buf,
293299 ) ?;
300+ eprintln ! ( "Step 2 done" ) ;
294301 manager:: write_frame ( & mut handle, & d) ?;
302+ eprintln ! ( "Step 3 done" ) ;
295303 manager:: read_response ( & mut handle, & mut response) ?;
304+ eprintln ! ( "Step 4 done" ) ;
296305 manager:: close_device ( handle, interfaces) ?;
306+ eprintln ! ( "Step 5 done" ) ;
297307
298308 // Check response.
299309 if crc16 ( & response[ ..18 ] ) != CRC_RESIDUAL_OK {
0 commit comments