Package org.bouncycastle.tls.crypto.impl
Class AbstractTlsSecret
- java.lang.Object
-
- org.bouncycastle.tls.crypto.impl.AbstractTlsSecret
-
- All Implemented Interfaces:
TlsSecret
- Direct Known Subclasses:
BcTlsSecret,JceTlsSecret
public abstract class AbstractTlsSecret extends java.lang.Object implements TlsSecret
Base class for a TlsSecret implementation which captures common code and fields.
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]data
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractTlsSecret(byte[] data)Base constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TlsSecretadoptLocalSecret(byte[] data)protected voidcheckAlive()TlsCiphercreateCipher(TlsCryptoParameters cryptoParams, int encryptionAlgorithm, int macAlgorithm)Create a cipher suite that matches the passed in encryption algorithm and mac algorithm.voiddestroy()Destroy the internal state of the secret.byte[]encrypt(TlsCertificate certificate)Return the an encrypted copy of the data this secret is based on.byte[]extract()Return the internal data from this secret.protected abstract AbstractTlsCryptogetCrypto()TlsSecrethkdfExpand(short hashAlgorithm, byte[] info, int length)RFC 5869 HKDF-Expand function, with this secret's data as the pseudo-random key ('prk').TlsSecrethkdfExtract(short hashAlgorithm, byte[] ikm)RFC 5869 HKDF-Extract function, with this secret's data as the 'salt'.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bouncycastle.tls.crypto.TlsSecret
deriveUsingPRF
-
-
-
-
Method Detail
-
adoptLocalSecret
protected abstract TlsSecret adoptLocalSecret(byte[] data)
-
checkAlive
protected void checkAlive()
-
getCrypto
protected abstract AbstractTlsCrypto getCrypto()
-
createCipher
public TlsCipher createCipher(TlsCryptoParameters cryptoParams, int encryptionAlgorithm, int macAlgorithm) throws java.io.IOException
Description copied from interface:TlsSecretCreate a cipher suite that matches the passed in encryption algorithm and mac algorithm.See enumeration classes
EncryptionAlgorithm,MACAlgorithmfor appropriate argument values.- Specified by:
createCipherin interfaceTlsSecret- Parameters:
cryptoParams- context specific parameters.encryptionAlgorithm- the encryption algorithm to be employed by the cipher suite.macAlgorithm- the MAC algorithm to be employed by the cipher suite.- Returns:
- a TlsCipherSuite supporting the encryption and mac algorithm.
- Throws:
java.io.IOException
-
destroy
public void destroy()
Description copied from interface:TlsSecretDestroy the internal state of the secret. After this call, any attempt to use theTlsSecretwill result in anIllegalStateExceptionbeing thrown.
-
encrypt
public byte[] encrypt(TlsCertificate certificate) throws java.io.IOException
Description copied from interface:TlsSecretReturn the an encrypted copy of the data this secret is based on.
-
extract
public byte[] extract()
Description copied from interface:TlsSecret
-
hkdfExpand
public TlsSecret hkdfExpand(short hashAlgorithm, byte[] info, int length)
Description copied from interface:TlsSecretRFC 5869 HKDF-Expand function, with this secret's data as the pseudo-random key ('prk').- Specified by:
hkdfExpandin interfaceTlsSecret- Parameters:
hashAlgorithm- the hash algorithm to instantiate HMAC with. SeeHashAlgorithmfor 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
public TlsSecret hkdfExtract(short hashAlgorithm, byte[] ikm)
Description copied from interface:TlsSecretRFC 5869 HKDF-Extract function, with this secret's data as the 'salt'.- Specified by:
hkdfExtractin interfaceTlsSecret- Parameters:
hashAlgorithm- the hash algorithm to instantiate HMAC with. SeeHashAlgorithmfor values.ikm- input keying material.- Returns:
- a pseudo-random key (of HashLen octets).
-
-