Skip to content

FIPS jdk_security3_0 javax/security/auth/Destroyable/KeyDestructionTest.java DestroyFailedException #21921

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

Closed
JasonFengJ9 opened this issue May 21, 2025 · 2 comments · Fixed by ibmruntimes/openj9-openjdk-jdk11#925

Comments

@JasonFengJ9
Copy link
Member

JasonFengJ9 commented May 21, 2025

Failure link

From internal Test_openjdk11_j9_extended.openjdk_ppc64le_linux_fips140_3_openjceplusfips (rhel10le-rtbeta-1)

java version "11.0.28-beta" 2025-07-15
IBM Semeru Runtime Certified Edition 11.0.28+2-202505170106 (build 11.0.28-beta+2-202505170106)
Eclipse OpenJ9 VM 11.0.28+2-202505170106 (build master-4d2cc8437f, JRE 11 Linux ppc64le-64-Bit Compressed References 20250517_1144 (JIT enabled, AOT enabled)
OpenJ9   - 4d2cc8437f
OMR      - 06d80e2d9
JCL      - 9641840883 based on jdk-11.0.28+2)

Rerun in Grinder - Change TARGET to run only the failed test targets

Optional info

Failure output (captured from console output)

[2025-05-17T02:22:48.373Z] variation: Mode150
[2025-05-17T02:22:48.373Z] JVM_OPTIONS:  -XX:+UseCompressedOops -Xverbosegclog  -Dsemeru.fips=true -Dsemeru.customprofile=OpenJCEPlusFIPS

[2025-05-17T02:23:06.285Z] TEST: javax/security/auth/Destroyable/KeyDestructionTest.java

