Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-36134

C_GetInfo can throw an exception if called before initialization in some PKCS #11 tokens [rhel-8, openjdk-17]

    • java-17-openjdk-17.0.7.0.7-3.el8
    • None
    • None
    • sst_java
    • None
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • If docs needed, set a value
    • None

      In some PKCS #11 tokens, calling C_GetInfo before initialization returns a CKR_CRYPTOKI_NOT_INITIALIZED error [1]. If this happens, the error is then transformed into a PKCS11Exception and thrown in the PKCS11 constructor [2]. Throwing an exception at that point would be unnecessarily fatal: execution should continue and it's only Password-Based Encryption who might, at some point, require the information —hopefully, the token will be initialized by then. Notice that this problem could not be reproduced with the NSS Software Token but with p11-kit-trust.so.

      JDK-8255409 [3], available since JDK-18 (OpenJDK upstream), seems to handle a C_GetInfo throwing an exception in the constructor of PKCS11 [4]. It's not the goal of this ticket to backport JDK-8255409 to 17u but to fix this regression. Other options, such as backporting JDK-8255409 to 17u, will be considered in the future once the Password-Based Cryptography enhancement is accepted in OpenJDK head and backported to 17u [5].

      PR discussion: https://github.com/rh-openjdk/jdk/pull/26


      [1] - https://docs.oasis-open.org/pkcs11/pkcs11-spec/v3.1/cs01/pkcs11-spec-v3.1-cs01.html#_Toc111203257
      [2] - https://github.com/rh-openjdk/jdk/blob/1e26894969d911776f60eaa557d25a2b389060da/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11.java#L156
      [3] - https://bugs.openjdk.org/browse/JDK-8255409
      [4] - https://github.com/openjdk/jdk/commit/83e6a4c0e9e4a9474ae0c1252378b1a09d1d2df0#diff-507046ab6e8d2a75a31fe49822a43729eefa2ca12b4fe1c27f427ebb0702e208R160
      [5] - https://github.com/openjdk/jdk/pull/12396

            mbalaoal Martin Balao
            mbalaoal Martin Balao
            Martin Balao Martin Balao
            David Kutalek David Kutalek
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: