Skip navigation links

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

E10668-04


oracle.security.crypto.core
Class PasswordBasedMAC

java.lang.Object
  extended by oracle.security.crypto.core.MessageDigest
      extended by oracle.security.crypto.core.PasswordBasedMAC

All Implemented Interfaces:
java.lang.Cloneable

public class PasswordBasedMAC
extends MessageDigest

The password-base MAC algorithm, as defined in CRMF (RFC 2511). Supports HMAC-SHA1 and HMAC-MD5 for the underlying keyed MAC algorithm.

Since:
2.2
See Also:
PBMacAlgID

Nested Class Summary

 

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

 

Field Summary
static int DEFAULT_ITER_COUNT
          Default password-based key derivation iteration count.
static AlgorithmIdentifier DEFAULT_MAC
          Default password-based MAC algorithm is HMAC-SHA.
static AlgorithmIdentifier DEFAULT_OWF
          Default password-based key derivation hash function is SHA-1.
static int DEFAULT_SALT_LEN
          Default password-based key derivation salt length.

 

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

 

Constructor Summary
PasswordBasedMAC()
          Creates a new PasswordBasedMAC instance.
PasswordBasedMAC(AlgorithmIdentifier algID, byte[] password)
          Creates a new PasswordBasedMAC instance with the given algorithm identifier and password.
PasswordBasedMAC(AlgorithmIdentifier algID, byte[] password, RandomBitsSource rbs)
          Creates a new PasswordBasedMAC instance with the given algorithm identifier and password.
PasswordBasedMAC(byte[] password)
          Creates a new PasswordBasedMAC instance with the given password.

 

Method Summary
 java.lang.String algName()
          Returns the algorithm name of this message digest.
 int blockSize()
          Returns the blocksize of this instance.
 java.lang.Object clone()
          Returns a clone of this message digest object.
 void computeCurrent()
          Completes the hash computation, performing any necessary operations such as padding.
 AlgorithmIdentifier getAlgID()
          Returns the algorithm identifier for this PasswordBasedMAC.
 int getCount()
          Returns the iteration count to use for password-based key derivation.
 byte[] getDigestBits()
          Returns a copy of the current digest bytes.
 int getDigestLength()
          Returns the length in bytes of the message digest.
 AlgorithmIdentifier getMacAlgID()
          Returns the keyed MAC algorithm to use.
 AlgorithmIdentifier getOwfAlgID()
          Returns the one-way (hash) function to use for password-based key derivation.
 byte[] getSalt()
          Gets the salt value used in this PasswordBasedMAC.
protected  MessageDigest.MDState getState()
          Gets the state of this MessageDigest instance.
 void init()
          Resets this message digest object to its initial state.
 boolean isValid()
          Returns true if this PasswordBasedMAC is in a valid state and its digest bits are usable; otherwise returns false.
 void setAlgID(AlgorithmIdentifier algID)
          Sets the algorithm identifier for this PasswordBasedMAC.
 void setCount(int count)
          Sets the iteration count to use for password-based key derivation.
 void setMacAlgID(AlgorithmIdentifier macAlgID)
          Sets the keyed MAC algorithm to use.
 void setOwfAlgID(AlgorithmIdentifier owfAlgID)
          Sets the one-way (hash) function to use for password-based key derivation.
 void setPassword(byte[] password)
          Sets the password to be used for this PasswordBasedMAC.
 void setRandomBitsSource(RandomBitsSource rbs)
          Sets the RNG to use for generating random salt bytes, if needed.
 void setSalt(byte[] salt)
          Sets the salt value.
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.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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Field Detail

DEFAULT_SALT_LEN

public static final int DEFAULT_SALT_LEN
Default password-based key derivation salt length.
See Also:
PKCS5.DEFAULT_SALT_LEN, Constant Field Values

DEFAULT_OWF

public static final AlgorithmIdentifier DEFAULT_OWF
Default password-based key derivation hash function is SHA-1.

DEFAULT_ITER_COUNT

public static final int DEFAULT_ITER_COUNT
Default password-based key derivation iteration count.
See Also:
PKCS5.DEFAULT_ITER_COUNT, Constant Field Values

DEFAULT_MAC

public static final AlgorithmIdentifier DEFAULT_MAC
Default password-based MAC algorithm is HMAC-SHA.

Constructor Detail

PasswordBasedMAC

public PasswordBasedMAC()
Creates a new PasswordBasedMAC instance.

PasswordBasedMAC

public PasswordBasedMAC(byte[] password)
                 throws AlgorithmIdentifierException
Creates a new PasswordBasedMAC instance with the given password. The default algorithm identifier AlgID.PasswordBasedMac will be used.
Parameters:
password - The password to use.
Throws:
AlgorithmIdentiferException - If algID does not identify a password-based MAC or if an error occurs processing the parameters.
AlgorithmIdentifierException

PasswordBasedMAC

public PasswordBasedMAC(AlgorithmIdentifier algID,
                        byte[] password)
                 throws AlgorithmIdentifierException
Creates a new PasswordBasedMAC instance with the given algorithm identifier and password.
Parameters:
algID - The algorithm identifier to use.
password - The password to use.
Throws:
AlgorithmIdentiferException - If algID does not identify a password-based MAC or if an error occurs processing the parameters.
AlgorithmIdentifierException
See Also:
PBMacAlgID

