Skip to content

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.

Security, Cryptography & Tenant Isolation

Security across the EricksonLopez.* ecosystem follows Principle 5 (Secure defaults over permissive defaults). EricksonLopez.Security combines authenticated encryption (AesGcmEncryptionEngine, ChaCha20Poly1305EncryptionEngine), versioned key management (KeyRing), memory-hard password hashing (Argon2idPasswordHasher), and constant-time comparison (ConstantTimeComparer).

AesGcmSecretProtector encrypts secrets with 256-bit AES-GCM (AesGcmEncryptionEngine.Shared), resolves active keys via IEncryptionKeyProvider / KeyRing, disposes SecretBuffer immediately after encryption so key bytes are zeroed via CryptographicOperations.ZeroMemory, and binds Authenticated Associated Data (AuthenticatedContext) to prevent cross-tenant ciphertext confusion:

using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using EricksonLopez.Result;
using EricksonLopez.Security.Abstractions.Cryptography;
using EricksonLopez.Security.Abstractions.KeyManagement;
using EricksonLopez.Security.Abstractions.Primitives;
using EricksonLopez.Security.Secrets;
namespace Example.Security;
public static class TenantSecretHelper
{
public static ValueTask<Result<string>> ProtectTenantTokenAsync(
AesGcmSecretProtector protector,
string tenantId,
string rawApiToken,
CancellationToken cancellationToken)
{
ReadOnlySpan<byte> plaintext = Encoding.UTF8.GetBytes(rawApiToken);
var aad = AuthenticatedContext.ForTenant(tenantId);
Result<string> protectedEnvelope = protector.ProtectToBase64Url(
secret: plaintext,
purpose: KeyPurpose.SecretProtection,
expectedAssociatedData: aad);
return ValueTask.FromResult(protectedEnvelope);
}
}

Note: On decryption (UnprotectFromBase64Url / UnprotectToSecretBufferAsync), callers must supply the exact matching AuthenticatedContext (tenant:{tenantId}); otherwise AesGcmSecretProtector returns SecurityError.AssociatedDataMismatch.

  • Argon2idPasswordHasher (RFC 9106): Defaults to 64 MiB memory (65536 KiB), 3 iterations, 4 parallelism lanes, and 16-byte random salt, with bounded verification parameters (MaxAllowedMemoryCost = 65536, MaxAllowedTimeCost = 10) to prevent denial-of-service exhaustion.
  • ConstantTimeComparer / TimingSafeString: Prevents timing side-channel leaks when comparing API keys, HMAC tags, or webhook signatures.
  • Zero-Trust ABAC (EricksonLopez.Security.ZeroTrust): AbacPolicyEngine evaluates explicit AbacContext attributes rather than trusting ambient state.