diff --git a/.vs/SecureCore/v16/.suo b/.vs/SecureCore/v16/.suo index 70d44bb..c4dc54f 100644 Binary files a/.vs/SecureCore/v16/.suo and b/.vs/SecureCore/v16/.suo differ diff --git a/SecureCore/Authentication/PasswordManager.cs b/SecureCore/Authentication/PasswordManager.cs index 7925ca4..7a22d57 100644 --- a/SecureCore/Authentication/PasswordManager.cs +++ b/SecureCore/Authentication/PasswordManager.cs @@ -8,17 +8,22 @@ namespace SecureCore.Authentication { //Add some pepper to the passwords for good measure: //https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html - public static string Pepper { get; } = "rVk/OwQUw01qy76Q+5WimPk+NdqUMMghftMXyJzzckOj/+eFn056PDYzBD61E/ZNjRdgiMK6RhcHEcdfpJdbcw=="; + private static string Pepper { get; } = "rVk/OwQUw01qy76Q+5WimPk+NdqUMMghftMXyJzzckOj/+eFn056PDYzBD61E/ZNjRdgiMK6RhcHEcdfpJdbcw=="; private static string ConnectionString = @"Server=DESKTOP-OEDDVKC\SQLEXPRESS;Database=main;Integrated Security=true;"; + private static int Iterations { get; } = 100000; + private static KeyDerivationPrf KeyType { get; } = KeyDerivationPrf.HMACSHA512; + private static int KeySize { get; } = 512 / 8; + private static int SaltSize { get; } = 128 / 8; //128 bit salt + public PasswordManager() { } public static (string Hash, string Salt) HashPassword(string password) { - var salt = new byte[Settings.SaltSize]; + var salt = new byte[SaltSize]; ByteGenerator.GetRandomBytes(ref salt); @@ -72,7 +77,7 @@ namespace SecureCore.Authentication private static string GetHash(string password, byte[] salt) { - return Convert.ToBase64String(KeyDerivation.Pbkdf2($"{password}{Pepper}", salt, Settings.KeyType, Settings.Iterations, Settings.KeySize)); + return Convert.ToBase64String(KeyDerivation.Pbkdf2($"{password}{Pepper}", salt, KeyType, Iterations, KeySize)); } } } diff --git a/SecureCore/Authentication/SessionManager.cs b/SecureCore/Authentication/SessionManager.cs index 5009182..9381245 100644 --- a/SecureCore/Authentication/SessionManager.cs +++ b/SecureCore/Authentication/SessionManager.cs @@ -7,9 +7,11 @@ namespace SecureCore.Authentication { public class SessionManager { + private static int SessionKeySize { get; } = 32; //32 bytes + public static string CreateSessionToken() { - var token = new byte[Settings.SessionKeySize]; + var token = new byte[SessionKeySize]; ByteGenerator.GetRandomBytes(ref token); diff --git a/SecureCore/Authentication/Settings.cs b/SecureCore/Authentication/Settings.cs deleted file mode 100644 index bb3ce7b..0000000 --- a/SecureCore/Authentication/Settings.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Microsoft.AspNetCore.Cryptography.KeyDerivation; - -namespace SecureCore.Authentication -{ - public static class Settings - { - public static int Iterations { get; } = 100000; - public static KeyDerivationPrf KeyType { get; } = KeyDerivationPrf.HMACSHA512; - public static int KeySize { get; } = 512 / 8; - public static int SaltSize { get; } = 128 / 8; //128 bit salt - public static int SessionKeySize { get; } = 32; //32 bytes - } -}