KMS keys, policies and envelope encryption
Protect data at two boundaries
Encryption in transit protects traffic between endpoints, typically using TLS with certificate and hostname verification. Encryption at rest protects stored bytes and backups. Neither prevents an authorized application from reading plaintext or a compromised application from leaking it. For a fictional reports service, require TLS to the API and database, keep objects private, and choose a storage encryption option supported by the service. Check the encryption of replicas, snapshots and exported copies separately.
Envelope encryption
A data encryption key (DEK) encrypts the payload using an authenticated encryption library. A symmetric encryption KMS key protects that DEK. GenerateDataKey can return a plaintext DEK and an encrypted copy; use the plaintext only as long as needed and store the encrypted DEK with the ciphertext and required metadata. On reading, an authorized caller asks KMS to decrypt the encrypted DEK, then uses the recovered DEK to authenticate and decrypt the payload. This diagram is conceptual, not cryptographic code. Prefer a supported service integration or AWS Encryption SDK over inventing a format. Never log plaintext keys.
Payload + plaintext DEK -> authenticated ciphertextDEK + wrapping KMS key -> encrypted DEKStore: ciphertext + encrypted DEK + required metadataChoose the key owner and purpose
AWS owned keys are controlled by the service across accounts and are not directly visible to customers. AWS managed keys are service-managed keys in your account; customers cannot edit their key policies. Customer managed keys offer policy, lifecycle and audit control, with additional cost and operational responsibility. Separate symmetric encryption, asymmetric encryption/signing and HMAC use cases; a key specification and usage must match the operation. CloudHSM provides dedicated HSM cluster capacity; a KMS CloudHSM custom key store supports symmetric encryption KMS keys and adds cluster availability and cost dependencies. Verify service support before choosing it.
Authorization and regional recovery
A KMS key policy is central to authorization. IAM permission is not sufficient unless the key policy enables that permission path; grants can provide scoped access, and applicable explicit denies still matter. Separate key administration from cryptographic use. For example, a report reader needs the appropriate storage read permission plus the applicable KMS decrypt authorization when using a customer managed key. Keys are regional; related multi-Region keys share key material and identifier but have independent regional policies, grants and aliases. Replicating a key does not replicate data or permissions. Check destination service integration, restore access and cost: key storage, API requests, replicas and any HSM cluster charges.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
KMS keys, policies and envelope encryption — knowledge check
Reason about synthetic encryption and credential lifecycle cases.
What protects a stored DEK in envelope encryption?
Which key category lets a customer edit the key policy?
Does storage encryption replace TLS?
What must be checked independently for a multi-Region replica key?
Why separate key administration and use?