Martin Grajcar
2014-10-13 18:36:34 UTC
I'm rather new to BC and I'd like to ask you if I got it right: Given a
password and a salt, I want to get an instance of Salsa20, so I did this
private static StreamCipher newCipher(byte[] password, byte[] salt) {
final PBEParametersGenerator generator = new
PKCS5S2ParametersGenerator();
generator.init(password, salt, 5000);
Arrays.fill(password, (byte) 0);
final CipherParameters cipherParameters =
generator.generateDerivedParameters(257, 64);
final StreamCipher result = new Salsa20Engine();
result.init(true, cipherParameters);
return result;
}
It sounds trivial, but with crypto I never know. Is PKCS5S2 with 50000
about right?
Regards,
Martin.
PS: I hope this is the right place to ask this.
password and a salt, I want to get an instance of Salsa20, so I did this
private static StreamCipher newCipher(byte[] password, byte[] salt) {
final PBEParametersGenerator generator = new
PKCS5S2ParametersGenerator();
generator.init(password, salt, 5000);
Arrays.fill(password, (byte) 0);
final CipherParameters cipherParameters =
generator.generateDerivedParameters(257, 64);
final StreamCipher result = new Salsa20Engine();
result.init(true, cipherParameters);
return result;
}
It sounds trivial, but with crypto I never know. Is PKCS5S2 with 50000
about right?
Regards,
Martin.
PS: I hope this is the right place to ask this.