[2025-05-17T02:23:06.287Z] STDERR:
[2025-05-17T02:23:06.287Z] javax.security.auth.DestroyFailedException
[2025-05-17T02:23:06.287Z] 	at java.base/javax.security.auth.Destroyable.destroy(Destroyable.java:54)
[2025-05-17T02:23:06.287Z] 	at KeyDestructionTest.destroyKey(KeyDestructionTest.java:172)
[2025-05-17T02:23:06.287Z] 	at KeyDestructionTest.testKeyDestruction(KeyDestructionTest.java:98)
[2025-05-17T02:23:06.287Z] 	at KeyDestructionTest.main(KeyDestructionTest.java:62)
[2025-05-17T02:23:06.287Z] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2025-05-17T02:23:06.287Z] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[2025-05-17T02:23:06.287Z] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2025-05-17T02:23:06.287Z] 	at java.base/java.lang.reflect.Method.invoke(Method.java:572)
[2025-05-17T02:23:06.287Z] 	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:333)
[2025-05-17T02:23:06.287Z] 	at java.base/java.lang.Thread.run(Thread.java:835)
[2025-05-17T02:23:06.287Z] 
[2025-05-17T02:23:06.287Z] JavaTest Message: Test threw exception: javax.security.auth.DestroyFailedException
[2025-05-17T02:23:06.287Z] JavaTest Message: shutting down test
[2025-05-17T02:23:06.287Z] 
[2025-05-17T02:23:06.287Z] 
[2025-05-17T02:23:06.287Z] TEST RESULT: Failed. Execution failed: `main' threw exception: javax.security.auth.DestroyFailedException
[2025-05-17T02:23:06.287Z] --------------------------------------------------
[2025-05-17T02:30:53.005Z] Test results: passed: 284; failed: 1

[2025-05-17T02:30:53.005Z] jdk_security3_0_FAILED

10x internal Grinder - failed 100%

openjdk11_j9_extended.openjdk_x86-64_linux_fips140_3_openjceplusfips.fips140-3

[2025-05-17T02:19:46.739Z] TEST: javax/security/auth/Destroyable/KeyDestructionTest.java

[2025-05-17T02:19:46.740Z] java.security.InvalidParameterException: RSA keys must be at least 2048 bits long
[2025-05-17T02:19:46.740Z] 	at openjceplus/com.ibm.crypto.plus.provider.RSAKeyPairGenerator.initialize(RSAKeyPairGenerator.java:62)
[2025-05-17T02:19:46.740Z] 	at openjceplus/com.ibm.crypto.plus.provider.RSAKeyPairGenerator$Legacy.initialize(RSAKeyPairGenerator.java:129)
[2025-05-17T02:19:46.740Z] 	at java.base/java.security.KeyPairGenerator$Delegate.initialize(KeyPairGenerator.java:672)
[2025-05-17T02:19:46.740Z] 	at java.base/java.security.KeyPairGenerator.initialize(KeyPairGenerator.java:376)
[2025-05-17T02:19:46.740Z] 	at KeyDestructionTest.generateKeyPair(KeyDestructionTest.java:149)
[2025-05-17T02:19:46.740Z] 	at KeyDestructionTest.main(KeyDestructionTest.java:45)

FYI @jasonkatonica

jasonkatonica added a commit to jasonkatonica/openj9-openjdk-jdk11 that referenced this issue May 29, 2025
This test is failing since the FIPS 140-3 requires RSA key sizes to be
2048 or higher.

fixes eclipse-openj9/openj9#21921
jasonkatonica added a commit to jasonkatonica/openj9-openjdk-jdk11 that referenced this issue May 29, 2025
This test is failing since the FIPS 140-3 requires RSA key sizes to be
2048 or higher.

Fixes eclipse-openj9/openj9#21921
@jasonkatonica
Copy link
Contributor

jasonkatonica commented May 29, 2025

This behavior is due to the delayed provider exception feature of the JCE framework. This test displays what can be done to recreate:

import java.security.*;
import java.util.*;
import javax.crypto.*;
import javax.security.auth.Destroyable;
import javax.security.auth.DestroyFailedException;

public class KeyDestructionTest {
    public static void main(String[] args) throws Exception {
        String kpgAlgorithm = "RSA";
        KeyPair keypair = generateKeyPair(kpgAlgorithm, 1024);
    }

    private static KeyPair generateKeyPair(String algorithm, int size)
        throws NoSuchAlgorithmException {
        KeyPairGenerator generator = KeyPairGenerator.getInstance(algorithm);
        //System.out.println("Generator provider: " + generator.getProvider().getName());
        generator.initialize(size);
        return generator.genKeyPair();
    }
}

No error on weak profile:

# java -Dsemeru.fips=true -Dsemeru.customprofile=OpenJCEPlusFIPS Test.java

Expected error on strict profile:

# java -Dsemeru.fips=true -Dsemeru.customprofile=OpenJCEPlusFIPS.FIPS140-3 Test.java
Exception in thread "main" java.security.InvalidParameterException: RSA keys must be at least 2048 bits long
	at openjceplus/com.ibm.crypto.plus.provider.RSAKeyPairGenerator.initialize(RSAKeyPairGenerator.java:62)
	at openjceplus/com.ibm.crypto.plus.provider.RSAKeyPairGenerator$Legacy.initialize(RSAKeyPairGenerator.java:129)
	at java.base/java.security.KeyPairGenerator$Delegate.initialize(KeyPairGenerator.java:672)
	at java.base/java.security.KeyPairGenerator.initialize(KeyPairGenerator.java:377)
	at KeyDestructionTest.generateKeyPair(Test.java:18)
	at KeyDestructionTest.main(Test.java:10)

The selection of generator from the JCE framework is delayed until initialize is called.

For weak profile:
When we run initialize in weak profile it first gets the error from OpenJCEPlusFIPS correctly since its a small key. This error however is hidden from us since the JCE framework decides to fail over to get the next algorothm in the list to see if it works. It does and returns the instance from SunRsaSign since this provider is available in weak profile.

If the user adds a line such as System.out.println("Generator provider: " + generator.getProvider().getName()); then this disables the delayed provider selection and then properly gets the correct error on initalize without failing over to SunRsaSign provider.

For strict profile:
When we run initialize in strict profile it first gets the error from OpenJCEPlusFIPS correctly during initialize since its a small key. The framework has no other choice to return the exception since there are no other providers available that support "RSA" algorithm.

This test can be fixed by updating from 1024 to 2048 key size which is expected to work in various FIPS and non FIPS scenarios.

@jasonkatonica
Copy link
Contributor

This test is already using 2048 in other releases which is why updates are only needed in the Java 11 version of the test:

Update made with ibmruntimes/openj9-openjdk-jdk11#925

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants