Package org.bouncycastle.crypto.internal
Class PBEParametersGenerator<T extends Parameters>
java.lang.Object
org.bouncycastle.crypto.internal.PBEParametersGenerator<T>
- All Implemented Interfaces:
PasswordBasedDeriver<T>
public abstract class PBEParametersGenerator<T extends Parameters>
extends Object
implements PasswordBasedDeriver<T>
super class for all Password Based Encryption (PBE) parameter generator classes.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.bouncycastle.crypto.PasswordBasedDeriver
PasswordBasedDeriver.KeyType
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected byte[]
protected byte[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract CipherParameters
generateDerivedMacParameters
(int keySize) generate derived parameters for a key of length keySize, specifically for use with a MAC.abstract CipherParameters
generateDerivedParameters
(int keySize) generate derived parameters for a key of length keySize.abstract CipherParameters
generateDerivedParameters
(int keySize, int ivSize) generate derived parameters for a key of length keySize, and an initialisation vector (IV) of length ivSize.int
return the iteration count.Return the parameters for this deriver.byte[]
return the password byte array.byte[]
getSalt()
return the salt byte array.void
init
(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)static byte[]
PKCS5PasswordToUTF8Bytes
(char[] password) converts a password to a byte array according to the scheme in PKCS5 (UTF-8, no padding)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bouncycastle.crypto.PasswordBasedDeriver
deriveKey, deriveKeyAndIV
-
Field Details
-
password
protected byte[] password -
salt
protected byte[] salt -
iterationCount
protected int iterationCount
-
-
Constructor Details
-
PBEParametersGenerator
base constructor.
-
-
Method Details
-
getParameters
Description copied from interface:PasswordBasedDeriver
Return the parameters for this deriver.- Specified by:
getParameters
in interfacePasswordBasedDeriver<T extends Parameters>
- Returns:
- the deriver's parameters.
-
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.
-
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.
-
getIterationCount
public int getIterationCount()return the iteration count.- Returns:
- the iteration count.
-
generateDerivedParameters
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
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.
-
generateDerivedMacParameters
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.
-
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 representing the password.- Returns:
- a byte array representing the password.
-
PKCS5PasswordToUTF8Bytes
public static byte[] PKCS5PasswordToUTF8Bytes(char[] password) converts a password to a byte array according to the scheme in PKCS5 (UTF-8, no padding)- Parameters:
password
- a character array representing the password.- Returns:
- a byte array representing the password.
-
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 representing the password.- Returns:
- a byte array representing the password.
-