de.rtner.security.auth.spi
Class MacBasedPRF

java.lang.Object
  extended by de.rtner.security.auth.spi.MacBasedPRF
All Implemented Interfaces:
PRF

public class MacBasedPRF
extends java.lang.Object
implements PRF

Default PRF implementation based on standard javax.crypt.Mac mechanisms.


Field Summary
protected  int hLen
           
protected  javax.crypto.Mac mac
           
protected  java.lang.String macAlgorithm
           
 
Constructor Summary
MacBasedPRF(java.lang.String macAlgorithm)
          Create Mac-based Pseudo Random Function.
MacBasedPRF(java.lang.String macAlgorithm, java.lang.String provider)
           
 
Method Summary
 byte[] doFinal(byte[] M)
          Pseudo Random Function
 int getHLen()
          Query block size of underlying algorithm/mechanism.
 void init(byte[] P)
          Initialize this instance with the user-supplied password.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mac

protected javax.crypto.Mac mac

hLen

protected int hLen

macAlgorithm

protected java.lang.String macAlgorithm
Constructor Detail

MacBasedPRF

public MacBasedPRF(java.lang.String macAlgorithm)
Create Mac-based Pseudo Random Function.

Parameters:
macAlgorithm - Mac algorithm to use, i.e. HMacSHA1 or HMacMD5.

MacBasedPRF

public MacBasedPRF(java.lang.String macAlgorithm,
                   java.lang.String provider)
Method Detail

doFinal

public byte[] doFinal(byte[] M)
Description copied from interface: PRF
Pseudo Random Function

Specified by:
doFinal in interface PRF
Parameters:
M - Input data/message etc. Together with any data supplied during initilization.
Returns:
Random bytes of hLen length.

getHLen

public int getHLen()
Description copied from interface: PRF
Query block size of underlying algorithm/mechanism.

Specified by:
getHLen in interface PRF
Returns:
block size

init

public void init(byte[] P)
Description copied from interface: PRF
Initialize this instance with the user-supplied password.

Specified by:
init in interface PRF
Parameters:
P - The password supplied as array of bytes. It is the caller's task to convert String passwords to bytes as appropriate.