PasswordBasedMAC

public PasswordBasedMAC(AlgorithmIdentifier algID,
                        byte[] password,
                        RandomBitsSource rbs)
                 throws AlgorithmIdentifierException
Creates a new PasswordBasedMAC instance with the given algorithm identifier and password. Use this constructor if algID does not contain parameters; the given RandomBitsSource will be used to generate the salt bytes.
Parameters:
algID - The algorithm identifier to use.
password - The password to use.
rbs - The RNG to use for generating the salt bytes.
Throws:
AlgorithmIdentiferException - If algID does not identify a password-based MAC or if an error occurs processing the parameters.
AlgorithmIdentifierException
See Also:
PBMacAlgID

Method Detail

setAlgID

public void setAlgID(AlgorithmIdentifier algID)
              throws AlgorithmIdentifierException
Sets the algorithm identifier for this PasswordBasedMAC.
Overrides:
setAlgID in class MessageDigest
Parameters:
algID - The algorithm identifier to use.
Throws:
AlgorithmIdentiferException - If algID does not identify a password-based MAC or if an error occurs processing the parameters.
AlgorithmIdentifierException
See Also:
PBMacAlgID

getAlgID

public AlgorithmIdentifier getAlgID()
Returns the algorithm identifier for this PasswordBasedMAC.

If all of the parameter fields (salt, one-way function algorithm, iteration count and MAC algorithm) are defined (or defaults can be used and/or generated), then a new PBMacAlgID containing the parameters is returned; otherwise a PBMacAlgID with no parameters is returned.

Specified by:
getAlgID in class MessageDigest
Returns:
An AlgorithIdentifier object representing the hash algorithm of this MessageDigest instance.
Throws:
java.lang.IllegalStateException - If an error occurs constructing a new PBMacAlgID using the parameters present in this PasswordBasedMAC.
See Also:
PBMacAlgID

setSalt

public void setSalt(byte[] salt)
Sets the salt value.
Parameters:
salt - The salt value to use for password-based key derivation.
See Also:
PBMacAlgID

getSalt

public byte[] getSalt()
Gets the salt value used in this PasswordBasedMAC.
Returns:
A byte array containing the salt value, or null is none is present.
See Also:
PBMacAlgID

setOwfAlgID

public void setOwfAlgID(AlgorithmIdentifier owfAlgID)
                 throws AlgorithmIdentifierException
Sets the one-way (hash) function to use for password-based key derivation.
Parameters:
owfAlgID - The algorithm identifier for the password-based key derivation one-way (hash) function.
Throws:
AlgorithmIdentifierException
See Also:
PBMacAlgID

getOwfAlgID

public AlgorithmIdentifier getOwfAlgID()
Returns the one-way (hash) function to use for password-based key derivation.
Returns:
The algorithm identifier for the password-based key derivation one-way (hash) function, or null if none is present.
See Also:
PBMacAlgID

setCount

public void setCount(int count)
Sets the iteration count to use for password-based key derivation.
Parameters:
count - The iteration count to use for password-based key derivation.
See Also:
PBMacAlgID

getCount

public int getCount()
Returns the iteration count to use for password-based key derivation.
Returns:
The iteration count to use for password-based key derivation.
See Also:
PBMacAlgID

setMacAlgID

public void setMacAlgID(AlgorithmIdentifier macAlgID)
                 throws AlgorithmIdentifierException
Sets the keyed MAC algorithm to use.
Parameters:
macAlgID - The algorithm identifier for the keyed MAC algorithm.
Throws:
AlgorithmIdentifierException - If macAlgID does not identify a a supported MAC algorithm.
See Also:
PBMacAlgID

getMacAlgID

public AlgorithmIdentifier getMacAlgID()
Returns the keyed MAC algorithm to use.
Returns:
The algorithm identifier for the keyed MAC algorithm, or null if none is present.
See Also:
PBMacAlgID

setRandomBitsSource

public void setRandomBitsSource(RandomBitsSource rbs)
Sets the RNG to use for generating random salt bytes, if needed.
Parameters:
rbs - The RNG to use for generating random salt bytes.
See Also:
PBMacAlgID

setPassword

public void setPassword(byte[] password)
Sets the password to be used for this PasswordBasedMAC.
Parameters:
password - The bytes of the password.

init

public void init()
Description copied from class: MessageDigest
Resets this message digest object to its initial state.
Specified by:
init in class MessageDigest

blockSize

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

update

public void update(byte b)
Description copied from class: MessageDigest
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)
Description copied from class: MessageDigest
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()
Description copied from class: MessageDigest
Completes the hash computation, performing any necessary operations such as padding. The result of the hash can be obtained using MessageDigest.getDigestBits().
Specified by:
computeCurrent in class MessageDigest

algName

public java.lang.String algName()
Description copied from class: MessageDigest
Returns the algorithm name of this message digest.
Specified by:
algName 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 PasswordBasedMAC is in a valid state and its digest bits are usable; otherwise returns false.
Overrides:
isValid in class MessageDigest

clone

public java.lang.Object clone()
Description copied from class: MessageDigest
Returns a clone of this message digest 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 Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10668-04


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