APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.provider

pack-priv abstract Class DigestBase

extends MessageDigestSpi
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
sun.security.provider.MD2, sun.security.provider.MD4, sun.security.provider.MD5, sun.security.provider.SHA, sun.security.provider.SHA2, sun.security.provider.SHA3, sun.security.provider.SHA5
Imports
java.security.MessageDigestSpi, .DigestException, .ProviderException, java.util.Arrays, .Objects, jdk.internal.util.Preconditions, jdk.internal.vm.annotation.IntrinsicCandidate

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.
Author
Andreas Sterbenz
Since
1.5

Field Summary

Modifier and TypeField and Description
private final String
protected final int
pack-priv byte[]
private int
pack-priv long
private final int
private byte[]
pack-priv static final byte[]

Constructor Summary

AccessConstructor and Description
pack-priv
DigestBase(String algorithm, int digestLength, int blockSize)

Main constructor.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.security.MessageDigestSpi.clone.

Returns a clone if the implementation is cloneable.

protected final byte[]
engineDigest()

Implements abstract java.security.MessageDigestSpi.engineDigest.

Completes the hash computation by performing final operations such as padding.

protected final int
engineDigest(byte[] out, int ofs, int len)

Overrides java.security.MessageDigestSpi.engineDigest.

Completes the hash computation by performing final operations such as padding.

protected final int
engineGetDigestLength()

Overrides java.security.MessageDigestSpi.engineGetDigestLength.

Returns the digest length in bytes.

protected final void
engineReset()

Implements abstract java.security.MessageDigestSpi.engineReset.

Resets the digest for further use.

protected final void
engineUpdate(byte b)

Implements abstract java.security.MessageDigestSpi.engineUpdate.

Updates the digest using the specified byte.

protected final void
engineUpdate(byte[] b, int ofs, int len)

Implements abstract java.security.MessageDigestSpi.engineUpdate.

Updates the digest using the specified array of bytes, starting at the specified offset.

pack-priv abstract void
implCompress(byte[] b, int ofs)

Core compression function.

private int
implCompressMultiBlock(byte[] b, int ofs, int limit)

private int
implCompressMultiBlock0(byte[] b, int ofs, int limit)

private void
implCompressMultiBlockCheck(byte[] b, int ofs, int limit)

pack-priv abstract void
implDigest(byte[] out, int ofs)

Return the digest.

pack-priv void
implDigestFixedLengthPreprocessed(byte[]
byte array to be digested
input
,
int
the length of the input
inLen
,
byte[]
the output buffer
output
,
int
the offset into output buffer where digest should be written
outOffset
,
int
the length of the output buffer
outLen
)

Digest block-length bytes in a single operation.

pack-priv abstract void
implReset()

Reset subclass specific state to their initial values.

Inherited from java.security.MessageDigestSpi:
engineUpdate

Field Detail

algorithmback to summary
private final String algorithm
blockSizeback to summary
protected final int blockSize
bufferback to summary
pack-priv byte[] buffer
bufOfsback to summary
private int bufOfs
bytesProcessedback to summary
pack-priv long bytesProcessed
digestLengthback to summary
private final int digestLength
oneByteback to summary
private byte[] oneByte
paddingback to summary
pack-priv static final byte[] padding

Constructor Detail

DigestBaseback to summary
pack-priv DigestBase(String algorithm, int digestLength, int blockSize)

Main constructor.

Method Detail

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides java.security.MessageDigestSpi.clone.

Doc from java.security.MessageDigestSpi.clone.

Returns a clone if the implementation is cloneable.

Exceptions
CloneNotSupportedException:
if this is called on an implementation that does not support Cloneable.
engineDigestback to summary
protected final byte[] engineDigest()

Implements abstract java.security.MessageDigestSpi.engineDigest.

Doc from java.security.MessageDigestSpi.engineDigest.

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.

engineDigestback to summary
protected final int engineDigest(byte[] out, int ofs, int len) throws DigestException

Overrides java.security.MessageDigestSpi.engineDigest.

Doc from java.security.MessageDigestSpi.engineDigest.

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.

Exceptions
DigestException:
if an error occurs.
engineGetDigestLengthback to summary
protected final int engineGetDigestLength()

Overrides java.security.MessageDigestSpi.engineGetDigestLength.

Doc from java.security.MessageDigestSpi.engineGetDigestLength.

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.

engineResetback to summary
protected final void engineReset()

Implements abstract java.security.MessageDigestSpi.engineReset.

Doc from java.security.MessageDigestSpi.engineReset.

Resets the digest for further use.

engineUpdateback to summary
protected final void engineUpdate(byte b)

Implements abstract java.security.MessageDigestSpi.engineUpdate.

Doc from java.security.MessageDigestSpi.engineUpdate.

Updates the digest using the specified byte.

engineUpdateback to summary
protected final void engineUpdate(byte[] b, int ofs, int len)

Implements abstract java.security.MessageDigestSpi.engineUpdate.

Doc from java.security.MessageDigestSpi.engineUpdate.

Updates the digest using the specified array of bytes, starting at the specified offset.

implCompressback to summary
pack-priv abstract void implCompress(byte[] b, int ofs)

Core compression function. Processes blockSize bytes at a time and updates the state of this object.

implCompressMultiBlockback to summary
private int implCompressMultiBlock(byte[] b, int ofs, int limit)
implCompressMultiBlock0back to summary
private int implCompressMultiBlock0(byte[] b, int ofs, int limit)
Annotations
@IntrinsicCandidate
implCompressMultiBlockCheckback to summary
private void implCompressMultiBlockCheck(byte[] b, int ofs, int limit)
implDigestback to summary
pack-priv abstract void implDigest(byte[] out, int ofs)

Return the digest. Subclasses do not need to reset() themselves, DigestBase calls implReset() when necessary.

implDigestFixedLengthPreprocessedback to summary
pack-priv void implDigestFixedLengthPreprocessed(byte[] input, int inLen, byte[] output, int outOffset, int outLen) throws UnsupportedOperationException

Digest block-length bytes in a single operation. Subclasses are expected to override this method. It is intended for fixed-length short input where input includes padding bytes.

Parameters
input:byte[]

byte array to be digested

inLen:int

the length of the input

output:byte[]

the output buffer

outOffset:int

the offset into output buffer where digest should be written

outLen:int

the length of the output buffer

Exceptions
UnsupportedOperationException:
if a subclass does not override this method
implResetback to summary
pack-priv abstract void implReset()

Reset subclass specific state to their initial values. DigestBase calls this method when necessary.