Skip to content

JWE header inspector

Read the protected header of an encrypted JWT (JWE) to see how the key was delivered, how the content was encrypted, and which key can decrypt it.

Runs in your browser. Nothing you paste is sent to us.

Encrypted token

A sample JWE for the made-up realm acme (RSA-OAEP with A256GCM) is filled in.

RSA-OAEPA256GCMkid sample-acme-enccty JWT
Encrypted key
256 bytes
IV
12 bytes
Ciphertext
1434 bytesAbout the size of the content, plus padding for CBC
Tag
16 bytes

Header

Protected header
{
  "alg": "RSA-OAEP",
  "enc": "A256GCM",
  "kid": "sample-acme-enc",
  "cty": "JWT"
}
alg
RSA-OAEPRSA-OAEP with SHA-1 wraps a random content key
enc
A256GCMAES-256-GCM
kid
sample-acme-encThe recipient’s key that can decrypt it
cty
JWTThe content is another JWT, usually a signed one
  • PassIV is 12 bytes, as A256GCM needs
  • PassTag is 16 bytes, as A256GCM needs
  • PassThe recipient’s RSA key is 2048 bitsRead from the size of the encrypted key, which equals the RSA modulus.
The header is readable by anyone; the claims are not. Only the holder of the recipient’s private key can decrypt the content.

How to use it

  1. Paste the encrypted token: five parts joined by dots.
  2. Read alg (key management), enc (content encryption) and kid.
  3. Check the part sizes against what the algorithms need.

What to know

A JWE has five parts: protected header, encrypted key, initialization vector, ciphertext and authentication tag. Only the header can be read without the key.

With RSA-OAEP, a random content key is encrypted to the recipient’s public key; the size of that encrypted key equals the RSA key size. With dir and ECDH-ES the encrypted key part is empty.

Keycloak can encrypt ID tokens for a client. The algorithms are set in the client’s advanced settings, and Keycloak encrypts to a public key the client provides, such as through its JWKS URL.

What an encrypted JWT is

Most JWTs are signed: anyone can read them, but nobody can change them. An encrypted JWT uses JSON Web Encryption (JWE, RFC 7516) instead, so only the intended recipient can read the content. You use it when a token carries data that the parties in between should not see.

You can recognize a JWE in compact form by its five parts separated by dots, where a signed token has three. Only the first part, the protected header, can be read without the key.

Encryption also changes what intermediaries can do. A gateway that routes requests by reading claims cannot read an encrypted token, so routing must rely on other information, or the gateway must hold the decryption key itself.

The five parts

PartContentsReadable?
1. Protected headerJSON naming alg, enc, kid and moreYes
2. Encrypted keyThe content key, encrypted for the recipientNo
3. Initialization vectorRandom bytes for the content cipherBytes only
4. CiphertextThe encrypted contentNo
5. Authentication tagProves the ciphertext and header were not changedBytes only

All five are Base64url-encoded. The protected header is also the additional authenticated data for the content cipher, so changing the header breaks decryption.

alg and enc: two layers

A JWE uses two algorithms. alg says how the content key reaches the recipient. enc says how the content is encrypted with that key.

Key management (alg)

algHow the key is deliveredEncrypted key part
RSA-OAEP, RSA-OAEP-256Encrypted to the recipient’s RSA public keyAs long as the RSA modulus
RSA1_5RSA PKCS #1 v1.5, deprecated in practiceAs long as the RSA modulus
ECDH-ESDerived from an ephemeral EC key and the recipient’s keyEmpty
ECDH-ES+A128KW and similarDerived key wraps a random content keyPresent
A128KW, A256KWWrapped with a shared AES keyPresent
dirThe shared key is the content keyEmpty

Content encryption (enc)

encCipherIVTag
A128GCM, A192GCM, A256GCMAES-GCM12 bytes16 bytes
A128CBC-HS256AES-128-CBC with HMAC SHA-25616 bytes16 bytes
A192CBC-HS384AES-192-CBC with HMAC SHA-38416 bytes24 bytes
A256CBC-HS512AES-256-CBC with HMAC SHA-51216 bytes32 bytes

What this inspector does

  • Decodes and shows the protected header.
  • Explains alg, enc, kid, cty and epk in words.
  • Measures each part in bytes.
  • Checks the IV and tag sizes against what enc requires.
  • Checks that the encrypted key part is empty or present as alg requires.
  • Reads the recipient’s RSA key size from the encrypted key length.
  • Warns about RSA1_5 and notes compression (zip).

It does not decrypt. Decryption needs the recipient’s private key or the shared key, and this page never asks for either.

The protected header of the sample JWE
{
  "alg": "RSA-OAEP",
  "enc": "A256GCM",
  "kid": "sample-acme-enc",
  "cty": "JWT"
}

How to inspect a token

  1. Paste the token in compact form: five parts joined by dots.
  2. Read the badges for alg, enc, kid and cty.
  3. Read the explanations next to each header field.
  4. Check the size checks; a failed one means the token was damaged or built wrongly.

If you paste a three-part token, the tool tells you it is a signed JWT and points you to the JWT decoder.

Nested tokens: signed, then encrypted

