Overview | Package | Class | Tree | Deprecated | Index | Help
| For the latest news and information visit The GNU Crypto project
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## gnu.crypto.mac
Class HMac

    java.lang.Object
      |
      +--gnu.crypto.mac.BaseMac
            |
            +--gnu.crypto.mac.HMac

All Implemented Interfaces:
  java.lang.Cloneable, IMac

public class HMac
extends BaseMac

The implementation of the HMAC (Keyed-Hash Message Authentication Code).

HMAC can be used in combination with any iterated cryptographic hash function. HMAC also uses a secret key for calculation and verification of the message authentication values. The main goals behind this construction are

- To use, without modifications, available hash functions. In particular, hash functions that perform well in software, and for which code is freely and widely available.
- To preserve the original performance of the hash function without incurring a significant degradation.
- To use and handle keys in a simple way.
- To have a well understood cryptographic analysis of the strength of the authentication mechanism based on reasonable assumptions on the underlying hash function.
- To allow for easy replaceability of the underlying hash function in case that faster or more secure hash functions are found or required.

References:

1. RFC 2104HMAC: Keyed-Hashing for Message Authentication.
   H. Krawczyk, M. Bellare, and R. Canetti.

Version:
  $Revision: 1.3 $

Field Summary
`protected int` | `blockSize`
`protected IMessageDigest` | `ipadHash`
`protected int` | `macSize`
`protected IMessageDigest` | `opadHash`

Fields inherited from class gnu.crypto.mac.BaseMac
`name, truncatedSize, underlyingHash`

Fields inherited from interface gnu.crypto.mac.IMac
`MAC_KEY_MATERIAL, TRUNCATED_SIZE`

Constructor Summary
`protected` | `HMac(IMessageDigest underlyingHash)` Trivial constructor for use by concrete subclasses.

Method Summary
`java.lang.Object` | `clone()` Returns a clone copy of this instance.
`byte[]` | `digest()` Completes the MAC by performing final operations such as padding and resetting the instance.
`void` | `init(java.util.Map attributes)` Initialises the algorithm with designated attributes.
`boolean` | `selfTest()` A basic test.

Methods inherited from class gnu.crypto.mac.BaseMac
`macSize, name, reset, update, update`

Methods inherited from class java.lang.Object
`, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### macSize

    protected int macSize

### blockSize

    protected int blockSize

### ipadHash

    protected IMessageDigest ipadHash

### opadHash

    protected IMessageDigest opadHash

Constructor Detail

### HMac

    protected HMac(IMessageDigest underlyingHash)

  Trivial constructor for use by concrete subclasses.

  Parameters:
    `underlyingHash` - the underlying hash algorithm instance.

Method Detail

### clone

    public java.lang.Object clone()

  Description copied from interface: `IMac`

  Returns a clone copy of this instance.

  Overrides:
    `clone` in class `BaseMac`
  Following copied from interface: `gnu.crypto.mac.IMac`
  Returns:
    a clone copy of this instance.

### init

    public void init(java.util.Map attributes)
              throws java.security.InvalidKeyException,
                     java.lang.IllegalStateException

  Description copied from interface: `IMac`

  Initialises the algorithm with designated attributes. Permissible names and values are described in the class documentation above.

  Overrides:
    `init` in class `BaseMac`
  Following copied from interface: `gnu.crypto.mac.IMac`
  Parameters:
    `attributes` - a set of name-value pairs that describe the desired future instance behaviour.
  Throws:
    `java.security.InvalidKeyException` - if the key data is invalid.
    `java.lang.IllegalStateException` - if the instance is already initialised.
  See Also:
    `IMac.MAC_KEY_MATERIAL`

### digest

    public byte[] digest()

  Description copied from interface: `IMac`

  Completes the MAC by performing final operations such as padding and resetting the instance.

  Overrides:
    `digest` in class `BaseMac`
  Following copied from interface: `gnu.crypto.mac.IMac`
  Returns:
    the array of bytes representing the MAC value.

### selfTest

    public boolean selfTest()

  Description copied from interface: `IMac`

  A basic test. Ensures that the MAC of a pre-determined message is equal to a known pre-computed value.

  Overrides:
    `selfTest` in class `BaseMac`
  Following copied from interface: `gnu.crypto.mac.IMac`
  Returns:
    `true` if the implementation passes a basic self-test. Returns `false` otherwise.

Overview | Package | Class | Tree | Deprecated | Index | Help
| For the latest news and information visit The GNU Crypto project
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright ©2001-2002 Free Software Foundation, Inc.. All Rights Reserved.