Removed redundant code, fixed some warnings, other minor fixes

This commit is contained in:
Tim Visée
2015-11-23 22:18:04 +01:00
parent 82bf0f45ca
commit 09067ddbd1
9 changed files with 21 additions and 25 deletions
@@ -4,6 +4,7 @@ import fr.xephi.authme.security.pbkdf2.PBKDF2Engine;
import fr.xephi.authme.security.pbkdf2.PBKDF2Parameters;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
/**
*/
@@ -25,7 +26,7 @@ public class CryptPBKDF2 implements EncryptionMethod {
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000);
PBKDF2Engine engine = new PBKDF2Engine(params);
return result + String.valueOf(engine.deriveKey(password, 64));
return result + Arrays.toString(engine.deriveKey(password, 64));
}
/**
@@ -41,7 +41,7 @@ public interface PBKDF2 {
*
* @return internal byte array
*/
public abstract byte[] deriveKey(String inputPassword);
byte[] deriveKey(String inputPassword);
/**
* Convert String-based input to internal byte array, then invoke PBKDF2.
@@ -51,7 +51,7 @@ public interface PBKDF2 {
*
* @return internal byte array
*/
public abstract byte[] deriveKey(String inputPassword, int dkLen);
byte[] deriveKey(String inputPassword, int dkLen);
/**
* Convert String-based input to internal byte arrays, then invoke PBKDF2
@@ -63,28 +63,28 @@ public interface PBKDF2 {
* @return <code>true</code> password match; <code>false</code> incorrect
* password
*/
public abstract boolean verifyKey(String inputPassword);
boolean verifyKey(String inputPassword);
/**
* Allow reading of configured parameters.
*
* @return Currently set parameters.
*/
public abstract PBKDF2Parameters getParameters();
PBKDF2Parameters getParameters();
/**
* Allow setting of configured parameters.
*
* @param parameters
*/
public abstract void setParameters(PBKDF2Parameters parameters);
void setParameters(PBKDF2Parameters parameters);
/**
* Get currently set Pseudo Random Function.
*
* @return Currently set Pseudo Random Function
*/
public abstract PRF getPseudoRandomFunction();
PRF getPseudoRandomFunction();
/**
* Set the Pseudo Random Function to use. Note that deriveKeys/getPRF does
@@ -93,5 +93,5 @@ public interface PBKDF2 {
*
* @param prf Pseudo Random Function to set.
*/
public abstract void setPseudoRandomFunction(PRF prf);
void setPseudoRandomFunction(PRF prf);
}
@@ -40,7 +40,7 @@ public interface PBKDF2Formatter {
*
* @return String representation
*/
public abstract String toString(PBKDF2Parameters p);
String toString(PBKDF2Parameters p);
/**
* Convert String to parameters. Depending on actual implementation, it may
@@ -52,5 +52,5 @@ public interface PBKDF2Formatter {
* @return <code>false</code> syntax OK, <code>true</code> some syntax
* issue.
*/
public abstract boolean fromString(PBKDF2Parameters p, String s);
boolean fromString(PBKDF2Parameters p, String s);
}
@@ -47,7 +47,7 @@ public class PBKDF2HexFormatter implements PBKDF2Formatter {
}
String[] p123 = s.split(":");
if (p123 == null || p123.length != 3) {
if (p123.length != 3) {
return true;
}
@@ -39,7 +39,7 @@ public interface PRF {
* @param P The password supplied as array of bytes. It is the caller's
* task to convert String passwords to bytes as appropriate.
*/
public void init(byte[] P);
void init(byte[] P);
/**
* Pseudo Random Function
@@ -49,12 +49,12 @@ public interface PRF {
*
* @return Random bytes of hLen length.
*/
public byte[] doFinal(byte[] M);
byte[] doFinal(byte[] M);
/**
* Query block size of underlying algorithm/mechanism.
*
* @return block size
*/
public int getHLen();
int getHLen();
}