Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.spec.DHPrivateKeySpec;
import javax.crypto.spec.IvParameterSpec;

import sun.security.jca.JCAUtil;
Expand Down Expand Up @@ -194,34 +193,6 @@ static Long importKey(SunPKCS11 sunPKCS11, long hSession, CK_ATTRIBUTE[] attribu
attrsMap.put(CKA_NETSCAPE_DB,
new CK_ATTRIBUTE(CKA_NETSCAPE_DB, BigInteger.ZERO));
}
} else if (keyType == CKK_DH) {
if (debug != null) {
debug.println("Importing a Diffie-Hellman private key...");
}
if (DHKF == null) {
DHKFLock.lock();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to remove the DHKF and DHKFLock static variables from the start of the FIPSKeyImporter class.

try {
if (DHKF == null) {
DHKF = KeyFactory.getInstance(
"DH", P11Util.getSunJceProvider());
}
} finally {
DHKFLock.unlock();
}
}
DHPrivateKeySpec spec = new DHPrivateKeySpec
(((v = attrsMap.get(CKA_VALUE).getBigInteger()) != null)
? v : BigInteger.ZERO,
((v = attrsMap.get(CKA_PRIME).getBigInteger()) != null)
? v : BigInteger.ZERO,
((v = attrsMap.get(CKA_BASE).getBigInteger()) != null)
? v : BigInteger.ZERO);
keyBytes = DHKF.generatePrivate(spec).getEncoded();
if (token.config.getNssNetscapeDbWorkaround() &&
attrsMap.get(CKA_NETSCAPE_DB) == null) {
attrsMap.put(CKA_NETSCAPE_DB,
new CK_ATTRIBUTE(CKA_NETSCAPE_DB, BigInteger.ZERO));
}
} else {
if (debug != null) {
debug.println("Unrecognized private key type.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ static PrivateKey privateKey(Session session, long keyID, String algorithm,
new CK_ATTRIBUTE(CKA_SENSITIVE),
new CK_ATTRIBUTE(CKA_EXTRACTABLE),
});
if (!plainKeySupportEnabled && (attributes[1].getBoolean() ||
boolean exportable = plainKeySupportEnabled && !algorithm.equals("DH");
if (!exportable && (attributes[1].getBoolean() ||
(attributes[2].getBoolean() == false))) {
return new P11PrivateKey
(session, keyID, algorithm, keyLength, attributes);
Expand Down