Enigma Encryption Device | How it works
One of my favorite topics around the massive slaughterhouse called WWII. Enigma was the German key ingredient during WWII. Since safe communication is paramount, always was and always will be, German troops needed to ensure safe communication between troops’ positions. In this blog, I will write about the Enigma Encryption Device.
Enigma relied on the so-called rotor-based encryption mechanism invented by Theo A van Hengel and RPC Spengler, the two Dutch naval officers who worked for the Dutch War Department. This invention took place in 1915.
Why was Enigma that big of a deal?
Enigma had one useful feature that most ciphers of the time didn’t have: a polyalphabetic property - behavior to produce a different letter for the same entered letter of the open text (open text: not encrypted text). This means that if we type “A” three times we will, potentially, end up with three completely different letters. One flaw that Enigma construction presented was that the output letter will never be the same as the input letter: input letter “A” and the output will never be the letter “A”.
Let’s check out the Enigma construction so we can understand the process and polyalphabetic property. To understand the Enigma cipher mechanism we need to take a look at the main components of it:
How does it work?
To fully grasp Enigma’s mechanics let’s start adding one piece at a time and explaining its purpose.
The battery is used to power the electrical circuits within the Enigma machine so we can actually do something (type on a keyboard and see light bulbs lighting ciphertext letters). Let’s firsts see how a keyboard without any cipher mechanism would work. Also, I’ll use a keyboard of four letters only to trim off unnecessary complexity and for ease of understanding the entire concept.
This is how the keyboard without encryption of any kind functions:
When the key “A” is pressed the lightbulb “A” flashes. So far so good. Let’s check out how we can start encrypting pressed keys by adding one slight complication in the mix. We are adding one rotor now:
The rotor is a component with connectors for each letter where input and output connecting points are not directly or straight connected but rather swapped in random order. Instead of a letter, the rotor has numerical connectors from 1 to 26, for each letter (our example has only 4 for ease of grasping the mechanism). Now, imagine that each connector has wires inside the rotor swapping the connectors like on our graphic above.
Each time the key is pressed the rotor would turn for one position. This process complicates the cipher further by cross-connecting different letters each time it turns. As a result, the letter “A” would result in the letter “C” the first time we press the letter “A”. However, since the rotor turns immediately after we pressed it, the next time we hit the letter “A” it will result in a completely different letter:
We mentioned there are three rotors, right? No? Ok, there are three or four rotors depending on the design used in a particular scenario. Which one was to use was a matter of convention. Let’s add two more and see what we’ve got:
Each time a key on the Enigma machine is pressed, the rotors turn to complicate the cipher even more. This rotation happens in a very specific order. Of total three rotors, they turn in different rates, they behave like milage rotors on your car:
- The first rotor turns once every time a ley is pressed.
- The second rotor turns once every time the first rotor has completed a full circle of rotation.
- The third rotor turns once every time the second rotor has completed a full circle of rotation.
But how does it happen that the pressed key doesn’t produce the output the same as the input was? There is one component that adds up to the construction of the rotor, it’s called a Reflector. It’s a fourth piece that contains the same number of connections as any rotor with one difference. It doesn’t rotate, although it looks like one of the rotors, and it has connectors cross/connecting each other in order to send the electrical current back through rotors. In short, the reflector returns electrical current and the resulting circle looks like this:
A little bit of refactoring the electric circuit was needed to put everything in there, though. All in all, the principle is pretty simple. The battery supplies the circuit, current “flows” through a key on a keyboard (in our case, the key “A is pressed”), then it continues through all three rotors following the red line. On the opposite side, we have a reflector that returns the electrical current back by the green path. Eventually, when electrical current flows back through all three rotors it closes the circuit lighting the lightbulb “C”.
This is not Reflector’s main role in this mechanism. It is used as a key component in the process of the decrypting message. It closes the input and output circle relying on proper Enigma settings, otherwise, the decryption produces more gibberish.
This mechanism, convoluted as it seems, does show a flaw allowing cryptoanalysis to rule out the letter “C” from being a part of open-text (pre-cipher text).
It’s said that the plugboard used to shuffle the keys on the keyboard provided more cryptographic strength than an additional rotor. So, what’s the catch?
Plugboard is simply a shifting board of connectors shuffling letters on the keyboard. For example, letter “A” and letter “B” are connected, and thus, when typed “A”, letter “B” is actually in effect and thus, the electrical current path for letter “A” becomes what it would be if we pressed the letter “B”:
Now, we mentioned decryption while introducing the Reflector component. Let’s use the above example and settings (settings: the position of rotors and plugboard) and see if we can track the electrical current lighting the lightbulb “A” when the letter “D” is pressed:
There we go! Without the reflector, we’d need a separate logic for decryption because the same setting without a reflector provides the one-way encryption model. If we wanted to decrypt the message encrypted on Enigma without reflector we’d need to have a mirrored mechanism replacing switches with lightbulbs and lightbulbs with switches, as well as rotors order (third would become first, etc.).
In conclusion, what strengthens the Enigma was that it produced the polyalphabetic ciphertext, rotors enabled a large pool of settings variations, 26 × 26 × 26 = 17,576 for the three rotors system and the 4-rotors system enabled 26 × 17,576 = 456,976 variations and with 10 of possible 26 plugboard cross-connections we get 151 trillion combinations for Enigma encryption setting or a key-space size.
On the other hand, some flaws helped Alan Turing and his team to crack the Enigma in Bletchley Park. One of which is that the letter could never be encrypted into the same letter in the ciphertext and the plugboard was always cross-connecting two letters in reciprocity - A would connect to B nd B to A, so no option was available for, let say, A to connect to B, B to F, F to P, etc.