edu.vt.middleware.crypt.pbe
Class AbstractPKCSKeyGenerator

java.lang.Object
  extended by edu.vt.middleware.crypt.pbe.AbstractPKCSKeyGenerator
All Implemented Interfaces:
KeyGenerator
Direct Known Subclasses:
PBKDF1KeyGenerator, PBKDF2KeyGenerator, PKCS12KeyGenerator

public abstract class AbstractPKCSKeyGenerator
extends Object
implements KeyGenerator

Base class for all PKCS key generators that use a key derivation function that performs iterative hashing operations on a salted password.

For a key derivation function f, the following formula applies:
derivedKey = f(password, salt, iterations)

Classes derived from this class are NOT thread safe.

Version:
$Revision: 2744 $
Author:
Middleware Services

Field Summary
static int DEFAULT_ITERATION_COUNT
          Default number of iterations taken from examples in PKCS#5v2.
protected  int iterationCount
          Key derifcation function iteration count.
protected  byte[] salt
          Key derifcation function salt.
 
Constructor Summary
AbstractPKCSKeyGenerator()
           
 
Method Summary
 byte[] generate(char[] password, int size)
          Generates a symmetric key from a password for use in password-based encryption schemes.
protected abstract  org.bouncycastle.crypto.PBEParametersGenerator newParamGenerator()
          Creates a new BC parameter generator instance.
protected  void setIterationCount(int count)
          Gets the key derivation function iteration count.
protected abstract  byte[] toBytes(char[] password)
          Converts password characters to bytes in implementation-dependent fashion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ITERATION_COUNT

public static final int DEFAULT_ITERATION_COUNT
Default number of iterations taken from examples in PKCS#5v2.

See Also:
Constant Field Values

salt

protected byte[] salt
Key derifcation function salt.


iterationCount

protected int iterationCount
Key derifcation function iteration count.

Constructor Detail

AbstractPKCSKeyGenerator

public AbstractPKCSKeyGenerator()
Method Detail

generate

public byte[] generate(char[] password,
                       int size)
Generates a symmetric key from a password for use in password-based encryption schemes.

Specified by:
generate in interface KeyGenerator
Parameters:
password - Password used as basis for generated key.
size - Size of generated key in bits, unless otherwise noted.
Returns:
Secret key bytes.

setIterationCount

protected void setIterationCount(int count)
Gets the key derivation function iteration count.

Parameters:
count - Iteration count. MUST be positive integer.

newParamGenerator

protected abstract org.bouncycastle.crypto.PBEParametersGenerator newParamGenerator()
Creates a new BC parameter generator instance.

Returns:
New parameter generator.

toBytes

protected abstract byte[] toBytes(char[] password)
Converts password characters to bytes in implementation-dependent fashion.

Parameters:
password - Password to convert.
Returns:
Password bytes.


Copyright © 2003-2013 Virginia Tech. All Rights Reserved.