Skip to content

Commit

Permalink
8287246: DSAKeyValue should check for missing params instead of relyi…
Browse files Browse the repository at this point in the history
…ng on KeyFactory provider

Reviewed-by: weijun
  • Loading branch information
seanjmullan committed May 26, 2022
1 parent f58c9a6 commit f235955
Showing 1 changed file with 18 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* under the License.
*/
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
*/
package org.jcp.xml.dsig.internal.dom;

Expand Down Expand Up @@ -300,35 +300,23 @@ DSAPublicKey unmarshalKeyValue(Element kvtElem)
("unable to create DSA KeyFactory: " + e.getMessage());
}
}
Element curElem = DOMUtils.getFirstChildElement(kvtElem);
if (curElem == null) {
throw new MarshalException("KeyValue must contain at least one type");
}
// check for P and Q
BigInteger p = null;
BigInteger q = null;
if ("P".equals(curElem.getLocalName()) && XMLSignature.XMLNS.equals(curElem.getNamespaceURI())) {
p = decode(curElem);
curElem = DOMUtils.getNextSiblingElement(curElem, "Q", XMLSignature.XMLNS);
q = decode(curElem);
curElem = DOMUtils.getNextSiblingElement(curElem);
}
BigInteger g = null;
if (curElem != null
&& "G".equals(curElem.getLocalName()) && XMLSignature.XMLNS.equals(curElem.getNamespaceURI())) {
g = decode(curElem);
curElem = DOMUtils.getNextSiblingElement(curElem, "Y", XMLSignature.XMLNS);
}
BigInteger y = null;
if (curElem != null) {
y = decode(curElem);
curElem = DOMUtils.getNextSiblingElement(curElem);
}
//if (curElem != null && "J".equals(curElem.getLocalName())) {
//j = new DOMCryptoBinary(curElem.getFirstChild());
// curElem = DOMUtils.getNextSiblingElement(curElem);
//}
//@@@ do we care about j, pgenCounter or seed?
// P, Q, and G are optional according to the XML Signature
// Recommendation as they might be known from application context,
// but this implementation does not provide a mechanism or API for
// an application to supply the missing parameters, so they are
// required to be specified.
Element curElem =
DOMUtils.getFirstChildElement(kvtElem, "P", XMLSignature.XMLNS);
BigInteger p = decode(curElem);
curElem =
DOMUtils.getNextSiblingElement(curElem, "Q", XMLSignature.XMLNS);
BigInteger q = decode(curElem);
curElem =
DOMUtils.getNextSiblingElement(curElem, "G", XMLSignature.XMLNS);
BigInteger g = decode(curElem);
curElem =
DOMUtils.getNextSiblingElement(curElem, "Y", XMLSignature.XMLNS);
BigInteger y = decode(curElem);
DSAPublicKeySpec spec = new DSAPublicKeySpec(y, p, q, g);
return (DSAPublicKey) generatePublicKey(dsakf, spec);
}
Expand Down

5 comments on commit f235955

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on f235955 Apr 16, 2023

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on f235955 Apr 16, 2023

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch GoeLin-backport-f235955e in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit f235955e from the openjdk/jdk repository.

The commit being backported was authored by Sean Mullan on 26 May 2022 and was reviewed by Weijun Wang.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-f235955e:GoeLin-backport-f235955e
$ git checkout GoeLin-backport-f235955e
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-f235955e

@RealLucy
Copy link
Contributor

Choose a reason for hiding this comment

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

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on f235955 May 24, 2023

Choose a reason for hiding this comment

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

@RealLucy the backport was successfully created on the branch RealLucy-backport-f235955e in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit f235955e from the openjdk/jdk repository.

The commit being backported was authored by Sean Mullan on 26 May 2022 and was reviewed by Weijun Wang.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev.git RealLucy-backport-f235955e:RealLucy-backport-f235955e
$ git checkout RealLucy-backport-f235955e
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev.git RealLucy-backport-f235955e

Please sign in to comment.