IT. Expert System.

Android Reference

Mac


javax.crypto

Class Mac

  • All Implemented Interfaces:
    Cloneable


    public class Mac
    extends Object
    implements Cloneable
    This class provides the public API for Message Authentication Code (MAC) algorithms.
    • Constructor Summary

      Constructors
      Modifier Constructor and Description
      protected Mac(MacSpi macSpi, Provider provider, String algorithm)
      Creates a new Mac instance.
    • Method Summary

      Methods
      Modifier and Type Method and Description
      Object clone()
      Clones this Mac instance and the underlying implementation.
      byte[] doFinal()
      Computes the digest of this MAC based on the data previously specified in update(byte) calls.
      byte[] doFinal(byte[] input)
      Computes the digest of this MAC based on the data previously specified on update(byte) calls and on the final bytes specified by input (or based on those bytes only).
      void doFinal(byte[] output, int outOffset)
      Computes the digest of this MAC based on the data previously specified in update(byte) calls and stores the digest in the specified output buffer at offset outOffset.
      String getAlgorithm()
      Returns the name of the MAC algorithm.
      static Mac getInstance(String algorithm)
      Creates a new Mac instance that provides the specified MAC algorithm.
      static Mac getInstance(String algorithm, Provider provider)
      Creates a new Mac instance that provides the specified MAC algorithm from the specified provider.
      static Mac getInstance(String algorithm, String provider)
      Creates a new Mac instance that provides the specified MAC algorithm from the specified provider.
      int getMacLength()
      Returns the length of this MAC (in bytes).
      Provider getProvider()
      Returns the provider of this Mac instance.
      void init(Key key)
      Initializes this Mac instance with the specified key.
      void init(Key key, AlgorithmParameterSpec params)
      Initializes this Mac instance with the specified key and algorithm parameters.
      void reset()
      Resets this Mac instance to its initial state.
      void update(byte input)
      Updates this Mac instance with the specified byte.
      void update(byte[] input)
      Copies the buffer provided as input for further processing.
      void update(byte[] input, int offset, int len)
      Updates this Mac instance with the data from the specified buffer input from the specified offset and length len.
      void update(ByteBuffer input)
      Updates this Mac instance with the data from the specified buffer, starting at Buffer.position(), including the next Buffer.remaining() bytes.
    • Constructor Detail

      • Mac

        protected Mac(MacSpi macSpi,
           Provider provider,
           String algorithm)
        Creates a new Mac instance.
        Parameters:
        macSpi - the implementation delegate.
        provider - the implementation provider.
        algorithm - the name of the MAC algorithm.
    • Method Detail

      • getAlgorithm

        public final String getAlgorithm()
        Returns the name of the MAC algorithm.
        Returns:
        the name of the MAC algorithm.
      • getProvider

        public final Provider getProvider()
        Returns the provider of this Mac instance.
        Returns:
        the provider of this Mac instance.
      • getInstance

        public static final Mac getInstance(String algorithm)
                                     throws NoSuchAlgorithmException
        Creates a new Mac instance that provides the specified MAC algorithm.
        Parameters:
        algorithm - the name of the requested MAC algorithm.
        Returns:
        the new Mac instance.
        Throws:
        NoSuchAlgorithmException - if the specified algorithm is not available by any provider.
        NullPointerException - if algorithm is null (instead of NoSuchAlgorithmException as in 1.4 release).
      • getInstance

        public static final Mac getInstance(String algorithm,
                      Provider provider)
                                     throws NoSuchAlgorithmException
        Creates a new Mac instance that provides the specified MAC algorithm from the specified provider.
        Parameters:
        algorithm - the name of the requested MAC algorithm.
        provider - the provider that is providing the algorithm.
        Returns:
        the new Mac instance.
        Throws:
        NoSuchAlgorithmException - if the specified algorithm is not provided by the specified provider.
        IllegalArgumentException - if provider is null.
        NullPointerException - if algorithm is null (instead of NoSuchAlgorithmException as in 1.4 release).
      • getMacLength

        public final int getMacLength()
        Returns the length of this MAC (in bytes).
        Returns:
        the length of this MAC (in bytes).
      • init

        public final void init(Key key)
                        throws InvalidKeyException
        Initializes this Mac instance with the specified key.
        Parameters:
        key - the key to initialize this algorithm.
        Throws:
        InvalidKeyException - if initialization fails because the provided key is null.
        RuntimeException - if the specified key cannot be used to initialize this algorithm.
      • update

        public final void update(byte input)
                          throws IllegalStateException
        Updates this Mac instance with the specified byte.
        Parameters:
        input - the byte
        Throws:
        IllegalStateException - if this MAC is not initialized.
      • update

        public final void update(byte[] input,
                  int offset,
                  int len)
                          throws IllegalStateException
        Updates this Mac 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.
        Throws:
        IllegalStateException - if this MAC is not initialized.
        IllegalArgumentException - if offset and len do not specified a valid chunk in input buffer.
      • update

        public final void update(byte[] input)
                          throws IllegalStateException
        Copies the buffer provided as input for further processing.
        Parameters:
        input - the buffer.
        Throws:
        IllegalStateException - if this MAC is not initialized.
      • doFinal

        public final byte[] doFinal()
                             throws IllegalStateException
        Computes the digest of this MAC based on the data previously specified in update(byte) calls.

        This Mac 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.
        Throws:
        IllegalStateException - if this MAC is not initialized.
      • doFinal

        public final void doFinal(byte[] output,
                   int outOffset)
                           throws ShortBufferException,
                                  IllegalStateException
        Computes the digest of this MAC based on the data previously specified in update(byte) calls and stores the digest in the specified output buffer at offset outOffset.

        This Mac 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.

        Parameters:
        output - the output buffer
        outOffset - the offset in the output buffer
        Throws:
        ShortBufferException - if the specified output buffer is either too small for the digest to be stored, the specified output buffer is null, or the specified offset is negative or past the length of the output buffer.
        IllegalStateException - if this MAC is not initialized.
      • doFinal

        public final byte[] doFinal(byte[] input)
                             throws IllegalStateException
        Computes the digest of this MAC based on the data previously specified on update(byte) calls and on the final bytes specified by input (or based on those bytes only).

        This Mac 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.

        Parameters:
        input - the final bytes.
        Returns:
        the generated digest.
        Throws:
        IllegalStateException - if this MAC is not initialized.
      • reset

        public final void reset()
        Resets this Mac instance to its initial state.

        This Mac 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.



Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 223 / 158697732. Delta: 0.02903 с