RSA (Rivest, Shamir, Adleman, 1977) is a block cipher over Zn used for both encryption and digital signatures. Security rests on the integer factorization problem: given n=pq for 2 large equal-size primes, finding p,q is computationally intractable.
Compute n=pq, public, its bit length is the RSA key length.
Compute ϕ(n)=(p−1)(q−1), kept secret.
Choose e with 1<e<ϕ(n) and gcd(e,ϕ(n))=1, public.
Compute d≡e−1(modϕ(n)), secret.
Public key: {e,n}. Private key: {d}. p, q, and ϕ(n) must be destroyed after generation.
Encryption and Decryption
c=memodn,m=cdmodn
Encryption cost is a single exponentiation with a small exponent e. Decryption cost is a single exponentiation with an exponent up to the full length of n, far more expensive.
Correctness
(memodn)dmodn=m
Worked Example
p=17, q=11.
n=187.
ϕ(n)=16×10=160.
e=7, since gcd(7,160)=1.
d=23, since 23×7=161=160+1.
Public key {7,187}, private key {23}.
For m=88: c=887mod187=11, and m=1123mod187=88.
RSA Digital Signature
Uses the same key pair as RSA encryption, with the roles of e and d reversed.
With message recovery
Applies when the message m<n directly. Signature σ=mdmodn, signed with the signer’s private key.
Without message recovery
Hashes the message first. Signature σ=H(M)dmodn, sent as the pair (M,σ).
Verification
With recovery: compute m′=σemodn using the signer’s public key, and check it matches the expected message.
Without recovery: compute h′=H(M′) and h=σemodn, accept iffh=h′.
Signing cost is a hash plus a single exponentiation with a full-length exponent d. Verification cost is a hash plus a single exponentiation with the small exponent e, plus a comparison.