Encryption alone does not prove who sent a token: anyone with the recipient’s public key can encrypt. So the usual pattern is to sign first and encrypt the signed token. The header then says cty: JWT, and after decrypting, the recipient must still verify the inner token’s signature.

Encrypted tokens in Keycloak

Keycloak can encrypt the ID tokens it issues to a client. In the client’s Advanced tab, the fine-grained OpenID Connect settings include an ID token encryption key management algorithm and a content encryption algorithm. Keycloak encrypts to a public key the client provides, such as through the client’s JWKS URL on its Keys tab.

Keycloak also has its own encryption key in each realm, listed with use: enc and alg: RSA-OAEP in the realm’s certs endpoint. Clients use it to encrypt things sent to Keycloak, such as request objects, when that is configured.

Access tokens from Keycloak are signed JWTs by default. If you see five parts, check which token you copied and which client settings apply.

Use cases

Debugging a decryption failure

Check that kid names a key the recipient has, that the recipient supports alg and enc, and that the part sizes pass. A size failure points to a damaged token or a buggy encoder.

Confirming a client setting

After turning on ID token encryption, inspect a token to confirm the algorithms are the ones you chose and the kid is the client’s current key.

Reviewing a partner’s tokens

The header shows whether a partner uses current algorithms. RSA1_5 or compression are worth raising.

How decryption works, step by step

Knowing the steps a recipient follows helps you read the header and the part sizes.

  1. Read the protected header to learn alg, enc and kid.
  2. Find the private key or shared key named by kid.
  3. Recover the content key: decrypt the encrypted key with RSA-OAEP, unwrap it with AES key wrap, or derive it with ECDH-ES, as alg says.
  4. Decrypt the ciphertext with the content key and the IV, using the protected header as additional authenticated data.
  5. Check the authentication tag. If it does not match, reject the token: something was changed.
  6. If cty is JWT, verify the inner signed token.

Every step can fail on its own, which is why decryption errors are often vague. The header and the part sizes rule out half of the causes before you need the key.

Reading the sample

The sample token on this page is made up for the realm acme. Its header names RSA-OAEP and A256GCM.

  • The encrypted key is 256 bytes, so the recipient’s RSA key is 2048 bits.
  • The IV is 12 bytes and the tag 16 bytes, as AES-GCM requires.
  • The ciphertext is about the size of the signed token inside it, since GCM adds no padding.
  • cty: JWT says the content is a token to verify after decrypting.

Nobody can decrypt it: the private key was discarded when the sample was made.

JWE in JSON serialization

RFC 7516 also defines a JSON form, with members such as protected, encrypted_key, iv, ciphertext and tag, and optionally several recipients. It is rare in OAuth and OpenID Connect, which use the compact form. This tool reads the compact form only and tells you when you paste JSON.

Security notes

  • RSA1_5 has a long history of padding-oracle attacks. Prefer RSA-OAEP or RSA-OAEP-256.
  • Compression (zip: DEF) before encryption can leak information about the content through its length when an attacker controls part of it.
  • The header is not secret. Do not put sensitive data in custom header fields.
  • Decrypting does not authenticate the sender; verify the inner signature.

When a recipient cannot decrypt, start from the header: confirm the kid exists in the recipient’s key set with use: enc, that the recipient supports both alg and enc, and that the part sizes pass. Only then look at the key itself.

Best practices

  • Sign, then encrypt, and mark the content with cty: JWT.
  • Use RSA-OAEP-256 or ECDH-ES for key management and AES-GCM for content.
  • Give encryption keys their own kid and use: enc, separate from signing keys.
  • Use encryption only where intermediaries must not read the claims; it adds cost and complexity.
Questions

Frequently asked questions

Can this tool decrypt the token?

No. Decryption needs the recipient’s private key or the shared key. The tool reads only the header and the part sizes.

What does `cty: JWT` mean?

The encrypted content is itself a JWT, usually a signed one. After decrypting, verify that inner token’s signature.

How can I tell a JWE from a JWS?

Count the parts. A signed token (JWS) has three, an encrypted token (JWE) has five.

Why is the encrypted key part empty?

With `dir` and `ECDH-ES`, no key is sent: the shared key or the derived key is used directly. With any other `alg`, an empty encrypted key means the token is broken.

What is the difference between `alg` and `enc`?

`alg` says how the content key reaches the recipient, for example RSA-OAEP. `enc` says how the content is encrypted with that key, for example AES-256-GCM.

Can Keycloak issue encrypted tokens?

Yes, for ID tokens. In the client’s advanced settings you choose the key management and content encryption algorithms, and Keycloak encrypts to the client’s public key.

Why is RSA1_5 flagged?

RSA PKCS #1 v1.5 encryption has been broken repeatedly through padding-oracle attacks. RSA-OAEP avoids that class of attack.

Is a JWE also signed?

Not by itself. The authentication tag protects against changes, but anyone with the recipient’s public key can create a valid JWE. That is why tokens are usually signed first and then encrypted.

Which encryption algorithms should I use?

RSA-OAEP-256 or ECDH-ES for key management and A256GCM or A128GCM for content are sound choices. Avoid RSA1_5.

Rather not run Keycloak yourself?

We run it for you on a cluster of your own, with backups, upgrades and written support. Starter and Premium begin with a 7-day trial.