Package javax.crypto

Class MacSpi

java.lang.Object
javax.crypto.MacSpi
Direct Known Subclasses:
BaseMac, OpenSSLMac

public abstract class MacSpi
extends Object
The Service-Provider Interface (SPI) definition for the Mac class.
See Also:
Mac
  • Constructor Summary

    Constructors
    Constructor Description
    MacSpi()
    Creates a new MacSpi instance.
  • Method Summary

    Modifier and Type Method Description
    Object clone()
    Clones this MacSpi instance.
    protected abstract byte[] engineDoFinal()
    Computes the digest of this MAC based on the data previously specified in engineUpdate(byte) calls.
    protected abstract int engineGetMacLength()
    Returns the length of this MAC (in bytes).
    protected abstract void engineInit​(Key key, AlgorithmParameterSpec params)
    Initializes this MacSpi instance with the specified key and algorithm parameters.
    protected abstract void engineReset()
    Resets this MacSpi instance to its initial state.
    protected abstract void engineUpdate​(byte input)
    Updates this MacSpi instance with the specified byte.
    protected abstract void engineUpdate​(byte[] input, int offset, int len)
    Updates this MacSpi instance with the data from the specified buffer input from the specified offset and length len.
    protected void engineUpdate​(ByteBuffer input)
    Updates this MacSpi instance with the data from the specified buffer, starting at Buffer.position(), including the next Buffer.remaining() bytes.

    Methods inherited from class java.lang.Object

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

    • MacSpi

      public MacSpi()
      Creates a new MacSpi instance.
  • Method Details

    • engineGetMacLength

      protected abstract int engineGetMacLength()
      Returns the length of this MAC (in bytes).
      Returns:
      the length of this MAC (in bytes).
    • engineInit

      protected abstract void engineInit​(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException
      Initializes this MacSpi instance with the specified key and algorithm parameters.
      Parameters:
      key - the key to initialize this algorithm.
      params - the parameters for this algorithm.
      Throws:
      InvalidKeyException - if the specified key cannot be used to initialize this algorithm, or it is null.
      InvalidAlgorithmParameterException - if the specified parameters cannot be used to initialize this algorithm.
    • engineUpdate

      protected abstract void engineUpdate​(byte input)
      Updates this MacSpi instance with the specified byte.
      Parameters:
      input - the byte.
    • engineUpdate

      protected abstract void engineUpdate​(byte[] input, int offset, int len)
      Updates this MacSpi instance with the data from the specified buffer input from the specified offset and length len.
      Parameters:
      input - the buffer.
      offset - the offset in the buffer.
      len - the length of the data in the buffer.
    • engineUpdate

      protected void engineUpdate​(ByteBuffer input)
      Updates this MacSpi instance with the data from the specified buffer, starting at Buffer.position(), including the next Buffer.remaining() bytes.
      Parameters:
      input - the buffer.
    • engineDoFinal

      protected abstract byte[] engineDoFinal()
      Computes the digest of this MAC based on the data previously specified in engineUpdate(byte) calls.

      This MacSpi instance is reverted to its initial state and can be used to start the next MAC computation with the same parameters or initialized with different parameters.

      Returns:
      the generated digest.
    • engineReset

      protected abstract void engineReset()
      Resets this MacSpi instance to its initial state.

      This MacSpi instance is reverted to its initial state and can be used to start the next MAC computation with the same parameters or initialized with different parameters.

    • clone

      public Object clone() throws CloneNotSupportedException
      Clones this MacSpi instance.
      Overrides:
      clone in class Object
      Returns:
      the cloned instance.
      Throws:
      CloneNotSupportedException - if cloning is not supported.