← Cryptography guide

K081 / Cryptographic protocols and formats

JWE JOSE

JSON Web Encryption JWE · Survey date 2026-12-05

JWE is a JSON-based encryption format that encrypts a payload so only its recipient can read it.

CRYPTOGRAPHY LAB / K081

Cryptography Lab · JWE JOSE

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

JWE Compact (dir + A256GCM, fixed protected header)

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

Reference ↗

Open lab →

Definition and overview
JWE is a JSON-based encryption format that encrypts a payload so only its recipient can read it. Source document ↗
Classification and reversibility
Encryption protocol; recipient decrypts payload with key. Source document ↗
Key or secret requirements
Not confirmed in the survey
Operating principle and structure
Hybrid structure: symmetric CEK encrypts body, recipient public key or other key protects CEK. Source document ↗
Key size, block size and parameters
enc defines key length/mode parameters, e.g. A256GCM 256 bits and A128GCM 128 bits. Source document ↗
Security strength and recommendation
Some JWE algorithms such as RSA1_5 deprecated; constrain allowed algorithms. Source document ↗
Known attacks and vulnerabilities
Invalid Curve attacks in JWE implementations affected multiple libraries. Source document ↗
Standards and certification
Standardized in RFC 7516. Source document ↗
Typical uses
Encrypt arbitrary data such as token payload so only recipient can read it. Source document ↗
Implementations, libraries and tools
panva jose and other libraries support JWE Compact/JSON serialization encryption/decryption. Source document ↗
Decryption or decoding
Use key matching protected header alg/enc with decrypt_compact or equivalent. Source document ↗
Advantages
Confidentiality and integrity/tamper detection through authentication tag. Source document ↗
Limitations and cautions
Unchecked decompressed size in ZIP-compressed JWE may exhaust memory (DoS). Source document ↗
Distinguishing encryption, encoding and hashing
Base64URL segments are encoding, not encryption; distinguish from JWE cryptographic encryption/authentication. Source document ↗

Practical examples

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

Example

Set protected alg/enc, AEAD-encrypt payload with CEK, protect CEK with recipient key and serialize compact/JSON JWE. Recipient checks alg/enc, recovers CEK and decrypts/verifies tag.

Procedure

Allowlist alg/enc, generate CEK or use direct key, encrypt/generate tag, protect CEK by key-management alg, serialize header/ciphertext/IV/tag. On receipt parse header, validate allowlist, recover CEK, decrypt/verify and obtain plaintext. Base64URL is encoding.

Scenario

Encrypt sensitive service payloads or JWT claims with recipient public key, private-key decryption. General JSON Serialization supports multiple recipients with CEK protected for each.

Pitfalls and alternatives

Avoid RSA1_5/none, alg confusion, missing tag verification, ZIP bombs and Base64URL confusion. Use vetted libraries/current AEAD (A256GCM), fixed allowlist, decompression limits and key protection.

References