RSA: the public-key algorithm that changed cryptography
How RSA, the algorithm of Rivest, Shamir and Adleman, works: public and private keys, the mathematics of prime numbers, an example with small numbers, known attacks and use today.
For millennia, encrypting a message required sender and recipient to share the same secret key, delivered by some secure means. In 1977 three MIT researchers — Ron Rivest, Adi Shamir and Leonard Adleman — published a method that made the unthinkable possible: communicating secretly with someone using a key that anyone can know.
With RSA everyone has two keys. The public key is distributed freely and is used to encrypt messages meant for you or to verify your signatures. The private key stays yours alone and is used to decrypt those messages or to sign. Security rests on a mathematical fact: multiplying two large prime numbers is easy, recovering the two factors from the product is, with today’s computers, practically impossible.
What it makes possible
- Encryption
- Anyone can encrypt a message with your public key; only you can decrypt it.
- Digital signature
- You sign with the private key; anyone verifies with the public key that the document comes from you and has not been altered.
- Key exchange
- In the past RSA was used to securely transmit the session key of a much faster symmetric algorithm.
RSA is one of the pillars of public-key cryptography, alongside Diffie-Hellman and elliptic curves; its mathematics rests on modular arithmetic.
The pages of this topic
RSA: how it works
Key generation, encryption, decryption and signing with RSA, explained step by step without complicated formulas.
RSA: history
From Diffie and Hellman’s 1976 revolution to the invention of RSA, from the patent to the discovery of the secret British precedent.
RSA: the maths
The formulas of RSA — modulus, Euler’s function, exponents, encryption and decryption — and the factoring problem on which security rests.
RSA: worked example
A complete RSA example with small numbers, from choosing the primes to encrypting and decrypting a number.
RSA: weaknesses and attacks
Known attacks on RSA: keys that are too short, faulty random numbers, vulnerable padding, timing attacks and the threat of quantum computers.
RSA today
Where RSA is still used — certificates, digital signatures, email and code — and why it is giving way to elliptic curves and post-quantum algorithms.
RSA: pitfalls to avoid
The most common mistakes developers and administrators make with RSA, from short keys to home-made implementations.
RSA: frequently asked questions
Short answers to the most common doubts about RSA, keys, security and quantum computers.