gnu.crypto.mac

Class UHash32

public class UHash32 extends BaseMac

UHASH is a keyed hash function, which takes as input a string of arbitrary length, and produces as output a string of fixed length (such as 8 bytes). The actual output length depends on the parameter UMAC-OUTPUT-LEN.

UHASH has been shown to be epsilon-ASU ("Almost Strongly Universal"), where epsilon is a small (parameter-dependent) real number. Informally, saying that a keyed hash function is epsilon-ASU means that for any two distinct fixed input strings, the two outputs of the hash function with a random key "look almost like a pair of random strings". The number epsilon measures how non-random the output strings may be.

UHASH has been designed to be fast by exploiting several architectural features of modern commodity processors. It was specifically designed for use in UMAC. But UHASH is useful beyond that domain, and can be easily adopted for other purposes.

UHASH does its work in three layers. First, a hash function called NH is used to compress input messages into strings which are typically many times smaller than the input message. Second, the compressed message is hashed with an optimized polynomial hash function into a fixed-length 16-byte string. Finally, the 16-byte string is hashed using an inner-product hash into a string of length WORD-LEN bytes. These three layers are repeated (with a modified key) until the outputs total UMAC-OUTPUT-LEN bytes.

References:

  1. UMAC: Message Authentication Code using Universal Hashing.
    T. Krovetz, J. Black, S. Halevi, A. Hevia, H. Krawczyk, and P. Rogaway.

Version: $Revision: 1.7 $

Nested Class Summary
classUHash32.L1Hash32
First hash stage of the UHash32 algorithm.
classUHash32.L2Hash32

Second hash stage of the UHash32 algorithm.

5.4 L2-HASH-32: Second-layer hash.

  • Input:
    K string of length 24 bytes.
    M string of length less than 2^64 bytes.
  • Returns:
    Y, string of length 16 bytes.
classUHash32.L3Hash32
Third hash stage of the UHash32 algorithm.
Field Summary
static byte[]ALL_ZEROES
static longBOUNDARY
UHash32.L1Hash32[]l1hash
static BigIntegerLOWER_RANGE
intstreams
static BigIntegerTWO
static BigIntegerUPPER_RANGE
Constructor Summary
UHash32()
Trivial 0-arguments constructor.
Method Summary
Objectclone()
byte[]digest()
voidinit(Map attributes)
intmacSize()
static BigIntegerprime(int n)

The prime numbers used in UMAC are:

   +-----+--------------------+---------------------------------------+
   |  x  | prime(x) [Decimal] | prime(x) [Hexadecimal]                |
   +-----+--------------------+---------------------------------------+
   | 19  | 2^19  - 1          | 0x0007FFFF                            |
   | 32  | 2^32  - 5          | 0xFFFFFFFB                            |
   | 36  | 2^36  - 5          | 0x0000000F FFFFFFFB                   |
   | 64  | 2^64  - 59         | 0xFFFFFFFF FFFFFFC5                   |
   | 128 | 2^128 - 159        | 0xFFFFFFFF FFFFFFFF FFFFFFFF FFFFFF61 |
   +-----+--------------------+---------------------------------------+
voidreset()
booleanselfTest()
voidupdate(byte b)
voidupdate(byte[] b, int offset, int len)

Field Detail

ALL_ZEROES

static final byte[] ALL_ZEROES

BOUNDARY

static final long BOUNDARY

l1hash

UHash32.L1Hash32[] l1hash

LOWER_RANGE

static final BigInteger LOWER_RANGE

streams

int streams

TWO

static final BigInteger TWO

UPPER_RANGE

static final BigInteger UPPER_RANGE

Constructor Detail

UHash32

public UHash32()
Trivial 0-arguments constructor.

Method Detail

clone

public Object clone()

digest

public byte[] digest()

init

public void init(Map attributes)

macSize

public int macSize()

prime

static final BigInteger prime(int n)

The prime numbers used in UMAC are:

   +-----+--------------------+---------------------------------------+
   |  x  | prime(x) [Decimal] | prime(x) [Hexadecimal]                |
   +-----+--------------------+---------------------------------------+
   | 19  | 2^19  - 1          | 0x0007FFFF                            |
   | 32  | 2^32  - 5          | 0xFFFFFFFB                            |
   | 36  | 2^36  - 5          | 0x0000000F FFFFFFFB                   |
   | 64  | 2^64  - 59         | 0xFFFFFFFF FFFFFFC5                   |
   | 128 | 2^128 - 159        | 0xFFFFFFFF FFFFFFFF FFFFFFFF FFFFFF61 |
   +-----+--------------------+---------------------------------------+

Parameters: n a number of bits.

Returns: the largest prime number less than 2**n.

reset

public void reset()

selfTest

public boolean selfTest()

update

public void update(byte b)

update

public void update(byte[] b, int offset, int len)
Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.