marshallbrekka / go-u2fhost

A Go library for using U2F USB devices on the client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support discovering USB HID devices on linux

marshallbrekka opened this issue · comments

I'm trying to use this library on linux, but it filters out my keys due to this line: https://github.com/marshallbrekka/go-u2fhost/blob/master/hid/hid.go#L46
If you look at the doc for UsagePage and Usage you can see that those values are only for mac and windows. On linux they are zeroes. Why are you using those values?

@VictorDenisov this has been long on my personal backlog of issues to resolve.
I'd love some help on this, as it appears the solve exists outside the context of just this project.

Short answer:

usage and usage page are available on linux, but they are not accessible given the current way that hidapi uses libusb.

Longer Answer

I had done some research a while ago, but can't seem to find it, so sorry if my notes are a little sparse, or not as correct as they should be.

libusb currently has the code disabled for grabbing the full usage page. This is probably a fine choice as most users may not need it. In our case it would be ideal to be able to access it when needed to validate the device is u2f compatible.

There is another usability issue. The karalabe/hid project chooses to use the libusb backend on linux, as opposed to the hidraw backend.
As far as I remember, the hidraw backend could interact with the u2f devices without any special permissions, but the libusb backend required the end user to add udev rules.

Fortunately we can look at what Firefox has done, via their rust library.

I'm not 100% sure what the best path is to move forward, as it seems some decent changes would be required outside of this project.

Can the usage page check just be removed entirely?

Honestly I'm not sure what kind of dangers might arise by issuing commands to non-u2f devices. I'd be very open to exploring that if you have the bandwidth to do that research.

Thanks for your reply. I'll be looking into this problem as it's a more or less pressing issue for me. Though it looks like if I want a tool that works just for me I can just do the custom build of the tool that is using your library.

Also looks like there is some progress on making it more accessible on linux libusb/hidapi#139