Top Description Fields Constructors Methods
org.bouncycastle.crypto.generators

public Class OpenSSLPBEParametersGenerator

extends PBEParametersGenerator
Class Inheritance
Imports
org.bouncycastle.crypto.CipherParameters, .Digest, .PBEParametersGenerator, org.bouncycastle.crypto.params.KeyParameter, .ParametersWithIV, org.bouncycastle.crypto.util.DigestFactory

Generator for PBE derived keys and ivs as usd by OpenSSL.

Originally this scheme was a simple extension of PKCS 5 V2.0 Scheme 1 using MD5 with an iteration count of 1. The default digest was changed to SHA-256 with OpenSSL 1.1.0. This implementation still defaults to MD5, but the digest can now be set.

Field Summary

Modifier and TypeField and Description
private final Digest
Inherited from org.bouncycastle.crypto.PBEParametersGenerator:
iterationCountpasswordsalt

Constructor Summary

AccessConstructor and Description
public
OpenSSLPBEParametersGenerator()

Construct a OpenSSL Parameters generator - digest the original MD5.

public
OpenSSLPBEParametersGenerator(Digest
the digest to use as the PRF.
digest
)

Construct a OpenSSL Parameters generator - digest as specified.

Method Summary

Modifier and TypeMethod and Description
private byte[]
generateDerivedKey(int bytesNeeded)

the derived key function, the ith hash of the password and the salt.

public CipherParameters

Returns:

a KeyParameter object.
generateDerivedMacParameters
(int
the size of the key we want (in bits)
keySize
)

Implements abstract org.bouncycastle.crypto.PBEParametersGenerator.generateDerivedMacParameters.

Generate a key parameter for use with a MAC derived from the password, salt, and iteration count we are currently initialised with.

public CipherParameters

Returns:

a KeyParameter object.
generateDerivedParameters
(int
the size of the key we want (in bits)
keySize
)

Implements abstract org.bouncycastle.crypto.PBEParametersGenerator.generateDerivedParameters.

Generate a key parameter derived from the password, salt, and iteration count we are currently initialised with.

public CipherParameters

Returns:

a ParametersWithIV object.
generateDerivedParameters
(int
the size of the key we want (in bits)
keySize
,
int
the size of the iv we want (in bits)
ivSize
)

Implements abstract org.bouncycastle.crypto.PBEParametersGenerator.generateDerivedParameters.

Generate a key with initialisation vector parameter derived from the password, salt, and iteration count we are currently initialised with.

public void
init(byte[]
password to use.
password
,
byte[]
salt to use.
salt
)

Initialise - note the iteration count for this algorithm is fixed at 1.

Inherited from org.bouncycastle.crypto.PBEParametersGenerator:
getIterationCountgetPasswordgetSaltinitPKCS12PasswordToBytesPKCS5PasswordToBytesPKCS5PasswordToUTF8Bytes

Field Detail

digestback to summary
private final Digest digest

Constructor Detail

OpenSSLPBEParametersGeneratorback to summary
public OpenSSLPBEParametersGenerator()

Construct a OpenSSL Parameters generator - digest the original MD5.

OpenSSLPBEParametersGeneratorback to summary
public OpenSSLPBEParametersGenerator(Digest digest)

Construct a OpenSSL Parameters generator - digest as specified.

Parameters
digest:Digest

the digest to use as the PRF.

Method Detail

generateDerivedKeyback to summary
private byte[] generateDerivedKey(int bytesNeeded)

the derived key function, the ith hash of the password and the salt.

generateDerivedMacParametersback to summary
public CipherParameters generateDerivedMacParameters(int keySize)

Implements abstract org.bouncycastle.crypto.PBEParametersGenerator.generateDerivedMacParameters.

Generate a key parameter for use with a MAC derived from the password, salt, and iteration count we are currently initialised with.

Parameters
keySize:int

the size of the key we want (in bits)

Returns:CipherParameters

a KeyParameter object.

Exceptions
IllegalArgumentException:
if the key length larger than the base hash size.
generateDerivedParametersback to summary
public CipherParameters generateDerivedParameters(int keySize)

Implements abstract org.bouncycastle.crypto.PBEParametersGenerator.generateDerivedParameters.

Generate a key parameter derived from the password, salt, and iteration count we are currently initialised with.

Parameters
keySize:int

the size of the key we want (in bits)

Returns:CipherParameters

a KeyParameter object.

Exceptions
IllegalArgumentException:
if the key length larger than the base hash size.
generateDerivedParametersback to summary
public CipherParameters generateDerivedParameters(int keySize, int ivSize)

Implements abstract org.bouncycastle.crypto.PBEParametersGenerator.generateDerivedParameters.

Generate a key with initialisation vector parameter derived from the password, salt, and iteration count we are currently initialised with.

Parameters
keySize:int

the size of the key we want (in bits)

ivSize:int

the size of the iv we want (in bits)

Returns:CipherParameters

a ParametersWithIV object.

Exceptions
IllegalArgumentException:
if keySize + ivSize is larger than the base hash size.
initback to summary
public void init(byte[] password, byte[] salt)

Initialise - note the iteration count for this algorithm is fixed at 1.

Parameters
password:byte[]

password to use.

salt:byte[]

salt to use.