Table of Contents

Class TlsSuiteHmac

Namespace
Org.BouncyCastle.Tls.Crypto.Impl
Assembly
BouncyCastle.Cryptography.dll

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

public class TlsSuiteHmac : TlsSuiteMac
Inheritance
TlsSuiteHmac
Implements
Inherited Members

Constructors

TlsSuiteHmac(TlsCryptoParameters, TlsHmac)

Generate a new instance of a TlsMac.

public TlsSuiteHmac(TlsCryptoParameters cryptoParams, TlsHmac mac)

Parameters

cryptoParams TlsCryptoParameters

the TLS client context specific crypto parameters.

mac TlsHmac

The MAC to use.

Fields

m_cryptoParams

protected readonly TlsCryptoParameters m_cryptoParams

Field Value

TlsCryptoParameters

m_digestBlockSize

protected readonly int m_digestBlockSize

Field Value

int

m_digestOverhead

protected readonly int m_digestOverhead

Field Value

int

m_mac

protected readonly TlsHmac m_mac

Field Value

TlsHmac

m_macSize

protected readonly int m_macSize

Field Value

int

Properties

Size

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

public virtual int Size { get; }

Property Value

int

The output length of this MAC.

Methods

CalculateMac(long, short, byte[], byte[], int, int)

public virtual byte[] CalculateMac(long seqNo, short type, byte[] connectionID, byte[] msg, int msgOff, int msgLen)

Parameters

seqNo long
type short
connectionID byte[]
msg byte[]
msgOff int
msgLen int

Returns

byte[]

CalculateMac(long, short, byte[], int, int)

Calculate the MAC for some given data.

public virtual byte[] CalculateMac(long seqNo, short type, byte[] msg, int msgOff, int msgLen)

Parameters

seqNo long

The sequence number of the record.

type short

The content type of the message.

msg byte[]
msgOff int
msgLen int

Returns

byte[]

A new byte array containing the MAC value.

CalculateMac(long, short, ReadOnlySpan<byte>)

public virtual byte[] CalculateMac(long seqNo, short type, ReadOnlySpan<byte> message)

Parameters

seqNo long
type short
message ReadOnlySpan<byte>

Returns

byte[]

CalculateMac(long, short, ReadOnlySpan<byte>, ReadOnlySpan<byte>)

public virtual byte[] CalculateMac(long seqNo, short type, ReadOnlySpan<byte> connectionID, ReadOnlySpan<byte> message)

Parameters

seqNo long
type short
connectionID ReadOnlySpan<byte>
message ReadOnlySpan<byte>

Returns

byte[]

CalculateMacConstantTime(long, short, byte[], byte[], int, int, int, byte[])

public virtual byte[] CalculateMacConstantTime(long seqNo, short type, byte[] connectionID, byte[] msg, int msgOff, int msgLen, int fullLength, byte[] dummyData)

Parameters

seqNo long
type short
connectionID byte[]
msg byte[]
msgOff int
msgLen int
fullLength int
dummyData byte[]

Returns

byte[]

CalculateMacConstantTime(long, short, byte[], int, int, int, byte[])

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

public virtual byte[] CalculateMacConstantTime(long seqNo, short type, byte[] msg, int msgOff, int msgLen, int fullLength, byte[] dummyData)

Parameters

seqNo long

The sequence number of the record.

type short

The content type of the message.

msg byte[]
msgOff int
msgLen int
fullLength int
dummyData byte[]

Returns

byte[]

A new byte array containing the MAC value.

GetDigestBlockCount(int)

protected virtual int GetDigestBlockCount(int inputLength)

Parameters

inputLength int

Returns

int

GetHeaderLength(byte[])

protected virtual int GetHeaderLength(byte[] connectionID)

Parameters

connectionID byte[]

Returns

int

GetMacSize(TlsCryptoParameters, TlsMac)

protected static int GetMacSize(TlsCryptoParameters cryptoParams, TlsMac mac)

Parameters

cryptoParams TlsCryptoParameters
mac TlsMac

Returns

int

Truncate(byte[])

protected virtual byte[] Truncate(byte[] bs)

Parameters

bs byte[]

Returns

byte[]