7

I'm looking for a Java function to generate/verify password hashes that were encoded in the way crypt(3) does when storing them in the Linux "/etc/shadow" file if sha512 is activated in "/etc/pam.d/common-password".

The plaintext string "geheim" will translate to:

"$6$WoC532HB$LagBJ00vAGNGu8p9oeYDOSNZo9vTNTzOgPA.K0bJoiXfbcpj3jBuTkNwdzCrSNadRi8LanH1tH6tGGPPp/Lp3." 

From http://www.akkadia.org/drepper/SHA-crypt.txt I understand that, like with MD5, it's not just a SHA hash like DigestUtils or the Java MessageDigest classes produce but an algorithm that does a bit more magic.

1

3 Answers 3

5

I found Java implementations for all the new crypt() algorithms here: ftp://ftp.arlut.utexas.edu/java_hashes/

Sign up to request clarification or add additional context in comments.

4 Comments

Meanwhile the Apache Commons Codec project has complete support for all Linux crypt() algorithms!
I would appreciate a little info about where that link comes from. Downloading random jars can be a bad idea.
FYI the link is dead, and no archive.org version available. Do you have another source?
3

Take a look on Apache Commons Codec Digest

Also jBCrypt you may find useful.

In this article Modular Crypt Format or, a side note about a standard that isn’t a lot of details of Crypt3 format.

Comments

0

The othe question you refer to only provides links to the traditional crypt(3) method based on DES and the "$1$" method based on MD5. I need to check passwords that use the "$5$" method that is based on SHA-1 or even the "$6$" method that is based on SHA-512.

Based here means that crypt(3) uses e.g. SHA-512 but adds a salt value and does several iterations as described on http://www.akkadia.org/drepper/SHA-crypt.txt

2 Comments

After some searching I found at least one implementation of the $6$ mechanism based on SHA-512: tools.arlut.utexas.edu/gash2/doc/javadoc/arlut/csd/crypto/…
man 3 crypt → "NOTES" → "Features in glibc" → $5$ = SHA-256 (not SHA-1)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.