Table of Contents

Class AbstractTlsSecret

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

Base class for a TlsSecret implementation which captures common code and fields.

public abstract class AbstractTlsSecret : TlsSecret
Inheritance
AbstractTlsSecret
Implements
Derived
Inherited Members

Constructors

AbstractTlsSecret(byte[])

Base constructor.

protected AbstractTlsSecret(byte[] data)

Parameters

data byte[]

the byte[] making up the secret value.

Fields

m_data

protected byte[] m_data

Field Value

byte[]

Properties

Crypto

protected abstract AbstractTlsCrypto Crypto { get; }

Property Value

AbstractTlsCrypto

Length

public virtual int Length { get; }

Property Value

int

Methods

CalculateHmac(int, byte[], int, int)

Calculate an HMAC with this secret's data as the key.

public virtual byte[] CalculateHmac(int cryptoHashAlgorithm, byte[] buf, int off, int len)

Parameters

cryptoHashAlgorithm int

the hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.

buf byte[]

array containing the input data.

off int

offset into the input array the input starts at.

len int

the length of the input data.

Returns

byte[]

CheckAlive()

protected virtual void CheckAlive()

CopyData(AbstractTlsSecret)

protected static byte[] CopyData(AbstractTlsSecret other)

Parameters

other AbstractTlsSecret

Returns

byte[]

DeriveUsingPrf(int, ReadOnlySpan<char>, ReadOnlySpan<byte>, int)

public abstract TlsSecret DeriveUsingPrf(int prfAlgorithm, ReadOnlySpan<char> label, ReadOnlySpan<byte> seed, int length)

Parameters

prfAlgorithm int
label ReadOnlySpan<char>
seed ReadOnlySpan<byte>
length int

Returns

TlsSecret

DeriveUsingPrf(int, string, byte[], int)

Return a new secret based on applying a PRF to this one.

public abstract TlsSecret DeriveUsingPrf(int prfAlgorithm, string label, byte[] seed, int length)

Parameters

prfAlgorithm int

PRF algorithm to use.

label string

the label details.

seed byte[]

the seed details.

length int

the size (in bytes) of the secret to generate.

Returns

TlsSecret

the new secret.

Destroy()

Destroy the internal state of the secret.

public virtual void Destroy()

Remarks

After this call, any attempt to use the TlsSecret will result in an InvalidOperationException being thrown.

Encrypt(TlsEncryptor)

public virtual byte[] Encrypt(TlsEncryptor encryptor)

Parameters

encryptor TlsEncryptor

Returns

byte[]

Exceptions

IOException

Extract()

Return the internal data from this secret.

public virtual byte[] Extract()

Returns

byte[]

the secret's internal data.

Remarks

The TlsSecret does not keep a copy of the data. After this call, any attempt to use the TlsSecret will result in an InvalidOperationException being thrown.

ExtractTo(Span<byte>)

public virtual void ExtractTo(Span<byte> output)

Parameters

output Span<byte>

HkdfExpand(int, byte[], int)

RFC 5869 HKDF-Expand function, with this secret's data as the pseudo-random key ('prk').

public abstract TlsSecret HkdfExpand(int cryptoHashAlgorithm, byte[] info, int length)

Parameters

cryptoHashAlgorithm int

the hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.

info byte[]

optional context and application specific information (can be zero-length).

length int

length of output keying material in octets.

Returns

TlsSecret

output keying material (of 'length' octets).

HkdfExpand(int, ReadOnlySpan<byte>, int)

public abstract TlsSecret HkdfExpand(int cryptoHashAlgorithm, ReadOnlySpan<byte> info, int length)

Parameters

cryptoHashAlgorithm int
info ReadOnlySpan<byte>
length int

Returns

TlsSecret

HkdfExtract(int, TlsSecret)

RFC 5869 HKDF-Extract function, with this secret's data as the 'salt'.

public abstract TlsSecret HkdfExtract(int cryptoHashAlgorithm, TlsSecret ikm)

Parameters

cryptoHashAlgorithm int

the hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.

ikm TlsSecret

input keying material.

Returns

TlsSecret

a pseudo-random key (of HashLen octets).

Remarks

The TlsSecret does not keep a copy of the data. After this call, any attempt to use the TlsSecret will result in an InvalidOperationException being thrown.

IsAlive()

public virtual bool IsAlive()

Returns

bool