|
21 | 21 | * under the License.
|
22 | 22 | */
|
23 | 23 | /*
|
24 |
| - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. |
| 24 | + * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. |
25 | 25 | */
|
26 | 26 | package org.jcp.xml.dsig.internal.dom;
|
27 | 27 |
|
@@ -300,35 +300,23 @@ DSAPublicKey unmarshalKeyValue(Element kvtElem)
|
300 | 300 | ("unable to create DSA KeyFactory: " + e.getMessage());
|
301 | 301 | }
|
302 | 302 | }
|
303 |
| - Element curElem = DOMUtils.getFirstChildElement(kvtElem); |
304 |
| - if (curElem == null) { |
305 |
| - throw new MarshalException("KeyValue must contain at least one type"); |
306 |
| - } |
307 |
| - // check for P and Q |
308 |
| - BigInteger p = null; |
309 |
| - BigInteger q = null; |
310 |
| - if ("P".equals(curElem.getLocalName()) && XMLSignature.XMLNS.equals(curElem.getNamespaceURI())) { |
311 |
| - p = decode(curElem); |
312 |
| - curElem = DOMUtils.getNextSiblingElement(curElem, "Q", XMLSignature.XMLNS); |
313 |
| - q = decode(curElem); |
314 |
| - curElem = DOMUtils.getNextSiblingElement(curElem); |
315 |
| - } |
316 |
| - BigInteger g = null; |
317 |
| - if (curElem != null |
318 |
| - && "G".equals(curElem.getLocalName()) && XMLSignature.XMLNS.equals(curElem.getNamespaceURI())) { |
319 |
| - g = decode(curElem); |
320 |
| - curElem = DOMUtils.getNextSiblingElement(curElem, "Y", XMLSignature.XMLNS); |
321 |
| - } |
322 |
| - BigInteger y = null; |
323 |
| - if (curElem != null) { |
324 |
| - y = decode(curElem); |
325 |
| - curElem = DOMUtils.getNextSiblingElement(curElem); |
326 |
| - } |
327 |
| - //if (curElem != null && "J".equals(curElem.getLocalName())) { |
328 |
| - //j = new DOMCryptoBinary(curElem.getFirstChild()); |
329 |
| - // curElem = DOMUtils.getNextSiblingElement(curElem); |
330 |
| - //} |
331 |
| - //@@@ do we care about j, pgenCounter or seed? |
| 303 | + // P, Q, and G are optional according to the XML Signature |
| 304 | + // Recommendation as they might be known from application context, |
| 305 | + // but this implementation does not provide a mechanism or API for |
| 306 | + // an application to supply the missing parameters, so they are |
| 307 | + // required to be specified. |
| 308 | + Element curElem = |
| 309 | + DOMUtils.getFirstChildElement(kvtElem, "P", XMLSignature.XMLNS); |
| 310 | + BigInteger p = decode(curElem); |
| 311 | + curElem = |
| 312 | + DOMUtils.getNextSiblingElement(curElem, "Q", XMLSignature.XMLNS); |
| 313 | + BigInteger q = decode(curElem); |
| 314 | + curElem = |
| 315 | + DOMUtils.getNextSiblingElement(curElem, "G", XMLSignature.XMLNS); |
| 316 | + BigInteger g = decode(curElem); |
| 317 | + curElem = |
| 318 | + DOMUtils.getNextSiblingElement(curElem, "Y", XMLSignature.XMLNS); |
| 319 | + BigInteger y = decode(curElem); |
332 | 320 | DSAPublicKeySpec spec = new DSAPublicKeySpec(y, p, q, g);
|
333 | 321 | return (DSAPublicKey) generatePublicKey(dsakf, spec);
|
334 | 322 | }
|
|
1 commit comments
openjdk-notifier[bot] commentedon Apr 18, 2023
Review
Issues