Procedure Keygen

01: Choose two random λ/2-bit primes p and q
02: n = p · q
03: ϕ = (p − 1)(q − 1)
04: Select e such that 1 < e < ϕ and gcd(e, ϕ) = 1
05: Compute d such that 1 < d < ϕ and (e · d) ≡ 1 mod ϕ
06: Set PK = (e, n)
07: Set SK = (d, n)
08: return (PK, SK)

Procedure Encrypt(PK ,m)

// Assume m ∈ ℤₙ* (i.e., m is invertible mod n)
Procedure Encrypt(m, PK = (e, n))
01: c = m^e mod n
02: return c

Procedure Decrypt(SK, c)

Procedure Decrypt(c, SK = (d, n))
01: m = c^d mod n
02: return m
  • RSA security depends on hardness of finding from , ; Related to hardness of factoring of .
  • The textbook algorithm are deterministic. In practice, some random padding is used.
  • Shor’s quantum algorithm can solve factoring in polynomial time. However, a quantum computer of required capacity is still quite far away in the future.
  • Wikipedia says would work. Strictly speaking, it is required that . On the other hand, finding a such that will lead to finding or , and breaking the system.
  • Wikipedia says any would work. Strictly speaking, it is required that . On the other hand, finding a such that will lead to finding p or q, and breaking the system.