byte[] enc = c.doFinal(salt);
c = Cipher.getInstance(algorithm, "BC");
PBEKeySpec keySpec = new PBEKeySpec(password, salt, iCount);
SecretKeyFactory fact = SecretKeyFactory.getInstance(algorithm, "BC");
c.init(Cipher.DECRYPT_MODE, fact.generateSecret(keySpec));
byte[] dec = c.doFinal(enc);
if (!arrayEquals(salt, dec))
{
fail("" + algorithm + "failed encryption/decryption test");
}
//
// get the parameters
//
AlgorithmParameters param = checkParameters(c, salt, iCount);
//
// try using parameters
//
c = Cipher.getInstance(algorithm, "BC");
keySpec = new PBEKeySpec(password);
c.init(Cipher.DECRYPT_MODE, fact.generateSecret(keySpec), param);
checkParameters(c, salt, iCount);
dec = c.doFinal(enc);
if (!arrayEquals(salt, dec))
{
fail("" + algorithm + "failed encryption/decryption test");
}
//
// try using PBESpec
//
c = Cipher.getInstance(algorithm, "BC");
keySpec = new PBEKeySpec(password);
c.init(Cipher.DECRYPT_MODE, fact.generateSecret(keySpec), param.getParameterSpec(PBEParameterSpec.class));
checkParameters(c, salt, iCount);