Package org.bouncycastle.tls.crypto
Interface TlsSecret
- All Known Implementing Classes:
AbstractTlsSecret
,BcTlsSecret
,JceTlsSecret
public interface TlsSecret
Interface supporting the generation of key material and other SSL/TLS secret values from PRFs.
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
calculateHMAC
(int cryptoHashAlgorithm, byte[] buf, int off, int len) Calculate an HMAC with this secret's data as the key.deriveUsingPRF
(int prfAlgorithm, String label, byte[] seed, int length) Return a new secret based on applying a PRF to this one.void
destroy()
Destroy the internal state of the secret.byte[]
encrypt
(TlsEncryptor encryptor) Return an encrypted copy of the data this secret is based on.byte[]
extract()
Return the internal data from this secret.hkdfExpand
(int cryptoHashAlgorithm, byte[] info, int length) RFC 5869 HKDF-Expand function, with this secret's data as the pseudo-random key ('prk').hkdfExtract
(int cryptoHashAlgorithm, TlsSecret ikm) RFC 5869 HKDF-Extract function, with this secret's data as the 'salt'.boolean
isAlive()
-
Method Details
-
calculateHMAC
byte[] calculateHMAC(int cryptoHashAlgorithm, byte[] buf, int off, int len) Calculate an HMAC with this secret's data as the key.- Parameters:
cryptoHashAlgorithm
- the hash algorithm to instantiate HMAC with. SeeCryptoHashAlgorithm
for values.buf
- array containing the input data.off
- offset into the input array the input starts at.len
- the length of the input data.- Returns:
-
deriveUsingPRF
Return a new secret based on applying a PRF to this one.- Parameters:
prfAlgorithm
- PRF algorithm to use.label
- the label details.seed
- the seed details.length
- the size (in bytes) of the secret to generate.- Returns:
- the new secret.
-
destroy
void destroy()Destroy the internal state of the secret. After this call, any attempt to use theTlsSecret
will result in anIllegalStateException
being thrown. -
encrypt
Return an encrypted copy of the data this secret is based on.- Parameters:
encryptor
- the encryptor to use for protecting the internal data.- Returns:
- an encrypted copy of this secret's internal data.
- Throws:
IOException
-
extract
byte[] extract()Return the internal data from this secret. TheTlsSecret
does not keep a copy of the data. After this call, any attempt to use theTlsSecret
will result in anIllegalStateException
being thrown.- Returns:
- the secret's internal data.
-
hkdfExpand
RFC 5869 HKDF-Expand function, with this secret's data as the pseudo-random key ('prk').- Parameters:
cryptoHashAlgorithm
- the hash algorithm to instantiate HMAC with. SeeCryptoHashAlgorithm
for values.info
- optional context and application specific information (can be zero-length).length
- length of output keying material in octets.- Returns:
- output keying material (of 'length' octets).
-
hkdfExtract
RFC 5869 HKDF-Extract function, with this secret's data as the 'salt'. TheTlsSecret
does not keep a copy of the data. After this call, any attempt to use theTlsSecret
will result in anIllegalStateException
being thrown.- Parameters:
cryptoHashAlgorithm
- the hash algorithm to instantiate HMAC with. SeeCryptoHashAlgorithm
for values.ikm
- input keying material.- Returns:
- a pseudo-random key (of HashLen octets).
-
isAlive
boolean isAlive()
-