Do all Linux distributions use the same cryptographic hash function

password

Do all Linux distributions use the same cryptographic hash function?

If yes, is it provided with the kernel itself?

EDIT:- I refer to the function mainly used for storing user login passwords.

Best Answer

No & no to your questions.

I'd take a look at the crypt(3) function for more info. From man crypt(3):

GNU EXTENSION

The glibc2 version of this function has the following additional features. If salt is a character string starting with the three characters $1$ followed by at most eight characters, and optionally terminated by $, then instead of using the DES machine, the glibc crypt function uses an MD5-based algorithm, and outputs up to 34 bytes, namely $1$&‹string›$, where ‹string› stands for the up to 8 characters following $1$ in the salt, followed by 22 bytes chosen from the set [a–zA–Z0–9./]. The entire key is significant here (instead of only the first 8 bytes).

You can check your pam setup to see whether you're using MD5 or DES:

$ egrep "password.*pam_unix.so" /etc/pam.d/system-auth
password    sufficient    pam_unix.so md5 shadow nis nullok try_first_pass use_authtok

And you can see in this systems /etc/shadow file that it's using MD5 as well:

root:$1$<DELETED PASSWORD HASH>:14245:0:99999:7:::

The codes you'll see in the /etc/shadow for each type of hashing:

  • $1 – MD5
  • $2 – blowfish
  • $2a – eksblowfish
  • $5 – SHA-256
  • $6 – SHA-512

On Red Hat distros you can change this using the authconfig command.

$ sudo authconfig --passalgo=sha512 --update

References

Related Question