Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot parse sha256/sha512 Password-Hashes #576

Open
C0D3-M4513R opened this issue Mar 6, 2025 · 6 comments
Open

Cannot parse sha256/sha512 Password-Hashes #576

C0D3-M4513R opened this issue Mar 6, 2025 · 6 comments

Comments

@C0D3-M4513R
Copy link
Contributor

C0D3-M4513R commented Mar 6, 2025

I cannot parse sha256_crypt or sha512_crypt Password-Hashes with this library, because none of the encodings fit.

I tested with the password password hashed by https://www.dcode.fr/crypt-hashing-function to sha512 at 5000 rounds: $6$$bLTg4cpho8PIUrjfsE7qlU08Qx2UEfw..xOc6I1wpGVtyVYToGrr7BzRdAAnEr5lYFr1Z9WcCf1xNZ1HG9qFW1.

The crate you use for decoding the output hash seems to have a Decoder/Encoder ready for that use-case: Base64ShaCrypt

Edit: I also just realised, that this probably belongs to https://github.com/RustCrypto/traits/

@tarcieri
Copy link
Member

tarcieri commented Mar 6, 2025

Please provide a complete reproduction of the problem

@C0D3-M4513R
Copy link
Contributor Author

C0D3-M4513R commented Mar 6, 2025

password_hash::Encoding::Crypt can be swapped out for any existing encoding, and the decode will fail

password_hash::Output::decode("bLTg4cpho8PIUrjfsE7qlU08Qx2UEfw..xOc6I1wpGVtyVYToGrr7BzRdAAnEr5lYFr1Z9WcCf1xNZ1HG9qFW1", password_hash::Encoding::Crypt).expect("Expected Hash to decode")

@C0D3-M4513R
Copy link
Contributor Author

C0D3-M4513R commented Mar 6, 2025

Seems like this was already addressed in RustCrypto/traits@fd48936 , but I don't have that yet, because I am still using the 2 years old version 0.5.0 and 0.6.0 is still in release candidate stage after 8 months.

@tarcieri
Copy link
Member

tarcieri commented Mar 6, 2025

The only support for that hash format is in the sha-crypt crate.

It's a legacy MCF encoding (where MCF isn't really a "standard" but a collection of algorithm-specific encodings), whereas the password-hash crate supports the PHC string format.

@C0D3-M4513R
Copy link
Contributor Author

I want my application to support lazily re-hashing the passwords though.
I have made wrappers (in my app) for sha-crypt and bcrypt-pbkf for that exact purpose to support password-hash.

@tarcieri
Copy link
Member

tarcieri commented Mar 6, 2025

We'd need to look into if there are proper PHC encodings for sha-crypt hashes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants