password-hashes icon indicating copy to clipboard operation
password-hashes copied to clipboard

add bcrypt_simple and bcrypt_check

Open abonander opened this issue 5 years ago • 6 comments

These two functions are conspicuously missing from bcrypt-pbkdf2 compared to pbkdf2 and scrypt. It would be nice to have them to not have to worry about password string encoding or constant-time equality.

abonander avatar Jul 31 '20 01:07 abonander

Is there a well-defined MCF (or PHC, see #34) hash format for bcrypt-pbkdf2?

tarcieri avatar Jan 29 '21 15:01 tarcieri

There doesn't seem to be. In our use of bcrypt-pbkdf we ended up going with a custom PHC format using our own internal identifier, using just a rounds parameter.

I would probably say to use pbkdf2-bhash as the identifier which falls in line with the MCF convention for PBKDF2 with different SHA variants: https://passlib.readthedocs.io/en/stable/modular_crypt_format.html#application-defined-hashes

"bhash" being what the following page describes as the bcrypt-derivative used in this case: https://flak.tedunangst.com/post/bcrypt-pbkdf

Thus, for this crate, I propose the following:

$pbkdf2-bhash$rounds=<u32>$<salt>$<hash>

abonander avatar Mar 03 '21 19:03 abonander

The $pbkdf2-bhash identifier seems reasonable enough.

Regarding rounds, using a full word like that is a bit unprecedented given the existing PHC hashes we implement:

  • PBKDF2 uses i
  • scrypt uses n
  • Argon2 uses t

I would probably suggest i so as to match PBKDF2

tarcieri avatar Mar 04 '21 13:03 tarcieri

i sounds fine, that would save a few bytes per user of storage in databases.

abonander avatar Mar 04 '21 19:03 abonander

I think this would probably all be rolled into implementing the new password-hash API in bcrypt-pbkdf, correct?

abonander avatar Mar 04 '21 19:03 abonander

Yep. If you're interested feel free to open a PR, or otherwise I'll take a look when I have some time

tarcieri avatar Mar 04 '21 20:03 tarcieri

Since there's no interop story here, I'm not sure this makes sense.

bcrypt_pbkdf2 is really useful for deriving an encryption key for SSH private keys, not for general password strage.

tarcieri avatar Mar 05 '23 04:03 tarcieri