From 7df83c98779122dd7722f8deee79d6c2557b3d8d Mon Sep 17 00:00:00 2001 From: Timothy Schenk Date: Sat, 2 Mar 2024 13:14:49 +0100 Subject: [PATCH] fix: autodispose argon2id --- .../PacketHandlers/LoginHandler.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Continuity.AuthServer/PacketHandlers/LoginHandler.cs b/Continuity.AuthServer/PacketHandlers/LoginHandler.cs index 142970f..75c8bc9 100644 --- a/Continuity.AuthServer/PacketHandlers/LoginHandler.cs +++ b/Continuity.AuthServer/PacketHandlers/LoginHandler.cs @@ -86,14 +86,12 @@ public class LoginHandler : IPacketHandler using var activity = _activitySource.StartActivity(); // https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Chea1t_Sheet.html#argon2id // "Use Argon2id with a minimum configuration of 19 MiB of memory, an iteration count of 2, and 1 degree of parallelism." - var argon2Id = new Argon2id(Encoding.ASCII.GetBytes(password)) - { - MemorySize = 1024 * 19, - Iterations = 2, - DegreeOfParallelism = 1, - Salt = salt, - AssociatedData = userId.ToByteArray() - }; + using var argon2Id = new Argon2id(Encoding.ASCII.GetBytes(password)); + argon2Id.MemorySize = 1024 * 19; + argon2Id.Iterations = 2; + argon2Id.DegreeOfParallelism = 1; + argon2Id.Salt = salt; + argon2Id.AssociatedData = userId.ToByteArray(); return await argon2Id.GetBytesAsync(16); }