Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8295343

sun/security/pkcs11 tests fail on Linux RHEL 8.6 and newer

    XMLWordPrintable

Details

    Backports

      Description

        On our RHEL 8.6 Linux x86_64 test machine, a couple of sun/security/pkcs11 tests fail.
        Below are a number of examples. It looks like the native libs of the system do not support any more RSA keys with 512 bit length.
        Should the tests be adjusted so that some keys are not tested any more in case the system is too new?

        Examples of errors :

        sun/security/pkcs11/KeyStore/Basic.java
        ----------------------------------------------
         ....
        test 31 passed
        test 32 passed
        test 33 passed
        got [pk1] signing key: SunPKCS11-nss RSA private key, 512 bits token object, not sensitive, extractable)
        test Basic.testBasic(): failure
        java.security.InvalidKeyException: RSA key must be at least 1023 bits
        at jdk.crypto.cryptoki/sun.security.pkcs11.P11Signature.checkKeySize(P11Signature.java:430)
        at jdk.crypto.cryptoki/sun.security.pkcs11.P11Signature.engineInitSign(P11Signature.java:496)
        at java.base/java.security.Signature$Delegate.engineInitSign(Signature.java:1357)
        at java.base/java.security.Signature.initSign(Signature.java:636)
        at Basic.signAlias(Basic.java:313)
        at Basic.sign(Basic.java:287)
        at Basic.doTest(Basic.java:234)
        at Basic.main(Basic.java:190)
        at PKCS11Test.premain(PKCS11Test.java:174)
        at PKCS11Test.testNSS(PKCS11Test.java:550)
        at PKCS11Test.main(PKCS11Test.java:210)
        at Basic.testBasic(Basic.java:116)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:578)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132)
        at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:599)
        at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174)
        at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
        at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822)
        at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at org.testng.TestRunner.privateRun(TestRunner.java:764)
        at org.testng.TestRunner.run(TestRunner.java:585)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
        at org.testng.SuiteRunner.run(SuiteRunner.java:286)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
        at org.testng.TestNG.runSuites(TestNG.java:1069)
        at org.testng.TestNG.run(TestNG.java:1037)
        at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:93)
        at com.sun.javatest.regtest.agent.TestNGRunner.main(TestNGRunner.java:53)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:578)
        at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:125)
        at java.base/java.lang.Thread.run(Thread.java:1591)

        sun/security/pkcs11/rsa/TestKeyFactory.java
        ------------------------------------------------

        java.security.InvalidKeyException: Could not create RSA public key
        at jdk.crypto.cryptoki/sun.security.pkcs11.P11RSAKeyFactory.implTranslatePublicKey(P11RSAKeyFactory.java:70)
        at jdk.crypto.cryptoki/sun.security.pkcs11.P11KeyFactory.engineTranslateKey(P11KeyFactory.java:153)
        at java.base/java.security.KeyFactory.translateKey(KeyFactory.java:469)
        at TestKeyFactory.testPublic(TestKeyFactory.java:164)
        at TestKeyFactory.test(TestKeyFactory.java:221)
        at TestKeyFactory.main(TestKeyFactory.java:241)
        at PKCS11Test.premain(PKCS11Test.java:174)
        at PKCS11Test.testNSS(PKCS11Test.java:550)
        at PKCS11Test.main(PKCS11Test.java:210)
        at TestKeyFactory.main(TestKeyFactory.java:228)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:578)
        at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:125)
        at java.base/java.lang.Thread.run(Thread.java:1591)
        Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_ATTRIBUTE_VALUE_INVALID
        at jdk.crypto.cryptoki/sun.security.pkcs11.wrapper.PKCS11.C_CreateObject(Native Method)
        at jdk.crypto.cryptoki/sun.security.pkcs11.P11RSAKeyFactory.generatePublic(P11RSAKeyFactory.java:193)
        at jdk.crypto.cryptoki/sun.security.pkcs11.P11RSAKeyFactory.implTranslatePublicKey(P11RSAKeyFactory.java:59)
        ... 13 more


        sun/security/pkcs11/rsa/TestKeyPairGenerator.java
        -------------------------------------------------------
        sunpkcs11: Initializing PKCS#11 library /usr/lib64/libsoftokn3.so
        java.security.InvalidParameterException: RSA key must be at least 1023 bits. The specific key size 512 is not supported
        at jdk.crypto.cryptoki/sun.security.pkcs11.P11KeyPairGenerator.initialize(P11KeyPairGenerator.java:154)
        at java.base/java.security.KeyPairGenerator$Delegate.initialize(KeyPairGenerator.java:665)
        at java.base/java.security.KeyPairGenerator.initialize(KeyPairGenerator.java:377)
        at TestKeyPairGenerator.main(TestKeyPairGenerator.java:127)
        at PKCS11Test.premain(PKCS11Test.java:174)
        at PKCS11Test.testNSS(PKCS11Test.java:550)
        at PKCS11Test.main(PKCS11Test.java:210)
        at TestKeyPairGenerator.main(TestKeyPairGenerator.java:108)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:578)
        at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:125)
        at java.base/java.lang.Thread.run(Thread.java:1591)

        Attachments

          Issue Links

            Activity

              People

                mdonovan Matthew Donovan
                mbaesken Matthias Baesken
                Votes:
                1 Vote for this issue
                Watchers:
                19 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: