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

InvalidKeyException from javax.crypto.Cipher.init(int, (Certificate)null)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P3 P3
    • None
    • 5.0
    • security-libs



      Name: iiR10263 Date: 11/20/2003



      The specification describes exceptions that are throw by
      javax.crypto.Cipher.init(int, Certificate) as follows:

      Throws:
      InvalidKeyException - if the public key in the given certificate is
      inappropriate for initializing this cipher, or this cipher is being
      initialized for decryption or unwrapping keys and requires algorithm
      parameters that cannot be determined from the public key in the given
      certificate, or the keysize of the public key in the given certificate
      has a keysize that exceeds the maximum allowable keysize (as determined
      by the configured jurisdiction policy files).

      The above means that InvalidKeyException is thrown when a key is
      inappropriate, but exists. There is no any key in null Certificate so
      InvalidKeyException is inappropriate. NullPointerException is more
      appliciable here, because the specification mentions a key that is
      derived from the argument - the situation fits for
      NullPointerException: "Applications should throw instances of this
      class to indicate other illegal uses of the null object."

      The one hand such behaviour may be documented and specification
      may be updated, but on the other hand jdk1.4.2 specification says
      the same as 1.5 specification. So it is reasonable not to change the
      specification but change implementation.


      ======================================================================

            valeriep Valerie Peng
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: