Column-Level AES-256-GCM Encryption
1. Transparent Entity Encryption
Section titled “1. Transparent Entity Encryption”Sensitive attributes (such as Tax IDs, medical document numbers, and confidential notes) are encrypted at the column level within PostgreSQL using AES-256-GCM.
The [Encrypted] Attribute Pattern
Section titled “The [Encrypted] Attribute Pattern”public class Patient : AggregateRoot, IMustHaveTenant{ [Encrypted] public string Cpf { get; private set; } = string.Empty;}2. Encryption Pipeline
Section titled “2. Encryption Pipeline”- On
SaveChanges()/SaveChangesAsync(): EF Core interceptor detects properties annotated with[Encrypted], serializes and encrypts the plaintext using AES-256-GCM with a tenant-isolated cryptographic key. - On Materialization / Query: Decrypted automatically into C# plaintext in memory before reaching application code.
- Database Security: In the event of a raw PostgreSQL database dump or leak, encrypted columns appear as random base64 ciphertext with zero readable data.