RSA · 04 Worked example

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.

  1. 01
    Two primes

    p = 61, q = 53.

  2. 02
    Modulus

    n = 61 × 53 = 3233.

  3. 03
    Euler’s function

    φ(n) = 60 × 52 = 3120.

  4. 04
    Public exponent

    e = 17, which shares no divisors with 3120.

  5. 05
    Private exponent

    d = 2753, because 17 × 2753 = 46801 = 15 × 3120 + 1.

  6. 06
    Keys

    Public: (3233, 17). Private: (3233, 2753).

Encrypting and decrypting the number 65

terminale
Encryption c = 65^17 mod 3233 = 2790
Decryption m = 2790^2753 mod 3233 = 65

Anyone 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.

Continue with
05 Weaknesses and attacks

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.

↑