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

NullPointerException in byte[] javax.crypto.Cipher#update(byte[], int, int)

XMLWordPrintable

    • jce1.2.2beta
    • generic
    • generic



        Name: bsC130419 Date: 09/05/2001


        java version "1.4.0-beta2"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
        Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)

        http://java.sun.com/j2se/1.4/docs/api/javax/crypto/CipherSpi.html#engineUpdate(byte[],int, int) says:
        Returns: the new buffer with the result, or null if the underlying cipher is a
        block cipher and the input data is too short to result in a new block.

        But if I return null in engineUpdate(byte[], int, int) in my subclass (DES
        algorithm implementation) that inherits from javax.crypto.CipherSpi if there no
        data to return, the JCE, especialy javax.crypto.Cipher#update(byte[], int, int)
        throws a java.lang.NullPointerException.

        I think there is a lack in the javadoc
        http://java.sun.com/j2se/1.4/docs/api/javax/crypto/CipherSpi.html#engineUpdate(byte[],int, int).

        The techwriters should write better:

        Returns: the new buffer with the result, or new byte[0] if the underlying cipher
        is a block cipher and the input data is too short to result in a new block.

        All in all it will be a good thing if Sun make the several checks that are done
        in JCE more public, because it is very bad to do reverse engineering to learn
        the behaivior of JCE-API. I think that are not so secret things that no one
        should know.
        (Review ID: 131420)
        ======================================================================

              valeriep Valerie Peng
              bstrathesunw Bill Strathearn (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: