org.bouncycastle.crypto

Class PBEParametersGenerator

public abstract class PBEParametersGenerator extends Object

super class for all Password Based Encryption (PBE) parameter generator classes.
Field Summary
protected intiterationCount
protected byte[]password
protected byte[]salt
Constructor Summary
protected PBEParametersGenerator()
base constructor.
Method Summary
abstract CipherParametersgenerateDerivedMacParameters(int keySize)
generate derived parameters for a key of length keySize, specifically for use with a MAC.
abstract CipherParametersgenerateDerivedParameters(int keySize)
generate derived parameters for a key of length keySize.
abstract CipherParametersgenerateDerivedParameters(int keySize, int ivSize)
generate derived parameters for a key of length keySize, and an initialisation vector (IV) of length ivSize.
intgetIterationCount()
return the iteration count.
byte[]getPassword()
return the password byte array.
byte[]getSalt()
return the salt byte array.
voidinit(byte[] password, byte[] salt, int iterationCount)
initialise the PBE generator.
static byte[]PKCS12PasswordToBytes(char[] password)
converts a password to a byte array according to the scheme in PKCS12 (unicode, big endian, 2 zero pad bytes at the end).
static byte[]PKCS5PasswordToBytes(char[] password)
converts a password to a byte array according to the scheme in PKCS5 (ascii, no padding)

Field Detail

iterationCount

protected int iterationCount

password

protected byte[] password

salt

protected byte[] salt

Constructor Detail

PBEParametersGenerator

protected PBEParametersGenerator()
base constructor.

Method Detail

generateDerivedMacParameters

public abstract CipherParameters generateDerivedMacParameters(int keySize)
generate derived parameters for a key of length keySize, specifically for use with a MAC.

Parameters: keySize the length, in bits, of the key required.

Returns: a parameters object representing a key.

generateDerivedParameters

public abstract CipherParameters generateDerivedParameters(int keySize)
generate derived parameters for a key of length keySize.

Parameters: keySize the length, in bits, of the key required.

Returns: a parameters object representing a key.

generateDerivedParameters

public abstract CipherParameters generateDerivedParameters(int keySize, int ivSize)
generate derived parameters for a key of length keySize, and an initialisation vector (IV) of length ivSize.

Parameters: keySize the length, in bits, of the key required. ivSize the length, in bits, of the iv required.

Returns: a parameters object representing a key and an IV.

getIterationCount

public int getIterationCount()
return the iteration count.

Returns: the iteration count.

getPassword

public byte[] getPassword()
return the password byte array.

Returns: the password byte array.

getSalt

public byte[] getSalt()
return the salt byte array.

Returns: the salt byte array.

init

public void init(byte[] password, byte[] salt, int iterationCount)
initialise the PBE generator.

Parameters: password the password converted into bytes (see below). salt the salt to be mixed with the password. iterationCount the number of iterations the "mixing" function is to be applied for.

PKCS12PasswordToBytes

public static byte[] PKCS12PasswordToBytes(char[] password)
converts a password to a byte array according to the scheme in PKCS12 (unicode, big endian, 2 zero pad bytes at the end).

Parameters: password a character array reqpresenting the password.

Returns: a byte array representing the password.

PKCS5PasswordToBytes

public static byte[] PKCS5PasswordToBytes(char[] password)
converts a password to a byte array according to the scheme in PKCS5 (ascii, no padding)

Parameters: password a character array reqpresenting the password.

Returns: a byte array representing the password.