Skip to Content
Asterrr's Handbook
5 · Data protection

AWS KMS keys and envelope encryption

KMS key types, ownership models, envelope encryption, data key APIs, aliases, multi-Region keys and deletion. The base of almost every encryption question.

Exam tasks: 5.2.1 (choose KMS and server- or client-side encryption), 5.3.5 (create and manage KMS keys across one or many Regions)

The decision: which kind of KMS key protects this data, and how does it move between Regions and retire safely?

AWS KMS is a regional managed service that creates and controls KMS keys. KMS keys never leave KMS unencrypted and run inside HSMs validated to FIPS 140-3 Security Level 3. A KMS key directly encrypts at most 4,096 bytes, so real data is protected with envelope encryption.

GenerateDataKeyplaintext + wrappedencrypt, then storeApplicationKMS keyData keyCiphertext +wrapped key
Envelope encryption. KMS returns a data key twice, once in plaintext and once wrapped. The app encrypts locally, discards the plaintext copy and stores the wrapped key beside the ciphertext. To read, the app sends the wrapped key to KMS Decrypt.
90–2,560 days
Allowed automatic rotation period for customer managed keys. The default is 365.
1 year
Fixed rotation for AWS managed keys.
25
On-demand rotations allowed per KMS key.
7–30 days
Deletion waiting period. The default is 30.
4 KB
Largest plaintext for a direct Encrypt call.

Which one to use

nonoyesyesencrypt data in AWSservices or with theEncryption SDKsign or verify, orencrypt outside AWS witha public keygenerate and verifymessage MACs or tokensyesnoData needs a KMS keyMust you write the keypolicy, share itcross-account, disable itor choose the rotationperiod?Need CloudTrail record ofeach use?AWS owned keyAWS managed key(aws/service)What operation?Symmetric customer managedkey (SYMMETRIC_DEFAULT)Asymmetric key RSA, ECC orML-DSAHMAC keySame ciphertext must bedecrypted in anotherRegion?Multi-Region key (mrk-prefix)Single-Region key
Decision tree for picking the key

The tables below compare the three ownership models and the key specs the tree ends on.

Who owns the key

AWS ownedAWS managedCustomer managed
Where it livesService's own account, invisible to youYour account, alias aws/<service>Your account
Key policyNone you can seeWritten by AWS, read-onlyYours
RotationService decidesEvery year, automatic, can't changeOff by default; automatic every 90–2,560 days, plus on demand
Usable by other accountsNoNoYes, through the key policy
Disable, schedule deletionNoNoYes
Shows in your CloudTrailNoYesYes
Typical signal"Encryption with no management""Audit, no control needed""Separation of duties", "revoke", "cross-account", "custom rotation"

Rules that follow from the table:

  • AWS managed keys can only be used through the service that owns them and only by principals in your account. You cannot share resources encrypted under one with another account.
  • The aws/ alias prefix is reserved. You cannot create an alias that starts with it.
  • AWS managed keys are not created for new services any more. New services default to AWS owned keys.

Exam signal

A question that says a DynamoDB table, SQS queue or EventBridge bus "must be encrypted, with no additional cost or management" is satisfied by the default AWS owned key. As soon as the question adds "the security team must be able to audit and revoke access", move to a customer managed key.

Legacy

Older material says customer master key (CMK). The current terms are KMS key, customer managed key and AWS managed key. Older guides also say AWS managed keys rotate every three years. That changed to yearly in May 2022.

Key types

Key specKey usageNotes
SYMMETRIC_DEFAULT (AES-256-GCM)Encrypt and decryptThe only type AWS services use for server-side encryption. Never leaves KMS unencrypted. Every type has a key that is created once and cannot change its usage
RSA 2048, 3072, 4096Encrypt and decrypt, or sign and verifyDownload the public key to encrypt or verify outside AWS
ECC NIST (P-256, P-384, P-521), ECC SECG P-256K1Sign and verify, or key agreementSigning for code, JWTs and blockchain-style workloads
ML-DSA 44, 65, 87Sign and verifyPost-quantum signatures
HMAC 224 to 512Generate and verify MACTamper-evident tokens without sharing a secret
  • Key usage is fixed at creation. An RSA key created for signing can't later encrypt.
  • Asymmetric and HMAC keys don't rotate automatically or on demand. "Rotate" them by creating a new key and moving the alias.
  • Asymmetric private keys never leave KMS. If a partner needs to verify your signatures offline, give them the public key from GetPublicKey.

