fr.xephi.authme.security.pbkdf2
Class MacBasedPRF

java.lang.Object
  extended by fr.xephi.authme.security.pbkdf2.MacBasedPRF
All Implemented Interfaces:
PRF

public class MacBasedPRF
extends java.lang.Object
implements PRF

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


A free Java implementation of Password Based Key Derivation Function 2 as defined by RFC 2898. Copyright (c) 2007 Matthias Gärtner

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

For Details, see http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.

Version:
1.0
Author:
Matthias Gärtner

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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.