PBKDF2WithHmacSHA512 Vs. PBKDF2WithHmacSHA1
Ich arbeite an einem Java-Authentifizierungssubsystem, das die Speicherung von Passwörtern in der DB als angibtPBKDF2
-generierte Hashes, und ich versuche jetzt zu entscheiden, ob ich sie verwenden sollSHA1
oderSHA512
als PFR. Ich habe beide Spezifikationen durchgesehen, aber sie sind für mich sehr mathematisch aufwendig. Kann jemand mit besserem Kryptoverständnis erklären, wiePBKDF2WithHmacSHA512
unterscheidet sich vonPBKDF2WithHmacSHA1
?
Folgendes versuche ich zu tun:
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"); // we would like this to be "PBKDF2WithHmacSHA512" instead? What Provider implements it?
byte[] hash = skf.generateSecret(spec).getEncoded();
// convert hash and salt to hex and store in DB as CHAR(64)...