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 Object implements TlsSecret
Base class for a TlsSecret implementation which captures common code and fields.
  • 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

      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: TlsSecret
      Calculate an HMAC with this secret's data as the key.
      Specified by:
      calculateHMAC in interface TlsSecret
      Parameters:
      cryptoHashAlgorithm - the hash algorithm to instantiate HMAC with. See CryptoHashAlgorithm 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 the TlsSecret will result in an IllegalStateException being thrown.
      Specified by:
      destroy in interface TlsSecret
    • encrypt

      public byte[] encrypt(TlsEncryptor encryptor) throws IOException
      Description copied from interface: TlsSecret
      Return an encrypted copy of the data this secret is based on.
      Specified by:
      encrypt in interface TlsSecret
      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. The TlsSecret does not keep a copy of the data. After this call, any attempt to use the TlsSecret will result in an IllegalStateException being thrown.
      Specified by:
      extract in interface TlsSecret
      Returns:
      the secret's internal data.
    • isAlive

      public boolean isAlive()
      Specified by:
      isAlive in interface TlsSecret