fix: autodispose argon2id

This commit is contained in:
Timothy Schenk 2024-03-02 13:14:49 +01:00
parent aff98c4144
commit 7df83c9877
Signed by: rainote
SSH key fingerprint: SHA256:pnkNSDwpAnaip00xaZlVFHKKsS7T8UtOomMzvs0yITE

View file

@ -86,14 +86,12 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket, AuthSession>
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);
}