Class AbstractMessageDigestSpi

  • All Implemented Interfaces:
    Cloneable
    Direct Known Subclasses:
    AbstractBufferedMessageDigestSpi

    public abstract class AbstractMessageDigestSpi
    extends MessageDigestSpi
    implements Cloneable
    Common base message digest implementation for the Sun provider. It implements all the JCA methods as suitable for a Java message digest implementation of an algorithm based on a compression function (as all commonly used algorithms are). The individual digest subclasses only need to implement the following methods: . abstract void implCompress(byte[] b, int ofs); . abstract void implDigest(byte[] out, int ofs); . abstract void implReset(); See the inline documentation for details. Implementation copied from sun.security.provider.DigestBase.
    Since:
    1.5
    • Method Detail

      • engineGetDigestLength

        public final int engineGetDigestLength()
        Description copied from class: MessageDigestSpi
        Returns the digest length in bytes.

        This concrete method has been added to this previously-defined abstract class. (For backwards compatibility, it cannot be abstract.)

        The default behavior is to return 0.

        This method may be overridden by a provider to return the digest length.

        Overrides:
        engineGetDigestLength in class MessageDigestSpi
        Returns:
        the digest length in bytes.
      • engineUpdate

        protected final void engineUpdate​(byte b)
        Description copied from class: MessageDigestSpi
        Updates the digest using the specified byte.
        Specified by:
        engineUpdate in class MessageDigestSpi
        Parameters:
        b - the byte to use for the update.
      • engineUpdate

        public final void engineUpdate​(byte[] b,
                                       int ofs,
                                       int len)
        Description copied from class: MessageDigestSpi
        Updates the digest using the specified array of bytes, starting at the specified offset.
        Specified by:
        engineUpdate in class MessageDigestSpi
        Parameters:
        b - the array of bytes to use for the update.
        ofs - the offset to start from in the array of bytes.
        len - the number of bytes to use, starting at offset.
      • engineDigest

        public final byte[] engineDigest()
        Description copied from class: MessageDigestSpi
        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.
        Specified by:
        engineDigest in class MessageDigestSpi
        Returns:
        the array of bytes for the resulting hash value.
      • engineDigest

        protected final int engineDigest​(byte[] out,
                                         int ofs,
                                         int len)
                                  throws DigestException
        Description copied from class: MessageDigestSpi
        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.
        Overrides:
        engineDigest in class MessageDigestSpi
        Parameters:
        out - the output buffer in which to store the digest
        ofs - 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.