gnu.javax.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.

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.javax.crypto.mac.BaseMac

name, truncatedSize, underlyingHash

Fields inherited from interface gnu.javax.crypto.mac.IMac

MAC_KEY_MATERIAL, TRUNCATED_SIZE

Constructor Summary

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

Method Summary

Object
clone()
byte[]
digest()
void
init(Map<K,V> attributes)
void
reset()
boolean
selfTest()

Methods inherited from class gnu.javax.crypto.mac.BaseMac

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

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

USE_WITH_PKCS5_V2

public static final String USE_WITH_PKCS5_V2
Field Value:
"gnu.crypto.hmac.pkcs5"

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

clone

public Object clone()
            throws CloneNotSupportedException
Specified by:
clone in interface IMac
Overrides:
clone in interface BaseMac

digest

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

init

public void init(Map<K,V> 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

HMac.java -- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.