Class HMACAccumulator
- java.lang.Object
-
- org.apache.camel.converter.crypto.HMACAccumulator
-
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.
-
-
Field Summary
Fields Modifier and Type Field Description protected OutputStream
outputStream
-
Constructor Summary
Constructors Constructor Description HMACAccumulator(Key key, String macAlgorithm, String cryptoProvider, int buffersize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attachStream(OutputStream 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()
-
-
-
Field Detail
-
outputStream
protected OutputStream outputStream
-
-
Method Detail
-
encryptUpdate
public void encryptUpdate(byte[] buffer, int read)
Update buffer with MAC. Typically used in the encryption phase where no hmac is appended to the buffer.
-
decryptUpdate
public void decryptUpdate(byte[] buffer, int read) throws IOException
Update buffer with MAC taking into account that a MAC is appended to the buffer and should be precluded from the MAC calculation.- Throws:
IOException
-
getCalculatedMac
public byte[] getCalculatedMac()
-
getAppendedMac
public byte[] getAppendedMac()
-
validate
public void validate()
-
getMaclength
public int getMaclength()
-
attachStream
public void attachStream(OutputStream outputStream)
-
-