-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USB HID: add product name and serial to descriptor. #113
USB HID: add product name and serial to descriptor. #113
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this looks very promising!
In general the approach looks fine. One change I'd request is to use None
when no value is present instead of an empty string.
For NFC, I suppose we could use the PCSC reader name instead of product name. I'm not sure how useful it is, but then again, maybe it's better than nothing?
I ran some quick tests of this on Ubuntu, seems to work fine there.
I also tried running this on Windows and it immediately broke things. It looks like it just needs to handle the case where there is no value present by returning None
instead of raising a WinError.
I'll try to do some testing on the other OSes as well!
I changed the code to return Thank you very much for your feedback and the valuable hints for improvement! |
Great, functionally looks good. One small improvement is to replace the pattern:
With:
I'm not done testing this on the different platforms yet, but so far I've run into some Python2 specific problems on Linux. I've also found a few other Python2 compatibility issues that are unrelated to this PR (like the use of
I'll get back to you when I've done more testing with anything I find! |
Tested: - Linux - Windows - MacOS - OpenBSD - FreeBSD (needs updated uhid-freebsd) (product/serial number OK, but fragmented CTAP messages did not work in my VM setup?)
Now using correct black version.
Return `None` instead of empty string if there is no product name or serial number. The same happens for certain errors like UnicodeDecodeError.
66caee5
to
14ff435
Compare
I rebased to include your Python 2 fixes and incorporated your latest feedback. |
Everything looks good to me! I've run some very basic tests of the latest code on Ubuntu (py2 and 3), MacOS (x86, py2 and 3), FreeBSD (py 2 and 3) and OpenBSD (py3 only, couldn't get python 2 to run properly) and Windows 10 (py2 and 3). No issues found. I'm not super happy about the FreeBSD code relying on an unmerged PR to uhid-freebsd (which looks like it hasn't been updated in some time), but I'm OK with making an exception here since it's so minor and shouldn't break anything. Again, thanks for your work on this! |
Thanks! |
The changes of Yubico#113 left trailing zeroes in the serial number and product name on Linux. The ioctl() for retrieving the attributes returns the string length on success. Use the returned value to retrieve strings of the correct length.
The changes of Yubico#113 left trailing zeroes in the serial number and product name on Linux. The ioctl() for retrieving the attributes returns the string length on success. Use the returned value to retrieve strings of the correct length.
The changes of Yubico#113 left trailing zeroes in the serial number and product name on Linux. The ioctl() for retrieving the attributes returns the string length on success. Use the returned value to retrieve strings of the correct length.
I tried to add product name and serial number support to the internal descriptor for USB HID devices. If there is something similar for NFC devices it might be possible to add it, as well.
Tested in following environments:
struct usb_device_info
, see OpenBSD bug mailing list. I don't know how this can be addressed to support older versions, too.)