#685 Fix PBKDF2 implementation

- Fix our PBKDF2 hash implementation and its test class
- Use external dependency as PBKDF2 implementation
This commit is contained in:
ljacqu
2016-11-25 15:51:15 +01:00
parent 57e7c71d72
commit de5324bbc6
19 changed files with 46 additions and 1028 deletions
@@ -2,7 +2,9 @@ package fr.xephi.authme.security.crypts;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.security.crypts.description.AsciiRestricted;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.List;
@@ -100,6 +102,11 @@ public abstract class AbstractEncryptionMethodTest {
GIVEN_PASSWORDS[3], result3);
}
@BeforeClass
public static void setupLogger() {
TestHelper.setupLogger();
}
@Test
public void testGivenPasswords() {
// Start with the 2nd to last password if we skip long tests
@@ -1,9 +1,7 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.HooksSettings;
import org.junit.BeforeClass;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
@@ -13,11 +11,6 @@ import static org.mockito.Mockito.mock;
*/
public class BcryptTest extends AbstractEncryptionMethodTest {
@BeforeClass
public static void initializeLogger() {
TestHelper.setupLogger();
}
public BcryptTest() {
super(new BCRYPT(mockSettings()),
"$2a$10$6iATmYgwJVc3YONhVcZFve3Cfb5GnwvKhJ20r.hMjmcNkIT9.Uh9K", // password
@@ -1,18 +1,10 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.TestHelper;
import org.junit.BeforeClass;
/**
* Test for {@link CryptPBKDF2Django}.
*/
public class CryptPBKDF2DjangoTest extends AbstractEncryptionMethodTest {
@BeforeClass
public static void setupLogger() {
TestHelper.setupLogger();
}
public CryptPBKDF2DjangoTest() {
super(new CryptPBKDF2Django(),
"pbkdf2_sha256$15000$50a7ff2d7e00$t7Qx2CfzMhGEbyCa3Wk5nJvNjj3N+FdxhpwJDerl4Fs=", // password
@@ -1,20 +1,16 @@
package fr.xephi.authme.security.crypts;
import org.junit.Ignore;
/**
* Test for {@link CryptPBKDF2}.
*/
@Ignore
// TODO #685: This algorithm seems broken
public class CryptPBKDF2Test extends AbstractEncryptionMethodTest {
public CryptPBKDF2Test() {
super(new CryptPBKDF2(),
"pbkdf2_sha256$10000$dd9b1cd071f2$[82, -69, -58, -51, 101, 105, 61, -48, -49, 25, 50, -126, 115, 36, 16, -94, 4, 84, -94, 13, -115, -12, 94, -27, 94, -103, 115, -31, -56, -18, 8, 77, 36, 78, -61, 105, -7, -114, 41, 3, 48, 122, 27, 1, 56, 76, 126, 68, -120, 127, -95, 119, -7, 100, -87, -128, -77, 83, -118, 28, 43, 84, 73, 103]", // password
"pbkdf2_sha256$10000$4b3b650288cd$[99, 25, 45, 22, -66, -109, -109, 30, 117, 77, 22, 63, -36, -126, -116, -66, 35, 109, -33, -4, -112, 53, 48, 33, -20, 107, -100, -37, -89, 59, -29, -83, 57, -123, -40, 11, 98, 32, -74, 77, 107, -76, 95, -9, 110, -92, -31, -2, -18, 115, 43, -27, 16, 36, 75, -56, -11, 58, -62, 21, 0, 37, -59, -82]", // PassWord1
"pbkdf2_sha256$10000$035205f5ab39$[-121, -15, 97, 35, -105, -57, -49, -60, -58, -106, 101, 78, -103, 2, -116, -120, 0, 106, -107, 10, 78, -97, 111, 98, -15, 40, -53, 84, 120, -86, 116, 12, -60, 19, 105, 1, 71, 99, 4, 43, -4, -36, 35, -110, 59, 73, -20, -8, 46, 102, 51, 84, 54, -92, -41, -84, 28, 36, 37, 26, 90, -6, -49, 70]", // &^%te$t?Pw@_
"pbkdf2_sha256$10000$ca72ded579e9$[-81, 76, -103, 78, 68, -10, -58, -88, -57, 88, -38, 108, 115, -86, 13, -84, 80, 69, 48, 15, 105, 25, -2, 123, 9, 97, 23, -96, 95, -64, -56, 59, -124, 116, 36, 10, 96, -12, -76, -121, -51, 76, -96, -27, 84, 66, 85, 75, 95, -97, -60, -98, -41, -32, -58, 39, 82, -19, -25, 98, -15, -68, 59, -48]"); // âË_3(íù*
"pbkdf2_sha256$10000$b25801311edf$093E38B16DFF13FCE5CD64D5D888EE6E0376A3E572FE5DA6749515EA0F384413223A21C464B0BE899E64084D1FFEFD44F2AC768453C87F41B42CC6954C416900", // password
"pbkdf2_sha256$10000$fe705da06c57$A41527BD58FED9C9E6F452FC1BA8B0C4C4224ECC63E37F71EB1A0865D2AB81BBFEBCA9B7B6A6E8AEF4717B43F8EB6FB4EDEFFBB399D9D991EF7E23013595BAF0", // PassWord1
"pbkdf2_sha256$10000$05603593cdda$1D30D1D90D826C866755969F06C312E21CC3E8DA0B777E2C764700E4E1FD890B731FAF44753D68F3FC025D3EAA709E800FBF2AF61DB23464311FCE7D35353A30", // &^%te$t?Pw@_
"pbkdf2_sha256$10000$fb944d66d754$F7E3BF8CB07CE3B3C8C5C534F803252F7B4FD58832E33BA62BA46CA06F23BAE12BE03A9CB5874BCFD4469E42972406F920E59F002247B23C22A8CF3D0E7BFFE0"); // âË_3(íù*
}
}
@@ -1,18 +1,10 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.TestHelper;
import org.junit.BeforeClass;
/**
* Test for {@link IPB4}.
*/
public class IPB4Test extends AbstractEncryptionMethodTest {
@BeforeClass
public static void setUpSettings() {
TestHelper.setupLogger();
}
public IPB4Test() {
super(new IPB4(),
new HashedPassword("$2a$13$leEvXu77OIwPwNvtZIJvaeAx8EItGHuR3nIlq8416g0gXeJaQdrr2", "leEvXu77OIwPwNvtZIJval"), //password
@@ -1,18 +1,10 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.TestHelper;
import org.junit.BeforeClass;
/**
* Test for {@link XFBCRYPT}.
*/
public class XFBCRYPTTest extends AbstractEncryptionMethodTest {
@BeforeClass
public static void setup() {
TestHelper.setupLogger();
}
public XFBCRYPTTest() {
super(new XFBCRYPT(),
"$2a$10$UtuON/ZG.x8EWG/zQbryB.BHfQVrfxk3H7qykzP.UJQ8YiLjZyfqq", // password