Reformatted all code files, cleaned up the project
This commit is contained in:
@@ -28,7 +28,7 @@ public class PasswordSecurity {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
public static String createSalt(int length)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
byte[] msg = new byte[40];
|
||||
rnd.nextBytes(msg);
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
|
||||
@@ -21,37 +21,37 @@ import java.security.SecureRandom;
|
||||
* BCrypt implements OpenBSD-style Blowfish password hashing using the scheme
|
||||
* described in "A Future-Adaptable Password Scheme" by Niels Provos and David
|
||||
* Mazieres.
|
||||
* <p>
|
||||
* <p/>
|
||||
* This password hashing system tries to thwart off-line password cracking using
|
||||
* a computationally-intensive hashing algorithm, based on Bruce Schneier's
|
||||
* Blowfish cipher. The work factor of the algorithm is parameterised, so it can
|
||||
* be increased as computers get faster.
|
||||
* <p>
|
||||
* <p/>
|
||||
* Usage is really simple. To hash a password for the first time, call the
|
||||
* hashpw method with a random salt, like this:
|
||||
* <p>
|
||||
* <p/>
|
||||
* <code>
|
||||
* String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt()); <br />
|
||||
* </code>
|
||||
* <p>
|
||||
* <p/>
|
||||
* To check whether a plaintext password matches one that has been hashed
|
||||
* previously, use the checkpw method:
|
||||
* <p>
|
||||
* <p/>
|
||||
* <code>
|
||||
* if (BCrypt.checkpw(candidate_password, stored_hash))<br />
|
||||
* System.out.println("It matches");<br />
|
||||
* else<br />
|
||||
* System.out.println("It does not match");<br />
|
||||
* </code>
|
||||
* <p>
|
||||
* <p/>
|
||||
* The gensalt() method takes an optional parameter (log_rounds) that determines
|
||||
* the computational complexity of the hashing:
|
||||
* <p>
|
||||
* <p/>
|
||||
* <code>
|
||||
* String strong_salt = BCrypt.gensalt(10)<br />
|
||||
* String stronger_salt = BCrypt.gensalt(12)<br />
|
||||
* </code>
|
||||
* <p>
|
||||
* <p/>
|
||||
* The amount of work increases exponentially (2**log_rounds), so each increment
|
||||
* is twice as much work. The default log_rounds is 10, and the valid range is 4
|
||||
* to 31.
|
||||
@@ -95,7 +95,7 @@ public class BCRYPT implements EncryptionMethod {
|
||||
* @return base64-encoded string * @throws IllegalArgumentException if the length is invalid * @throws IllegalArgumentException
|
||||
*/
|
||||
private static String encode_base64(byte d[], int len)
|
||||
throws IllegalArgumentException {
|
||||
throws IllegalArgumentException {
|
||||
int off = 0;
|
||||
StringBuffer rs = new StringBuffer();
|
||||
int c1, c2;
|
||||
@@ -150,7 +150,7 @@ public class BCRYPT implements EncryptionMethod {
|
||||
* @return an array containing the decoded bytes * @throws IllegalArgumentException if maxolen is invalid * @throws IllegalArgumentException
|
||||
*/
|
||||
private static byte[] decode_base64(String s, int maxolen)
|
||||
throws IllegalArgumentException {
|
||||
throws IllegalArgumentException {
|
||||
StringBuffer rs = new StringBuffer();
|
||||
int off = 0, slen = s.length(), olen = 0;
|
||||
byte ret[];
|
||||
@@ -513,7 +513,7 @@ public class BCRYPT implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return hashpw(password, salt);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class BCRYPT2Y implements EncryptionMethod {
|
||||
|
||||
/**
|
||||
* Method getHash.
|
||||
*
|
||||
* @param password String
|
||||
* @param salt String
|
||||
* @param name String
|
||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
if (salt.length() == 22)
|
||||
salt = "$2y$10$" + salt;
|
||||
return (BCRYPT.hashpw(password, salt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method comparePassword.
|
||||
*
|
||||
* @param hash String
|
||||
* @param password String
|
||||
* @param playerName String
|
||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
||||
*/
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String ok = hash.substring(0, 29);
|
||||
if (ok.length() != 29)
|
||||
return false;
|
||||
return hash.equals(getHash(password, ok, playerName));
|
||||
}
|
||||
|
||||
}
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class BCRYPT2Y implements EncryptionMethod {
|
||||
|
||||
/**
|
||||
* Method getHash.
|
||||
*
|
||||
* @param password String
|
||||
* @param salt String
|
||||
* @param name String
|
||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
if (salt.length() == 22)
|
||||
salt = "$2y$10$" + salt;
|
||||
return (BCRYPT.hashpw(password, salt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method comparePassword.
|
||||
*
|
||||
* @param hash String
|
||||
* @param password String
|
||||
* @param playerName String
|
||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
||||
*/
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String ok = hash.substring(0, 29);
|
||||
if (ok.length() != 29)
|
||||
return false;
|
||||
return hash.equals(getHash(password, ok, playerName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class CRAZYCRYPT1 implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
final String text = "ÜÄaeut//&/=I " + password + "7421€547" + name + "__+IÄIH§%NK " + password;
|
||||
try {
|
||||
final MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||
|
||||
@@ -19,7 +19,7 @@ public class CryptPBKDF2 implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
String result = "pbkdf2_sha256$10000$" + salt + "$";
|
||||
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000);
|
||||
PBKDF2Engine engine = new PBKDF2Engine(params);
|
||||
@@ -46,4 +46,4 @@ public class CryptPBKDF2 implements EncryptionMethod {
|
||||
return engine.verifyKey(password);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class CryptPBKDF2Django implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
String result = "pbkdf2_sha256$15000$" + salt + "$";
|
||||
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 15000);
|
||||
PBKDF2Engine engine = new PBKDF2Engine(params);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class DOUBLEMD5 implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getMD5(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
@@ -33,7 +33,7 @@ public class DOUBLEMD5 implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(getMD5(password));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public interface EncryptionMethod {
|
||||
* @return Hashing password * @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException;
|
||||
throws NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* @param hash
|
||||
@@ -36,6 +36,6 @@ public interface EncryptionMethod {
|
||||
* @return true if password match, false else * @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
boolean comparePassword(String hash, String password, String playerName)
|
||||
throws NoSuchAlgorithmException;
|
||||
throws NoSuchAlgorithmException;
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class IPB3 implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getMD5(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
@@ -35,7 +35,7 @@ public class IPB3 implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(getMD5(salt) + getMD5(password));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class JOOMLA implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getMD5(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
@@ -33,7 +33,7 @@ public class JOOMLA implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(password + salt) + ":" + salt;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class MD5 implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getMD5(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
@@ -33,7 +33,7 @@ public class MD5 implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(password);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class MD5VB implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getMD5(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
@@ -33,7 +33,7 @@ public class MD5VB implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return "$MD5vb$" + salt + "$" + getMD5(getMD5(password) + salt);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class MYBB implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getMD5(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
@@ -35,7 +35,7 @@ public class MYBB implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(getMD5(salt) + getMD5(password));
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ public class PHPBB implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return phpbb_hash(password, salt);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class PHPFUSION implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getSHA1(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
@@ -39,7 +39,7 @@ public class PHPFUSION implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
String digest = null;
|
||||
String algo = "HmacSHA256";
|
||||
String keyString = getSHA1(salt);
|
||||
|
||||
@@ -16,7 +16,7 @@ public class PLAINTEXT implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return password;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ROYALAUTH implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
for (int i = 0; i < 25; i++)
|
||||
password = hash(password, salt);
|
||||
return password;
|
||||
@@ -31,7 +31,7 @@ public class ROYALAUTH implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
public String hash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||
md.update(password.getBytes());
|
||||
byte byteData[] = md.digest();
|
||||
|
||||
@@ -17,7 +17,7 @@ public class SALTED2MD5 implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getMD5(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
@@ -35,7 +35,7 @@ public class SALTED2MD5 implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(getMD5(password) + salt);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class SALTEDSHA512 implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getSHA512(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest sha512 = MessageDigest.getInstance("SHA-512");
|
||||
sha512.reset();
|
||||
sha512.update(message.getBytes());
|
||||
@@ -35,7 +35,7 @@ public class SALTEDSHA512 implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getSHA512(password + salt);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class SHA1 implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getSHA1(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
@@ -33,7 +33,7 @@ public class SHA1 implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getSHA1(password);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class SHA256 implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getSHA256(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
|
||||
sha256.reset();
|
||||
sha256.update(message.getBytes());
|
||||
@@ -33,7 +33,7 @@ public class SHA256 implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return "$SHA$" + salt + "$" + getSHA256(getSHA256(password) + salt);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class SHA512 implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getSHA512(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest sha512 = MessageDigest.getInstance("SHA-512");
|
||||
sha512.reset();
|
||||
sha512.update(message.getBytes());
|
||||
@@ -33,7 +33,7 @@ public class SHA512 implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getSHA512(password);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class SMF implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getSHA1(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
@@ -33,7 +33,7 @@ public class SMF implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getSHA1(name.toLowerCase() + password);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class WBB3 implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getSHA1(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
@@ -35,7 +35,7 @@ public class WBB3 implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getSHA1(salt.concat(getSHA1(salt.concat(getSHA1(password)))));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public class WBB4 implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return BCRYPT.getDoubleHash(password, salt);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@ package fr.xephi.authme.security.crypts;
|
||||
|
||||
/**
|
||||
* The Whirlpool hashing function.
|
||||
* <p>
|
||||
* <p>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <b>References</b>
|
||||
* <p>
|
||||
* <p>
|
||||
* <p/>
|
||||
* <p/>
|
||||
* The Whirlpool algorithm was developed by <a
|
||||
* href="mailto:pbarreto@scopus.com.br">Paulo S. L. M. Barreto</a> and <a
|
||||
* href="mailto:vincent.rijmen@cryptomathic.com">Vincent Rijmen</a>.
|
||||
* <p>
|
||||
* <p/>
|
||||
* See P.S.L.M. Barreto, V. Rijmen, ``The Whirlpool hashing function,'' First
|
||||
* NESSIE workshop, 2000 (tweaked version, 2003),
|
||||
* <https://www.cosic.esat.kuleuven
|
||||
@@ -19,33 +19,33 @@ package fr.xephi.authme.security.crypts;
|
||||
* @author Paulo S.L.M. Barreto
|
||||
* @author Vincent Rijmen.
|
||||
* @version 3.0 (2003.03.12)
|
||||
* <p>
|
||||
* <p/>
|
||||
* ====================================================================
|
||||
* =========
|
||||
* <p>
|
||||
* <p/>
|
||||
* Differences from version 2.1:
|
||||
* <p>
|
||||
* <p/>
|
||||
* - Suboptimal diffusion matrix replaced by cir(1, 1, 4, 1, 8, 5, 2,
|
||||
* 9).
|
||||
* <p>
|
||||
* <p/>
|
||||
* ====================================================================
|
||||
* =========
|
||||
* <p>
|
||||
* <p/>
|
||||
* Differences from version 2.0:
|
||||
* <p>
|
||||
* <p/>
|
||||
* - Generation of ISO/IEC 10118-3 test vectors. - Bug fix: nonzero
|
||||
* carry was ignored when tallying the data length (this bug apparently
|
||||
* only manifested itself when feeding data in pieces rather than in a
|
||||
* single chunk at once).
|
||||
* <p>
|
||||
* <p/>
|
||||
* Differences from version 1.0:
|
||||
* <p>
|
||||
* <p/>
|
||||
* - Original S-box replaced by the tweaked, hardware-efficient
|
||||
* version.
|
||||
* <p>
|
||||
* <p/>
|
||||
* ====================================================================
|
||||
* =========
|
||||
* <p>
|
||||
* <p/>
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@@ -401,7 +401,7 @@ public class WHIRLPOOL implements EncryptionMethod {
|
||||
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) */
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
byte[] digest = new byte[DIGESTBYTES];
|
||||
NESSIEinit();
|
||||
NESSIEadd(password);
|
||||
|
||||
@@ -137,7 +137,7 @@ public class WORDPRESS implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
byte random[] = new byte[6];
|
||||
this.randomGen.nextBytes(random);
|
||||
return crypt(password, gensaltPrivate(stringToUtf8(new String(random))));
|
||||
|
||||
@@ -31,7 +31,7 @@ public class XAUTH implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
String hash = getWhirlpool(salt + password).toLowerCase();
|
||||
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
|
||||
return hash.substring(0, saltPos) + salt + hash.substring(saltPos);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class XF implements EncryptionMethod {
|
||||
*/
|
||||
@Override
|
||||
public String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getSHA256(getSHA256(password) + regmatch("\"salt\";.:..:\"(.*)\";.:.:\"hashFunc\"", salt));
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public class PBKDF2Engine implements PBKDF2 {
|
||||
* ISO-8559-1 encoding. Output result as
|
||||
* "Salt:iteration-count:PBKDF2" with binary data in hexadecimal
|
||||
* encoding.
|
||||
* <p>
|
||||
* <p/>
|
||||
* Example: Password "password" (without the quotes) leads to
|
||||
* 48290A0B96C426C3:1000:973899B1D4AFEB3ED371060D0797E0EE0142BD04
|
||||
*
|
||||
@@ -123,7 +123,7 @@ public class PBKDF2Engine implements PBKDF2 {
|
||||
* @throws IOException * @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
throws IOException, NoSuchAlgorithmException {
|
||||
throws IOException, NoSuchAlgorithmException {
|
||||
String password = "password";
|
||||
String candidate = null;
|
||||
PBKDF2Formatter formatter = new PBKDF2HexFormatter();
|
||||
|
||||
Reference in New Issue
Block a user