K034 / Cipher modes and AEAD
Envelope encryption
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.
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.Output
Previous state
- 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
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
- Untitled result ↗
- Untitled result ↗
- Envelope encryption | Cloud Key Management Service | Google Cloud Documentation ↗
- Use envelope encryption - Key Management Service - Alibaba Cloud Documentation Center ↗
- AWS KMS cryptography essentials - AWS Key Management Service ↗
- Envelope Encryption: KEK vs. DEK and Key Wrapping ↗
- SP 800-38F, Recommendation for Block Cipher Modes of Operation: Methods for Key Wrapping | CSRC ↗
- I want to use client-side encryption with a cloud KMS | Tink | Google for Developers ↗
- python/examples/envelope_aead/README.md ↗
- Envelope Encryption and Key Management: KMS, HSM, Key Rotati ↗