Top Description Fields Constructors Methods
org.bouncycastle.tls.crypto.impl

public final Class TlsSuiteHMac

extends Object
implements TlsSuiteMac
Class Inheritance
All Implemented Interfaces
org.bouncycastle.tls.crypto.impl.TlsSuiteMac
Imports
org.bouncycastle.tls.ContentType, .ProtocolVersion, .TlsUtils, org.bouncycastle.tls.crypto.TlsCryptoParameters, .TlsHMAC, .TlsMAC, org.bouncycastle.util.Arrays

A generic TLS MAC implementation, acting as an HMAC based on some underlying Digest.

Field Summary

Modifier and TypeField and Description
private final TlsCryptoParameters
private final int
private final int
private final TlsHMAC
private final int
private static final long

Constructor Summary

AccessConstructor and Description
public
TlsSuiteHMac(TlsCryptoParameters
the TLS client context specific crypto parameters.
cryptoParams
,
TlsHMAC
The MAC to use.
mac
)

Generate a new instance of a TlsMac.

Method Summary

Modifier and TypeMethod and Description
public byte[]
calculateMac(long
The sequence number of the record.
seqNo
,
short
The content type of the message.
type
,
byte[] connectionID, byte[]
A byte array containing the message.
msg
,
int
The number of bytes to skip, before the message starts.
msgOff
,
int
The length of the message.
msgLen
)

Implements org.bouncycastle.tls.crypto.impl.TlsSuiteMac.calculateMac.

Calculate the MAC for some given data.

public byte[]
calculateMacConstantTime(long
The sequence number of the record.
seqNo
,
short
The content type of the message.
type
,
byte[] connectionID, byte[]
A byte array containing the message.
msg
,
int
The number of bytes to skip, before the message starts.
msgOff
,
int
The length of the message.
msgLen
,
int
The expected length of the full message.
fullLength
,
byte[]
Random data for padding out the MAC calculation if required.
dummyData
)

Implements org.bouncycastle.tls.crypto.impl.TlsSuiteMac.calculateMacConstantTime.

Constant time calculation of the MAC for some given data with a given expected length.

private int
getDigestBlockCount(int inputLength)

private int
getHeaderLength(byte[] connectionID)

private static int
public int
getSize()

Implements org.bouncycastle.tls.crypto.impl.TlsSuiteMac.getSize.

Return the output length (in bytes) of this MAC.

private byte[]
truncate(byte[] bs)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cryptoParamsback to summary
private final TlsCryptoParameters cryptoParams
digestBlockSizeback to summary
private final int digestBlockSize
digestOverheadback to summary
private final int digestOverhead
macback to summary
private final TlsHMAC mac
macSizeback to summary
private final int macSize
SEQUENCE_NUMBER_PLACEHOLDERback to summary
private static final long SEQUENCE_NUMBER_PLACEHOLDER

Constructor Detail

TlsSuiteHMacback to summary
public TlsSuiteHMac(TlsCryptoParameters cryptoParams, TlsHMAC mac)

Generate a new instance of a TlsMac.

Parameters
cryptoParams:TlsCryptoParameters

the TLS client context specific crypto parameters.

mac:TlsHMAC

The MAC to use.

Method Detail

calculateMacback to summary
public byte[] calculateMac(long seqNo, short type, byte[] connectionID, byte[] msg, int msgOff, int msgLen)

Implements org.bouncycastle.tls.crypto.impl.TlsSuiteMac.calculateMac.

Doc from org.bouncycastle.tls.crypto.impl.TlsSuiteMac.calculateMac.

Calculate the MAC for some given data.

Parameters
seqNo:long

The sequence number of the record.

type:short

The content type of the message.

msg:byte[]

A byte array containing the message.

msgOff:int

The number of bytes to skip, before the message starts.

msgLen:int

The length of the message.

Returns:byte[]

A new byte array containing the MAC value.

calculateMacConstantTimeback to summary
public byte[] calculateMacConstantTime(long seqNo, short type, byte[] connectionID, byte[] msg, int msgOff, int msgLen, int fullLength, byte[] dummyData)

Implements org.bouncycastle.tls.crypto.impl.TlsSuiteMac.calculateMacConstantTime.

Doc from org.bouncycastle.tls.crypto.impl.TlsSuiteMac.calculateMacConstantTime.

Constant time calculation of the MAC for some given data with a given expected length.

Parameters
seqNo:long

The sequence number of the record.

type:short

The content type of the message.

msg:byte[]

A byte array containing the message.

msgOff:int

The number of bytes to skip, before the message starts.

msgLen:int

The length of the message.

fullLength:int

The expected length of the full message.

dummyData:byte[]

Random data for padding out the MAC calculation if required.

Returns:byte[]

A new byte array containing the MAC value.

getDigestBlockCountback to summary
private int getDigestBlockCount(int inputLength)
getHeaderLengthback to summary
private int getHeaderLength(byte[] connectionID)
getMacSizeback to summary
private static int getMacSize(TlsCryptoParameters cryptoParams, TlsMAC mac)
getSizeback to summary
public int getSize()

Implements org.bouncycastle.tls.crypto.impl.TlsSuiteMac.getSize.

Doc from org.bouncycastle.tls.crypto.impl.TlsSuiteMac.getSize.

Return the output length (in bytes) of this MAC.

Returns:int

The output length of this MAC.

truncateback to summary
private byte[] truncate(byte[] bs)