Make it so we can login to accounts created with TC
This commit is contained in:
@@ -86,7 +86,7 @@ namespace BNetServer.Networking
|
||||
uint loginTicketExpiry = result.Read<uint>(4);
|
||||
bool isBanned = result.Read<ulong>(5) != 0;
|
||||
|
||||
if (CalculateShaPassHash(login, password) == pass_hash)
|
||||
if (CalculateShaPassHash(login.ToUpper(), password.ToUpper()) == pass_hash)
|
||||
{
|
||||
if (loginTicket.IsEmpty() || loginTicketExpiry < Time.UnixTime)
|
||||
{
|
||||
@@ -168,8 +168,8 @@ namespace BNetServer.Networking
|
||||
string CalculateShaPassHash(string name, string password)
|
||||
{
|
||||
SHA256 sha256 = SHA256.Create();
|
||||
var i = sha256.ComputeHash(Encoding.UTF8.GetBytes(name));
|
||||
return sha256.ComputeHash(Encoding.UTF8.GetBytes(i.ToHexString() + ":" + password)).ToHexString();
|
||||
var email = sha256.ComputeHash(Encoding.UTF8.GetBytes(name));
|
||||
return sha256.ComputeHash(Encoding.UTF8.GetBytes(email.ToHexString() + ":" + password)).ToHexString(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,9 +36,12 @@ namespace System
|
||||
return (lValue & lFlag) != 0;
|
||||
}
|
||||
|
||||
public static string ToHexString(this byte[] byteArray)
|
||||
public static string ToHexString(this byte[] byteArray, bool reverse = false)
|
||||
{
|
||||
return byteArray.Aggregate("", (current, b) => current + b.ToString("X2"));
|
||||
if (reverse)
|
||||
return byteArray.Reverse().Aggregate("", (current, b) => current + b.ToString("X2"));
|
||||
else
|
||||
return byteArray.Aggregate("", (current, b) => current + b.ToString("X2"));
|
||||
}
|
||||
|
||||
public static byte[] ToByteArray(this string str)
|
||||
|
||||
@@ -45,13 +45,13 @@ namespace Game
|
||||
if (GetId(username) != 0)
|
||||
return AccountOpResult.NameAlreadyExist; // username does already exist
|
||||
|
||||
(byte[] salt, byte[] verifier) registrationData = SRP6.MakeRegistrationData(username, password);
|
||||
(byte[] salt, byte[] verifier) = SRP6.MakeRegistrationData(username, password);
|
||||
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_ACCOUNT);
|
||||
stmt.AddValue(0, username);
|
||||
stmt.AddValue(1, registrationData.Item1);
|
||||
stmt.AddValue(2, registrationData.Item2);
|
||||
stmt.AddValue(2, email);
|
||||
stmt.AddValue(1, salt);
|
||||
stmt.AddValue(2, verifier);
|
||||
stmt.AddValue(3, email);
|
||||
stmt.AddValue(4, email);
|
||||
if (bnetAccountId != 0 && bnetIndex != 0)
|
||||
{
|
||||
@@ -163,10 +163,10 @@ namespace Game
|
||||
stmt.AddValue(1, accountId);
|
||||
DB.Login.Execute(stmt);
|
||||
|
||||
(byte[] salt, byte[] verifier) registrationData = SRP6.MakeRegistrationData(newUsername, newPassword);
|
||||
(byte[] salt, byte[] verifier) = SRP6.MakeRegistrationData(newUsername, newPassword);
|
||||
stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_LOGON);
|
||||
stmt.AddValue(0, registrationData.salt);
|
||||
stmt.AddValue(1, registrationData.verifier);
|
||||
stmt.AddValue(0, salt);
|
||||
stmt.AddValue(1, verifier);
|
||||
stmt.AddValue(2, accountId);
|
||||
DB.Login.Execute(stmt);
|
||||
|
||||
@@ -190,11 +190,11 @@ namespace Game
|
||||
if (newPassword.Length > MaxAccountLength)
|
||||
return AccountOpResult.PassTooLong;
|
||||
|
||||
(byte[] salt, byte[] verifier) registrationData = SRP6.MakeRegistrationData(username, newPassword);
|
||||
(byte[] salt, byte[] verifier) = SRP6.MakeRegistrationData(username, newPassword);
|
||||
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_LOGON);
|
||||
stmt.AddValue(0, registrationData.salt);
|
||||
stmt.AddValue(1, registrationData.verifier);
|
||||
stmt.AddValue(0, salt);
|
||||
stmt.AddValue(1, verifier);
|
||||
stmt.AddValue(2, accountId);
|
||||
DB.Login.Execute(stmt);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Game
|
||||
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_BNET_ACCOUNT);
|
||||
stmt.AddValue(0, email);
|
||||
stmt.AddValue(1, CalculateShaPassHash(email, password));
|
||||
stmt.AddValue(1, CalculateShaPassHash(email.ToUpper(), password.ToUpper()));
|
||||
DB.Login.DirectExecute(stmt);
|
||||
|
||||
uint newAccountId = GetId(email);
|
||||
@@ -176,7 +176,7 @@ namespace Game
|
||||
{
|
||||
SHA256 sha256 = SHA256.Create();
|
||||
var i = sha256.ComputeHash(Encoding.UTF8.GetBytes(name));
|
||||
return sha256.ComputeHash(Encoding.UTF8.GetBytes(i.ToHexString() + ":" + password)).ToHexString();
|
||||
return sha256.ComputeHash(Encoding.UTF8.GetBytes(i.ToHexString() + ":" + password)).ToHexString(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user