List of usage examples for org.bouncycastle.asn1.pkcs PBEParameter getSalt
public byte[] getSalt()
From source file:org.cryptacular.pbe.PBES1EncryptionScheme.java
License:Open Source License
/** * Creates a new instance with the given parameters. * * @param alg Describes hash/algorithm pair suitable for PBES1 scheme. * @param params Key generation function salt and iteration count. * @param password Password used to derive key. *//*from w w w . ja v a 2 s .co m*/ public PBES1EncryptionScheme(final PBES1Algorithm alg, final PBEParameter params, final char[] password) { final byte[] salt = params.getSalt(); final int iterations = params.getIterationCount().intValue(); final PKCS5S1ParametersGenerator generator = new PKCS5S1ParametersGenerator( alg.getDigestSpec().newInstance()); generator.init(PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(password), salt, iterations); setCipher(alg.getCipherSpec().newInstance()); setCipherParameters(generator.generateDerivedParameters(KEY_LENGTH, IV_LENGTH)); }