-
Notifications
You must be signed in to change notification settings - Fork 712
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
"pkcs11-tool --test" fails with a SIPR card #1524
Comments
Please check #1515 |
@srsross you can use the CryptokiMPX to generate more useful logs: |
@frankmorgner Thanks for your suggestion. As per @dengert in #1515, I changed
to
in
I posted the |
This looks like a
The card is always using short APDUs where Lc must be <=255. I have no way to test this... |
@dengert Thanks for taking a look at the log.
After looking through the code that you pointed out in
If you have any suggestions, I would be able to test them with the card. |
Were did you get the "Secure Internet Protocol Router (SIPR) smart card (with a CoolKey applet)". Do you know by other means that it has a COOLKEY applet? Do you have any documentation on the applet? The ATR appears to be Your card appears to be mentioned in this: It also appears to be related to: #943 The Using a 3K key would require someway to pass more the 255 bytes of data. Dos the applet support extended APDUs? There are a number of ways to pass more then 255 bytes while using short APDUs. Some cards support Command Chaining. Some cards use some other form of multiple APDUs. I am not a COOLKEY expert. |
@dengert Thanks for your in-depth response.
I received this test card from one of our customers.
It has public keys with 2048 bits.
It responds to APDUs for the CoolKey applet. See the below interaction with the card using the
See https://github.com/elmarco/coolkey/blob/master/applet/doc/CoolKeyApplet.odt.
Yes, that is the correct ATR.
Yes, the card is a SafeNet SC650 v4 card.
Yes, at least to the extent that the applet on the card is CoolKey.
Thanks for pointing out the RSA initialization for those three key lengths in the
I don't know whether or not it supports extended APDUs. How would I check this?
Is there any way to test (maybe via
That would make two of us! |
Looking closer at the source, it looks like in line 1734 coolkey_rsa_op calls:
so in line 1179
resulting in this APDU:
So far so good. at line 1740
So here is the problem: I suspect other card may be using a smaller nonce. A 6 byte nonce would write 255 bytes and work. So the the line 71: I assume in the comment 255-8 the 8 is for max nonce. I would suggest that @srsross can you try this: Someone who understands COOLKEY @Jakuje ? needs to look at this too. |
In the above patch the MAX should be MIN. Sorry |
@dengert Thank you for the analysis. It looks correct as well as the patch (with the addition in the last comment). Unfortunately I have only 1K RSA key on my testing card so I am not able to test this case (I will ask around on Monday if we could get some bigger keys ... 1K is really not sensible these days). At this moment, probably only @sross is the one who can test your patch. |
In addition to a 2048 bit key the nonce must be bigger the 6 for a failure. What size nonce does your test card have? |
According to the applet source, the default length is 8: |
@denger and @Jakuje Thanks for your analysis and comments.
You're patch works! Following are the details. I used the following patch file. It is pretty much the same as that of @dengert but (as he pointed out) replaces
The OpenSC log from my test run with the POTTER.HARRY SIPR card is: The command line output is the following:
What is the next step? |
You could submit the patch as a Pull request. Or @Jakuje or I could submit it. |
@dengert, given that you did the digging through the code and log, and provided the patch, please feel free to submit it. (Otherwise, I could do it.) One other change could be made to the patch: change the comment from
to something like
|
For a problem description, see <OpenSC#1524>. In a nutshell, for a card with the CoolKey applet and 2048-bit keys, the command pkcs11-tool --test --login fails to complete all of its tests. This commit consists of a patch from @dengert. To avoid triggering an error when the data exceeds 255 bytes, this commit limits the amount of the payload sent to the CoolKey applet on the card based on the maximum amount of data that the card can receive, and overhead bytes (namely, a header and nonce) that accompany the payload. With this change, the command pkcs11-tool --test --login succeeds.
Pull Reqest is #1532. |
For a problem description, see <#1524>. In a nutshell, for a card with the CoolKey applet and 2048-bit keys, the command pkcs11-tool --test --login fails to complete all of its tests. This commit consists of a patch from @dengert. To avoid triggering an error when the data exceeds 255 bytes, this commit limits the amount of the payload sent to the CoolKey applet on the card based on the maximum amount of data that the card can receive, and overhead bytes (namely, a header and nonce) that accompany the payload. With this change, the command pkcs11-tool --test --login succeeds.
Problem Description
pkcs11-tool --test
fails with a test SIPR card.On Fedora 28, I am using a test Secure Internet Protocol Router (SIPR) smart card (with a CoolKey applet) that fails the testing sequence of
pkcs11-tool --test
with the error of:Proposed Resolution
none
Steps to reproduce
The OpenSC version is:
Following is the command line output:
I dunno if this has any relation to #1225 which is titled "pkcs11-tool tests with random data in RSA_X_509 mechanism are failing with modern cards".
The content of my OpenSC configuration file is:
Logs
The OpenSC debug log (with "debug=3") is at https://gist.github.com/srsross/c303c8a6a268c52850f5fd7fad7b4d10
The text was updated successfully, but these errors were encountered: