Modern Cryptography

Lecture 25
→ next · ← back · F fullscreen

Secure communication

Alice Bob M M C = EncK(M) K K Eve

Alice encrypts with EncK, Bob decrypts with DecK:  M = DecK(C).  Eve sees C, but not K.

Recall: the one-time pad

C = M ⊕ K      M = C ⊕ K

Perfectly secret, but the key must be random,
as long as the message, and used only once.

Block ciphers and AES

Block ciphers

EncK : {0,1}n → {0,1}n,    DecK = EncK−1
  • A short key (128–256 bits), whatever the message length
  • Long messages are split into blocks of n bits
  • Security rests on computational assumptions
AEScurrent standard
DES, 3DESobsolete
Serpent, Twofishsecure alternatives

AES

plaintext block
16 bytes
→
key
128 bits
↓
AES
10 rounds
→
ciphertext block
16 bytes
each round
SubBytesreplace each byte using a table
→
ShiftRowsshift the rows
→
MixColumnsmix each column
→
AddRoundKeyXOR with a round key

SubBytes

Each byte is replaced using a fixed table (the S-box).

input byte (click the bits)

ShiftRows

MixColumns

AddRoundKey

state[i, j] ← state[i, j] ⊕ roundkey[i, j]

Click any bit. XOR: 1 when the two bits differ.

AES, round by round

Avalanche effect

plaintext: 128 bits (click one to flip it)
ciphertext: bits that changed are highlighted

Security of AES

Assumption: without the key, AES output looks random.

No known attack is much faster than trying every key.

number of keys2128 ≈ 3.4 × 1038
a very fast attacker1018 keys per second
time to try them all≈ 10 trillion years

about 800 times the age of the universe

Modes of operation

ECB mode

Ci = EncK(Mi)     Mi = DecK(Ci)

Identical plaintext blocks give identical ciphertext blocks.

Encrypting an image

original
AES in ECB mode
AES in CTR mode

CTR mode

Ci = Mi ⊕ EncK(nonce ‖ counteri)
Never reuse a nonce with the same key: it leaks  C1 ⊕ C2 = M1 ⊕ M2

Common modes

ModeHow it worksSecurity
ECBencrypt each block independentlyinsecure: leaks patterns
CBCchain each block into the next, random IVsecure if used properly
CTRencrypt a counter, XOR with the messagesecure if the nonce is never reused
GCMCTR plus authenticationsecure, and detects tampering
SIVsynthetic IV (misuse-resistant)nonce reuse only reveals repeated messages

Public-key cryptography

The key-exchange problem

Alice Bob K ? Eve

Alice and Bob have never met, and Eve hears everything.
How can they agree on a secret key?

Public-key cryptography

Alice Bob M M C = Encpk(M) pkBob’s public key skBob’s secret key Eve

Like an open padlock: anyone can snap it shut (pk),
only Bob’s key opens it (sk).

RSA

key generation (Bob)
  1. Choose large primes p, q; let n = pq
  2. φ(n) = (p − 1)(q − 1)
  3. Pick e with gcd(e, φ(n)) = 1
  4. d ≡ e−1 (mod φ(n))
keys

pk = (n, e)    sk = (n, d)

encrypt / decrypt

C = Me mod n

M = Cd mod n

RSA: example

Why RSA works

Claim. (Me)d ≡ M (mod n) for every 0 ≤ M < n.

Since ed ≡ 1 (mod φ(n)):   ed = 1 + k(p − 1)(q − 1) for some integer k.

Step 1. Med ≡ M (mod p):

  • if p | M: both sides are ≡ 0 (mod p);
  • if p ∤ M: Fermat gives Mp−1 ≡ 1, so Med = M · (Mp−1)k(q−1) ≡ M (mod p).

Why RSA works (continued)

Step 2. The same argument with q:  Med ≡ M (mod q).

Step 3. p and q are distinct primes, so by the Chinese Remainder Theorem

Med ≡ M (mod p) and (mod q)  ⟹  Med ≡ M (mod n).  ∎

Security of RSA

Security rests on the assumption that factoring large n is infeasible.

factoring easy  ⟹  RSA broken
RSA broken  ?⟹  factoring easy  (open)
Largest RSA challenge number factored: 896 bits (September 2026). Keys in use today: 2048 bits or more.

Digital signatures

Digital signatures

Bob wants to know:

  • did this message come from Alice?
  • was it changed on the way?
  • can Alice later deny sending it?
sign Alice uses her secret key
verify anyone uses her public key

RSA signatures

sign: S = Md mod n      verify: Se mod n =? M
Alice signs
Bob receives and checks

Putting it together

Combining AES and RSA

AESRSA
speedfastslow
shared secret key neededyesno
used forencrypting the datasharing the key, signatures

Real systems use RSA to share an AES key, then AES for everything else.

Hybrid encryption

Alice
Bob
1
publishes pkA
⇄
publishes pkB
2
picks a random AES key K, sends CK = EncpkB(K) and S = SignskA(CK)
→
checks S with pkA, recovers K = DecskB(CK)
3
sends C = AES-GCMK(M)
→
checks the GCM tag, decrypts M

Quantum computers

RSA

Shor’s algorithm factors in polynomial time.

Broken by a large quantum computer.

AES

Grover’s algorithm: only a square-root speed-up.

Still secure with 256-bit keys.

Summary