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

Some impls of javax.crypto.Cipher.init() do not throw UnsupportedOperationExc for unsupported modes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 17
    • 7, 8, 11, 17
    • security-libs

    Backports

      Description

        Looks like the Cipher init methods throw InvalidAlgorithmParameterException instead of UnsupportedOperationException when an unsupported mode is encountered. The SunPKCS11 provider is the example here:

        The SunPKCS11 provider's implementation of Cipher.init() method does not seem to align with the spec. According to the spec:

        "
        UnsupportedOperationException - if opmode is WRAP_MODE or UNWRAP_MODE but the mode is not implemented by the underlying CipherSpi.
        "

        However, the attached code throws the following exception:

        -----------------------------------------------------

        java.security.InvalidAlgorithmParameterException: Unsupported mode: 3
                at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.implInit(P11Cipher.java:359)
                at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.engineInit(P11Cipher.java:320)
                at java.base/javax.crypto.Cipher.init(Cipher.java:1431)
                at java.base/javax.crypto.Cipher.init(Cipher.java:1364)
                at KeywrapTest.main(KeywrapTest.java:20)

        -----------------------------------------------------

        It seems like an InvalidAlgorithmParameterException is thrown instead of the UnsupportedOperationException?

        Attachments

          Issue Links

            Activity

              People

                valeriep Valerie Peng
                tvoniadka Thejasvi Voniadka (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: