#if STELLAOPS_CRYPTO_SODIUM
using System;
using System.Text;
using Org.BouncyCastle.Crypto.Generators;
using Org.BouncyCastle.Crypto.Parameters;
namespace StellaOps.Cryptography;
///
/// Placeholder for libsodium-backed Argon2id implementation.
/// Falls back to the managed BouncyCastle variant until native bindings land.
///
public sealed partial class Argon2idPasswordHasher
{
private static partial byte[] DeriveHashCore(string password, ReadOnlySpan salt, PasswordHashOptions options)
{
// TODO(SEC1.B follow-up): replace with libsodium/core bindings and managed pinning logic.
var passwordBytes = Encoding.UTF8.GetBytes(password);
var parameters = new Argon2Parameters.Builder(Argon2Parameters.Argon2id)
.WithSalt(salt.ToArray())
.WithParallelism(options.Parallelism)
.WithIterations(options.Iterations)
.WithMemoryAsKB(options.MemorySizeInKib)
.Build();
var generator = new Argon2BytesGenerator();
generator.Init(parameters);
var result = new byte[HashLengthBytes];
generator.GenerateBytes(passwordBytes, result);
return result;
}
}
#endif