Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8270797: ShortECDSA.java test is not complete
Backport-of: 221e4b9c61cd1c9c3f4c037589ba639541532910
  • Loading branch information
TheRealMDoerr committed Mar 29, 2022
1 parent 86ac4ab commit b16d037
Showing 1 changed file with 16 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 @@ -91,6 +94,18 @@ public static void main(String[] args) throws Exception {
System.out.println(HexFormat.ofDelimiter(":").formatHex(sig));
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));
throw new RuntimeException("Failed");
}
}

public static class XmlSigningUtils {
Expand Down

1 comment on commit b16d037

@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.