kms.sa-saopaulo-1.basaltic.sh. A key exists in
one region and can only be used from there, so a ciphertext produced in one
region cannot be opened in another.
Create a key
Specs, usages, and the one choice you cannot change afterwards.
Envelope encryption
What a data key is, and why you should almost never call encrypt
directly.
Sign and verify
Algorithms per spec, and why you must not pre-hash.
Disable and delete
The recovery window, what cancelling gives you back, and what it does
not.
Creating a key
enabled,
ready for crypto operations — there is nothing to poll.
name is unique per account and lands in the CRN, so it has to be URL-safe:
^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$.
Specs and usages
A key is pinned to one usage at creation: eitherencrypt_decrypt or
sign_verify. The spec decides which usages are even possible.
Omit
key_usage for aes-256 or ecdsa-p256 and the only usage the spec
supports is applied. Omit it for an RSA spec and the request is rejected — RSA
can do both, so the service will not guess.
Envelope encryption
POST /v1/keys/{key_id}/encrypt sends your plaintext to KMS and gets
ciphertext back. That is fine for something small and rare — a config value, an
API token. It is the wrong shape for anything else, because every byte crosses
the network twice and every operation costs a round trip.
The alternative is a data key: KMS mints a fresh random key, hands you two
copies of it, and never stores it.
plaintext, then throw plaintext away and
store ciphertext beside the data it protects. To read the data back, send
ciphertext to POST /v1/keys/{key_id}/decrypt and you have the data key
again.
Your bulk data never leaves your process, one KMS call covers a whole batch,
and the KMS key stays a key-encrypting key — the only thing it ever wraps is
other keys.
number_of_bytes accepts 16, 32 or 64 and nothing else — 16 for AES-128,
32 for AES-256 (the default), 64 for HMAC-SHA512. Any other value fails.
When direct encrypt runs out
A symmetric key has no comparable algorithmic ceiling, but the request body still has to fit in one HTTP call and you still pay a round trip per operation. Treat direct encrypt as a convenience for small, infrequent values, and reach for a data key for everything else.Encryption context
aad is optional additional authenticated data. It is bound into the AES-GCM
tag, so a ciphertext will only open if the same context is presented again —
useful for pinning a blob to the thing it belongs to, so a stolen ciphertext
cannot be replayed against a different record.
Signing
signing_algorithm is optional; omitted, the default for the spec is used, and
the algorithm actually applied comes back in the response.
An algorithm that does not match the spec is rejected with
400 KMS_UNSUPPORTED_SIGNING_ALGORITHM rather than being attempted.
Signatures come back in the standard encodings, so nothing downstream needs
special handling: RSA-PSS uses saltLen = hashLen = 32, and ECDSA returns the
ASN.1 DER (r, s) sequence of ANSI X9.62.
POST /v1/keys/{key_id}/verify answers {"signature_valid": false} for a
signature that simply does not match. That is a 200, not an error — an error
means the request or the backend was wrong, not that the signature was.
The API does not expose the public half of an asymmetric key, so verification
goes through
verify rather than offline against a published key. Plan on a
call per check — and note that verify is a separate IAM action, so a party
that should only check signatures never needs kms:Sign.Turning a key off
Disable
POST /v1/keys/{key_id}/disable refuses every crypto operation with
409 KMS_KEY_DISABLED while leaving the material intact. This is the
reversible move: stop a suspected-compromised key now, keep the ability to
read historical ciphertext after re-enabling.Schedule deletion
POST /v1/keys/{key_id}/schedule-deletion starts a countdown.
pending_window_in_days is 7 to 30, defaulting to 7. The key refuses
crypto operations for the whole window, then the material and the record
are destroyed.Cancelling
POST /v1/keys/{key_id}/cancel-deletion exits the window at any point before
deletion_scheduled_at.
A cancelled key comes back
disabled, not enabled. Nothing starts
working again until you explicitly call enable. The window was entered
because someone wanted the key gone; recovering it should not silently
restore traffic to it.- Scheduling a deletion releases the key’s quota immediately, so you can create a replacement inside the same limit without waiting out the window.
- Cancelling therefore has to take that quota back, and fails with
403 QUOTA_EXCEEDEDif your account is now at its limit. If you created a replacement key, free a slot before you cancel.
Controlling who may use a key
Every operation checks a distinct IAM action, and every operation on a specific key is authorized against that key’s CRN with the key’s tags available as condition context. Only the two collection-level operations are not.
A write path that can seal but not open:
kms:ListKeys is authorized against the collection, not against individual
keys, so restricting it by CRN or tag has no effect. Scope the operations
that use a key; listing tells a caller a key exists and nothing more.Keys other services can use
Some services will encrypt their data under a key of yours instead of a platform-managed one, which puts the kill switch in your hands: disable the key and that service stops being able to read what it stored.Secrets
Bind a secret to one of your keys at creation and every version is sealed
under it.
Telemetry
A log group or trace setting takes a
kms_key_crn; each ingest batch gets
its own data key wrapped under yours.Not everything encrypted at rest uses a key of yours. A certificate’s private
key, for example, is encrypted under a platform-managed regional key you do
not control. Where a service supports your own key, it exposes a field for
it — if there is no such field, there is no such binding.
Errors
Next
Secrets
Versioned application secrets, and how to put one behind your own key.
Writing policies
Scoping
kms:Decrypt to the keys and tags it should reach.API reference
Every KMS operation, with request and response schemas.
Authentication
Signing requests to a regional endpoint.