-
Notifications
You must be signed in to change notification settings - Fork 34
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
support cards which only have ALG_RSA_CRT #5
base: master
Are you sure you want to change the base?
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.
I'm not associated with this project, but I had a look over the changes and figured I would throw in my $0.02. Take it with a grain of salt.
-
You may want to consider gating this capability by adding a feature flag.
-
Now that you added support for
RSAPrivateCrtKey
, consider implementing all of the types (ELEMENT_RSA_P
,ELEMENT_RSA_Q
, etc.) thatRSAPrivateCrtKey
seems to support:OpenFIPS201/src/com/makina/security/OpenFIPS201/PIVKeyObjectPKI.java
Lines 108 to 133 in 8adcbcf
/* // RSA Prime Exponent P case ELEMENT_RSA_P: if (privateKey == null) allocate(); break; // RSA Prime Exponent Q case ELEMENT_RSA_Q: if (privateKey == null) allocate(); break; // RSA D mod P - 1 case ELEMENT_RSA_DP: if (privateKey == null) allocate(); break; // RSA D mod Q - 1 case ELEMENT_RSA_DQ: if (privateKey == null) allocate(); break; // RSA Inverse Q case ELEMENT_RSA_PQ: if (privateKey == null) allocate(); break; */
@@ -146,7 +153,11 @@ public void updateElement(byte element, byte[] buffer, short offset, short lengt | |||
*/ | |||
public void setPrivateExponent(byte[] buffer, short offset, short length) { | |||
if (privateKey == null) allocate(); | |||
privateKey.setExponent(buffer, offset, length); | |||
ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED); |
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.
Given the next few lines, I'm guessing this line was included in error.
@@ -35,9 +35,10 @@ of this software and associated documentation files (the "Software"), to deal | |||
*/ | |||
public final class PIVKeyObjectPKI extends PIVKeyObject { | |||
|
|||
private RSAPrivateKey privateKey; | |||
private Key privateKey; |
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.
Instead of Key
, should this be PrivateKey
?
@@ -168,7 +179,11 @@ public void setPublicExponent(byte[] buffer, short offset, short length) { | |||
*/ | |||
public void setModulus(byte[] buffer, short offset, short length) { | |||
if (privateKey == null || publicKey == null) allocate(); | |||
privateKey.setModulus(buffer, offset, length); | |||
ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED); |
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.
Same comment as that from line 156 above: I'm guessing this line was added in error.
try { | ||
keyPair = new KeyPair(KeyPair.ALG_RSA, KeyBuilder.LENGTH_RSA_1024); | ||
} catch (CryptoException e) { | ||
if (e.getReason() == CryptoException.NO_SUCH_ALGORITHM) { |
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.
Inconsistent whitespace.
try { | ||
keyPair = new KeyPair(KeyPair.ALG_RSA, KeyBuilder.LENGTH_RSA_2048); | ||
} catch (CryptoException e) { | ||
if (e.getReason() == CryptoException.NO_SUCH_ALGORITHM) { |
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.
Inconsistent whitespace.
None of the smartcards I tried (various JavaCOS, NXP, SmartCafe Expert) supported KeyPair(KeyPair.ALG_RSA, ...) only KeyPair.ALG_RSA_CRT.
This patch detects that and switches to using KeyPair.ALG_RSA_CRT.