All articles
Key pairs

RSA vs ECDSA: Choosing a Key Pair

Generate Secret Keys team June 4, 2026 7 min read

Symmetric secrets like AES keys use one shared value for everything. Asymmetric cryptography is different: it uses a pair of mathematically linked keys. This powers TLS certificates, SSH logins, code signing, and JWTs signed with RS256 or ES256. The two dominant choices are RSA and ECDSA.

How a key pair works

You generate a private key (kept secret) and a matching public key (shared freely). What one does, only the other can reverse:

  • Signing: you sign with the private key; anyone verifies with the public key. This proves authenticity.
  • Encryption: anyone encrypts to your public key; only your private key can decrypt.

The security rests on a hard math problem that makes deriving the private key from the public key infeasible.

RSA

RSA is the long-established standard, based on the difficulty of factoring large numbers. It's supported essentially everywhere.

  • Key sizes: 2048-bit is today's baseline; 3072- or 4096-bit for more margin.
  • Strengths: universal compatibility, simple to reason about.
  • Trade-offs: large keys and signatures, and noticeably slower key generation and signing as sizes grow.

ECDSA

ECDSA uses elliptic-curve math to reach the same security with dramatically smaller keys.

  • Curves: P-256 is the common default (P-384/P-521 for higher levels).
  • Strengths: a 256-bit ECDSA key offers security comparable to a 3072-bit RSA key, with smaller keys, smaller signatures, and faster operations.
  • Trade-offs: implementation is more delicate (it needs a unique random value per signature), and very old systems may not support it.

And Ed25519

Worth knowing: Ed25519 (EdDSA on Curve25519) is a modern signature scheme that's fast, compact, and designed to avoid common implementation pitfalls. Where it's supported — modern SSH and TLS stacks — it's an excellent default for signing.

Quick comparison

  • Key/signature size: ECDSA & Ed25519 win decisively (smaller).
  • Speed: ECC is generally faster to generate and sign; RSA verifies quickly but signs slowly.
  • Compatibility: RSA is the safest bet for legacy systems.
  • Security per bit: ECC achieves more with fewer bits.

Which should you choose?

For new systems, prefer ECDSA (P-256) or Ed25519 for smaller, faster keys. Choose RSA 2048+ when you must interoperate with older clients or a system that mandates it. Whatever you pick, protect the private key like any other secret and never commit it to source control.

Generate a key pair now

The Crypto Tools tab generates RSA-PSS 2048 or ECDSA P-256 key pairs and exports them as PEM — created entirely in your browser with the Web Crypto API.

Need a key pair? Generate an RSA or ECDSA public/private pair as PEM, locally and instantly.

Open the key pair tool