Authenticated Encryption at Rest: Implementing AES-256-GCM with OpenSSL EVP in C++17

INTTECH Security Engineering — October 2026

Understanding initialization vector uniqueness, 128-bit GCM authentication tags, and key derivation when persisting encrypted key-value records to NVMe storage.

1. Why Confidentiality Alone Is Not Enough

Legacy block cipher modes such as AES-CBC without HMAC allow attackers with disk access to flip ciphertext bits undetected. Authenticated Encryption with Associated Data (AEAD) via AES-256-GCM simultaneously encrypts payloads and computes a 128-bit cryptographic tag verifying data integrity before decryption succeeds.

2. Deterministic Key Derivation & CSPRNG Nonces

Using OpenSSL RAND_bytes to generate a fresh 96-bit initialization vector (IV) for every single record write guarantees that identical plaintext values never produce identical ciphertext blocks on disk. Master passphrases are hashed via SHA-256 into fixed 32-byte symmetric keys inside locked memory.

3. Detecting Disk Corruption & Tampering Early

During read operations, EVP_DecryptFinal_ex validates the stored authentication tag against the computed tag. If a storage sector degrades or an unauthorized process alters a single byte in the vault file, the engine immediately rejects the record rather than returning corrupted application state.