public class TlsMac extends Object
Modifier and Type | Field and Description |
---|---|
protected TlsContext |
context |
protected int |
digestBlockSize |
protected int |
digestOverhead |
protected Mac |
mac |
protected int |
macLength |
protected byte[] |
secret |
Constructor and Description |
---|
TlsMac(TlsContext context,
Digest digest,
byte[] key,
int keyOff,
int keyLen)
Generate a new instance of an TlsMac.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
calculateMac(long seqNo,
short type,
byte[] message,
int offset,
int length)
Calculate the MAC for some given data.
|
byte[] |
calculateMacConstantTime(long seqNo,
short type,
byte[] message,
int offset,
int length,
int fullLength,
byte[] dummyData) |
protected int |
getDigestBlockCount(int inputLength) |
byte[] |
getMACSecret() |
int |
getSize() |
protected byte[] |
truncate(byte[] bs) |
protected TlsContext context
protected byte[] secret
protected Mac mac
protected int digestBlockSize
protected int digestOverhead
protected int macLength
public TlsMac(TlsContext context, Digest digest, byte[] key, int keyOff, int keyLen)
context
- the TLS client contextdigest
- The digest to use.key
- A byte-array where the key for this MAC is located.keyOff
- The number of bytes to skip, before the key starts in the buffer.keyLen
- The length of the key.public byte[] getMACSecret()
public int getSize()
public byte[] calculateMac(long seqNo, short type, byte[] message, int offset, int length)
type
- The message type of the message.message
- A byte-buffer containing the message.offset
- The number of bytes to skip, before the message starts.length
- The length of the message.public byte[] calculateMacConstantTime(long seqNo, short type, byte[] message, int offset, int length, int fullLength, byte[] dummyData)
protected int getDigestBlockCount(int inputLength)
protected byte[] truncate(byte[] bs)