liveBook · Manning

Signature algorithm

As explained in Secure APIs

A signing algorithm is a cryptographic algorithm that generates or verifies signatures on digital data.

A signature algorithm generates or verifies a signature on digital data. For a JWT, it signs the base64url-encoded header and payload, joined by a dot. Verification shows that the token remains intact and comes from the holder of the signing secret or private key. section 7.2.2 section 7.8

The JWT header’s alg value selects the algorithm, so accepting an attacker-controlled choice can undermine validation. Constrain accepted algorithms, use strong signing choices, and verify the signature on every request alongside the token’s claims. section 8.7 section 1.4

Common signing arrangements include:

  • HS256 uses HMAC-SHA256 with one shared secret to create and verify the signature. section 7.2.2
  • PS256 uses an asymmetric key pair: the issuer signs with the private key and validators verify with the public key. section 8.2 section 8.7
  • A JWT library should support the required signing algorithms, while the application explicitly limits which algorithm it will accept. section 8.2 section 8.7

Issuing a PS256 token

Generate an RSA key pair with OpenSSL, load the private key, and pass it to PyJWT with algorithm="PS256". A receiving API uses the corresponding public key to verify the signature. section 8.7

How Secure APIs covers it

How deep it goes
Explains JWT signing input, HMAC and asymmetric keys, then stops short of detailed cryptographic mathematics.
Examples
Demonstrates HS256 and PS256 JWTs, PyJWT issuance, OpenSSL RSA keys, JWKS key lookup, and JWT signature verification.
What it assumes
Assumes basic JWT structure and claims while introducing signing inputs, shared secrets, private keys, and public-key verification.
What you can do after
Build it from scratch, issue JWTs with PyJWT, configure asymmetric keys, and validate signatures with constrained algorithms.
How it connects
Connects signature algorithms with JWT, JOSE, HMAC, asymmetric cryptography, OpenID Connect, and role-based access control.

Also explained in

Compare how 2 books explain signature algorithm →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secure APIs. The section links point to the parts of the book it draws on.