RSA · 01 How it works

RSA: how it works

Key generation, encryption, decryption and signing with RSA, explained step by step without complicated formulas.

RSA can be described in three moments: creating the keys, using the public key and using the private key.

  1. 01
    Choose two prime numbers

    Two very large primes are generated at random, each over three hundred decimal digits long for a 2048-bit key.

  2. 02
    Compute the modulus

    The two primes are multiplied: the product, called the modulus, is part of both keys.

  3. 03
    Choose the public exponent

    A number with certain properties relative to the primes is chosen; in practice almost always 65537.

  4. 04
    Compute the private exponent

    Knowing the two primes, a second number is calculated: the private exponent. Without knowing them, calculating it is infeasible.

  5. 05
    Publish the public key

    Modulus and public exponent are distributed; the primes are destroyed or kept with the private key.

Encrypting and signing

OperationKey usedWho can do it
Encrypt a message for AnnaAnna’s public keyAnyone
Decrypt the messageAnna’s private keyOnly Anna
Sign a documentAnna’s private keyOnly Anna
Verify the signatureAnna’s public keyAnyone
Continue with
02 History

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.

↑