cdepillabout / password

datatypes and functions for easily working with passwords in Haskell
http://hackage.haskell.org/package/password
55 stars 16 forks source link

Be able to use different hash formats #11

Open Vlix opened 4 years ago

Vlix commented 4 years ago

Seeing as some algorithms encode the password hashes in different ways, it might be a good idea to add functionality to dictate how the hash will be output (hashPassword) and/or how it will be read (checkPassword).

This will make the interoperability better between different programs/other languages, and thus make it easier for someone to switch to Haskell, or use Haskell to operate on already existing password hashes.

Here's a list of examples of different formats

Vlix commented 2 years ago

Started testing some other password libraries for formats they output. All hashes use testpass as the password. And only formats that differ are listed here (so you'll not see any bcrypt or argon2, since those have predefined hash formats)

I'll just add to this message if I find more later on.


Python's Passlib (1.7)

For PBKDF2, Passlib seems to use the OpenBSD Base64 encoding (with ./0-9A-Za-z) and ignoring any trailing =s. (Passlib calls this Hash64. See footnote: #1)

For scrypt, Passlib takes the argon2 approach, using ln for the logN rounds, r for the memory work, and p for the parallellism.


Node scrypt

Github README Stackexchange explanation of the hash format

Example from the GitHub README (not self-generated):


PHPs PHPass(Lib) (>= v2.1)

PHPass(Lib) seems to use the same format as Python's passlib. using the OpenBSD Base64 (Hash64) encoding (with ./0-9A-Za-z) and ignoring any trailing =s.


python-pbkdf2

Weird output format, not sure if this is generally used anywhere.


Yesod.Auth.Util.PasswordStore

writePwHash uses the same format we use in Data.Password.Scrypt (which I think we carried over from the scrypt library)


#1: Passlib's explanation of CharMaps (Base64, AltBase64, Hash64, Bcrypt64)