Class HmacSHA512

  • All Implemented Interfaces:
    java.lang.Cloneable

    public final class HmacSHA512
    extends javax.crypto.MacSpi
    This is an implementation of the HMAC-SHA512 algorithm.
    • Constructor Summary

      Constructors 
      Constructor Description
      HmacSHA512()
      Standard constructor, creates a new HmacSHA512 instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()  
      protected byte[] computeHMACUsingCCA​(byte[] text, int length, com.ibm.crypto.hdwrCCA.provider.HmacSHA.Segment segment)
      This method computes a partial ( or full ) HMACE on a given piece of text with a particular key used to initialize this instance of the HMAC.
      protected byte[] engineDoFinal()
      Completes the HMAC computation and resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.
      protected int engineGetMacLength()
      Returns the length of the HMAC in bytes.
      protected void engineInit​(java.security.Key key, java.security.spec.AlgorithmParameterSpec params)
      Initializes the HMAC with the given secret key and algorithm parameters.
      protected void engineReset()
      Resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.
      protected void engineUpdate​(byte input)
      Processes the given byte.
      protected void engineUpdate​(byte[] input, int offset, int len)
      Processes the first len bytes in input, starting at offset.
      • Methods inherited from class javax.crypto.MacSpi

        engineUpdate
      • Methods inherited from class java.lang.Object

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

      • HmacSHA512

        public HmacSHA512()
                   throws java.security.NoSuchAlgorithmException
        Standard constructor, creates a new HmacSHA512 instance. Verify the JCE framework in the constructor.
        Throws:
        java.lang.SecurityException - if fails to verify the JCE framework.
        java.security.NoSuchAlgorithmException
    • Method Detail

      • engineGetMacLength

        protected int engineGetMacLength()
        Returns the length of the HMAC in bytes.
        Specified by:
        engineGetMacLength in class javax.crypto.MacSpi
        Returns:
        the HMAC length in bytes.
      • engineInit

        protected void engineInit​(java.security.Key key,
                                  java.security.spec.AlgorithmParameterSpec params)
                           throws java.security.InvalidKeyException,
                                  java.security.InvalidAlgorithmParameterException
        Initializes the HMAC with the given secret key and algorithm parameters.
        Specified by:
        engineInit in class javax.crypto.MacSpi
        Parameters:
        key - the secret key, must be an instance of SecretKey
        params - the algorithm parameters. This parameter is ignored
        Throws:
        java.security.InvalidKeyException - if the given key is inappropriate for initializing this MAC.
        java.security.InvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for this MAC. This should not occur, since the params parameter is currently ignored.
      • engineUpdate

        protected void engineUpdate​(byte input)
        Processes the given byte.
        Specified by:
        engineUpdate in class javax.crypto.MacSpi
        Parameters:
        input - the input byte to be processed.
      • engineUpdate

        protected void engineUpdate​(byte[] input,
                                    int offset,
                                    int len)
        Processes the first len bytes in input, starting at offset.
        Specified by:
        engineUpdate in class javax.crypto.MacSpi
        Parameters:
        input - the input buffer.
        offset - the offset in input where the input starts.
        len - the number of bytes to process.
      • engineDoFinal

        protected byte[] engineDoFinal()
        Completes the HMAC computation and resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.
        Specified by:
        engineDoFinal in class javax.crypto.MacSpi
        Returns:
        the HMAC result.
      • engineReset

        protected void engineReset()
        Resets the HMAC for further use, maintaining the secret key that the HMAC was initialized with.
        Specified by:
        engineReset in class javax.crypto.MacSpi
      • clone

        public java.lang.Object clone()
        Overrides:
        clone in class javax.crypto.MacSpi
      • computeHMACUsingCCA

        protected byte[] computeHMACUsingCCA​(byte[] text,
                                             int length,
                                             com.ibm.crypto.hdwrCCA.provider.HmacSHA.Segment segment)
        This method computes a partial ( or full ) HMACE on a given piece of text with a particular key used to initialize this instance of the HMAC.
        Parameters:
        text - The clear text you wish to perform a HMAC upon.
        length - The length of clear text you wish to perform a HMAC upon.
        segment - The Segment that you wish to use.
        Returns:
        A byte array containing the computed mac if the segment is LAST or ONLY. A null value will be returned otherwise.