RFC 7516 — JSON Web Encryption (JWE)

Gap (not used; rarely needed in OAuth)

RFC 7516 — JSON Web Encryption (JWE)

Status: Standards Track
Published: 2015-05
L-tier / T-tier: L1 · T5 / T7 (only if encrypted tokens are issued)
OneAuth coverage: Gap (not used; rarely needed in OAuth)
JOSE family: JWS · JWE · JWK · JWA · JWT
See also: LANDSCAPE.md

In one sentence

JWE is the JOSE format for encrypted JSON payloads — the encrypted
counterpart to JWS. Rare in OAuth; common in OIDC for high-security id_tokens
and in some FAPI profiles.

What problem does it solve?

JWS gives you integrity (no tampering) but not confidentiality — anyone
holding a JWS token can read the payload (it’s base64url, not encrypted).
JWE adds the confidentiality layer when the payload itself is sensitive and
the channel can’t be trusted to keep it secret.

Typical scenarios:

  • Healthcare or financial JWTs that must not be readable by clients,
    proxies, or logs
  • OIDC id_token carrying sensitive claims where the client is browser-side
    and can’t be trusted with the plaintext
  • Government-grade SAML-replacement profiles

Note: most “we need encrypted tokens” requirements are actually solved by
shortening the token lifetime, using opaque tokens + introspection, or
TLS-terminating in a controlled place. JWE adds operational complexity
(key distribution, algorithm negotiation, debugging) — it’s a real cost.

Relatable example

You probably haven’t seen one. JWE is rare enough in 2025 OAuth that most
practitioners go a whole career without writing JWE code. The clearest
public example is OIDC encrypted id_tokens in FAPI 1.0 Advanced
profiles — a tiny minority of deployments.

If you’re integrating with a regulator-mandated OIDC IdP (UK Open Banking,
some EU health profiles), you may need to decrypt JWE-wrapped id_tokens.
Otherwise you almost certainly don’t need this.

Key concepts

  1. Five-part compact serialization (vs JWS’s three): header.encrypted_key.iv.ciphertext.tag.
  2. Two encryption stages: a random content encryption key (CEK)
    encrypts the payload (AES-GCM or AES-CBC-HMAC); the CEK itself is
    encrypted to the recipient’s key (RSA-OAEP, ECDH-ES, or a few others).
  3. Header carries alg and enc: alg is how the CEK is wrapped
    (e.g., RSA-OAEP-256); enc is the content encryption (e.g.,
    A256GCM).
  4. The JWS-then-JWE pattern: when both confidentiality and integrity
    are needed, sign first (JWS) then encrypt the result (JWE). The
    nested-JWT pattern (typ=JWT inside JWE).
  5. Key distribution is harder than for JWS. JWS verifiers need the
    public key from a JWKS; JWE encrypters need the recipient’s public
    key (also from a JWKS), but the recipient’s private key must be on
    the decrypter — usually the AS or RS. This doubles the key management.

Wire example

A JWE Compact Serialization has 5 parts:

HEADER         : {"alg":"RSA-OAEP-256","enc":"A256GCM","kid":"recipient-key-1","typ":"JWT"}
ENCRYPTED_KEY  : <RSA-OAEP-256(random_AES_key) base64url>
IV             : <12 random bytes for AES-GCM, base64url>
CIPHERTEXT     : <AES-GCM(payload, key=random_AES_key, iv=IV) base64url>
TAG            : <AES-GCM authentication tag, base64url>

On the wire:

eyJhbGciOi...J0eXAiOi...
.
g_hEwksO1...rHU2x6w0
.
48V1_ALb6US04U3b
.
5eym8TW_c8SuK0ltJ3rpYIzOeDQz7TALvtu6UG9oMo4vpzs9tX_EFShS8iB7j6jiSdiwkIr3ajwQzaBtQD_A
.
XFBoMYUZodetZdvTiFvSkQ

The reader inverts: decrypt CEK with private key → decrypt payload with CEK

  • IV → check AEAD tag.

Where it lands on the OAuth abstraction

  • L1 token format. JWE is the encryption sibling of JWS in the same
    JOSE family.
  • T5 (issue) and T7 (verify/decrypt) when used at all.
  • 99% of OAuth deployments don’t need this. The fact that you can nest
    JWE inside JWS or vice versa is a topic for FAPI-grade profiles, not
    daily life.

OAuth 2.0 status

JOSE family published 2015 — not part of 2.0. Not mandated by 2.0; rarely
deployed against 2.0.

OAuth 2.1 status

Not mandated by 2.1 either. FAPI 1.0 Advanced profile uses encrypted
id_tokens in some scenarios but that’s an L8 profile concern.

OneAuth status

7516 surface Status Notes
Issue encrypted JWTs (JWE Compact) Gap Not implemented; no observed demand
Verify/decrypt encrypted JWTs Gap Same
Nested JWS-then-JWE Gap Same

This is a “we’ll build it when a real consumer asks” item. The cost of
adding it speculatively is operational (key management for the encryption
side) without benefit.

If a FAPI 1.0 Advanced conformance push happens (related: issue 161 for
regional Open Banking profiles), JWE support becomes in-scope under that
effort.

When NOT to use it

You generally won’t. Specific anti-cases:

  • “We want to hide claims from the client” — use opaque tokens +
    introspection (RFC 7662) instead. Less ceremony, same result.
  • “We want at-rest encryption” — encrypt at storage layer; don’t push
    it into the wire format.
  • “Defense in depth on top of TLS” — TLS is the right place for
    channel-level confidentiality. JWE adds a key-management problem without
    meaningful additional protection in most threat models.
  • RFC 7515 JWS — the signing sibling; usually what you actually want
  • RFC 7519 JWT — JWTs can ride inside JWE just as they ride inside JWS
  • RFC 7517 JWK / JWKS — JWE needs recipient keys, not just signing keys
  • OIDC Core — defines encrypted id_token handling