Bookmarks

KMS — key management service

A service that creates cryptographic keys, stores them and manages their lifecycle: rotation, access control, auditing and destruction.

Also: key management system, key lifecycle management

checked 9 Nov

All terms

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.

textEnvelope encryption flow
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 data

That 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 caseHow a KMS helps
Encryption at restdisks, buckets, snapshots and backups are encrypted with keys from the KMS
Application secretsdatabase passwords and tokens are encrypted with a KMS key inside a secrets store
Signing and verificationsome KMSs hold asymmetric keys and sign data on request
Regulatory requirementsauditing key operations and a managed lifecycle are typical requirements of standards such as PCI DSS

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • secrets management

    A KMS holds encryption keys and does not hand them out; a secrets store hands out the secrets themselves — passwords, tokens, certificates.

  • HSMhardware security module

    An HSM is a physical device where keys live inside a protected chip; a cloud KMS often relies on an HSM underneath but hides that behind its API.

In depth in the references

where the topic is covered in detail