Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8270797: ShortECDSA.java test is not complete #285

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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