RSA encryption scheme

Algorithm

  1. Construction Phase:
    1. Select two random large primes p, and q.
    2. Calculate N = pq and ϕ(N) = (p−1)(q−1).
    3. Pick an encryption key e that is coprime with ϕ(N).
    4. Calculate the decryption key d such that de ≡ 1 (mod  ϕ(N)).
  2. Operation Phase:
    1. Make the public key (N,e) public, and keep p, q and d as secrets.
    2. Sender encrypts its message M as E(M) = Me (mod  N).
    3. Receiver decrypts it by calculating E(M)d = Med ≡ M (mod  N).