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 Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description byte[]calculateHMAC(int cryptoHashAlgorithm, byte[] buf, int off, int len)Calculate an HMAC with this secret's data as the key.protected voidcheckAlive()protected static byte[]copyData(AbstractTlsSecret other)voiddestroy()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.protected abstract AbstractTlsCryptogetCrypto()booleanisAlive()-
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, hkdfExpand, hkdfExtract
-
-
-
-
Method Detail
-
copyData
protected static byte[] copyData(AbstractTlsSecret other)
-
checkAlive
protected void checkAlive()
-
getCrypto
protected abstract AbstractTlsCrypto getCrypto()
-
calculateHMAC
public byte[] calculateHMAC(int cryptoHashAlgorithm, byte[] buf, int off, int len)Description copied from interface:TlsSecretCalculate an HMAC with this secret's data as the key.- Specified by:
calculateHMACin interfaceTlsSecret- Parameters:
cryptoHashAlgorithm- the hash algorithm to instantiate HMAC with. SeeCryptoHashAlgorithmfor 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:
-
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(TlsEncryptor encryptor) throws java.io.IOException
Description copied from interface:TlsSecretReturn an encrypted copy of the data this secret is based on.
-
extract
public byte[] extract()
Description copied from interface:TlsSecret
-
-