Data key APIs

APIReturnsUse when
Encrypt / DecryptCiphertext or plaintextSmall data, up to 4,096 bytes
GenerateDataKeyPlaintext key and wrapped keyEncrypt data now on the caller
GenerateDataKeyWithoutPlaintextWrapped key onlyCreate keys ahead of time. A different component calls Decrypt later, so the creator never sees plaintext
ReEncryptNew ciphertextMove ciphertext to another key without exposing plaintext

Delete the plaintext data key from memory after use.

  • Heavy request rates can hit KMS throttling. Use S3 Bucket Keys and data key caching in the AWS Encryption SDK before you ask for a quota increase.
  • Encryption context, the optional additional authenticated data on these calls, is covered on KMS key policy, IAM and grants.

Exam signal

Data keys, large files or "encrypt more than 4 KB" means envelope encryption with GenerateDataKey. "Never expose the plaintext key to the writer service" means GenerateDataKeyWithoutPlaintext.

Aliases

  • An alias is a friendly name such as alias/app-prod. One key can have many aliases, an alias points to one key, and alias names are unique per account and Region.
  • Applications that call by alias survive manual rotation. Run UpdateAlias to repoint it.
  • CreateGrant and some other calls do not accept an alias. Use the key ID or ARN.
  • Cross-account calls need the key ARN or alias ARN.

Multi-Region keys

  • Create a primary key, then call ReplicateKey. Replicas share key material, so ciphertext from one Region decrypts in another without re-encryption.
  • Key policy, grants, aliases and tags are independent per Region. Rotation settings are shared and managed from the primary.
  • UpdatePrimaryRegion swaps primary and replica roles.
  • To delete a primary key, schedule deletion of every replica first. A replica can be deleted at any time.
  • Use them for client-side encryption of data that moves between Regions, global tables with the Database Encryption SDK, and signing in several Regions. AWS services that re-encrypt on replication (S3 Replication, EBS snapshot copy, RDS cross-Region replicas) work fine with separate single-Region keys.
  • You can promote a replica to primary after losing the primary Region.

Multi-Region by default

"Encrypt all data with one key that works everywhere" isn't a best practice. Data sovereignty rules often require that ciphertext is not decryptable outside its Region. Choose multi-Region keys only when a workload needs the same ciphertext in more than one Region.

Deleting a key

ItemFact
Waiting period7 to 30 days, default 30
During waiting periodState is Pending deletion. Cannot be used for crypto operations. Deletion can be cancelled
After it endsKey, aliases and metadata are gone. Data encrypted under it is unrecoverable
Safer optionDisable the key. It can be re-enabled
DetectionCloudTrail logs the schedule and delete events. A CloudWatch alarm can watch for use attempts during the wait
  • Disable first if you suspect a key is unused. Watch CloudTrail for failed requests, then schedule deletion.
  • An EventBridge rule or CloudWatch alarm on use attempts during PendingDeletion catches forgotten dependencies before the key is gone.
  • An SCP that denies kms:ScheduleKeyDeletion to everyone except a break-glass role is a common guardrail.

Exam trap

A deleted KMS key cannot be recovered, and you cannot recreate it by importing the same material. Cancel deletion while the key is Pending deletion, or disable instead of deleting.

Scenarios

Scenario
A fintech firm signs outbound payment instructions and wants partners to verify the signatures offline. Its auditors also require that the private signing key never leaves an HSM and that every signing operation is logged. Which solution meets these requirements with the LEAST operational effort?
Scenario · choose 2
A security engineer is cleaning up unused customer managed keys and wants to make sure no production workload still depends on a key before it is gone for good. Which TWO steps should the engineer take?

Further reading

On this page