Change config to refer to BCryptWorkFactor instead of WorkFactor.

Change default work factor to 7.
This commit is contained in:
Lucas Nicodemus 2015-04-13 11:33:04 -06:00
parent 08fae75c0c
commit e55c37728f
2 changed files with 5 additions and 5 deletions

View file

@ -399,7 +399,7 @@ namespace TShockAPI
public bool SaveWorldOnLastPlayerExit = true; public bool SaveWorldOnLastPlayerExit = true;
[Description("Determines the BCrypt work factor to use. If increased, all passwords will be upgraded to new work-factor on verify. Range: 5-31.")] [Description("Determines the BCrypt work factor to use. If increased, all passwords will be upgraded to new work-factor on verify. Range: 5-31.")]
public int WorkFactor = 10; public int BCryptWorkFactor = 7;
/// <summary> /// <summary>
/// Reads a configuration file from a given path /// Reads a configuration file from a given path

View file

@ -374,7 +374,7 @@ namespace TShockAPI.DB
// Convert the password to BCrypt, and save it. // Convert the password to BCrypt, and save it.
try { try {
this.Password = BCrypt.Net.BCrypt.HashPassword(password, TShock.Config.WorkFactor); this.Password = BCrypt.Net.BCrypt.HashPassword(password, TShock.Config.BCryptWorkFactor);
} catch (ArgumentOutOfRangeException) { } catch (ArgumentOutOfRangeException) {
TShock.Log.ConsoleError("Invalid BCrypt work factor! Upgrading user password to BCrypt using default work factor."); TShock.Log.ConsoleError("Invalid BCrypt work factor! Upgrading user password to BCrypt using default work factor.");
this.Password = BCrypt.Net.BCrypt.HashPassword(password); this.Password = BCrypt.Net.BCrypt.HashPassword(password);
@ -394,9 +394,9 @@ namespace TShockAPI.DB
// If the destination work factor is not greater, we won't upgrade it or re-hash it // If the destination work factor is not greater, we won't upgrade it or re-hash it
int currentWorkFactor = Convert.ToInt32((this.Password.Split('$')[2])); int currentWorkFactor = Convert.ToInt32((this.Password.Split('$')[2]));
if (currentWorkFactor < TShock.Config.WorkFactor) { if (currentWorkFactor < TShock.Config.BCryptWorkFactor) {
try { try {
this.Password = BCrypt.Net.BCrypt.HashPassword(password, TShock.Config.WorkFactor); this.Password = BCrypt.Net.BCrypt.HashPassword(password, TShock.Config.BCryptWorkFactor);
} catch (ArgumentOutOfRangeException) { } catch (ArgumentOutOfRangeException) {
TShock.Log.ConsoleError("Invalid BCrypt work factor! Refusing to change work-factor on exsting password."); TShock.Log.ConsoleError("Invalid BCrypt work factor! Refusing to change work-factor on exsting password.");
} }
@ -411,7 +411,7 @@ namespace TShockAPI.DB
public void CreateBCryptHash(string password) { public void CreateBCryptHash(string password) {
try { try {
this.Password = BCrypt.Net.BCrypt.HashPassword(password, TShock.Config.WorkFactor); this.Password = BCrypt.Net.BCrypt.HashPassword(password, TShock.Config.BCryptWorkFactor);
} catch (ArgumentOutOfRangeException) { } catch (ArgumentOutOfRangeException) {
TShock.Log.ConsoleError("Invalid BCrypt work factor! Creating new hash using default work factor."); TShock.Log.ConsoleError("Invalid BCrypt work factor! Creating new hash using default work factor.");
this.Password = BCrypt.Net.BCrypt.HashPassword(password); this.Password = BCrypt.Net.BCrypt.HashPassword(password);