31
31
* java.base/sun.security.x509
32
32
* @run main/othervm SecureValidation
33
33
*/
34
+
35
+ /*
36
+ * ===========================================================================
37
+ * (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
38
+ * ===========================================================================
39
+ */
40
+
34
41
import jdk .test .lib .Asserts ;
35
42
import jdk .test .lib .security .XMLUtils ;
36
43
import jdk .test .lib .Utils ;
48
55
import javax .xml .xpath .XPathConstants ;
49
56
import javax .xml .xpath .XPathFactory ;
50
57
import java .security .PrivateKey ;
58
+ import java .security .Signature ;
51
59
import java .security .cert .X509Certificate ;
52
60
import java .security .spec .MGF1ParameterSpec ;
53
61
import java .security .spec .PSSParameterSpec ;
@@ -70,10 +78,24 @@ public static void main(String[] args) throws Exception {
70
78
MGF1ParameterSpec .SHA512 , 48 , TRAILER_FIELD_BC );
71
79
72
80
// Sign with PSS with SHA-384 and SHA-512
73
- Document signed = XMLUtils .signer (privateKey , cert )
81
+ var signer = XMLUtils .signer (privateKey , cert )
74
82
.dm (DigestMethod .SHA384 )
75
- .sm (SignatureMethod .RSA_PSS , new RSAPSSParameterSpec (pspec ))
76
- .sign (doc );
83
+ .sm (SignatureMethod .RSA_PSS , new RSAPSSParameterSpec (pspec ));
84
+ Document signed ;
85
+ try {
86
+ signed = signer .sign (doc );
87
+ } catch (javax .xml .crypto .dsig .XMLSignatureException xmlse ) {
88
+ Throwable cause = xmlse .getCause ();
89
+ if (cause instanceof java .security .InvalidAlgorithmParameterException ) {
90
+ if (Signature .getInstance ("RSASSA-PSS" ).getProvider ().getName ().equals ("OpenJCEPlus" )
91
+ && cause .getMessage ().equals ("The message digest within the PSSParameterSpec does not match the MGF message digest." )
92
+ ) {
93
+ System .out .println ("Expected error message is caught for OpenJCEPlus provider." );
94
+ return ;
95
+ }
96
+ }
97
+ throw xmlse ;
98
+ }
77
99
78
100
XPath xp = XPathFactory .newInstance ().newXPath ();
79
101
xp .setNamespaceContext (new NamespaceContext () {
0 commit comments