Skip navigation links

Oracle Fusion Middleware Crypto FIPS Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10696-05


oracle.security.crypto.core
Class HMAC

java.lang.Object
  extended by oracle.security.crypto.core.MessageDigest
      extended by oracle.security.crypto.core.MAC
          extended by oracle.security.crypto.core.HMAC

All Implemented Interfaces:
java.lang.Cloneable

public final class HMAC
extends MAC

This class implements HMAC [RFC2104] as a subclass of MessageDigest. MD5 and SHA are supported.


Nested Class Summary

 

Nested classes/interfaces inherited from class oracle.security.crypto.core.MessageDigest
MessageDigest.MDState

 

Field Summary

 

Fields inherited from class oracle.security.crypto.core.MessageDigest
algID

 

Constructor Summary
HMAC()
          Empty constructor.
HMAC(AlgorithmIdentifier hashAlgID, byte[] key)
          Deprecated.  
HMAC(AlgorithmIdentifier hashAlgID, byte[] key, int keyOff, int keyLen)
          Deprecated.  
HMAC(AlgorithmIdentifier hashAlgID, SymmetricKey key)
          Creates a new HMAC object with the specified parameters.

 

Method Summary
 java.lang.String algName()
          Returns the algorithm name of this HMAC.
 int blockSize()
          Returns the blocksize of this instance.
 java.lang.Object clone()
          Returns a clone of this HMAC object.
 void computeCurrent()
          Completes the hash computation, performing any necessary operations such as padding.
 void erase()
          Erases the keyBytes from this instance.
 void finalize()
          Finalizes this object by erasing sensitive data.
 AlgorithmIdentifier getAlgID()
          Returns the algorithm identifier of this object.
 byte[] getDigestBits()
          Returns a copy of the current digest bytes.
 int getDigestLength()
          Returns the length in bytes of the message digest.
protected  MessageDigest.MDState getState()
          Gets the state of this MessageDigest instance.
 void init()
          Resets this HMAC object to its initial state.
 void initialize(AlgorithmIdentifier algID, SymmetricKey key)
          Initializes this MAC with the specified parameter.
 boolean isValid()
          Returns true if this HMAC is in a valid state and its digest bits are usable; otherwise returns false.
 void setAlgID(AlgorithmIdentifier algID)
          Deprecated. Use initialize instead
 void setKey(byte[] key)
          Deprecated. Use initialize instead
 void setKey(byte[] key, int keyOff, int keyLen)
          Deprecated. Use initialize instead
protected  void setState(MessageDigest.MDState state)
          Sets the state of this MessageDigest instance.
 void update(byte b)
          Adds the specifed byte to the data being digested.
 void update(byte[] input, int off, int len)
          Adds the specified sequence of bytes to the data being digested.

 

Methods inherited from class oracle.security.crypto.core.MAC
computeMAC, computeMAC, getInstance, verifyMAC, verifyMAC

 

Methods inherited from class oracle.security.crypto.core.MessageDigest
computeDigest, computeDigest, getInstance, isEqual, toString, update, update, update, update, update, update, update, update, update, update, update, updateASCII

 

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

 

Constructor Detail

HMAC

public HMAC()
Empty constructor.

HMAC

public HMAC(AlgorithmIdentifier hashAlgID,
            SymmetricKey key)
     throws AlgorithmIdentifierException
Creates a new HMAC object with the specified parameters.
Parameters:
hashAlgID - The hash algorithm to use in this HMAC instance.
key - The key to use.
Throws:
AlgorithmIdentifierException

HMAC

public HMAC(AlgorithmIdentifier hashAlgID,
            byte[] key,
            int keyOff,
            int keyLen)
     throws AlgorithmIdentifierException
Deprecated. 
Throws:
AlgorithmIdentifierException

HMAC

public HMAC(AlgorithmIdentifier hashAlgID,
            byte[] key)
     throws AlgorithmIdentifierException
Deprecated. 
Throws:
AlgorithmIdentifierException

Method Detail

initialize

public void initialize(AlgorithmIdentifier algID,
                       SymmetricKey key)
                throws AlgorithmIdentifierException
Description copied from class: MAC
Initializes this MAC with the specified parameter.
Specified by:
initialize in class MAC
Parameters:
algID - The MAC algorithm.
key - The key to use in this MAC. The key bytes will be cloned when initialized.
Throws:
AlgorithmIdentifierException

setAlgID

public void setAlgID(AlgorithmIdentifier algID)
              throws AlgorithmIdentifierException
Deprecated. Use initialize instead
Description copied from class: MessageDigest
Sets the AlgorithmIdentifier of this MessageDigest instance.
Overrides:
setAlgID in class MessageDigest
Parameters:
algID - The AlgorithmIdentifier to use.
Throws:
AlgorithmIdentifierException

getAlgID

public AlgorithmIdentifier getAlgID()
Description copied from class: MessageDigest
Returns the algorithm identifier of this object.
Specified by:
getAlgID in class MessageDigest
Returns:
An AlgorithIdentifier object representing the hash algorithm of this MessageDigest instance.

setKey

public void setKey(byte[] key,
                   int keyOff,
                   int keyLen)
Deprecated. Use initialize instead

setKey

public void setKey(byte[] key)
Deprecated. Use initialize instead

init

public void init()
Resets this HMAC object to its initial state.
Specified by:
init in class MessageDigest

update

public void update(byte b)
Adds the specifed byte to the data being digested.
Specified by:
update in class MessageDigest

update

public void update(byte[] input,
                   int off,
                   int len)
Adds the specified sequence of bytes to the data being digested.
Overrides:
update in class MessageDigest
Parameters:
input - the input array
off - start position in the input array
len - the number of input array elements to add to the data being digested

computeCurrent

public void computeCurrent()
Completes the hash computation, performing any necessary operations such as padding. The result of the hash can be retrieved using getDigestBits().
Specified by:
computeCurrent in class MessageDigest

algName

public java.lang.String algName()
Returns the algorithm name of this HMAC. Possible name would be "HMAC-MD5" and "HMAC-SHA" and the other HMACSHA variants.
Specified by:
algName in class MessageDigest
Returns:
algorithm name

blockSize

public int blockSize()
Description copied from class: MessageDigest
Returns the blocksize of this instance.
Specified by:
blockSize in class MessageDigest

getDigestLength

public int getDigestLength()
Description copied from class: MessageDigest
Returns the length in bytes of the message digest.
Specified by:
getDigestLength in class MessageDigest

getDigestBits

public byte[] getDigestBits()
Returns a copy of the current digest bytes.
Overrides:
getDigestBits in class MessageDigest

isValid

public boolean isValid()
Returns true if this HMAC is in a valid state and its digest bits are usable; otherwise returns false.
Overrides:
isValid in class MessageDigest

erase

public void erase()
Erases the keyBytes from this instance.
Specified by:
erase in class MAC

finalize

public void finalize()
Finalizes this object by erasing sensitive data.
Overrides:
finalize in class java.lang.Object

clone

public java.lang.Object clone()
Returns a clone of this HMAC object.
Specified by:
clone in class MessageDigest

getState

protected MessageDigest.MDState getState()
Description copied from class: MessageDigest
Gets the state of this MessageDigest instance.
Specified by:
getState in class MessageDigest

setState

protected void setState(MessageDigest.MDState state)
Description copied from class: MessageDigest
Sets the state of this MessageDigest instance.
Specified by:
setState in class MessageDigest

Skip navigation links

Oracle Fusion Middleware Crypto FIPS Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10696-05


Copyright © 2005, 2013, Oracle. All rights reserved.