ES256 (ECDSA P-256) JWT Signing

Discover ES256 (ECDSA P-256) for JWT signing, its compact key sizes, performance advantages over RSA, and why it is gaining adoption in modern systems.

Algorithm

Detailed Explanation

ES256 (ECDSA using P-256 and SHA-256) is an asymmetric signing algorithm based on Elliptic Curve Cryptography (ECC). Like RS256, it uses a key pair: a private key for signing and a public key for verification. However, ES256 achieves equivalent security with much smaller keys, resulting in compact signatures and faster operations.

How ES256 signing works:

The algorithm computes the SHA-256 hash of the encoded header and payload, then applies the Elliptic Curve Digital Signature Algorithm (ECDSA) using the P-256 curve (also known as secp256r1 or prime256v1). The signature consists of two 256-bit integers (r, s) encoded as a 64-byte sequence after base64url encoding.

{
  "alg": "ES256",
  "typ": "JWT",
  "kid": "ec-key-2024"
}

Size and performance advantages:

An ES256 key pair uses a 256-bit private key and a 512-bit public key, compared to RS256's 2048-4096 bit keys. The resulting JWT signature is approximately 86 characters (base64url-encoded) versus 342 characters for RS256 with a 2048-bit key. This size reduction matters for tokens transmitted in HTTP headers, where every byte counts. Signing speed is comparable to RS256, but key generation is dramatically faster.

Security level:

ES256 with the P-256 curve provides 128 bits of security, equivalent to RSA with a 3072-bit key. For most applications, 128 bits of security is more than sufficient. The P-256 curve has been extensively analyzed and is endorsed by NIST, NSA Suite B, and numerous international standards bodies. It is supported by all major JWT libraries and cloud providers.

Adoption and compatibility:

ES256 is increasingly the recommended algorithm for new JWT implementations. Apple's Sign in with Apple uses ES256 exclusively. WebAuthn/FIDO2 specifications prefer ECDSA. AWS, Google Cloud, and Azure all support ES256 in their key management and identity services. The main compatibility concern is legacy systems that only support RSA, which is becoming less common. For new projects without legacy constraints, ES256 offers the best combination of security, performance, and compact token size.

Use Case

A mobile app backend uses ES256 for JWT signing to minimize token size, reducing bandwidth usage for clients on cellular connections where every byte impacts latency.

Try It — JWT Decoder

Open full tool