Skip to content

Key management and secrets

Envelope encryption with a KMS, rotation that rewraps keys instead of data, the key lifecycle from NIST SP 800-57, and how to keep secrets out of code.

25 min6 steps

By the end you can
  • Design envelope encryption with data keys and a key-encryption key, and estimate its KMS load
  • Plan a key rotation that rewraps data keys instead of re-encrypting data
  • Apply key lifecycle rules (single purpose, cryptoperiods, compromise response) to an incident
  • Keep secrets out of code and images, and respond correctly when one leaks

Envelope encryption

Sending all data through a KMS does not scale (calls cap payload; AWS KMS takes 4 KB). Envelope encryption: encrypt data with a local DEK, wrap the DEK under a KEK that never leaves the KMS, store the wrapped DEK beside the ciphertext. Caching a DEK cuts KMS load but widens the blast radius.

AppKMSwrite: wrap my DEK under the KEKwrapped DEKread: unwrap this DEKDEK (policy-checked, logged)
Data is encrypted locally with the DEK. Store the ciphertext with the wrapped DEK and drop the plaintext DEK.

Loading question…

Answer this step to continue.