DEV Community

Cover image for Enigma - The Complexity of the Machine
Ben Lyon
Ben Lyon

Posted on

Enigma - The Complexity of the Machine

World War 2.

A world-wide conflict that forever changed the faces of so many countries, and still leaves innumerable effects upon us today. While massive in scale and terrible in nature, this war brought to fore again, that necessity is the mother of invention.

During this conflict, we saw the beginning stages of supersonic flight, the creation of the atom bomb, the advancements of wireless communication, and the first tiny steps of growth in computational power. From atom bombs, we received nuclear power. From wireless communication, wireless devices we use daily. From supersonic flight, to putting man on the moon. From computational cryptography, to incredibly powerful and compact computer systems.

Today, we'll be talking about the most latter of the previously listed subjects: cryptography, and the mathematical computation required to crack those codes.

Image description
Pretty unassuming, right?

Enter, the Enigma Machine. Originally conceived of in 1915 and patented in 1918, the Enigma Machine is the brainchild of German engineer and inventor Arthur Scherbius. Developed toward the end of World War 1, it was used commercially for business secret keeping, until it was later adopted by the foreign military and government organizations, most notably Nazi Germany.

Mechanics

The primary mechanics of the Enigma machine consisted of a keyboard, a set of rotating discs (rotors) arranged along a spindle, stepping components to rotate at least one rotor upon each key press, and a series of lamps, one for each letter on the keyboard. Later versions of the Enigma machine included a plugboard on the front, with a plug for each letter in the alphabet. Also, this next bit is going to get a bit complex, so stay with me here.

Image description
Diagram of the circuit layout

Operation

Each rotor has 26 positions, with a label for each letter of the alphabet, and electrical contacts on the left and right side of the disc, corresponding to each letter. In operation, if you had three rotors set to a starting position of A-A-A, the initial key press would rotate the right most rotor 1/26th of its circumference, resulting with a rotor configuration displaying A-A-B at the bottom of the key stroke. The second rotor would rotate upon the first rotor completing one full cycle, and the third, at a full cycle of the first. At the bottom of the key stroke, an electrical pathway is made from the key through the rotor via the contact points. Because of this rotation on the key press, the resulting output will never be the same as the key that was pressed. The internal design of each rotor was such that a contact point corresponding with the letter 'A' could have wiring potentially corresponding to the output contact point of the letter 'D', and thus the remainder of the alphabet would have a similar mix. Now on it's own, a single rotor provides an easily crackable cipher, known as a substitution cipher, where one character is chosen for the place of another. The complexity of the Enigma machine comes in the use of multiple rotors, multiple rotors of varying internal wiring design, and the varying number of rotors used depending on the branch of military. For example, the German Army used three rotors, where the Navy used up to eight rotors. In a three-rotor configuration, with 26 contact points on each rotor, that gives us 17,576 possible outcomes for each key press. For additional complexity, the rotors had a reflector disc on the left most side of the rotor array, which flipped the signal back through the rotor array on a different channel, and the reflector disc could be given a different set of input and output contact points depending on the setting selected by the operator. But as anyone may say about cryptography, "No kill like overkill", so the later configurations of the Enigma machine were supplied with an alphabetical plug board. The operator would select a letter, say, 'B', and connect the other cable to plug 'G'. This means, that any time the letter 'B' is pressed, the output to the rotor will be the letter 'G', and vice versa. Most operators used a three rotor/10 plug configuration, which gives us a total of nearly 159 QUINTILLION OUTCOMES FOR ONE KEY PRESS.

Image description
Rotor contact points

Additionally, different branches of the military would use different key strokes to indicate spaces, periods, and other punctuation marks for added complexity outside of purely mechanical means. At the height of WWII, this huge computational complexity would take hundreds of people weeks to decode a single message, by which point the message was useless for intelligence operations. Today, the speed of modern computers can give us a brute-force result in less than ten minutes, given a properly trained AI to do the crunching.

Sources:
A really cool online demo of the Enigma Machine
Cornell Lecture document for building a simulated Enigma Machine
Another really cool technical overview of the mechanics inside the Enigma Machine

Suffice to say, the incredible complexity and ingenuity of ciphers will long outlive their ability to be useful, as it is because of them that we have the raw compute power we have today.

Top comments (0)