I absolutely love the movie The Imitation Game, but I have very little knowledge of cryptology or computer science (though I do have a relatively strong math background). Would it be possible for someone to explain in the most basic terms how Alan Turing and his team break Enigma during WW2?
Comments
I thought it was pretty well described in the movie. It was a combination of several things:
The Wikipedia page is pretty good, including the essential fact that Turing et al did not stand alone, but rather on the shoulders of the essential work done by the Polish team and some French spies beforehand. A truly international effort where, much like any code, all the pieces matter 🙂
https://en.m.wikipedia.org/wiki/Cryptanalysis_of_the_Enigma
There were several breakthroughs (I’m not going to explain how the ‘Bombe’ machine worked it’s complicated! But basically the machine could trundle through many versions of the rotor settings from the enigma machine and find matches) anyway,in a tour of Bletchley park I remember hearing from the tour guide that one of the main clues was that the signal senders often finished their messages with ‘Heil Hitler’ which gave the cryptographers a starting point for decryption.
They broke the code because the germans didn’t keep crypto discipline. They were able to deduce from outside clues what some recurring words must be, an when you have the original word and the coded word, all you need is a computer to work out the key.
The computer is needed because while its pretty straightforward math to work out the key, it is also A LOT of it. And because the way Enigma worked meant that you have to start your decoding all over again every time the key was changed, which was more or less every day, there was no way to do all the math with human power.
Also, they had a working enigma machine and a codebook from a sunk submarine. That definitely helped a lot, too.
One thing to know, they had access to an actual machine. It’s incredibly helpful to break the code!
Computerphile has a good couple videos, part 1 describes the problem, part 2 the solution
Part 1 https://youtu.be/d2NWPG2gB_A
Part 2 https://youtu.be/kj_7Jc1mS9k
Also Numberphile with similar structure
Part 1 https://youtu.be/G2_Q9FoD-oQ
Part 2 https://youtu.be/V4V2bpZlqx8
Edit
I realize now I might have broken the rules by not providing an actual explanation
Breaking the code in this context means guessing the machine settings that changed every day
You use clues like the facts that no letter is ever mapped to itself, and every day similar messages were sent like weather reports. Turing and his collaborators built an actual machine to assist them, that would mimic the Enigma and rapidly test the possible settings
Also read Gordon Welchman’s The Hut Six Story. He broke the other half of Enigma.
Don’t forget the several thousand women who worked there and actually decoded the messages, given the daily crib.
The Imitation game is a passable movie but very bad history. You probably should start learning that movies are entertainment, not a good way to get information.
Editing to bring in some clarity.
There is no evidence that Turing was autistic.
There is no conclusive evidence that Turing killed himself.
Turing was by turns abrupt, charming, witty and dismissive. He had little patience for fools.
Turing had no control whatsoever on how the information derived was used.
Turing was one of a large number of people that broke the enigma device. He was one of the key members, but probably not the most important.
Turing’s sexual proclivities were not what a modern person would call homosexuality. It was a combination of homosexuality and pederasty. His preferences were teenage prostitutes from the working class. That is ultimately what created the criminal issue.
Turing’s death happened more than a year after his temporary chemical sterilization had completed.
Turing was part of a far larger team than was shown in the movie. It was well funded.
There were many other efforts to break other more difficult German codes. Enigma was not the most difficult nor the most useful code to break.
Turing was an expert in what became computer structure and programming before the war. He didn’t come out of nowhere to solve enigma.
The difficult parts of Enigma had been solved by the Poles prewar.
Alan Turing was a pretty important figure, but it’s also important to remember that the Polish did a lot of the work beforehand. When the Nazis invaded Poland, Polish intelligence agents passed off most of their research to the Allies who were amazed at how much they’d done to deconstruct Enigma. The Polish were actually the ones who developed the bombes (massive arrays of mechanical mockups of Enigma) that were used in a crude form of parallel processing to break the code once the internals were figured out.
As others have stated, several other factors helped them break Enigma. One was the fact that the cords that swapped letters were static, and cryptographers were just all “Let’s just ignore that” so once those were eliminated from consideration they focused entirely on the disks which were the hardest part. The regular weather reports also would invariably start off saying “weather report” (“Wetterbericht” I believe) and knowing this the cryptographers would uses this as a starting point for decrypting things.
You can read more about this from Simon Singh’s “The Code Book.” It was what sparked my ADHD hyperfixation into cryptography back when I was in high school.
While lots of the other answers already contain lots of information, there is something that seems to be missing in nearly all of them:
The Enigma encryption (though a slightly weaker protocol) was broken first in 1932 by the Poles (in particular due to the Polish mathematician Marian Rejewski). They even built an electronic machine to facilitate the attack (although it had a different task than Turing’s bombs).
The attack already contained lots of the ideas that would be critical for Turing’s approach. Once it became clear that Poland would be conquered by Germany, the Poles gave all their knowledge on breaking the Enigma to the UK.
This is not to diminish Turing’s work. The Germans fixed one vulnerability on which the Polish approach relied, so the UK codebreakers needed a way to break the “new” Enigma encryption, to which Turings work was essential.
The Enigma had few weaknesses. A lot of if it was in how it was operated. The movie has to really cut down on the amount of effort they did to crack it and take some liberties.
They did use common words and try to find them as mentioned in the movie. The bombe automated this. Words like ‘weather’ ‘Hitler’ and numbers such as a likely temperature could be used as a crib. One station would often report Nothing changed, and thus expose the changes to that days keys.
Operational issues played a big part in cracking. Such as sending the message in a broken, simpler code and then sending it on to the bosses on the Enigma. Having plsintext makes it a lot easier.
Another was a policy that the messages always started off by typing in three random letters, two times and using that as a test of the encryption. it was discovered by the Polish people who originally cracked the Enigma that the first letter and the 4th, 2nd and 5th and the third and sixth letter were :tied together’ in a long chain that wpuld loop. And that let them figure out what the wiring on the wheels was. It was really a flaw in procedures the way it was USED, not a flaw in the Enigma.
So these three repeated keys were supposed to be random. To pick a random key, the overworked operators would sometimes pick three consecutive letters from the Enigma keyboard, such as QWE or BNM. These predictable message keys became known as cillies.
Another small design flaw that was a huge help was the wiring in the front. It’s the main difference in the commercial CA military enigma. It greatly increased the complexity by many orders of magnitude but there was a flaw. It was designed to swap one letter with another. The flaw is in that definition.
CAN YOU SEE IT?
A letter cannot be swapped to itself!
it could swap any two letters but as a result the letter A can never be encrypted to an A or a B to a B. One day someone studying the data in one intercept saw that there wasn’t a particular letter anywhere in this cybertext. Part of cracking codes is you write down how many A’s, B’s and C’s as some letters like e are used more often. And this was missing a letter.
But this one has no L’s. They took it to the cryptanslyst and it meant that the letter was just the letter L. Somebody was doing a test. And just hitting one key, being lazy. They were able to recover the days key from that one operational mistake.
Turing realized there were certain patterns where a possible key they were checking could create the same letter. Like an A being run thru Enigma and encoding an A. Thus would mean the key was no good. The Bombe had a “diagonal” set of checks added to it that checked this.. It eliminated a huge amount of work when guessing the plug board. So he designed the Bombe machine with 36 Enigmas to test the letters A-z and 0-9 at the same time that could try this.
Let’s say I want to communicate to you the password to use to access a safe. If I send the password to you “normally” (clear text), someone might intercept the message and steal the content of the safe, so I want to encrypt the message that I’m using to tell you the password.
Let’s take a very simple encryption method I could use to send the message to you: Caesar Cipher. The way Caesar Cipher works is that by choosing a key, like a number 1-25, a message is encrypted by shifting every letter by that key in the alphabet, which means that for a key 1 a->b, b->c, c->d, etc…
I send you the following message then: zwddg hskkogjv xgj ksxw ak jwvval
Often, in this kind of communications, both parties already have the key (so we met at some point and I told you “hey, I’d like to use 8 as a key”), so, if you know that the key I used is 8, the problem is as simple as shifting back every letter by 8, yielding the right answer (witholded for suspense).
However, if someone intercepts the message and they want to decrypt it, there are many possible ways to do so (the Caesar cipher is indeed very frail), but one such way of doing so is if you KNOW part of the content already. For example, if the attacker knows we are communicating about a password, and since there is an 8-letters word in the encrypted message (hskkogjv) they might try to find a key that maps the word “password” to that 8-letters word, and lo and behold you do indeed find a key of 8.
If you apply the key to the encrypted message you get “hello password for safe is reddit”. In hindsight, this message is terrible: “hello” is also very attackable even if you don’t know what the message is about.
Now finally enter the movie: Enigma is MUCH more complex than Caesar cipher, but the attack Turing did is very similar to this conceptually: they guessed the Germans were saying “heil hitler” in every communication they had, so they only had to look for keys that made the encrypted message match that sentence, and then they’d have the rest of the message “for free”.
by not letting the Germans know they had broken it.
I haven’t seen this mentioned yet in the other comments, but one of the main vulnerabilities they found was that an enigma machine, cannot scramble a letter back into itself. so for example, A, would never randomly be scrambled back to A at any point in the machine. This combined with the cribs made cracking the code much easier because they could eliminate any possible settings where the cribs and words in the cipher overlapped.
Neal Stephenson’s novel “Cryptonomicon” walks you through the process step by step, if you have the patience to work your way through it. Good book, too.
If you are genuinely interested in how it was done, I highly recommended The Code Book by Simon Singh (978-1-85702-879-9). It goes into the history and technical details of how Enigma worked and was broken.
The Imitation Game is a poor movie, and gives a grossly simplistic view of the events at Bletchley Park to introduce movie drama.
Let’s start from the beginning.
A very basic coding technique is basically shifting the alphabet. Then you have a shifting value, and you replace each letter with another letter shifted by that value. If the value is 2, then you replace each “a” with “c”, each “b” with “d” and it rolls over. For example a message “aaa” would always look like “ccc”. It’s very easy to decipher.
The next level could be, shifting the shifting value by a rule. So the first letter is shifted by 2, the second letter is shifted by 5, then the next is shifted by 1. For example the message “aaa” would look like “ceb”. For this to decipher, you need to figure the rule, but if you have enough messages, you can figure it out.
Enigma was a machine that created shifting rules. It had a lot of setting and each setting was basically a new shifting rule. So one day, “aaa” would become “ceb”, the other day it would become “xft”. All because of the initial setting.
The problem with it is that every day it’s a new setting out of millions of possible ones, and just because you figure some letters, you can’t tell the others.
And here comes the brute force. What if, you had 10000 of enigmas, and they could go through the settings automatically? (Enigma was set up with wires and wheels turned by people, but you can motorize the wheels and replace cable plugs with switches moved by relays.) So now you have a machine that can go through each setting one by one by turning the wheels and switching the relays.
The last thing you need, is a known word to compare with the cipher. Then you need to run the machine until it figures a setting at which “gh uwvg” becomes “my word”. The longer the word the better, short words can be produced by many settings. But if you have a long enough word, your machine will turn the settings until the input message matches the known part, and at that setting the rest of the message must be intelligible.
They figured out that certain messages contained predictable words and phrases. For example every morning at a particular time, bang on time (German efficency) a weather report would be transmitted. They had copies of these from other sources, and knew the format.
The message always started “Wetterbericht” which is weather report in German, and it always ended “Heil Hitler” every day. There were other messages they could use two, that’s just one example.
Enigma worked by swapping letters with each other, so for example a G would become a U, and a U became a G. The tricky part is each time you type a letter the code wheels advance, and this changes which letters swap with which, so its not a static relationship. If I press G 3 times in a row it’ll encode as 3 different letters. Let’s say U, B, L.
Ok, because the letters are a direct swap, if I start with identical settings and type U, B, L I’ll get G, G, G back. Thats how messages are encoded and decrypted. Theres an agreed start point for the settings on the device. You type your message and record what comes out. Thats the coded message. Type the coded message in from the same start settings and you get the original message back. If the initial settings arent correct though you get gibberish.
Operators of Enigma were issued a crypto book, and it would show each day and the initial settings to be used on that day. Unfortunately the Germans forgot to issue the Brits with this code book…. spoil sports.
What Turing and his team did was build a machine, based on a Polish device, that could VERY rapidly go through every possible combination of settings on Enigma. You put the predictable message in and it checks every combination of settings to find the one that outputs what you expect, I.e. the settings that give you “Wetterbericht” and “Heil Hitler” back from the encoded message.
Its effectively a brute force solution, you try every combination until one works.
Once youve found the settings that work…. well now youve got today’s initial settings, so you can decode any more messages today exactly as the German Enigma operators are doing.
He didn’t. Marian Rejewski did back in the early 30s. Once Poland fell they transferred what they’d accomplished to the British and that formed the foundation for Turing’s work. Turing took the ball and ran with it, though, and thanks to him the Allies were able to determine the keys for decryption faster and faster, but they wouldn’t have been able to do it without building on the work of the Poles.
The movie and the responses to this question vastly underestimate the amount of work put in to break Enigma. Alan Turing was a key member but not the one and only guy who figured everything out. They never even mention the REAL genius responsible for breaking Enigma — a Pole who broke it before the war. The Poles basically handed the Brits a working Enigma replica and half a dozen tools for breaking messages.
There were half a dozen geniuses who came up with dozens of tools and techniques to tease out some minor info from messages, like which rotors were in use Tuesday 6 weeks ago, and hundreds of people that we would all describe as really really smart supporting them.
One of the most important techniques didn’t even work directly on the messages. It turns out that for each particular setup of rotors and rotor positions, the letters in the output formed “cycles”. Like this particular setup generates text where cycles PGX, BNF, QKJO, and UIMZA exist a couple times each. Like some long message has “…GXP….PGX….PGX…XPG…” where “…” are long stretches of other letters. That means the setup generates two 3s, a 4, and a 5 cycle. Doesn’t matter what the letters are, some other message that day may have 3, 3, 4, 5 where the “4” is TBNZ instead of QKJO. What matters is that they made a set of books where they can look up every known rotor setup that generates 3,3,4,5. There will be thousands of such setups, but not billions. So now they can set up a bombe (the big machine in the movie) to run through those thousand setups. The output is still mostly unreadable, but now it’s closer to a simple substitution cypher, like A is swapped with T, etc..
One thing I hated about the movie was the whole “oh no, it’s midnight and we didn’t solve the cipher. Shut it down and start over tomorrow.” This is obviously BS. Week-old intel was still very useful, and they’d work on some particular day’s intercepts (that had promising patterns for decrypt) for weeks.
If you’re interested in a much more accurate history of Turing’s contributions, read the excellent biography Alan Turing: The Enigma by Andrew Hodges. The movie was supposedly based on that book, but basically just made shit up.
As others have mentioned, one of Turing’s contributions was improving (not inventing) the bombe, a mechanical (not electronic) device created by the Poles to try different combinations of Enigma settings. Turing, who had designed a theoretical model of computing in the 1930s that’s still used today, would not have considered the bombe a computer in the modern sense, and he certainly didn’t name it “Christopher” after his boyhood crush. (Fun fact: The codebreakers called the machines “bombes” because the ticking sounds they made reminded them of time bombs.)
Also, the actual Turing was confident and athletic, not the stuttering nerd portrayed in the movie.