update infra docs

This commit is contained in:
Aaron Po
2026-08-04 06:18:54 -04:00
parent 88abb8e995
commit 64302286fb
11 changed files with 21 additions and 151 deletions

View File

@@ -15,15 +15,9 @@ public class Argon2Infrastructure : IPasswordInfrastructure
private const int ArgonMemoryKb = 65536; // 64MB
/// <summary>
/// Hashes a plaintext password using Argon2id with a newly generated 128-bit cryptographically
/// random salt, 4 iterations, 64MB of memory, and a degree of parallelism equal to the number of
/// available processors (minimum 1).
/// Hashes a plaintext password using Argon2id with a fresh random salt.
/// </summary>
/// <param name="password">The plaintext password to hash.</param>
/// <returns>
/// A string of the form <c>"{base64Salt}:{base64Hash}"</c> containing the salt and the resulting
/// 256-bit hash, suitable for storage and later verification.
/// </returns>
/// <returns>A string of the form <c>"{base64Salt}:{base64Hash}"</c>, suitable for storage.</returns>
public string Hash(string password)
{
byte[] salt = RandomNumberGenerator.GetBytes(SaltSize);
@@ -40,18 +34,12 @@ public class Argon2Infrastructure : IPasswordInfrastructure
}
/// <summary>
/// Verifies a plaintext password against a stored salt/hash string by recomputing the Argon2id
/// hash with the extracted salt and comparing it to the stored hash using a fixed-time comparison
/// Verifies a plaintext password against a stored salt/hash string, using a fixed-time comparison
/// to mitigate timing attacks.
/// </summary>
/// <param name="password">The plaintext password to verify.</param>
/// <param name="stored">
/// The stored string of the form <c>"{base64Salt}:{base64Hash}"</c> previously produced by <see cref="Hash" />.
/// </param>
/// <returns>
/// <c>true</c> if the password matches the stored hash; <c>false</c> if it does not match, the stored
/// string is malformed (e.g. not in the expected two-part format, or not valid base64), or any other
/// error occurs while verifying.
/// <c>false</c> if the password doesn't match, if <paramref name="stored" /> is malformed, or if any
/// other error occurs during verification.
/// </returns>
public bool Verify(string password, string stored)
{