RSA key length and choosing alg
The bit length comes from n
The size of an RSA public key is the bit length of the modulus n. In a JWK, n is a Base64URL unsigned integer, so decode it and count from the most significant non-zero byte. A 256-byte value whose first byte is 0x80 or above is 2048 bits.
A 2048-bit modulus is 256 bytes, 3072 bits is 384 bytes and 4096 bits is 512 bytes. The Base64URL string length gives a rough hint, but leading zeros make it unreliable, so decode before you compute.
| Modulus | Bytes | Verdict |
|---|---|---|
| 1024 bits | 128 | Critical; unsuitable for signature verification |
| 2048 bits | 256 | The minimum; most OIDC issuers |
| 3072 bits | 384 | Ample; slower verification |
| 4096 bits | 512 | Ample but heavy for tokens and keys |
alg must match kty
The alg in a JWKS names the algorithm for signatures made with that key. RS256, RS384, RS512 and PS256, PS384, PS512 need an RSA key; ES256, ES384 and ES512 need EC; EdDSA needs OKP. A key with kty EC and alg RS256 can verify no RS256 signature at all. This tool marks that combination critical.
ES512 uses the P-521 curve. The number in the name and the curve size differ, which is easy to confuse: ES256 is P-256, ES384 is P-384 and ES512 is P-521.
Algorithm confusion attacks
If a verifier trusts the alg in the token header, an attacker can switch it to none or HS256 and skip signature verification. HS256 uses the public key as an HMAC secret, so anyone who knows the public key can produce a valid signature. The defence is to pin the allowed algorithms on the server and compare them with the kty and alg of the JWKS key.
- Check the allow-list before verification and reject anything not on it.
- Reject tokens whose alg is none.
- Check that the key's kty matches the alg; never use an RSA key as an HMAC secret.
- Fail when more than one key carries the same kid.
The e value and common mistakes
The public exponent is normally 65537 (AQAB). A key with e=3 is legal but discouraged in some environments. An even e, or e=1, is a broken key. Hand-built JWKs sometimes drop e or set it to zero, so run one real verification with a library after converting.
Key length speaks only to signature strength. Private key handling, kid management and rotation cadence are separate problems, and a 2048-bit key is worthless once its private half is public.
Questions
Is 2048 bits enough?
For ordinary signature verification today, 2048 bits is the minimum. A new system may consider 3072 bits, at the cost of slower verification and larger tokens.
How do RS256 and PS256 differ?
Both are RSA signatures, but RS256 uses PKCS#1 v1.5 padding and PS256 uses PSS. PSS is the newer construction; check library support and interoperability.
What does e=AQAB mean?
Decoding AQAB from Base64URL gives 0x010001, or 65537, the most common RSA public exponent.
Paste an RSA key and the modulus bit length and e value are computed immediately.
Open the toolThis article follows RFC 7517 (JWK), RFC 7518 (JWA), RFC 7638 (JWK thumbprint), RFC 5280 (X.509), RFC 5958 (PKCS#8), RFC 5915 (SEC1) and RFC 8037 (OKP). Every example key is synthetic and was made for this site.