gnu.crypto.mac

Class HMac

Implemented Interfaces:
Cloneable, IMac

public class HMac
extends BaseMac
implements Cloneable

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

References:

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

Field Summary

static String
USE_WITH_PKCS5_V2
protected int
blockSize
protected byte[]
ipad
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

HMac(IMessageDigest underlyingHash)
Trivial constructor for use by concrete subclasses.

Method Summary

byte[]
digest()
void
init(Map attributes)
void
reset()
boolean
selfTest()

Methods inherited from class gnu.crypto.mac.BaseMac

clone, digest, init, macSize, name, reset, selfTest, update, update

Field Details

USE_WITH_PKCS5_V2

public static final String USE_WITH_PKCS5_V2

blockSize

protected int blockSize

ipad

protected byte[] ipad

ipadHash

protected IMessageDigest ipadHash

macSize

protected int macSize

opadHash

protected IMessageDigest opadHash

Constructor Details

HMac

protected HMac(IMessageDigest underlyingHash)
Trivial constructor for use by concrete subclasses.
Parameters:
underlyingHash - the underlying hash algorithm instance.

Method Details

digest

public byte[] digest()
Specified by:
digest in interface IMac
Overrides:
digest in interface BaseMac

init

public void init(Map attributes)
            throws InvalidKeyException,
                   IllegalStateException
Specified by:
init in interface IMac
Overrides:
init in interface BaseMac

reset

public void reset()
Specified by:
reset in interface IMac
Overrides:
reset in interface BaseMac

selfTest

public boolean selfTest()
Specified by:
selfTest in interface IMac
Overrides:
selfTest in interface BaseMac

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