← Cryptography guide

K034 / Cipher modes and AEAD

Envelope encryption

envelope encryption KMS data key · Survey date 2026-12-05

Envelope encryption protects a data key by encrypting it with a separate key-encryption key (KEK).

CRYPTOGRAPHY LAB / K034

Cryptography Lab · Envelope encryption

Run real computations and inspect intermediate states step by step.

Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.

Scope: Limited implementation

Envelope encryption (AES-256-GCM key wrapping + data encryption)

See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.

Open lab →

Definition and overview
Envelope encryption protects a data key by encrypting it with a separate key-encryption key (KEK). Source document ↗
Classification and reversibility
Encryption construction decryptable with wrapping and data keys. Source document ↗
Key or secret requirements
Requires a DEK (data encryption key) and KEK (key encryption/wrapping key). Source document ↗
Operating principle and structure
Generate DEK, encrypt data, wrap DEK with KEK, store ciphertext and wrapped DEK. Source document ↗
Key size, block size and parameters
Data key length is stated as at least 24 bytes; AES uses 16/24/32 bytes. Source document ↗
Security strength and recommendation
A strong option prioritizing NIST-approved cryptographic algorithms. Source document ↗
Known attacks and vulnerabilities
Compromising KEK can expose every protected DEK, with catastrophic impact. Source document ↗
Standards and certification
NIST SP 800-38F specifies key wrapping (KW/KWP). Source document ↗
Typical uses
Client-side encryption with cloud KMS key protection. Source document ↗
Implementations, libraries and tools
Libraries/tools include Tink Envelope AEAD. Source document ↗
Decryption or decoding
Unwrap DEK with wrapping key, then decrypt data with plaintext DEK. Source document ↗
Advantages
Unique DEK per message reduces exposure and rotation burden. Source document ↗
Limitations and cautions
For AES-GCM never reuse a key/nonce pair. Source document ↗
Distinguishing encryption, encoding and hashing
Key-based encryption construction, not encoding or hashing. Source document ↗

Practical examples

Examples are illustrative; they are not execution-tested implementations or operational recommendations.

Example

Encrypt data with a unique DEK; wrap DEK with KMS KEK and store alongside ciphertext. To decrypt, unwrap DEK, decrypt data and discard plaintext DEK.

Procedure

Generate DEK, encrypt data, wrap DEK with KEK, store ciphertext/wrapped DEK/nonce/tag. Unwrap DEK, decrypt data and discard plaintext DEK. Base64 is separate keyless encoding.

Scenario

Cloud app encrypts each large file with its own DEK and stores only the wrapped DEK under a KMS KEK. Rotate KEK through rewrapping and control decryption through KMS policy.

Pitfalls and alternatives

KEK leakage exposes all DEKs; use HSM/KMS storage, rotation and access controls. Never reuse AES-GCM key/nonce; beware plaintext DEK in memory/logs. Distinguish hashes/Base64; use AEAD and key wrapping for confidentiality/integrity.

References