#1150 - Add Argon2 support
- Add argon2 implementation - Extract argon2 library check to method on Argon 2 - Add link to Wiki page on errors - Check within Argon2Test if the test cases should be run, not in the abstract parent
This commit is contained in:
committed by
GitHub
parent
90a7b47217
commit
8fe92da119
@@ -2,6 +2,7 @@ package fr.xephi.authme.security;
|
||||
|
||||
import ch.jalu.injector.Injector;
|
||||
import ch.jalu.injector.InjectorBuilder;
|
||||
import fr.xephi.authme.security.crypts.Argon2;
|
||||
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||
import fr.xephi.authme.security.crypts.description.Recommendation;
|
||||
@@ -61,6 +62,10 @@ public class HashAlgorithmIntegrationTest {
|
||||
// given / when / then
|
||||
for (HashAlgorithm algorithm : HashAlgorithm.values()) {
|
||||
if (!HashAlgorithm.CUSTOM.equals(algorithm) && !HashAlgorithm.PLAINTEXT.equals(algorithm)) {
|
||||
if (HashAlgorithm.ARGON2.equals(algorithm) && !Argon2.isLibraryLoaded()) {
|
||||
System.out.println("[WARNING] Cannot find argon2 library, skipping integration test");
|
||||
continue;
|
||||
}
|
||||
EncryptionMethod method = injector.createIfHasDependencies(algorithm.getClazz());
|
||||
if (method == null) {
|
||||
fail("Could not create '" + algorithm.getClazz() + "' - forgot to provide some class?");
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assume.assumeThat;
|
||||
|
||||
/**
|
||||
* Test for {@link Argon2}.
|
||||
*/
|
||||
public class Argon2Test extends AbstractEncryptionMethodTest {
|
||||
|
||||
private static final boolean IS_LIBRARY_LOADED = Argon2.isLibraryLoaded();
|
||||
|
||||
public Argon2Test() {
|
||||
super(new Argon2(),
|
||||
"$argon2i$v=19$m=65536,t=2,p=1$dOP8NiXsPTcMgzI4Z8Rbew$ShdowtoTEWTL5UTFz1UgQOigb9JOlm4ZxWPA6WbIeUw", // password
|
||||
"$argon2i$v=19$m=65536,t=2,p=1$amZHbPfgc5peKd/4w1AI1g$Q2PUiOVw47TACijP57U0xf7QfiZ00HV4eFzMDA6yKRE", // PassWord1
|
||||
"$argon2i$v=19$m=65536,t=2,p=1$58v7dWNn9/bpD00QLzSebw$7cMC7p0qceE3Mgf2yQp4X7c+UkO9oyJwQ7S6XTBubNs", // &^%te$t?Pw@_
|
||||
"$argon2i$v=19$m=65536,t=2,p=1$93OSU71DgBOzpmhti7+6rQ$sSSI6QQQdoG9DlGwLjYz576kTek89nwr9CyNpy6bsL0"); // âË_3(íù*
|
||||
|
||||
assumeThat("Argon2 library is not loaded - skipping test",
|
||||
IS_LIBRARY_LOADED, equalTo(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean testHashEqualityForSameSalt() {
|
||||
// Argon2 has a salt but it is handled internally
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user