Table of Contents

Class BcTlsSecret

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

BC light-weight support class for handling TLS secrets and deriving key material and other secrets from them.

public class BcTlsSecret : AbstractTlsSecret, TlsSecret
Inheritance
BcTlsSecret
Implements
Inherited Members

Constructors

BcTlsSecret(BcTlsCrypto, byte[])

public BcTlsSecret(BcTlsCrypto crypto, byte[] data)

Parameters

crypto BcTlsCrypto
data byte[]

Fields

m_crypto

protected readonly BcTlsCrypto m_crypto

Field Value

BcTlsCrypto

Properties

Crypto

protected override AbstractTlsCrypto Crypto { get; }

Property Value

AbstractTlsCrypto

Methods

Convert(BcTlsCrypto, TlsSecret)

public static BcTlsSecret Convert(BcTlsCrypto crypto, TlsSecret secret)

Parameters

crypto BcTlsCrypto
secret TlsSecret

Returns

BcTlsSecret

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

public override 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 override 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.

HkdfExpand(int, byte[], int)

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

public override 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 override 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 override 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.

HmacHash(int, byte[], int, int, byte[], byte[])

protected virtual void HmacHash(int cryptoHashAlgorithm, byte[] secret, int secretOff, int secretLen, byte[] seed, byte[] output)

Parameters

cryptoHashAlgorithm int
secret byte[]
secretOff int
secretLen int
seed byte[]
output byte[]

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

protected virtual byte[] Prf(int prfAlgorithm, ReadOnlySpan<char> label, ReadOnlySpan<byte> seed, int length)

Parameters

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

Returns

byte[]

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

protected virtual byte[] Prf(int prfAlgorithm, string label, byte[] seed, int length)

Parameters

prfAlgorithm int
label string
seed byte[]
length int

Returns

byte[]

Prf_1_0(byte[], int)

protected virtual byte[] Prf_1_0(byte[] labelSeed, int length)

Parameters

labelSeed byte[]
length int

Returns

byte[]

Prf_1_2(int, byte[], int)

protected virtual byte[] Prf_1_2(int prfAlgorithm, byte[] labelSeed, int length)

Parameters

prfAlgorithm int
labelSeed byte[]
length int

Returns

byte[]

Prf_Ssl(byte[], int)

protected virtual byte[] Prf_Ssl(byte[] seed, int length)

Parameters

seed byte[]
length int

Returns

byte[]

Prf_Ssl(ReadOnlySpan<byte>, int)

protected virtual byte[] Prf_Ssl(ReadOnlySpan<byte> seed, int length)

Parameters

seed ReadOnlySpan<byte>
length int

Returns

byte[]

UpdateMac(IMac)

protected virtual void UpdateMac(IMac mac)

Parameters

mac IMac