de.flexiprovider.core.kdf
Class PBKDF2

java.lang.Object
  |
  +--de.flexiprovider.api.KeyDerivation
        |
        +--de.flexiprovider.core.kdf.PBKDF2

public class PBKDF2
extends KeyDerivation

This class implements the PBKDF2 key derivation function as specified in PKCS #5 v2.0.

Author:
Martin Döring

Field Summary
static java.lang.String OID
          The OID of PBKDF2.
 
Constructor Summary
PBKDF2()
           
 
Method Summary
 byte[] deriveKey(int keySize)
          Start the derivation process and return the derived key.
 void init(byte[] secret, AlgorithmParameterSpec params)
          Initialize this KDF with a secret and parameters.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OID

public static final java.lang.String OID
The OID of PBKDF2.
Constructor Detail

PBKDF2

public PBKDF2()
Method Detail

init

public void init(byte[] secret,
                 AlgorithmParameterSpec params)
          throws InvalidKeyException,
                 InvalidAlgorithmParameterException
Initialize this KDF with a secret and parameters. The supported parameters type is PBKDF2ParameterSpec.
Overrides:
init in class KeyDerivation
Parameters:
secret - the secret from which to derive the key
params - the parameters
Throws:
InvalidKeyException - if the secret is null.
InvalidAlgorithmParameterException - if the parameters are not an instance of PBKDF2ParameterSpec.

deriveKey

public byte[] deriveKey(int keySize)
Start the derivation process and return the derived key. If supported by the concrete implementation, the derived key will be of the specified length.
Overrides:
deriveKey in class KeyDerivation
Parameters:
keySize - the desired length of the derived key
Returns:
the derived key with the specified length, or null if the key size is < 0.