Skip to content

Commit 9a74059

Browse files
committed
Tolerate RSA-PSS in OpenJCEPlus signature
The mask generation function (MGF) based on a hash algorithm is recommended to use the same hash function as the hash function fingerprinting the message for RSA-PSS. However, the structures in [PKCS#1v2.1] allow for separate parameterization of the MGF and the message digest. OpenJCEPlus restricts to use the same hash algorithm for both MGF and message digest. This will cause test failures since the tests are expecting different MGF and message digest behavior. Signed-off-by: Jinhang Zhang <[email protected]>
1 parent 5b98e3e commit 9a74059

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)