public abstract class MAC extends MessageDigest
HMACMessageDigest.MDStatealgID, digestBits, digestValid| Modifier | Constructor and Description |
|---|---|
protected |
MAC()
Empty constructor.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
computeMAC()
Computes the MAC based on the data entered with the update() methods.
|
byte[] |
computeMAC(byte[] document)
Computes the MAC based on the specified parameter.
|
abstract void |
erase()
Erases the sensitive data.
|
static MAC |
getInstance(AlgorithmIdentifier algID, SymmetricKey key)
Creates a new initialized MAC instance with the specified parameters.
|
abstract void |
initialize(AlgorithmIdentifier algID, SymmetricKey key)
Initializes this MAC with the specified parameter.
|
boolean |
verifyMAC(byte[] macBytes)
Verifies the MAC based on the data entered with the update() methods and the parameter.
|
boolean |
verifyMAC(byte[] document, byte[] macBytes)
Verifies the MAC based on the specified parameters.
|
algName, blockSize, clone, computeCurrent, computeDigest, computeDigest, getAlgID, getDigestBits, getDigestLength, getInstance, getState, init, isEqual, isValid, setAlgID, setState, toString, update, update, update, update, update, update, update, update, update, update, update, update, update, updateASCIIpublic static MAC getInstance(AlgorithmIdentifier algID, SymmetricKey key) throws AlgorithmIdentifierException
algID - The MAC algorithm identifier representing the MAC instance to create (can be AlgID.hmacMD5, AlgID.hmacSHA...).key - The key to use in this MAC. The key bytes will be cloned when initialized.AlgorithmIdentifierExceptionpublic abstract void initialize(AlgorithmIdentifier algID, SymmetricKey key) throws AlgorithmIdentifierException
algID - The MAC algorithm.key - The key to use in this MAC. The key bytes will be cloned when initialized.AlgorithmIdentifierExceptionpublic byte[] computeMAC()
public byte[] computeMAC(byte[] document)
document - The document to digest to calculate the MAC.public boolean verifyMAC(byte[] macBytes)
macBytes - The MAC value to compare to the result of the MAC computation.
public boolean verifyMAC(byte[] document,
byte[] macBytes)
document - The document to digest to calculate the MAC.macBytes - The MAC value to compare to the result of the MAC computation.public abstract void erase()