The key space must be large
A shift cipher has 26 keys and falls to exhaustive search in seconds. Large key space is necessary and far from sufficient.
Three ciphers built from modular arithmetic, each broken by a different attack. They are worth studying because the reasons they fail are the requirements a real cipher must meet.
Core ideas
Each cipher is modular arithmetic on letters. Each is broken, and the break teaches the design requirement.
A shift cipher has 26 keys and falls to exhaustive search in seconds. Large key space is necessary and far from sufficient.
Any cipher mapping each letter to a fixed other letter preserves letter frequencies, and English frequencies are distinctive enough to break it.
Vigenère falls because the key repeats. The one-time pad is provably secure precisely because it never does.
The material
Construction, decryption and attack for each.
Encode letters as 0 … 25. Encryption is E(x) = (x + k) mod 26 and decryption is D(y) = (y − k) mod 26. Caesar's cipher is k = 3.
There are 25 useful keys, so an attacker tries them all and reads the output. This takes seconds by hand. The lesson is that a key space must be far too large to enumerate — modern ciphers use 2¹²⁸ keys or more.
E(x) = (ax + b) mod 26, with gcd(a, 26) = 1 so that a is invertible. Decryption is D(y) = a⁻¹(y − b) mod 26.
The coprimality condition is exactly “Bézout's Identity and Modular Inverses”'s: without it the map is not injective and decryption is impossible. Since 26 = 2 · 13, the valid multipliers are the twelve values coprime to 26, giving 12 · 26 = 312 keys.
a = 5, b = 8. The letter H is 7, so E(7) = 5·7 + 8 = 43 ≡ 17 = R. To decrypt, 5⁻¹ ≡ 21 (mod 26) since 5 · 21 = 105 = 4·26 + 1, so D(17) = 21(17 − 8) = 21 · 9 = 189 ≡ 7 = H. ✓
312 keys is still trivially searchable, and the cipher has a worse problem: it is a substitution, so letter frequencies survive. E is the commonest letter in English at about 12%, and whatever it maps to will be the commonest ciphertext letter. Two frequency matches determine a and b.
A keyword gives a repeating sequence of shifts: the ith letter of the message is shifted by the (i mod L)th letter of the key, where L is the key length.
This defeats simple frequency analysis, because one plaintext letter encrypts to different ciphertext letters depending on its position. It was called le chiffre indéchiffrable for three centuries.
It falls in two stages. First find the key length: repeated plaintext fragments aligned with the same key position produce repeated ciphertext, and the distances between repetitions are multiples of L (Kasiski's method). Second, split the ciphertext into L columns, each of which is a single shift cipher, and break each by frequency.
The structural failure is key reuse. Once the period is known, a message of any length gives as much frequency data as needed.
If the key is uniformly random, at least as long as the message, and never reused, then the ciphertext gives an attacker no information about the plaintext: every plaintext of that length is equally consistent with the observed ciphertext.
This is Shannon's theorem, and the one-time pad is genuinely unbreakable. It is also nearly unusable: the key is as long as the message and must be distributed securely in advance, which is the problem encryption was meant to solve.
Reusing a one-time pad destroys it completely. Two messages encrypted with the same key satisfy c₁ ⊕ c₂ = m₁ ⊕ m₂, from which both plaintexts can usually be recovered — the failure that broke the Soviet VENONA traffic.
“RSA Encryption”'s RSA answers the key-distribution problem instead: no shared secret is needed at all.
Interactive
Algorithms with their traces
Method
The requirement first, then the attack.
For an affine cipher gcd(a, 26) = 1, or the map is not invertible and decryption fails.
Convert to 0 … 25, apply the map modulo 26, convert back.
English frequencies are distinctive: E about 12%, T 9%, A 8%. Two matches determine an affine key.
Repeated fragments give multiples of the key length. Then each column is a shift cipher.
Ciphertext frequency analysis gives the two commonest letters.
Two frequency guesses gave a linear system, which “Linear Congruences” solves. If the decryption is nonsense the next guess is E→R, T→ something else, and there are only a few to try. The cipher offers no resistance beyond that.
Given that the two commonest ciphertext letters are K and D, solve for a and b assuming they correspond to E and T. The system is two linear congruences, which “Linear Congruences” handles; the key comes out as (3, 24), and the lab will confirm E → K and T → D.
Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.
No recommendations yet for this lesson.