-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
"salt" option property does not work #943
Comments
@Jazza-231 what version of the package are you using? This should have been addressed by #899 raised by #893 and fixed in v2+ |
I couldn't tell you I'm sorry, I have no version history on the project that used it, and that has been since deleted as it was just a test. |
Just ran a quick test, it seems the original issue of the hash function ignoring salt was fixed, BUT, the verify function still does not respect the provided salt. So it seems you are correct. A quick workaround would be to use hash again instead of verify using the same argon params and comparing them manually - but that shouldn't ever be required or used as a long term solution, and totally negates the point of having a verify function in the first place. @Brooooooklyn could you take another look please? |
Actually, my last post was incorrect. I just remembered the salt is included in the encoded password hash
So it doesn't need to be supplied to the verify function. And as per the Rust implementation's docs
So this is actually working as expected.. similar to any other password hasher that is encoded to the PHC format, which includes the salt in the output string. It simplifies having to store all parameters of the underlying hashing function manually and enables you to change your argon2 options at any time, without breaking previously generated passwords. So the real solution to @Jazza-231's intended usage of the salt, would be to use it as the 'secret' param instead. But it would still be possible to use your own generated salt AND secret as options when generating password hashes, and then supplying the secret when verifying. @Brooooooklyn perhaps it would be a good idea to change the TS types of the options parameter for the verify/verifySync methods to Pick<Options, 'secret'>. And reflect that change in the README. Hopefully that should prevent any confusion. Edit: |
I have two guesses: it is a bug, or it was not marked as deprecated in the types. Here is my testing:
This is one I can't explain too well.
This creates a salt using generateRandomString from
@oslojs/crypto/random
.It then uses hash from
@node-rs/argon2
:According to the types, salt is a correct property of Options, and is NOT marked as deprecated.
I then use the verify function from the same package, giving it the same password, and the hash created earlier, BUT i modofy the salt being passed.
This shows that the verify function that verifies the password against the hashed password, with a completely different salt input still passes.
Back to the fact I said it was not marked as deprecated, nowhere in the documentation nor the types does it say this. It also returns no error. However, using the secret prop instead of the salt prop now properly fails the verify function when the fake salt is given.
The text was updated successfully, but these errors were encountered: