public final class HMAC extends MAC
MessageDigest.MDStatealgID| Constructor and Description |
|---|
HMAC()
Empty constructor.
|
HMAC(AlgorithmIdentifier hashAlgID, byte[] key)
Deprecated.
|
HMAC(AlgorithmIdentifier hashAlgID, byte[] key, int keyOff, int keyLen)
Deprecated.
|
HMAC(AlgorithmIdentifier hashAlgID, SymmetricKey key)
Creates a new HMAC object with the specified parameters.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
algName()
Returns the algorithm name of this HMAC.
|
int |
blockSize()
Returns the blocksize of this instance.
|
java.lang.Object |
clone()
Returns a clone of this HMAC object.
|
void |
computeCurrent()
Completes the hash computation, performing any necessary operations such as padding.
|
void |
erase()
Erases the keyBytes from this instance.
|
void |
finalize()
Finalizes this object by erasing sensitive data.
|
AlgorithmIdentifier |
getAlgID()
Returns the algorithm identifier of this object.
|
byte[] |
getDigestBits()
Returns a copy of the current digest bytes.
|
int |
getDigestLength()
Returns the length in bytes of the message digest.
|
protected MessageDigest.MDState |
getState()
Gets the state of this MessageDigest instance.
|
void |
init()
Resets this HMAC object to its initial state.
|
void |
initialize(AlgorithmIdentifier algID, SymmetricKey key)
Initializes this MAC with the specified parameter.
|
boolean |
isValid()
Returns
true if this HMAC is in a valid state and its digest bits are usable; otherwise returns false. |
void |
setAlgID(AlgorithmIdentifier algID)
Deprecated.
Use initialize instead
|
void |
setKey(byte[] key)
Deprecated.
Use initialize instead
|
void |
setKey(byte[] key, int keyOff, int keyLen)
Deprecated.
Use initialize instead
|
protected void |
setState(MessageDigest.MDState state)
Sets the state of this MessageDigest instance.
|
void |
update(byte b)
Adds the specifed byte to the data being digested.
|
void |
update(byte[] input, int off, int len)
Adds the specified sequence of bytes to the data being digested.
|
computeMAC, computeMAC, getInstance, verifyMAC, verifyMACcomputeDigest, computeDigest, getInstance, isEqual, toString, update, update, update, update, update, update, update, update, update, update, update, updateASCIIpublic HMAC()
public HMAC(AlgorithmIdentifier hashAlgID, SymmetricKey key) throws AlgorithmIdentifierException
hashAlgID - The hash algorithm to use in this HMAC instance.key - The key to use.AlgorithmIdentifierExceptionpublic HMAC(AlgorithmIdentifier hashAlgID, byte[] key, int keyOff, int keyLen) throws AlgorithmIdentifierException
AlgorithmIdentifierExceptionpublic HMAC(AlgorithmIdentifier hashAlgID, byte[] key) throws AlgorithmIdentifierException
AlgorithmIdentifierExceptionpublic void initialize(AlgorithmIdentifier algID, SymmetricKey key) throws AlgorithmIdentifierException
MACinitialize in class MACalgID - The MAC algorithm.key - The key to use in this MAC. The key bytes will be cloned when initialized.AlgorithmIdentifierExceptionpublic void setAlgID(AlgorithmIdentifier algID) throws AlgorithmIdentifierException
MessageDigestsetAlgID in class MessageDigestalgID - The AlgorithmIdentifier to use.AlgorithmIdentifierExceptionpublic AlgorithmIdentifier getAlgID()
MessageDigestgetAlgID in class MessageDigest
public void setKey(byte[] key,
int keyOff,
int keyLen)
public void setKey(byte[] key)
public void init()
init in class MessageDigestpublic void update(byte b)
update in class MessageDigest
public void update(byte[] input,
int off,
int len)
update in class MessageDigestinput - the input arrayoff - start position in the input arraylen - the number of input array elements to add to the data being digestedpublic void computeCurrent()
getDigestBits().computeCurrent in class MessageDigestpublic java.lang.String algName()
algName in class MessageDigestpublic int blockSize()
MessageDigestblockSize in class MessageDigestpublic int getDigestLength()
MessageDigestgetDigestLength in class MessageDigestpublic byte[] getDigestBits()
getDigestBits in class MessageDigestpublic boolean isValid()
true if this HMAC is in a valid state and its digest bits are usable; otherwise returns false.isValid in class MessageDigestpublic void finalize()
finalize in class java.lang.Objectpublic java.lang.Object clone()
clone in class MessageDigestprotected MessageDigest.MDState getState()
MessageDigestgetState in class MessageDigestprotected void setState(MessageDigest.MDState state)
MessageDigestsetState in class MessageDigest