From 3cf5bf80e4feea06728947f20657d49268b785d5 Mon Sep 17 00:00:00 2001 From: vnugent Date: Fri, 8 Sep 2023 23:21:30 -0400 Subject: Password hashing updates & async resource updates --- .../src/ManagedPasswordHashing.cs | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'lib/VNLib.Plugins.Extensions.Loading/src/ManagedPasswordHashing.cs') diff --git a/lib/VNLib.Plugins.Extensions.Loading/src/ManagedPasswordHashing.cs b/lib/VNLib.Plugins.Extensions.Loading/src/ManagedPasswordHashing.cs index 3489789..e382681 100644 --- a/lib/VNLib.Plugins.Extensions.Loading/src/ManagedPasswordHashing.cs +++ b/lib/VNLib.Plugins.Extensions.Loading/src/ManagedPasswordHashing.cs @@ -131,18 +131,22 @@ namespace VNLib.Plugins.Extensions.Loading //Convert to dict IReadOnlyDictionary hashingArgs = el.EnumerateObject().ToDictionary(static k => k.Name, static v => v.Value); - //Get hashing arguments - uint saltLen = hashingArgs["salt_len"].GetUInt32(); - uint hashLen = hashingArgs["hash_len"].GetUInt32(); - uint timeCost = hashingArgs["time_cost"].GetUInt32(); - uint memoryCost = hashingArgs["memory_cost"].GetUInt32(); - uint parallelism = hashingArgs["parallelism"].GetUInt32(); + Argon2ConfigParams p = new() + { + HashLen = hashingArgs["hash_len"].GetUInt32(), + MemoryCost = hashingArgs["memory_cost"].GetUInt32(), + Parallelism = hashingArgs["parallelism"].GetUInt32(), + SaltLen = (int)hashingArgs["salt_len"].GetUInt32(), + TimeCost = hashingArgs["time_cost"].GetUInt32() + }; + //Load passwords - Passwords = new(this, (int)saltLen, timeCost, memoryCost, parallelism, hashLen); + Passwords = PasswordHashing.Create(this, in p); } else { - Passwords = new(this); + //Load passwords with default config + Passwords = PasswordHashing.Create(this, new Argon2ConfigParams()); } //Get the pepper from secret storage @@ -152,7 +156,8 @@ namespace VNLib.Plugins.Extensions.Loading public SecretProvider(PluginBase plugin) { - Passwords = new(this); + //Load passwords with default config + Passwords = PasswordHashing.Create(this, new Argon2ConfigParams()); //Get the pepper from secret storage _pepper = plugin.GetSecretAsync(LoadingExtensions.PASSWORD_HASHING_KEY) -- cgit