The Oscar-winning film The Imitation Game is based on the life of British mathematical genius Alan Turing, whose team broke the Nazi Enigma code. But their triumph was built on the groundwork of Polish mathematicians.
At first glance, the Enigma machine looks like a clunky manual typewriter. But in fact, before and during World War II, it was one of Nazi Germany's most powerful weapons.
Back then, messages transmitted by radio and were easily intercepted by the enemy. But thanks to the Enigma machine's encryptions, the gibberish gathered by the Allies was completely unreadable. The machine was used to encrypt all German military communications and the Allies and even the Germans themselves thought the Enigma's secret code was unbreakable.
English mathematician Alan Turing and his team at Bletchley Park famously cracked the code during World War II. His story is now the focus of the Oscar-nominated film, The Imitation Game. But he was not the first to figure out the Enigma's secrets.
Even though Germany had been defeated in WWI, Poland was still driven by fear of its dominant neighbor and the rise of Adolf Hitler. So in the 1930s Polish intelligence secretly intercepted and deciphered German military messages.
Espionage and mathematics
How the Poles cracked pre-war Enigma codes is a tale of espionage and mathematical insight – mixed with a bit of luck. A destitute Berlin war ministry employee named Hans-Thilo Schmidt sold top secret Enigma documents to a French spy, who passed them on to the Poles.
The information was precisely what Polish mathematician Marian Rejewski and his colleagues needed to break Enigma. Schmidt's blueprints of the encryption mechanisms enabled the Poles to build a replica of Enigma, just like the pre-war military model on display at the Arithmeum museum of mathematics in Bonn, Germany.
Messages were easy to intercept...
but difficult to decipher, except for the recipient who had the secret code...
The machine has 26 alphabet keys and when one of the typewriter-like keys is pressed, the encrypted letter lights up on a lampboard above the keyboard.
Beneath the keyboard is a plugboard with 26 connections for cables that swap letters, so that, for example, A becomes B and vice versa (see graphic). Until the late 1930s, the German Wehrmacht had used six cables with 12 plugs to switch letters, leaving 14 letters unchanged.
Far more challenging for potential codebreakers than the plugboard, was the scrambler above the lampboard. It has slots for three interchangeable rotors or rotating wheels with 26 positions from A to Z.
“Once you have encoded a letter, the first wheel would rotate one position and thereby change its permutation, and after 26 rotations, the middle wheel would also rotate 26 times,” explained Bonn mathematician Stephan Held of the Research Institute for Discrete Mathematics.
“The permutation would change after every single letter and that made it difficult to decipher the Enigma machine.”
The number of letter combinations, or permutations, for three rotors - each with 26 positions from A to Z - created 17,576 starting positions (see graphic). But because each of the three rotors was wired differently and was interchangeable, there were 6 possible ways to insert them in the three slots. This resulted in 105,456 permutations - a large, but manageable number for Rejewski and his Polish mathematicians.
Searching for mathematical fingerprints
from 105,456 permutations to 1,054,560 overnight...
“This is the amount of set-ups that the Poles simulated in order to break the machine. They just catalogued every single one of these combinations,” Arithmeum's Enigma expert Mario Wolfram told DW.
Rejewski discovered that each of these 105,456 permutations generated a unique mathematical pattern, like DNA or fingerprints used by a detective to track down a suspect. He then tried to match a three-letter starting position for intercepted messages with patterns of known permutations in his catalog. If Rejewski found a match, he could decrypt the message.
But if a message was too short and a pattern was hard to discern, educated guesswork narrowed the possibilities.
"Human beings often choose simple keys like AAA, BBB or three consecutive letters on the keyboard. He would try these best guesses until he found a match," said Held.
Germans upgrade Enigma before WWII
But in late 1938, the Poles ran out of luck. Overnight the Germans added two more rotors to Enigma, so any possible combination of five rotors could be inserted into three slots (see graphic).
“This made it a lot harder for the Polish cryptographers. You get 60 possible ways of inserting the rotors in the machine, whereas before you only had six, so the work they had to do to decrypt messages was increased tenfold,” said Wolfram.
This increase meant more than one million starting positions for the five rotors. The number of cables for the plugboard was also increased from six to ten. The Poles didn't have the resources anymore to cope with the changes.
Besides, by that time the Polish mathematicians now had to flee their country. But they first handed over everything they knew about Enigma to French and British intelligence.
The Nazis invaded Poland on September 1, 1939. France was under occupation by 1940. So it was left to Alan Turing's team at Bletchley Park, north of London, to defeat the Enigma machine. And from there, thanks to history and now Hollywood, we know how the story ends.