Search in sources :

Example 1 with OpenSSLPBEParametersGenerator

use of org.spongycastle.crypto.generators.OpenSSLPBEParametersGenerator in project bitcoin-wallet by bitcoin-wallet.

the class Crypto method getAESPasswordKey.

/**
 * Get password and generate key and iv.
 *
 * @param password
 *            The password to use in key generation
 * @param salt
 *            The salt to use in key generation
 * @return The CipherParameters containing the created key
 */
private static CipherParameters getAESPasswordKey(final char[] password, final byte[] salt) {
    final PBEParametersGenerator generator = new OpenSSLPBEParametersGenerator();
    generator.init(PBEParametersGenerator.PKCS5PasswordToBytes(password), salt, NUMBER_OF_ITERATIONS);
    final ParametersWithIV key = (ParametersWithIV) generator.generateDerivedParameters(KEY_LENGTH, IV_LENGTH);
    return key;
}
Also used : ParametersWithIV(org.spongycastle.crypto.params.ParametersWithIV) PBEParametersGenerator(org.spongycastle.crypto.PBEParametersGenerator) OpenSSLPBEParametersGenerator(org.spongycastle.crypto.generators.OpenSSLPBEParametersGenerator) OpenSSLPBEParametersGenerator(org.spongycastle.crypto.generators.OpenSSLPBEParametersGenerator)

Aggregations

PBEParametersGenerator (org.spongycastle.crypto.PBEParametersGenerator)1 OpenSSLPBEParametersGenerator (org.spongycastle.crypto.generators.OpenSSLPBEParametersGenerator)1 ParametersWithIV (org.spongycastle.crypto.params.ParametersWithIV)1