提交 35507b2b 编写于 作者: M mullan

7187962: sun.security.pkcs11.P11DSAKeyFactory.implTranslatePublicKey doesn't...

7187962: sun.security.pkcs11.P11DSAKeyFactory.implTranslatePublicKey doesn't check if params is null
Reviewed-by: valeriep
上级 cd762851
...@@ -101,6 +101,14 @@ class BasicChecker extends PKIXCertPathChecker { ...@@ -101,6 +101,14 @@ class BasicChecker extends PKIXCertPathChecker {
public void init(boolean forward) throws CertPathValidatorException { public void init(boolean forward) throws CertPathValidatorException {
if (!forward) { if (!forward) {
prevPubKey = trustedPubKey; prevPubKey = trustedPubKey;
if (prevPubKey instanceof DSAPublicKey &&
((DSAPublicKey)prevPubKey).getParams() == null)
{
// If TrustAnchor is a DSA public key and it has no params, it
// cannot be used to verify the signature of the first cert,
// so throw exception
throw new CertPathValidatorException("Key parameters missing");
}
prevSubject = caName; prevSubject = caName;
} else { } else {
throw new throw new
...@@ -242,7 +250,7 @@ class BasicChecker extends PKIXCertPathChecker { ...@@ -242,7 +250,7 @@ class BasicChecker extends PKIXCertPathChecker {
} }
if (cKey instanceof DSAPublicKey && if (cKey instanceof DSAPublicKey &&
((DSAPublicKey)cKey).getParams() == null) { ((DSAPublicKey)cKey).getParams() == null) {
//cKey needs to inherit DSA parameters from prev key // cKey needs to inherit DSA parameters from prev key
cKey = makeInheritedParamsKey(cKey, prevPubKey); cKey = makeInheritedParamsKey(cKey, prevPubKey);
if (debug != null) debug.println("BasicChecker.updateState Made " + if (debug != null) debug.println("BasicChecker.updateState Made " +
"key with inherited params"); "key with inherited params");
...@@ -252,7 +260,7 @@ class BasicChecker extends PKIXCertPathChecker { ...@@ -252,7 +260,7 @@ class BasicChecker extends PKIXCertPathChecker {
} }
/** /**
* Internal method to create a new key with inherited key parameters * Internal method to create a new key with inherited key parameters.
* *
* @param keyValueKey key from which to obtain key value * @param keyValueKey key from which to obtain key value
* @param keyParamsKey key from which to obtain key parameters * @param keyParamsKey key from which to obtain key parameters
...@@ -263,7 +271,6 @@ class BasicChecker extends PKIXCertPathChecker { ...@@ -263,7 +271,6 @@ class BasicChecker extends PKIXCertPathChecker {
static PublicKey makeInheritedParamsKey(PublicKey keyValueKey, static PublicKey makeInheritedParamsKey(PublicKey keyValueKey,
PublicKey keyParamsKey) throws CertPathValidatorException PublicKey keyParamsKey) throws CertPathValidatorException
{ {
PublicKey usableKey;
if (!(keyValueKey instanceof DSAPublicKey) || if (!(keyValueKey instanceof DSAPublicKey) ||
!(keyParamsKey instanceof DSAPublicKey)) !(keyParamsKey instanceof DSAPublicKey))
throw new CertPathValidatorException("Input key is not " + throw new CertPathValidatorException("Input key is not " +
...@@ -279,13 +286,12 @@ class BasicChecker extends PKIXCertPathChecker { ...@@ -279,13 +286,12 @@ class BasicChecker extends PKIXCertPathChecker {
params.getP(), params.getP(),
params.getQ(), params.getQ(),
params.getG()); params.getG());
usableKey = kf.generatePublic(ks); return kf.generatePublic(ks);
} catch (GeneralSecurityException e) { } catch (GeneralSecurityException e) {
throw new CertPathValidatorException("Unable to generate key with" + throw new CertPathValidatorException("Unable to generate key with" +
" inherited parameters: " + " inherited parameters: " +
e.getMessage(), e); e.getMessage(), e);
} }
return usableKey;
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册