How does the Enigma Machine from the Imitation Game work? | Movie Tech

in #technology7 years ago

It is often remarked that wits win you a war, rather than numbers. Time and again it has been proven throughout history. There have been many such examples when, despite being on the defense for a long time, a sudden breakthrough with the help of sheer intelligence helps to turn
the tables.

This is precisely what happened during World War II when Allied forces cracked the Enigma code used by Germans in their radio communication. This not only helped lead to an Allied victory, but also proved how the pure intelligence of a small group of people can save millions of lives.

So how did these enigma machines work? Why was the enigma code so difficult to crack? Well you’re about to discover why….

download.jpg

The Imitation Game follows the story of Alan Turing, masterfully portrayed by Benedict Cumberbatch, a brilliant Cambridge mathematician who was instrumental in shortening World War II, having been employed by the British military to crack Nazi codes.

He famously lead a motley group of scholars, linguists, chess champions and intelligence officers, which cracked the so-called unbreakable codes of Germany's World War II Enigma machine. The Enigma Machine was a cipher machine that was developed back in the 1920s. It was meant to be a cipher device that would help in the transmission and reception of classified messages in the political and business domain. However, due to its brilliant ingenuity, it was used extensively during the second World War by German armed forces in their military operations.

Essentially, the Enigma Machine did the same work as any other cipher machine; it facilitated the encryption of classified communication. In other words, it coded and decoded messages that were then transmitted over thousands of miles. Although the machine was originally meant to be used to transmit confidential business-related information, but in the late 1930s, its unmatched potential as a transmission device in the theater of warfare was realized.So why was the enigma code so difficult to break?

For a single encoded message, there are a total of 159 million million million settings of the Enigma Machine, only one of which is correct. This means that you have to work through these many settings to find the one correct setting. For a normal human being working without the aid of machines, it would take hundreds of years to go through all these possible settings, and there would still be no guarantee of success.

Obviously, you could not possibly take that much time to decode a message in the theater of war, given the fact that the Nazi Army changed the settings of the machine as the clock struck 12 each day at midnight. All you had to work with was a meager 24 hours to go through trillions of millions of possible settings to decode a single message. Adages about finding needles in haystacks seem like childsplay compared to this. So how did the enigma machine work?

The Enigma machine is an electro-mechanical device. It is mechanically operated, with an electric signal passed through wires and various mechanical parts. The easiest way to explain the mechanics is to follow the journey of a single letter from keyboard to lampboard.

This diagram shows the path the signal takes from pressing the letter 'T' on the keyboard to the 'G' lamp lighting up.
download.png

Keyboard
When the operator presses the letter 'T' on the keyboard it creates an electric signal that begins the journey through the Enigma machine wiring that will end with a lamp flashing on the lampboard.

Plugboard
The first stop on the journey is the plugboard. Here the signal is connected to the 'T' input on the keyboard. Some of the letters on the plugboard will be wired up to other letters (the plugs), causing the signal to be diverted. If the 'T' input is not plugged to another letter then our signal will pass straight to the 'T output. In our case, though the 'T' is plugged to the 'K', so the signal is diverted to a new path, the letter is now 'K'.

Static Rotor
The next stop is the static rotor, which as the name suggests does nothing to the signal it simply turns wires into contacts (the signal only passes when the contacts touch). So our signal is still the letter 'K'. The static rotor output is connected to the input of the right rotor. This is where things get more complicated.
Rotors (Scramblers)
There are five possible rotors that can be used in any order for the three rotor positions: right, middle, left. Each rotor has an inner ring of contacts and an outer ring of contacts and their purpose is to scramble the signal. The outer ring contacts connect each rotor to the next rotor (or the static rotor / reflector) as well as its own inner ring. The inner ring contacts can be rotated relative to the outer ring which results in even more possible connections (and therefore, letter substitutions). The whole rotor itself can be rotated relative to the static rotor, so that the static rotor 'A' output is not connected to 'A' input on the rotating rotor.

Furthermore, as each letter is entered the rotors rotate by one position, so that the same letters are never connected together in the same message. To add further complication, each rotor has a notches (different rotors have the notch in different positions) which when reached, causes the next rotor to its left to step forward too. In the case of the middle rotor, it causes the left rotor to step as well as itself (the infamous double stepping mechanism).
In our example, we are using rotor III in the right-hand position.

Reflector
The reflector takes the input and reflects back the electrical signal for its return journey through the rotors. There are two possible reflectors, each of which is wired up differently so that the input letter is transformed to a different letter when reflected back. In our example, we are using 'Reflector B', which turns our input letter 'H' into output letter 'D'. It is important that the signal is scrambled when reflected, because of the way the Enigma machine is designed -- if you enter the cipher text you get back the clear text. So if the reflector output is the same letter as its input when the signal passes back through the rotors they will just unscramble what was already scrambled and you would get your original letter back again unencrypted!

Reverse Journey
The reflected signal now passes back through the rotors, which work in exactly the same way in reverse. So our letter 'D' passes through the left rotor and becomes 'G', which then passes through the middle rotor and becomes 'R', which then passes through the right rotor and becomes 'W'. The signal remains unchanged as it passes through the static rotor again (connecting contacts to wires), before it passes through the plugboard - here the signal is again left as it is if there is no plug, or changed if the letter 'W' is plugged to another letter. In our case the 'W' is plugged to the letter 'G', so our plugboard output is 'G'.

