Interface TlsSecret
- Namespace
- Org.BouncyCastle.Tls.Crypto
- Assembly
- BouncyCastle.Cryptography.dll
Interface supporting the generation of key material and other SSL/TLS secret values from PRFs.
public interface TlsSecret
Properties
Length
int Length { get; }
Property Value
Methods
CalculateHmac(int, byte[], int, int)
Calculate an HMAC with this secret's data as the key.
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[]
DeriveUsingPrf(int, ReadOnlySpan<char>, ReadOnlySpan<byte>, int)
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.
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.
void Destroy()
Remarks
After this call, any attempt to use the TlsSecret will result in an InvalidOperationException being thrown.
Encrypt(TlsEncryptor)
Return an encrypted copy of the data this secret is based on.
byte[] Encrypt(TlsEncryptor encryptor)
Parameters
encryptorTlsEncryptorthe encryptor to use for protecting the internal data.
Returns
- byte[]
an encrypted copy of this secret's internal data.
Exceptions
Extract()
Return the internal data from this secret.
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>)
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').
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)
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'.
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()
bool IsAlive()