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

(spec) javax.crypto.Cipher.getInstance() throws incorrect NoSuchAlgorithmException

XMLWordPrintable

      According to the spec, javax.crypto.Cipher.getInstance() should throw
      BadPaddingException if an invalid padding is requested:

      > public static final Cipher getInstance(String transformation)
      > throws NoSuchAlgorithmException,
      > NoSuchPaddingException
      ...
      > Throws:
      > NoSuchAlgorithmException - if the specified transformation is not
      > available in the default provider package or any of the other
      > provider packages that were searched.
      > NoSuchPaddingException - if transformation contains a padding
      > scheme that is not available.

      However, using the attached example which requests a clearly bogus
      padding scheme ("DES/CBC/BadPaddingSpecified"), we see a
      NoSuchAlgorithmException being thrown.

      > jrd@dickdale:6224620% uname -a
      > Linux dickdale 2.6.5-7.108-default #1 Wed Aug 25 13:34:40 UTC 2004 i686 i686 i386 GNU/Linux
      > jrd@dickdale:6224620% java -version
      > java version "1.6.0-ea"
      > Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b22)
      > Java HotSpot(TM) Client VM (build 1.6.0-ea-b22, mixed mode)
      > jrd@dickdale:6224620% java PaddingTest
      > Test failed: Unexpected exception java.security.NoSuchAlgorithmException: Cannot find any provider supporting DES/CBC/BadPaddingSpecified

      ###@###.### 2005-2-04 17:15:50 GMT

            kdriver Kevin Driver
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: