Is it useful to combine HMAC with Bcrypt ?
If it so, should I do the HMAC on the password before "Bcrypt"ing it ? or should I do the HMAC on the Bcrypt output ?
-
1$\begingroup$ Rather than do this yourself, just use argon2 which has an explicit parameter for this. $\endgroup$– Stephen TousetJul 29, 2021 at 2:41
1 Answer
The goal of a pepper is to protect passwords in the event that a database of password hashes is compromised but other parts of the authentication system are not compromised.
Password hashing functions' output contains their input parameters, salt, and the digest, so obscuring it irretrievably via HMAC would make it impossible to verify a user's password. Storing the plaintext password hash output next to the "peppered" HMACed output would leak the "unpeppered" value. Therefore, you apply the pepper on the input.
Nothing about this differs from hash to hash, it's the same for bcrypt as it is for PBKDF2 or Argon2 or Pufferfish2 or any other Password Hashing Function...