Open pmengelbert opened 3 years ago
Turing FidoDevice into a trait seems like a good idea anyway since that'll make testing in downstream crates easier since they'll be able to implement an dummy FidoDevice.
Another than that we could also abstract the usb transport layer into it's own trait which implements Read + Write and pass that into FidoDevice as a boxed trait.
But since FidoDevice trait is more flexible I'd be in favor of that option.
It would be great to have a cross-platform library. I'm going to use this issue to lay out the state of the problem and to get a sense of how to best solve it.
Currently, there is a HID library, hidapi, that works for Mac OS and Windows. The way it is implemented now is that it calls out to
libusb
C functions. The ctap-hid-fido2 crate useshidapi
to communicate with FIDO2 devices, but of course does not support Linux.Because the HID communication functions in the
hidapi
crate rely on C code, the struct representation of the HID device (equivalent toctap_hmac::FidoDevice
) in thectap-hid-fido2
library retains the C representation of the device. That would cause a problem here, since we would have two ways of representing the device.My proposal would be to abstract the functions in
FidoDevice
out into a Trait, and then to implement that trait for a separate struct that would represent a Fido Device on MacOs or Windows. What are your thoughts on that way of solving the problem? I'm not 100% sold that this is the way forward, and I defer to your judgment here. Thanks in advance for entertaining my suggestsions!