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
Base class for a TlsSecret implementation which captures common code and fields.
-
Field Summary
Fields -
Constructor Summary
Constructors -
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.protected void
protected static byte[]
copyData
(AbstractTlsSecret other) 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.protected abstract AbstractTlsCrypto
boolean
isAlive()
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
-
Field Details
-
data
protected byte[] data
-
-
Constructor Details
-
AbstractTlsSecret
protected AbstractTlsSecret(byte[] data) Base constructor.- Parameters:
data
- the byte[] making up the secret value.
-
-
Method Details
-
copyData
-
checkAlive
protected void checkAlive() -
getCrypto
-
calculateHMAC
public byte[] calculateHMAC(int cryptoHashAlgorithm, byte[] buf, int off, int len) Description copied from interface:TlsSecret
Calculate an HMAC with this secret's data as the key.- Specified by:
calculateHMAC
in interfaceTlsSecret
- 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:
-
destroy
public void destroy()Description copied from interface:TlsSecret
Destroy the internal state of the secret. After this call, any attempt to use theTlsSecret
will result in anIllegalStateException
being thrown. -
encrypt
Description copied from interface:TlsSecret
Return an encrypted copy of the data this secret is based on.- Specified by:
encrypt
in interfaceTlsSecret
- Parameters:
encryptor
- the encryptor to use for protecting the internal data.- Returns:
- an encrypted copy of this secret's internal data.
- Throws:
IOException
-
extract
public byte[] extract()Description copied from interface:TlsSecret
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. -
isAlive
public boolean isAlive()
-