-
Notifications
You must be signed in to change notification settings - Fork 27
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
Argon2 not working as expected #92
Comments
I realized that I have to use the method @Test
public void test_verify()
{
String hash = "$argon2id$v=19$m=16384,t=2,p=1$nlm7oNI5zquzSYkyby6oVw$JOkJAYrDB0i2gmiJrXC6o2r+u1rszCm/RO9gIQtnxlY";
Argon2Function function = Argon2Function.getInstanceFromHash(hash);
boolean verified = Password.check("Test123!", hash).with(function);
assertTrue(verified);
} |
Hi @anton-johansson, thank you for opening this issue. It might be an issue related to the salt encoding. When you use At first glance, it seems something related to the bytes padding during the encoding/decoding of the salt. Do you have other cases like this (password4j fails but not argon2.online)? What libraryhave you used to generate those? |
I've used the Node Argon2 library which is built on a native library written in C. But I think you're right. When I generate new hashes using |
Hello @anton-johansson ,
Thank you very much for pointing out this issue! |
@firaja That works like a charm, thanks for the quick support and fix! I accidentally noticed something else though. See this test: @Test
public void test_using_function_directly()
{
String hash = "$argon2id$v=19$m=16384,t=2,p=1$nlm7oNI5zquzSYkyby6oVw$JOkJAYrDB0i2gmiJrXC6o2r+u1rszCm/RO9gIQtnxlY";
Argon2Function function = Argon2Function.getInstanceFromHash(hash);
boolean test1 = Password.check("Test123!", hash).with(function);
assertTrue(test1);
boolean test2 = function.check("Test123!", hash);
assertTrue(test2);
} When using the function directly to check, it doesn't work. This is not the case with for example Bcrypt. Not a big deal for me, I'll use the first way, but I thought you should know. Maybe extract this to a separate issue? Or ignore, it's up to you. :) |
I will open a different issue but this one has lower priority: Thank you again. |
Hello @firaja, I am still seeing an issue with Argon2 in version 1.6.3 I have this test that passes with version 1.6.1: @Test
void testHashMatch() {
String plaintext = "password";
String hashed = "$argon2id$v=19$m=15,t=2,p=1$and1aHgwcThpM2EwMDAwMA$+GgRQ1NSPghlIAUWlO1mVTktS"
+ "QVSj35tUNvLiVfWiB0";
assertTrue(Password.check(plaintext, hashed).withArgon2());
} But it fails with 1.6.2 and 1.6.3. I generated the hashed version from the online generator https://argon2.online/ as well. Any ideas what is going on? |
@RohanNagar Hi! If you just use |
Thanks @anton-johansson! I will try this. I am curious as to why it passes consistently with version 1.6.1 though. Did some default settings change? |
Hi @RohanNagar , When you use |
Got it, thank you for the clarification! |
Describe the bug
I've been using Argon2 in an application not written in Java. Now, I want to start checking those Argon2 hashes in my Java application using password4j.
My other application has generated an Argon2 hash that looks like this:
The clear text password for this is
Test123!
. If I fill in those values on this online checker, things work exactly the way I want it:https://argon2.online
But when I use password4j, I always get
false
when running it like this:I've also noticed that it seems to ignore the configuration values in the hash itself (such as
t=2
andp=1
). I've tried setting them to match the hash, but that shouldn't be necessary...To Reproduce
See Java code above.
Expected behavior
I expect the above to yield
true
.Environment:
Additional context
N/A.
The text was updated successfully, but these errors were encountered: