Class TlsSuiteHMac

  • All Implemented Interfaces:
    TlsSuiteMac

    public final class TlsSuiteHMac
    extends java.lang.Object
    implements TlsSuiteMac
    A generic TLS MAC implementation, acting as an HMAC based on some underlying Digest.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] calculateMac​(long seqNo, short type, byte[] connectionID, byte[] msg, int msgOff, int msgLen)
      Calculate the MAC for some given data.
      byte[] calculateMacConstantTime​(long seqNo, short type, byte[] connectionID, byte[] msg, int msgOff, int msgLen, int fullLength, byte[] dummyData)
      Constant time calculation of the MAC for some given data with a given expected length.
      int getSize()
      Return the output length (in bytes) of this MAC.
      • Methods inherited from class java.lang.Object

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

      • TlsSuiteHMac

        public TlsSuiteHMac​(TlsCryptoParameters cryptoParams,
                            TlsHMAC mac)
        Generate a new instance of a TlsMac.
        Parameters:
        cryptoParams - the TLS client context specific crypto parameters.
        mac - The MAC to use.
    • Method Detail

      • getSize

        public int getSize()
        Description copied from interface: TlsSuiteMac
        Return the output length (in bytes) of this MAC.
        Specified by:
        getSize in interface TlsSuiteMac
        Returns:
        The output length of this MAC.
      • calculateMac

        public byte[] calculateMac​(long seqNo,
                                   short type,
                                   byte[] connectionID,
                                   byte[] msg,
                                   int msgOff,
                                   int msgLen)
        Description copied from interface: TlsSuiteMac
        Calculate the MAC for some given data.
        Specified by:
        calculateMac in interface TlsSuiteMac
        Parameters:
        seqNo - The sequence number of the record.
        type - The content type of the message.
        msg - A byte array containing the message.
        msgOff - The number of bytes to skip, before the message starts.
        msgLen - The length of the message.
        Returns:
        A new byte array containing the MAC value.
      • calculateMacConstantTime

        public byte[] calculateMacConstantTime​(long seqNo,
                                               short type,
                                               byte[] connectionID,
                                               byte[] msg,
                                               int msgOff,
                                               int msgLen,
                                               int fullLength,
                                               byte[] dummyData)
        Description copied from interface: TlsSuiteMac
        Constant time calculation of the MAC for some given data with a given expected length.
        Specified by:
        calculateMacConstantTime in interface TlsSuiteMac
        Parameters:
        seqNo - The sequence number of the record.
        type - The content type of the message.
        msg - A byte array containing the message.
        msgOff - The number of bytes to skip, before the message starts.
        msgLen - The length of the message.
        fullLength - The expected length of the full message.
        dummyData - Random data for padding out the MAC calculation if required.
        Returns:
        A new byte array containing the MAC value.