Overview of Ciphertext envelope encryption
The library implements application-layer envelope encryption using three layers of keys to provide encryption at rest, crypto-shredding, and cheap rotation:
- Root KEK: Derived from the
REBOOT_CRYPTO_ROOT_KEYSenvironment variable; never stored. - WrappingKey: A random 256-bit key stored encrypted under the root KEK. This is the revocable unit tied to a specific
scope. - DEK (Data Encryption Key): A random per-value key used to encrypt the actual plaintext. The DEK is wrapped (encrypted) by the
WrappingKey.
This architecture ensures that a leaked database backup is inert without the root keys, and that data can be permanently deleted (crypto-shredded) by destroying a single wrapping key without needing to rewrite the encrypted data.