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 TMMH16

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

All Implemented Interfaces:
  java.lang.Cloneable, IMac

public class TMMH16
extends BaseMac

TMMH is a universal hash function suitable for message authentication in the Wegman-Carter paradigm, as in the Stream Cipher Security Transform. It is simple, quick, and especially appropriate for Digital Signal Processors and other processors with a fast multiply operation, though a straightforward implementation requires storage equal in length to the largest message to be hashed.

TMMH is a simple hash function which maps a key and a message to a hash value. There are two versions of TMMH: TMMH/16 and TMMH/32. TMMH can be used as a message authentication code, as described in Section 5 (see References).

The key, message, and hash value are all octet strings, and the lengths of these quantities are denoted as `KEY_LENGTH`, `MESSAGE_LENGTH`, and `TAG_LENGTH`, respectively. The values of `KEY_LENGTH` and `TAG_LENGTH` MUST be fixed for any particular fixed value of the key, and must obey the alignment restrictions described below.

The parameter `MAX_HASH_LENGTH`, which denotes the maximum value which `MESSAGE_LENGTH` may take, is equal to `KEY_LENGTH - TAG_LENGTH`.

References:

1. The Truncated Multi-Modular Hash Function (TMMH), David A. McGrew.

Version:
  $Revision: 1.2 $

Field Summary
`static java.lang.String` | `KEYSTREAM`
`static java.lang.String` | `PREFIX`
`static java.lang.String` | `TAG_LENGTH`

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
`TMMH16()` Trivial 0-arguments constructor.

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.
`byte[]` | `digest(IRandom prng)` Similar to the same method with no arguments, but uses the designated random number generator to compute needed keying material.
`void` | `init(java.util.Map attributes)` Initialises the algorithm with designated attributes.
`int` | `macSize()` Returns the output length in bytes of this MAC algorithm.
`void` | `reset()` Resets the algorithm instance for re-initialisation and use with other characteristics.
`boolean` | `selfTest()` A basic test.
`void` | `update(byte b)` Continues a MAC operation using the input byte.
`void` | `update(byte[] b, int offset, int len)` Continues a MAC operation, by filling the buffer, processing data in the algorithm's MAC_SIZE-bit block(s), updating the context and count, and buffering the remaining bytes in buffer for the next operation.
`void` | `update(byte[] b, int offset, int len, IRandom prng)` Similar to the same method with three arguments, but uses the designated random number generator to compute needed keying material.
`void` | `update(byte b, IRandom prng)` Similar to the same method with one argument, but uses the designated random number generator to compute needed keying material.

Methods inherited from class gnu.crypto.mac.BaseMac
`name`

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

Field Detail

### TAG_LENGTH

    public static final java.lang.String TAG_LENGTH

### KEYSTREAM

    public static final java.lang.String KEYSTREAM

### PREFIX

    public static final java.lang.String PREFIX

Constructor Detail

### TMMH16

    public TMMH16()

  Trivial 0-arguments constructor.

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.

### macSize

    public int macSize()

  Description copied from interface: `IMac`

  Returns the output length in bytes of this MAC algorithm.

  Overrides:
    `macSize` in class `BaseMac`
  Following copied from interface: `gnu.crypto.mac.IMac`
  Returns:
    the output length in bytes of this MAC algorithm.

### 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`

### update

    public void update(byte b)

  Description copied from interface: `IMac`

  Continues a MAC operation using the input byte.

  Overrides:
    `update` in class `BaseMac`
  Following copied from interface: `gnu.crypto.mac.IMac`
  Parameters:
    `b` - the input byte to digest.

### update

    public void update(byte[] b,
                       int offset,
                       int len)

  Description copied from interface: `IMac`

  Continues a MAC operation, by filling the buffer, processing data in the algorithm's MAC_SIZE-bit block(s), updating the context and count, and buffering the remaining bytes in buffer for the next operation.

  Overrides:
    `update` in class `BaseMac`
  Following copied from interface: `gnu.crypto.mac.IMac`
  Parameters:
    `in` - the input block.
    `offset` - start of meaningful bytes in input block.
    `length` - number of bytes, in input block, to consider.

### 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.

### reset

    public void reset()

  Description copied from interface: `IMac`

  Resets the algorithm instance for re-initialisation and use with other characteristics. This method always succeeds.

  Overrides:
    `reset` in class `BaseMac`

### 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.

### update

    public void update(byte b,
                       IRandom prng)

  Similar to the same method with one argument, but uses the designated random number generator to compute needed keying material.

  Parameters:
    `b` - the byte to process.
    `prng` - the source of randomness to use.

### update

    public void update(byte[] b,
                       int offset,
                       int len,
                       IRandom prng)

  Similar to the same method with three arguments, but uses the designated random number generator to compute needed keying material.

  Parameters:
    `b` - the byte array to process.
    `offset` - the starting offset in `b` to start considering the bytes to process.
    `len` - the number of bytes in `b` starting from `offset` to process.
    `prng` - the source of randomness to use.

### digest

    public byte[] digest(IRandom prng)

  Similar to the same method with no arguments, but uses the designated random number generator to compute needed keying material.

  Parameters:
    `prng` - the source of randomness to use.
  Returns:
    the final result of the algorithm.

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.