public class HMACAccumulator extends Object
HMACAccumulator
is used to build Hash Message Authentication
Codes. It has two modes, one where all the data acquired is used to build the
MAC and a second that assumes that the last n bytes of the acquired data will
contain a MAC for all the data previous.
The first mode it used in an encryption phase to create a MAC for the encrypted data. The second mode is used in the decryption phase and recalculates the MAC taking into account that for cases where the encrypted data MAC has been appended. Internally the accumulator uses a circular buffer to simplify the housekeeping of avoiding the last n bytes.
It is assumed that the supplied buffersize is always greater than or equal to the mac length.
Modifier and Type | Field and Description |
---|---|
protected OutputStream |
outputStream |
Constructor and Description |
---|
HMACAccumulator(Key key,
String macAlgorithm,
String cryptoProvider,
int buffersize) |
Modifier and Type | Method and Description |
---|---|
void |
attachStream(ByteArrayOutputStream outputStream) |
void |
decryptUpdate(byte[] buffer,
int read)
Update buffer with MAC taking into account that a MAC is appended to the
buffer and should be precluded from the MAC calculation.
|
void |
encryptUpdate(byte[] buffer,
int read)
Update buffer with MAC.
|
byte[] |
getAppendedMac() |
byte[] |
getCalculatedMac() |
int |
getMaclength() |
void |
validate() |
protected OutputStream outputStream
public void encryptUpdate(byte[] buffer, int read)
public void decryptUpdate(byte[] buffer, int read) throws IOException
IOException
public byte[] getCalculatedMac()
public byte[] getAppendedMac()
public void validate()
public int getMaclength()
public void attachStream(ByteArrayOutputStream outputStream)
Apache Camel