de.flexiprovider.core.kdf
Class PBKDF1_PKCS12

java.lang.Object
  |
  +--de.flexiprovider.api.KeyDerivation
        |
        +--de.flexiprovider.core.kdf.PBKDF1_PKCS12
Direct Known Subclasses:
PBKDF1_PKCS12.MD5, PBKDF1_PKCS12.SHA1

public abstract class PBKDF1_PKCS12
extends KeyDerivation

This class implements the PBKDF1 key derivation function specified in PKCS #12 v1.0. This key derivation function is based on PBKDF1 specified in PKCS #5 v2.0.

Author:
Martin Döring

Inner Class Summary
static class PBKDF1_PKCS12.MD5
           
static class PBKDF1_PKCS12.SHA1
           
 
Constructor Summary
protected PBKDF1_PKCS12(MessageDigest md, int v)
          Constructor.
 
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
 

Constructor Detail

PBKDF1_PKCS12

protected PBKDF1_PKCS12(MessageDigest md,
                        int v)
Constructor. Set the message digest and its block size in bytes.
Parameters:
md - the message digest
v - the block size in bytes of the message digest
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 PBKDF1_PKCS12ParameterSpec.
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 PBKDF1_PKCS12ParameterSpec.

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.