Replace all '/' in path to File.separator - Code Refactor
This commit is contained in:
@@ -31,6 +31,7 @@ package fr.xephi.authme.security.pbkdf2;
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BinTools {
|
||||
|
||||
public static final String hex = "0123456789ABCDEF";
|
||||
|
||||
/**
|
||||
@@ -101,9 +102,7 @@ public class BinTools {
|
||||
if (c >= 'a' && c <= 'f') {
|
||||
return (c - 'a' + 10);
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"Input string may only contain hex digits, but found '" + c
|
||||
+ "'");
|
||||
throw new IllegalArgumentException("Input string may only contain hex digits, but found '" + c + "'");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -42,6 +42,7 @@ import javax.crypto.spec.SecretKeySpec;
|
||||
* @version 1.0
|
||||
*/
|
||||
public class MacBasedPRF implements PRF {
|
||||
|
||||
protected Mac mac;
|
||||
|
||||
protected int hLen;
|
||||
|
||||
@@ -32,6 +32,7 @@ package fr.xephi.authme.security.pbkdf2;
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface PBKDF2 {
|
||||
|
||||
/**
|
||||
* Convert String-based input to internal byte array, then invoke PBKDF2.
|
||||
* Desired key length defaults to Pseudo Random Function block size.
|
||||
|
||||
@@ -70,6 +70,7 @@ import java.security.SecureRandom;
|
||||
* @version 1.0
|
||||
*/
|
||||
public class PBKDF2Engine implements PBKDF2 {
|
||||
|
||||
protected PBKDF2Parameters parameters;
|
||||
|
||||
protected PRF prf;
|
||||
@@ -135,8 +136,7 @@ public class PBKDF2Engine implements PBKDF2 {
|
||||
if (dkLen == 0) {
|
||||
dkLen = prf.getHLen();
|
||||
}
|
||||
r = PBKDF2(prf, parameters.getSalt(), parameters.getIterationCount(),
|
||||
dkLen);
|
||||
r = PBKDF2(prf, parameters.getSalt(), parameters.getIterationCount(), dkLen);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -337,8 +337,7 @@ public class PBKDF2Engine implements PBKDF2 {
|
||||
byte[] salt = new byte[8];
|
||||
sr.nextBytes(salt);
|
||||
int iterations = 1000;
|
||||
PBKDF2Parameters p = new PBKDF2Parameters("HmacSHA1", "ISO-8859-1",
|
||||
salt, iterations);
|
||||
PBKDF2Parameters p = new PBKDF2Parameters("HmacSHA1", "ISO-8859-1", salt, iterations);
|
||||
PBKDF2Engine e = new PBKDF2Engine(p);
|
||||
p.setDerivedKey(e.deriveKey(password));
|
||||
candidate = formatter.toString(p);
|
||||
@@ -349,9 +348,7 @@ public class PBKDF2Engine implements PBKDF2 {
|
||||
p.setHashAlgorithm("HmacSHA1");
|
||||
p.setHashCharset("ISO-8859-1");
|
||||
if (formatter.fromString(p, candidate)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Candidate data does not have correct format (\""
|
||||
+ candidate + "\")");
|
||||
throw new IllegalArgumentException("Candidate data does not have correct format (\"" + candidate + "\")");
|
||||
}
|
||||
PBKDF2Engine e = new PBKDF2Engine(p);
|
||||
boolean verifyOK = e.verifyKey(password);
|
||||
|
||||
@@ -32,6 +32,7 @@ package fr.xephi.authme.security.pbkdf2;
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface PBKDF2Formatter {
|
||||
|
||||
/**
|
||||
* Convert parameters to String.
|
||||
*
|
||||
|
||||
@@ -32,6 +32,7 @@ package fr.xephi.authme.security.pbkdf2;
|
||||
* @version 1.0
|
||||
*/
|
||||
public class PBKDF2HexFormatter implements PBKDF2Formatter {
|
||||
|
||||
public boolean fromString(PBKDF2Parameters p, String s) {
|
||||
if (p == null || s == null) {
|
||||
return true;
|
||||
@@ -53,9 +54,7 @@ public class PBKDF2HexFormatter implements PBKDF2Formatter {
|
||||
}
|
||||
|
||||
public String toString(PBKDF2Parameters p) {
|
||||
String s = BinTools.bin2hex(p.getSalt()) + ":"
|
||||
+ String.valueOf(p.getIterationCount()) + ":"
|
||||
+ BinTools.bin2hex(p.getDerivedKey());
|
||||
String s = BinTools.bin2hex(p.getSalt()) + ":" + String.valueOf(p.getIterationCount()) + ":" + BinTools.bin2hex(p.getDerivedKey());
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ package fr.xephi.authme.security.pbkdf2;
|
||||
* @version 1.0
|
||||
*/
|
||||
public class PBKDF2Parameters {
|
||||
|
||||
protected byte[] salt;
|
||||
|
||||
protected int iterationCount;
|
||||
|
||||
@@ -32,6 +32,7 @@ package fr.xephi.authme.security.pbkdf2;
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface PRF {
|
||||
|
||||
/**
|
||||
* Initialize this instance with the user-supplied password.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user