-
Notifications
You must be signed in to change notification settings - Fork 48
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
Timeout too short for multiple HID packets to be sent in send_transport_response
#25
Comments
We can certainly try increasing timeout value, however there are others that use the OnlyKey Agent with RSA 4096 keys. Is it possible there is another issue on the system you are using? Are you able to check on another workstation to see if the issue persists there? Here is the documentation on the RawHID function https://pjrc.com/teensy/rawhid.html |
@svareille I am working on the next OnlyKey firmware release, if I send you firmware with this increased timeout value can you test to see if this corrects the issue you are seeing? |
Sure, I would gladly try it! |
Okay, so I finally got a MWE and it gives me the same result: only 7 packets are received. I have tried it on Windows and Debian, and on multiple hardware. The code can be found here: https://github.com/svareille/test-rsa4096 |
@svareille Thanks for putting together the test script, I have used this to test but I am seeing all 8 packets returned.
USB devices like OnlyKey have send buffers so RawHID.send doesn't really send the message to your computer it just places message in a buffer and then next time the computer polls to read it reads out the messages in the buffer if that makes sense. The buffer size is larger than 8 so all 8 messages are stored in the USB buffer to be read first in first out. So I don't think changing the timeout value will have any affect, but we can try it if you would like to test. Another cause of this issue might be if there is another app on the computer polling OnlyKey and it gets the first message 1 of 8. Then the agent polls and there are only 7 messages left. Can you try with the OnlyKey app closed and make sure there isn't something else running that might do this? |
Thanks for your feedback. The result is indeed strange: the same script gives me only 7 packets on On the computer I currently use (Windows), with no OnlyKey App running, the script gives me 7 packets As this seems to work fine for you and there is no obvious oddity on my computers, I would tend to
Looking at So I guess there can be only 4 packets waiting in the buffer... Anyway, trying with the increased timeout of 100ms as for FIDO should definitely show if the issue is this or not. |
Hi!
I'm currently playing with PGP key signature and decryption using my OnlyKey. I dialogue directly with the key, sending the OKSIGN and OKDECRYPT messages over HID. While testing with a 4096 bits RSA key, signing gives a wrong signature:
Signatures with a 4096 bits RSA key should be 512 bytes long (8 HID packets). However I only get 448 bytes (7 HID packets). I think I understand why: the
usb_rawhid_send2
function will send a packet only if there is less than 4 packets processed at the moment. If there is 4 packets currently processed, the function will "sleep" a little then try again until the packet can be sent or a timeout is reached. That's the problem: thesend_transport_response
function has to send 8 packets, but a timeout of 0 ms is specified (RawHID.send2(resp_buffer, 0);
):libraries/onlykey/okcore.cpp
Lines 2552 to 2566 in a133bea
I guess the timeout is too short for the packet to be sent, thus the loss.
Increasing this timeout to 100 ms (as for FIDO) should be enough I think
libraries/fido2/device.cpp
Lines 181 to 194 in a133bea
The text was updated successfully, but these errors were encountered: