Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8270797: ShortECDSA.java test is not complete
Reviewed-by: mdoerr
Backport-of: 221e4b9
  • Loading branch information
GoeLin committed Apr 1, 2022
1 parent 164febe commit 319309e
Showing 1 changed file with 19 additions and 1 deletion.
Expand Up @@ -25,9 +25,12 @@
* @test
* @bug 8259535
* @summary ECDSA SignatureValue do not always have the specified length
* @modules java.xml.crypto
* @modules java.xml.crypto/com.sun.org.apache.xml.internal.security
* java.xml.crypto/com.sun.org.apache.xml.internal.security.signature
*/

import com.sun.org.apache.xml.internal.security.Init;
import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
Expand Down Expand Up @@ -95,6 +98,21 @@ public static void main(String[] args) throws Exception {
System.out.println();
throw new RuntimeException("Failed");
}

// Internal way
Init.init();
XMLSignature signature = new XMLSignature(document, null,
SignatureMethod.ECDSA_SHA256, CanonicalizationMethod.INCLUSIVE);
signature.sign(privateKey);
sig = signature.getSignatureValue();
if (sig.length != 64) {
System.out.println("Length: " + sig.length);
//System.out.println(HexFormat.ofDelimiter(":").formatHex(sig));
for (int i = 0; i < sig.length; ++i) {
System.out.print(String.format(i == 0 ? "%02x" : ":%02x", sig[i]));
}
throw new RuntimeException("Failed");
}
}

public static class XmlSigningUtils {
Expand Down

1 comment on commit 319309e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.