Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
Key wrapping is encrypting one cryptographic key with another so it can be stored or transported safely. Dedicated algorithms exist because keys are not ordinary plaintext.

What Is Key Wrapping?
A cryptographic key has to leave the device that created it more often than people expect. It must be backed up, replicated to another region, handed to a hardware module, exported from one system and imported into another, or stored next to the data it protects. Key wrapping is the practice of encrypting that key under a second key — the key encryption key, or KEK — so that the wrapped form can be written to disk or sent over a network without exposing anything.
The wrapped key is sometimes called a blob or a cryptogram. It is useless to anyone who cannot reach the KEK, which is usually held in a hardware security module or a managed key service.
You could wrap a key with ordinary AES-GCM, and plenty of systems do. Purpose-built wrapping algorithms exist because key material has properties that ordinary data does not:
AES-KW, specified in RFC 3394, answers all three. It is deterministic, needs no nonce, and includes a fixed integrity check value so that unwrapping either returns the exact original key or fails outright. AES-KWP in RFC 5649 extends it to inputs that are not a multiple of eight bytes. AES-GCM-SIV and AES-SIV are modern alternatives where nonce misuse resistance is wanted alongside wrapping.
| Mechanism | KEK type | Typical use |
|---|---|---|
| AES-KW / AES-KWP | Symmetric | HSM backup, PKCS#11 C_WrapKey, JWE A256KW |
| RSA-OAEP | Asymmetric | Importing a key into a service that published a public wrapping key |
| ECDH-ES plus AES-KW | Asymmetric to symmetric | JWE key agreement, encrypting to a recipient’s public key |
| AES-GCM | Symmetric | General purpose; acceptable with strict nonce handling |
The asymmetric options matter for one particular workflow: bring your own key. Cloud providers publish a public wrapping key, you encrypt your own key material under it, and the result can only be unwrapped inside their HSM. The plaintext key never exists outside your premises and theirs.
The two terms are often used interchangeably, and they are not the same thing. Key wrapping is the cryptographic operation: encrypt key A with key B. Envelope encryption is the architectural pattern that uses it: generate a data key, encrypt the data locally, wrap the data key with a master key, and store the wrapped form alongside the ciphertext.
Put another way, wrapping is the verb and envelope encryption is the design. You will also find wrapping used outside that pattern entirely — in HSM backup and replication, in PKCS#11 key transfer between modules, in TPM key hierarchies where each key is sealed to its parent, and in disk encryption, where the volume key is wrapped by each key protector in turn.
That last point is the failure we see most often: a correctly implemented wrapping scheme whose KEK sits in an environment variable next to the wrapped blob. The cryptography is fine; the hierarchy is a circle. Key hierarchies and the policies around them are part of what we assess in our cloud security services.
You can, and many systems do successfully. Dedicated wrapping algorithms such as AES-KW remove the need to manage a unique nonce for every wrap and build in an integrity check designed for key-sized inputs. Where your platform handles nonces reliably, AES-GCM with an authenticated context is a perfectly sound choice.
A key whose only job is to protect other keys, never application data. It sits higher in the hierarchy, usually inside an HSM or a key management service, and ideally is non-exportable. Separating it from data encryption keys limits exposure, enables rotation without re-encrypting data, and gives you a single auditable control point.
Yes, through bring your own key. The provider publishes a public wrapping key, you encrypt your key material with RSA-OAEP, and only their HSM can unwrap it. This keeps key generation under your control and can satisfy regulatory requirements, at the cost of owning the backup and recovery of that material yourself.
Yes, provided the key encryption key is held somewhere genuinely separate with its own access control. That is exactly the design behind envelope encryption. It stops being safe when the KEK lives in the same application configuration, container image, or repository as the wrapped blob, which removes the separation the scheme depends on.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.