Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

Digital signatures

A digital signature lets anyone holding a public key check that a message came from the matching private key and has not changed, however many systems it passed through. What it cannot do is decide whether the message suits this reader, now.

A token worth checking

When Ava connects the printer to her photos, the photo service's authorization server issues the printer an access token. The printer stores it, and later sends it with each request to the photo API. Each connection along the way may use HTTPS, but HTTPS only protects data while it moves between two endpoints. On the last hop it protects the token from the printer to the API. It says nothing about whether the printer, or anyone who broke into the printer's storage, changed the token after the authorization server issued it.

The photo API wants assurance that travels with the token itself: that it came from the authorization server, and that nobody changed a value on the way. A digital signature provides that. The authorization server signs the token with its private key, and anyone holding the matching public key can check it, no matter how many systems the token passed through.

Signing and verifying

Signing starts with a hash. As Encoding and hashing showed, a cryptographic hash function such as SHA-256 turns any amount of data into a short, fixed-size digest, and changing even one character of the input changes the digest completely. The digest acts as a compact fingerprint of the exact bytes being signed.

The authorization server calculates the hash of the token's signed part and uses its private key to produce a signature over it. Most signature algorithms work this way; EdDSA takes the message itself and does its hashing inside the algorithm, mixed with key material, but the idea is the same. It sends the token and the signature together. The photo API calculates the hash of what it received, then uses the public key to check that the signature matches that hash. Widely used signature algorithms include ECDSA, EdDSA (often as Ed25519), and RSA. The example later in this lesson uses ES256, ECDSA on a P-256 key with SHA-256, from Secrets and key pairs.

If anyone changes a value in the token, the API's hash no longer matches the one that was signed and verification fails. They cannot produce a new matching signature without the authorization server's private key.

A signature covers exact bytes, not meaning. If a gateway decodes the token's payload and encodes it again with different spacing, or with its fields in a different order, the hash changes and the signature fails even though the content means the same thing. Signed formats deal with this by signing a fixed encoding. A JSON Web Token signed as a JSON Web Signature (JWS), for example, signs its encoded header and payload exactly as they appear in the token, the base64url text before the second dot, and the verifier checks those same characters.

As the authorization server signed it

Signed bytes
Unchanged
Signature check
Passes
Claims check
Passes

Accept

aud edited after signing

Signed bytes
One value changed
Signature check
Fails
Claims check
Not reached

Reject

Same meaning, different spacing

Signed bytes
Spacing changed
Signature check
Fails
Claims check
Not reached

Reject

Checked by another reader

Signed bytes
Unchanged
Signature check
Passes
Claims check
Fails: aud names another reader

Reject

A signature covers exact bytes, not meaning.

The signature check catches any change to the signed bytes, even a harmless one. Only the claims check catches a genuine token sent to the wrong reader.

What a signature shows

A signature that verifies shows two things: the content has not changed since it was signed, and it was signed with the private key matching the public key the photo API used. Everything else needs another source of confidence.

It does not show who holds that private key. If the API was given the wrong public key, a valid signature proves only that the wrong party signed. It does not show that the content is true; an authorization server with a bug can sign a mistaken claim. It does not keep the content secret either. As Protecting credentials and messages explains, a signed JSON Web Token can usually be decoded and read by anyone who has it.

A signature also does not say that a message is recent or intended for its reader. Someone who recorded a signed token can present it again later, or to a different recipient, and the signature will still verify.

Deciding what to accept

To close those gaps, the authorization server includes the facts the photo API needs inside the signed content. Here is a fictional signed access token for Ava, shown decoded so the fields are readable:

Header
{
  "alg": "ES256",
  "kid": "photos-2026-10",
  "typ": "at+jwt"
}

Payload
{
  "iss": "https://auth.photos.example",
  "aud": "https://api.photos.example",
  "sub": "user-3117",
  "scope": "photos.read",
  "iat": 1792800000,
  "exp": 1792803600,
  "jti": "at-5c81e2"
}

The issuer (iss) names the authorization server, and the audience (aud) names the photo API as the intended recipient. The issued-at (iat) and expiry (exp) times, in Unix seconds, bound when the token is acceptable, and the unique identifier (jti) lets a recipient notice a token it has already seen when that matters. The type (typ) at+jwt marks it as an access token, so it cannot be mistaken for another kind of signed statement from the same key. Because these fields are covered by the signature, nobody can change them without verification failing.

The header also carries an algorithm name and a key ID, which the API treats as hints for choosing among the issuers, keys and algorithms it already trusts, never as instructions:

key = trusted_issuer_keys.find(header.kid)   # from the API's own configuration
if key is None or header.alg not in key.allowed_algorithms:
    reject()
if not verify(key, signed_bytes, signature):
    reject()
if header.typ != "at+jwt":
    reject()
if payload.iss != PHOTOS_ISSUER or payload.aud != PHOTO_API:
    reject()
if now() > payload.exp:
    reject()
accept(payload)

Where signatures appear

Once you know the pattern, signatures appear throughout identity systems. The passport chip from Proofing methods carries data signed by the issuing authority. A passkey signs a challenge during sign-in. Identity providers sign the assertions and ID tokens that tell an application who signed in, and the certificates from HTTPS and certificates in practice are themselves signed statements.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

A gateway decodes a signed access token's payload and encodes it again with different spacing and field order, without changing any value. What happens when the photo API verifies the signature? 1 of 3

Choose one answer.

A signed access token verifies correctly with the authorization server's key, but its aud names a different API. What should the photo API do? 2 of 3

Choose one answer.

Someone recorded Ava's signed access token and presents it to the photo API two hours later. Its signature still verifies. What should make the API refuse it? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity