Class JceTlsHMAC

java.lang.Object
org.bouncycastle.tls.crypto.impl.jcajce.JceTlsHMAC
All Implemented Interfaces:
TlsHMAC, TlsMAC

public class JceTlsHMAC extends Object implements TlsHMAC
Wrapper class for a JCE MAC based on HMAC to provide the necessary operations for TLS.
  • Constructor Summary

    Constructors
    Constructor
    Description
    JceTlsHMAC(int cryptoHashAlgorithm, Mac hmac, String algorithm)
    Base constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Return calculated MAC for any input passed in.
    void
    calculateMAC(byte[] output, int outOff)
    Write the calculated MAC to an output buffer.
    int
    Return the internal block size for the message digest underlying this HMAC service.
    int
    Return the length of the MAC generated by this service.
    void
    Reset the MAC underlying this service.
    void
    setKey(byte[] key, int keyOff, int keyLen)
    Set the key to be used by the MAC implementation supporting this service.
    void
    update(byte[] input, int inOff, int length)
    Update the MAC with the passed in input.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JceTlsHMAC

      public JceTlsHMAC(int cryptoHashAlgorithm, Mac hmac, String algorithm)
      Base constructor.
      Parameters:
      cryptoHashAlgorithm - the hash algorithm underlying the MAC implementation
      hmac - MAC implementation.
      algorithm - algorithm name to use for keys and to get the internal block size.
  • Method Details

    • setKey

      public void setKey(byte[] key, int keyOff, int keyLen)
      Description copied from interface: TlsMAC
      Set the key to be used by the MAC implementation supporting this service.
      Specified by:
      setKey in interface TlsMAC
      Parameters:
      key - array holding the MAC key.
      keyOff - offset into the array the key starts at.
      keyLen - length of the key in the array.
    • update

      public void update(byte[] input, int inOff, int length)
      Description copied from interface: TlsMAC
      Update the MAC with the passed in input.
      Specified by:
      update in interface TlsMAC
      Parameters:
      input - input array containing the data.
      inOff - offset into the input array the input starts at.
      length - the length of the input data.
    • calculateMAC

      public byte[] calculateMAC()
      Description copied from interface: TlsMAC
      Return calculated MAC for any input passed in.
      Specified by:
      calculateMAC in interface TlsMAC
      Returns:
      the MAC value.
    • calculateMAC

      public void calculateMAC(byte[] output, int outOff)
      Description copied from interface: TlsMAC
      Write the calculated MAC to an output buffer.
      Specified by:
      calculateMAC in interface TlsMAC
      Parameters:
      output - output array to write the MAC to.
      outOff - offset into the output array to write the MAC to.
    • getInternalBlockSize

      public int getInternalBlockSize()
      Description copied from interface: TlsHMAC
      Return the internal block size for the message digest underlying this HMAC service.
      Specified by:
      getInternalBlockSize in interface TlsHMAC
      Returns:
      the internal block size for the digest (in bytes).
    • getMacLength

      public int getMacLength()
      Description copied from interface: TlsMAC
      Return the length of the MAC generated by this service.
      Specified by:
      getMacLength in interface TlsMAC
      Returns:
      the MAC length.
    • reset

      public void reset()
      Description copied from interface: TlsMAC
      Reset the MAC underlying this service.
      Specified by:
      reset in interface TlsMAC