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

pack-priv final Class P11Digest

extends MessageDigestSpi
implements Cloneable, MessageDigestSpi2
Class Inheritance
All Implemented Interfaces
sun.security.util.MessageDigestSpi2, java.lang.Cloneable
Imports
java.nio.ByteBuffer, java.security.*, javax.crypto.SecretKey, jdk.internal.access.JavaNioAccess, .SharedSecrets, sun.nio.ch.DirectBuffer, sun.security.util.MessageDigestSpi2, sun.security.pkcs11.wrapper.*

MessageDigest implementation class. This class currently supports MD2, MD5, SHA-1, SHA-2 family (SHA-224, SHA-256, SHA-384, and SHA-512) and SHA-3 family (SHA3-224, SHA3-256, SHA3-384, and SHA3-512) of digests. Note that many digest operations are on fairly small amounts of data (less than 100 bytes total). For example, the 2nd hashing in HMAC or the PRF in TLS. In order to speed those up, we use some buffering to minimize number of the Java->native transitions.
Author
Andreas Sterbenz
Since
1.5

Field Summary

Modifier and TypeField and Description
private final String
private byte[]
private static final int
private int
private final int
private final CK_MECHANISM
private static final JavaNioAccess
private static final int
private static final int
private static final int
private Session
private int
private final Token

Constructor Summary

AccessConstructor and Description
pack-priv
P11Digest(Token token, String algorithm, long mechanism)

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.security.MessageDigestSpi.clone.

Returns a clone if the implementation is cloneable.

protected byte[]
engineDigest()

Implements abstract java.security.MessageDigestSpi.engineDigest.

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

protected int
engineDigest(byte[] digest, int ofs, int len)

Overrides java.security.MessageDigestSpi.engineDigest.

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

protected int
engineGetDigestLength()

Overrides java.security.MessageDigestSpi.engineGetDigestLength.

Returns the digest length in bytes.

protected void
engineReset()

Implements abstract java.security.MessageDigestSpi.engineReset.

Resets the digest for further use.

protected void
engineUpdate(byte in)

Implements abstract java.security.MessageDigestSpi.engineUpdate.

Updates the digest using the specified byte.

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

Implements abstract java.security.MessageDigestSpi.engineUpdate.

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

public void
engineUpdate(SecretKey key)

Implements sun.security.util.MessageDigestSpi2.engineUpdate.

Updates the digest using the specified key.

protected void
engineUpdate(ByteBuffer byteBuffer)

Overrides java.security.MessageDigestSpi.engineUpdate.

Update the digest using the specified ByteBuffer.

private void

Field Detail

algorithmback to summary
private final String algorithm
bufferback to summary
private byte[] buffer
BUFFER_SIZEback to summary
private static final int BUFFER_SIZE
bufOfsback to summary
private int bufOfs
digestLengthback to summary
private final int digestLength
mechanismback to summary
private final CK_MECHANISM mechanism
NIO_ACCESSback to summary
private static final JavaNioAccess NIO_ACCESS
S_BLANKback to summary
private static final int S_BLANK
S_BUFFEREDback to summary
private static final int S_BUFFERED
S_INITback to summary
private static final int S_INIT
sessionback to summary
private Session session
stateback to summary
private int state
tokenback to summary
private final Token token

Constructor Detail

P11Digestback to summary
pack-priv P11Digest(Token token, String algorithm, long mechanism)

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 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 int engineDigest(byte[] digest, 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 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 void engineReset()

Implements abstract java.security.MessageDigestSpi.engineReset.

Doc from java.security.MessageDigestSpi.engineReset.

Resets the digest for further use.

engineUpdateback to summary
protected void engineUpdate(byte in)

Implements abstract java.security.MessageDigestSpi.engineUpdate.

Doc from java.security.MessageDigestSpi.engineUpdate.

Updates the digest using the specified byte.

engineUpdateback to summary
protected void engineUpdate(byte[] in, 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.

engineUpdateback to summary
public void engineUpdate(SecretKey key) throws InvalidKeyException

Implements sun.security.util.MessageDigestSpi2.engineUpdate.

Doc from sun.security.util.MessageDigestSpi2.engineUpdate.

Updates the digest using the specified key. This is used for SSL 3.0 only, we may deprecate and remove the support of this in the future

engineUpdateback to summary
protected void engineUpdate(ByteBuffer byteBuffer)

Overrides java.security.MessageDigestSpi.engineUpdate.

Doc from java.security.MessageDigestSpi.engineUpdate.

Update the digest using the specified ByteBuffer. The digest is updated using the input.remaining() bytes starting at input.position(). Upon return, the buffer's position will be equal to its limit; its limit will not have changed.

fetchSessionback to summary
private void fetchSession()