public abstract class MessageDigest extends Object
MessageDigest
class is the base class for hashing
algorithms. Implementations of MessageDigest
algorithms must
extend this class and implement all the abstract methods.
A tear or card reset event resets a MessageDigest
object to
the initial state (state upon construction).
Even if a transaction is in progress, update of intermediate result state in the implementation instance shall not participate in the transaction.
Modifier and Type | Class and Description |
---|---|
static class |
MessageDigest.OneShot
The
OneShot class is a specialization of the
MessageDigest class intended to support efficient one-shot hash
operations that may avoid persistent memory writes entirely. |
Modifier and Type | Field and Description |
---|---|
static byte |
ALG_MD5
Message Digest algorithm MD5.
|
static byte |
ALG_NULL
This constant indicates that there is no discrete message digest
algorithm.
|
static byte |
ALG_RIPEMD160
Message Digest algorithm RIPE MD-160.
|
static byte |
ALG_SHA
Message Digest algorithm SHA-1.
|
static byte |
ALG_SHA_224
Message Digest algorithm SHA-224.
|
static byte |
ALG_SHA_256
Message Digest algorithm SHA-256.
|
static byte |
ALG_SHA_384
Message Digest algorithm SHA-384.
|
static byte |
ALG_SHA_512
Message Digest algorithm SHA-512.
|
static byte |
ALG_SHA3_224
Message Digest algorithm SHA3-224.
|
static byte |
ALG_SHA3_256
Message Digest algorithm SHA3-256.
|
static byte |
ALG_SHA3_384
Message Digest algorithm SHA3-384.
|
static byte |
ALG_SHA3_512
Message Digest algorithm SHA3-512.
|
static byte |
LENGTH_MD5
Length of digest in bytes for MD5
|
static byte |
LENGTH_RIPEMD160
Length of digest in bytes for RIPE MD-160
|
static byte |
LENGTH_SHA
Length of digest in bytes for SHA-1
|
static byte |
LENGTH_SHA_224
Length of digest in bytes for SHA-224
|
static byte |
LENGTH_SHA_256
Length of digest in bytes for SHA-256
|
static byte |
LENGTH_SHA_384
Length of digest in bytes for SHA-384
|
static byte |
LENGTH_SHA_512
Length of digest in bytes for SHA-512
|
static byte |
LENGTH_SHA3_224
Length of digest in bytes for SHA3-224
|
static byte |
LENGTH_SHA3_256
Length of digest in bytes for SHA3-256
|
static byte |
LENGTH_SHA3_384
Length of digest in bytes for SHA3-384
|
static byte |
LENGTH_SHA3_512
Length of digest in bytes for SHA3-512
|
Modifier | Constructor and Description |
---|---|
protected |
MessageDigest()
Protected Constructor
|
Modifier and Type | Method and Description |
---|---|
abstract short |
doFinal(byte[] inBuff,
short inOffset,
short inLength,
byte[] outBuff,
short outOffset)
Generates a hash of all/last input data.
|
abstract byte |
getAlgorithm()
Gets the Message digest algorithm.
|
static InitializedMessageDigest |
getInitializedMessageDigestInstance(byte algorithm,
boolean externalAccess)
Creates a
InitializedMessageDigest object instance of the
selected algorithm. |
static MessageDigest |
getInstance(byte algorithm,
boolean externalAccess)
Creates a
MessageDigest object instance of the selected
algorithm. |
abstract byte |
getLength()
Returns the byte length of the hash.
|
abstract void |
reset()
Resets the
MessageDigest object to the initial state for
further use. |
abstract void |
update(byte[] inBuff,
short inOffset,
short inLength)
Accumulates a hash of the input data.
|
public static final byte ALG_NULL
Signature.getInstance(byte, byte, byte, boolean)
method.
If this constant in used in the
getInstance(byte, boolean)
it results
in a CryptoException.
public static final byte ALG_SHA
public static final byte ALG_MD5
public static final byte ALG_RIPEMD160
public static final byte ALG_SHA_256
public static final byte ALG_SHA_384
public static final byte ALG_SHA_512
public static final byte ALG_SHA_224
public static final byte ALG_SHA3_224
public static final byte ALG_SHA3_256
public static final byte ALG_SHA3_384
public static final byte ALG_SHA3_512
public static final byte LENGTH_MD5
public static final byte LENGTH_RIPEMD160
public static final byte LENGTH_SHA
public static final byte LENGTH_SHA_224
public static final byte LENGTH_SHA_256
public static final byte LENGTH_SHA_384
public static final byte LENGTH_SHA_512
public static final byte LENGTH_SHA3_224
public static final byte LENGTH_SHA3_256
public static final byte LENGTH_SHA3_384
public static final byte LENGTH_SHA3_512
public static final MessageDigest getInstance(byte algorithm, boolean externalAccess) throws CryptoException
MessageDigest
object instance of the selected
algorithm.algorithm
- the desired message digest algorithm. Valid codes listed in
ALG_*
constants above, for example,
ALG_SHA
.externalAccess
- true
indicates that the instance will be shared
among multiple applet instances and that the
MessageDigest
instance will also be accessed
(via a Shareable
. interface) when the owner of
the MessageDigest
instance is not the currently
selected applet. If true
the implementation
must not allocate CLEAR_ON_DESELECT transient space for
internal data.MessageDigest
object instance of the requested
algorithmCryptoException
- with the following reason codes:
CryptoException.NO_SUCH_ALGORITHM
if
the requested algorithm or shared access mode is not
supported.
public static final InitializedMessageDigest getInitializedMessageDigestInstance(byte algorithm, boolean externalAccess) throws CryptoException
InitializedMessageDigest
object instance of the
selected algorithm.algorithm
- the desired message digest algorithm. Valid codes listed in
ALG_*
constants above, for example,
ALG_SHA
.externalAccess
- true
indicates that the instance will be shared
among multiple applet instances and that the
InitializedMessageDigest
instance will also be
accessed (via a Shareable
. interface) when the
owner of the InitializedMessageDigest
instance
is not the currently selected applet. If true
the implementation must not allocate CLEAR_ON_DESELECT
transient space for internal data.InitializedMessageDigest
object instance of
the requested algorithmCryptoException
- with the following reason codes:
CryptoException.NO_SUCH_ALGORITHM
if
the requested algorithm or shared access mode is not
supported.
public abstract byte getAlgorithm()
public abstract byte getLength()
public abstract short doFinal(byte[] inBuff, short inOffset, short inLength, byte[] outBuff, short outOffset) throws CryptoException
MessageDigest
object is reset to the initial state after
this call is made. The data format is big-endian.
The input and output buffer data may overlap.
In addition to returning ashort
result, this method sets the
result in an internal state which can be rechecked using assertion methods
of the SensitiveResult
class,
if supported by the platform.inBuff
- the input buffer of data to be hashedinOffset
- the offset into the input buffer at which to begin hash
generationinLength
- the byte length to hashoutBuff
- the output buffer, may be the same as the input bufferoutOffset
- the offset into the output buffer where the resulting hash
value beginsoutBuff
CryptoException
- with the following reason codes:
CryptoException.ILLEGAL_USE
if the
accumulated message length is greater than the maximum
length supported by the algorithm.
public abstract void update(byte[] inBuff, short inOffset, short inLength) throws CryptoException
doFinal()
method is recommended. The
doFinal()
method must be called to complete processing of
input data accumulated by one or more calls to the update()
method. The data format is big-endian.
Note:
inLength
is 0 this method does nothing.
inBuff
- the input buffer of data to be hashedinOffset
- the offset into the input buffer at which to begin hash
generationinLength
- the byte length to hashCryptoException
- with the following reason codes:
CryptoException.ILLEGAL_USE
if the
accumulated message length is greater than the maximum
length supported by the algorithm.
doFinal
public abstract void reset()
MessageDigest
object to the initial state for
further use.Copyright © 1998, 2015, Oracle and/or its affiliates. All rights reserved.