Diffie-Hellman & RSA

Public-key math your exam tests

Mission tie-in: DH agrees on a secret; RSA encrypts messages. Both use modular exponentiation — practice the arithmetic until it's automatic.

Diffie-Hellman

Purpose: Key agreement over an insecure channel.

Y = α^X mod q
K = Y_other^X mod q

Public: q, α. Private: X. Never send X.

RSA

Purpose: Encrypt/decrypt (and sign).

C = M^e mod n
M = C^d mod n

Public: {e, n}. Private: {d, n}.

Diffie-Hellman — visual flow

Canonical course example: q=353, α=3, X_A=97, X_B=233. Values below are computed live.

MITM weakness: Without authentication, an attacker can substitute their own Y values. DH alone does not prove identity.

RSA — key generation steps

Example p=11, q=17 — encrypt/decrypt math in RSA Modular Math (computed tables).

StepFormula
1n = p × q
2φ(n) = (p−1)(q−1)
3Choose e: gcd(e, φ)=1
4d = e⁻¹ mod φ (Extended Euclidean)

RSA — encrypt & decrypt

Message M = 21, e = 19, n = 187 → C = 2119 mod 187. Use RSA Modular Math successive-squaring calculator for C and d.

Retrieval practice

Which statement is true about Diffie-Hellman?

Retrieval practice

For RSA with p=11, q=17, what is φ(n)?

Stuck? Ask: "Compute 3^97 mod 353 step by step" or "Find d when e=19 and φ=160."