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

engineDigest: unspecified behavior when parameters are illegal

    XMLWordPrintable

    Details

      Description


      The spec. doesn't define behavior for the method
      MessageDigestSpi.engineDigest(byte[] buff, int offset, int len)
      when one of its parameters is illegal.

      The spec says:
        "protected int engineDigest(byte[] buf, int offset, int len)
             throws DigestException

         Completes the hash computation by performing final operations such as
         padding. Once engineDigest has been called, the engine should be reset
         (see engineReset). Resetting is the responsibility of the engine implementor.
         This method should be abstract, but we leave it concrete for binary
         compatibility. Knowledgeable providers should override this method.

         Parameters:
             buf - the output buffer in which to store the digest
             offset - offset to start from in the output buffer
             len - number of bytes within buf allotted for the digest. Both this
               default implementation and the SUN provider do not return partial
               digests. The presence of this parameter is solely for consistency in
               our API's. If the value of this parameter is less than the actual
               digest length, the method will throw a DigestException. This parameter
               is ignored if its value is greater than or equal to the actual digest
               length.
        Returns:
             the length of the digest stored in the output buffer.
        Throws:
             DigestException - if an error occurs."

      So, the behavior is defined only when len is illegal but the spec.
      should also define the method behavior when:
      1) 'buf' array is null
      2) 'offset' is outside 'input' array bounds.

      ###@###.### 2004-02-26

        Attachments

          Activity

            People

            Assignee:
            valeriep Valerie Peng
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: