I'm working on a Java authentication subsystem that specs the storage of passwords in the DB as
PBKDF2-generated hashes, and I'm now trying to decide whether I should use
SHA512 as PFR. I'm under the impression that the consensus is that
SHA1 has some theoretical weaknesses, and that
SHA512 should be chosen instead. However the standard
javax.crypto package does not offer a
PBKDF2WithHmacSHA512 implementation, how is that so? Furthermore, I can't seem to find any Provider offering it, apart from IKAI (they charge a few thousand $ for their JCE library, oopss..)
private static final int HASH_BYTE_SIZE = 64; // 512 bits private static final int PBKDF2_ITERATIONS = 1000; // generate random salt SecureRandom random = new SecureRandom(); byte salt = new byte[SALT_BYTE_SIZE]; // use salt size at least as long as hash random.nextBytes(salt); // generate Hash PBEKeySpec spec = new PBEKeySpec(password, salt, PBKDF2_ITERATIONS, HASH_BYTE_SIZE); SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); // this throws a NoSuchAlgorithmException if I replace with "PBKDF2WithHmacSHA512" byte hash = skf.generateSecret(spec).getEncoded(); // convert hash and salt to hex and store in DB as CHAR(64)...