Always specify Locale on toLowerCase and toUpperCase usages, fixes AuthMe not working correctly on machines with turkish locale. ('I'.toLowerCase() => 'ı')

This commit is contained in:
Gabriele C
2022-08-20 04:41:04 +02:00
parent c38e2aba28
commit 75b3a571e1
67 changed files with 217 additions and 143 deletions
@@ -7,6 +7,8 @@ import fr.xephi.authme.security.crypts.description.SaltType;
import fr.xephi.authme.security.crypts.description.Usage;
import fr.xephi.authme.util.RandomStringUtils;
import java.util.Locale;
import static fr.xephi.authme.security.HashUtils.isEqual;
/**
@@ -29,7 +31,7 @@ public class Smf implements EncryptionMethod {
@Override
public String computeHash(String password, String salt, String name) {
return HashUtils.sha1(name.toLowerCase() + password);
return HashUtils.sha1(name.toLowerCase(Locale.ROOT) + password);
}
@Override
@@ -3,6 +3,8 @@ package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.Usage;
import java.util.Locale;
import static fr.xephi.authme.security.HashUtils.isEqual;
@Recommendation(Usage.RECOMMENDED)
@@ -19,7 +21,7 @@ public class XAuth extends HexSaltedMethod {
@Override
public String computeHash(String password, String salt, String name) {
String hash = getWhirlpool(salt + password).toLowerCase();
String hash = getWhirlpool(salt + password).toLowerCase(Locale.ROOT);
int saltPos = password.length() >= hash.length() ? hash.length() - 1 : password.length();
return hash.substring(0, saltPos) + salt + hash.substring(saltPos);
}