Skip to content

Commit ac13056

Browse files
authored
Merge pull request ibmruntimes#465 from JinhangZhang/openjceplus/bug/rsapsssignature
Tolerate RSA-PSS in OpenJCEPlus signature
2 parents 5b98e3e + 9a74059 commit ac13056

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

test/jdk/javax/xml/crypto/dsig/PSSSpec.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
* questions.
2222
*/
2323

24+
/*
25+
* ===========================================================================
26+
* (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
27+
* ===========================================================================
28+
*/
29+
2430
import jdk.test.lib.Asserts;
2531
import jdk.test.lib.Utils;
2632
import jdk.test.lib.security.XMLUtils;
@@ -34,6 +40,7 @@
3440
import javax.xml.crypto.dsig.dom.DOMValidateContext;
3541
import javax.xml.crypto.dsig.spec.RSAPSSParameterSpec;
3642
import java.security.KeyPairGenerator;
43+
import java.security.Signature;
3744
import java.security.spec.MGF1ParameterSpec;
3845
import java.security.spec.PSSParameterSpec;
3946

@@ -54,7 +61,20 @@ public class PSSSpec {
5461

5562
public static void main(String[] args) throws Exception {
5663
unmarshal();
57-
marshal();
64+
try {
65+
marshal();
66+
} catch (javax.xml.crypto.dsig.XMLSignatureException xmlse) {
67+
Throwable cause = xmlse.getCause();
68+
if (cause instanceof java.security.InvalidAlgorithmParameterException) {
69+
if (Signature.getInstance("RSA-PSS").getProvider().getName().equals("OpenJCEPlus")
70+
&& cause.getMessage().equals("The message digest within the PSSParameterSpec does not match the MGF message digest.")
71+
) {
72+
System.out.println("Expected error message is caught for OpenJCEPlus provider.");
73+
return;
74+
}
75+
}
76+
throw xmlse;
77+
}
5878
spec();
5979
}
6080

0 commit comments

Comments
 (0)