I wonder what the canonical approach to generating keys using KDFs is on Android. The JCA provides a SecretKeyFactory
, outlined in this post, where the method would look like
public byte[] deriveKey(String password, byte[] salt, int keyLen) {
SecretKeyFactory kf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
KeySpec specs = new PBEKeySpec(password.toCharArray(), salt, 1024, keyLen);
SecretKey key = kf.generateSecret(specs);
return key.getEncoded();
}
It doesn't specify the number of rounds, however. Is this the canonical approach?