Encryption keys must be stored and issued so that they never end up in code, config files or logs. A KMS centralises this work: the application asks the service to encrypt or decrypt data, while the keys themselves never leave the service. In the cloud it is a managed service (AWS KMS, Google Cloud KMS, Azure Key Vault); on your own servers — Vault, OpenBao or an HSM.
What a KMS does
- creates keys and stores them so they cannot be read directly — only used through the API
- controls access: who can work with which keys, often through IAM policies
- manages the lifecycle: scheduled rotation, a “pending deletion” state, a log of every operation in the audit trail
- encrypts small amounts of data directly — keys, tokens, short secrets; larger data goes through envelope encryption
Envelope encryption
Encrypting gigabytes with a KMS key is wasteful: every call is a network request and a charge for it. That is why envelope encryption is used: the KMS encrypts not the data itself but the data key (DEK) that encrypts the data.
1. the application asks the KMS for a data key → receives a plaintext DEK + the DEK encrypted by the root key2. the data is encrypted with the DEK locally, the DEK is removed from memory3. the encrypted data and the encrypted DEK are stored side by side (for example, in S3)4. to read: the encrypted DEK → to the KMS → the plaintext DEK → decrypt the dataThat is how S3 encryption, EBS volume encryption and snapshots of databases and object storage work: there is one root key in the KMS, millions of data keys, and the KMS is called when an object is written (the KMS issues a data key) and when it is read (the KMS decrypts that key). The number of KMS calls is reduced with caching: for example, S3 Bucket Keys cut the cost of KMS requests by up to 99%.
Where it is used
| Use case | How a KMS helps |
|---|---|
| Encryption at rest | disks, buckets, snapshots and backups are encrypted with keys from the KMS |
| Application secrets | database passwords and tokens are encrypted with a KMS key inside a secrets store |
| Signing and verification | some KMSs hold asymmetric keys and sign data on request |
| Regulatory requirements | auditing key operations and a managed lifecycle are typical requirements of standards such as PCI DSS |
Sources
the term is written from these pages- NIST Glossary — Key management (SP 800-57 Part 1 Rev. 5)csrc.nist.gov/glossary/term/key_management(opens in a new tab)
- AWS KMS Developer Guide — AWS KMS keysdocs.aws.amazon.com/kms/latest/developerguide/concepts.html(opens in a new tab)
- Amazon S3 User Guide — SSE-KMS и шифрование конвертомdocs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html(opens in a new tab)
Verified 9 Nov