RSA: worked example
A complete RSA example with small numbers, from choosing the primes to encrypting and decrypting a number.
With small numbers everything can be followed by hand. Nobody would actually use these keys: they would break in an instant.
- 01
Two primes
p = 61, q = 53.
- 02
Modulus
n = 61 × 53 = 3233.
- 03
Euler’s function
φ(n) = 60 × 52 = 3120.
- 04
Public exponent
e = 17, which shares no divisors with 3120.
- 05
Private exponent
d = 2753, because 17 × 2753 = 46801 = 15 × 3120 + 1.
- 06
Keys
Public: (3233, 17). Private: (3233, 2753).
Encrypting and decrypting the number 65
Encryption c = 65^17 mod 3233 = 2790
Decryption m = 2790^2753 mod 3233 = 65Anyone intercepting 2790 and knowing the public key (3233, 17) would have to discover that 3233 = 61 × 53 to compute the private exponent. With a four-digit number it is child’s play; with a number of six hundred and seventeen digits, like the modulus of a 2048-bit key, it is not.
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.
The pages of this topic
Back to the overviewRSA: 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 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.