Lampboard
The final stop is the lampboard, where the plugboard output is connected to the corresponding lamp for that letter. In our example, the letter 'G' lights up meaning the original letter 'T' is encrypted as 'G'.

The Enigma machine operator notes down the output letter and then enters the next letter in the message, and so on for every letter in the message.
So it was extremely well designed, but like the unsinkable ship before it, the unbreakable code was broken by Turing and his team. But how? Well, unlike the movie would have you believe, he actually had a lot of help.

The Polish Cipher Bureau became aware of a new German code in 1926 and set to work on it. Without having access to an Enigma machine and only having access to encrypted messages, Marian Rejewski, a Polish Mathematician and cryptologist was able to deduce the wiring of the rotors and the reflector; this was a huge intellectual accomplishment that is unfortunately little known today.

Thanks to Rejewski, Poland was able to read Enigma enciphered messages from 1932 to the outbreak of World War II. The Polish Cipher Bureau provided all its information on the Enigma machine - a reconstruction of the Enigma machine, details on decryption techniques and "bombe" decryption machines - to French and British intelligence services in July 1939. Both France and Britain had made no headway on the Enigma based ciphers up to that point. The cryptanalysts of the Cipher Bureau, including Rejewski, escaped to France at the outbreak of the war and continued their work on Enigma. With the fall of France, Rejewski fled again making a roundabout escape to Britain. On arriving in Britain, Rejewski was inducted into the Polish Army and was set to work on low level German ciphers. He and other Polish cryptographers were not allowed to work on Enigma at Bletchley Park, a senseless waste of their talents. So what contribution to breaking Enigma did Alan Turing make?

Knowing all the internal details of Enigma does not mean any given message can be readily decrypted. If the initial settings of the rotors and plug board are not known, there were 100,000,000,000,000,000,000,000 (Sextillion) possibilities of initial settings to check.

Polish cryptanalysts had invented techniques and machines - "bombes" - to automate the search for the initial settings but these had proved increasingly inefficient as Germany increased the complexity of the Enigma machine. Turing's great contribution to breaking Enigma was the design of an improved "bombe" to search for the daily Enigma settings. Unlike the mechanical Polish bombe, the Turing-Welchman bombe, developed by Turing and Gordon Welchman, was electro-mechanical and far faster than the mechanical bombes.

One of the fascinating weaknesses of the Enigma was that a letter could not be encrypted as itself. The cleartext letter A could be cypher letter B, C, D etc up to Z, but never A. Another was that the plugboard cross-connected up to ten pairs of letters.

This vastly increased the number of combinations, but also meant that if you cross-connected, say, W and T, a cypher W would come out as T after the plugboard and a cypher T would come out as W after the plugboard. These features could lead to contradictions. The bombe looked for contradictory settings where for instance both a cypher A and a cypher T would come out as a W after the plugboard, and eliminated that setting.

The Bombes themselves were 7ft wide, 6ft 6in tall and weighed a ton – literally. They had 12 miles of wiring and 97,000 different parts. Turning’s prototype was built on a budget of £100,000, which is around £4m today. Essentially, the Turing Bombe was an electromechanical machine comprised of the equivalent of 36 different Enigma machines, each one containing the exact internal wiring of the German counterpart.

When the Bombe was switched on, each of the Enigmas is allocated a pair of letters from the obtained crib text (for example, when a D becomes a T in the guessed word). Once the machine is switched on, each of the three rotors moves at a rate mimicking the Enigma itself, checking on approximately 17,500 possible positions until it finds a match. The machine only stops when each of the Enigma machines finds what it believes to be the correct pair of letters at the same time and opens up its electrical circuit. So rather than guessing the key, the Bombe used logic to dismiss certain possibilities. As Arthur Conan Doyle said: “When you have excluded the impossible, whatever remains, however improbable, must be the truth.”

This method, though successful, still provided a number of possible correct answers for the German ring settings, so further work needed to be done to narrow it down to the right one. With the help of a checking machine, the process could be repeated until the correct answer was discovered.

The Turing-Welchman bombes, followed by many improvements in design and speed, reduced the time to decrypt Enigma messages to hours instead of days or weeks making Enigma decrypts much more valuable.

Turing also devised a number of statistical tests to reduce the number of initial settings checked by bombes, thus making Enigma decryption more efficient. It was through this efficient enigma decryption that the allied forces knew the Axis powers every transmission and ultimately what helped steer them on a course to victory in the war. It’s really hard to understate the importance of this breakthrough or to conceive of a world where this small team, building on the work of their Polish counterparts, didn’t crack the enigma code.

Thankfully such a scenario can only play out in our imaginations in a very strange and difficult to conceptualize version of history…..a historical enigma.

If you enjoyed the video then hit the like button, it really helps us out and make sure you subscribe to see more content from us. Let us know in the comments what other pieces of tech we should explore from movies. Check us out on Facebook and Instagram, links are in the description. Thanks for watching and see you next time.