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
databyte[]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
Length
public virtual int Length { get; }
Property Value
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
cryptoHashAlgorithmintthe hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.
bufbyte[]array containing the input data.
offintoffset into the input array the input starts at.
lenintthe length of the input data.
Returns
- byte[]
CheckAlive()
protected virtual void CheckAlive()
CopyData(AbstractTlsSecret)
protected static byte[] CopyData(AbstractTlsSecret other)
Parameters
otherAbstractTlsSecret
Returns
- byte[]
DeriveUsingPrf(int, ReadOnlySpan<char>, ReadOnlySpan<byte>, int)
public abstract TlsSecret DeriveUsingPrf(int prfAlgorithm, ReadOnlySpan<char> label, ReadOnlySpan<byte> seed, int length)
Parameters
prfAlgorithmintlabelReadOnlySpan<char>seedReadOnlySpan<byte>lengthint
Returns
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
prfAlgorithmintPRF algorithm to use.
labelstringthe label details.
seedbyte[]the seed details.
lengthintthe 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
encryptorTlsEncryptor
Returns
- byte[]
Exceptions
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
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
cryptoHashAlgorithmintthe hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.
infobyte[]optional context and application specific information (can be zero-length).
lengthintlength 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
cryptoHashAlgorithmintinfoReadOnlySpan<byte>lengthint
Returns
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
cryptoHashAlgorithmintthe hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm for values.
ikmTlsSecretinput 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()