The Enigma was a portable cipher machine, roughly the size of a typewriter, which could encrypt and decrypt secret messages. It used electro-mechanical rotors to convert a message to a secret code, and then another machine could decode that same message and print out the original message. This machine was commercially available beginning in the early 1920s. The Nazi German military version generated codes widely thought to be unbreakable.
The Enigma machine was an electromechanical device, equipped with a 26-letter keyboard, with one light per letter of the alphabet. Inside the machine was a set of wired drums for scrambling the input. To encipher or encrypt a letter, the operator pushed the relevant key and observed which of the lights lit. The communication between two operators required that each had an Enigma machine set up in the same way as each other. The large number of possibilities for setting the rotors (and a plugboard that could swap letters) made for an astronomical number of possible configurations, each producing a different cipher. The Germans changed the settings daily, such that the machine had to be rebroken each day in order to decrypt the messages.
Decryption required an understanding of how Enigma functioned, the wiring of the rotors and the daily settings (both rotors and plugboard).
Nazi Germany used the Enigma before and during World War II to send messages about its military maneuvers. But in 1932 a 27-year-old Polish mathematician (cryptologist) named Marian Rejewski had used advanced mathematics (permutation theory with some group theory) to secretly break ("crack") the Enigma codes. He then helped design working "doubles" of the Enigmas that could find the keys necessary for decryption. By 1938 the Poles were decrypting most of the German messages. However, the Poles were forced to share their codebreaking techniques with Great Britain and France after the Germans brought in a new variant on Enigma that made it harder to decipher.
Following the German invasion of Poland work on breaking the Enigma codes moved to France and Great Britain. French efforts were ended by the Fall of France in 1940, but in Great Britain Enigma was finally cryptographically broken thanks to the work done by code-breaking experts in the secret Bletchley Park facility, where some of the earliest and crudest computers were built to work on the millions of code combinations used by Enigma.
Use of the Enigma by Nazi Germany in World War II
Enigma machines were heavily used by the various military services of Nazi Germany. This usage, and the successful breaking of the code by the British intelligence service at Bletchley Park, are a fascinating story.
How the System Worked
The Enigma machine used electromechanical "rotors", or disks, to scramble the letters typed on the keyboard. The rotors were randomly designed, but they were all manufactured from the same design, so every Enigma machine behaved identically.
Since the rotors scrambled the letters, any given rotor position just performed a "substitution cipher". If the rotor had never moved, this would have been the same sort of thing as the cryptograms in popular puzzle magazines and children's books. These can typically be solved by pencil and paper in a few minutes; modern computers can solve them in microseconds. What made the Enigma machine effective was that the rotors moved. After each letter, the rotors advanced to a new position. This was somewhat like the action of an automobile odometer, but more complicated—the pawls and ratchets on the rotors were randomly placed.
So the setup of the Enigma machine consisted of setting the rotors' initial position. This constituted the "key" of the code, which was changed daily according to a very secret protocol. The machine had some other features to increase the complexity: There was a plugboard to further scramble the letters, and the machine came equipped with half a dozen or so rotors, of which 3 (later 4) were inserted at any one time. So the daily setup instructions, or daily key, might be something like:
- Insert rotors 5, 2, and 4 into the rotor slots, from left to right.
- Set those rotors to initial positions K, T, and F.
- Connect Y to H, J to R, and F to B on the plugboard.
All Enigma machines used by a given military service were built the same way, so any machine set up by the above instructions would encrypt and decrypt messages the same way. Also, the transformation was reversible. If any particular setting of the rotors encoded ENIGMA as YPPFRH, the same setting would convert YPPFRH to ENIGMA. Military headquarters, and all other stations (submarines, for example) set up their machines the same way on a given day (the "code book"; see below), and everyone could communicate. (What the Nazis didn't know was that this included the British.)
Sophisticated hardware is only one part of a secure cryptographic system. The manner in which it is used is crucial. The Nazis made some serious mistakes.
The most secure way of handling keys is the "one-time-pad", commonly used in low traffic systems such as espionage. In this system, each submarine would have been given a different list of keys, randomly generated in advance, with headquarter keeping a copy. Each key would be used only once. That is, the code book would effectively say "For the 43rd message you send, use key XYZ; for the 44rd message, use key FUO, ..." After every message is sent, that key is crossed off the list.
This one-time-pad system is too unwieldy for a large operation such as general military communication, so a common daily key was used instead. Each submarine had a copy of the list, giving the key for each day; headquarters had that list also. This had two weaknesses:
- It was essential that the key list never be stolen. They were written with special ink on special paper, so that they could be destroyed instantly in the event of capture.
- It was essential that the keys never be able to be solved. Once a key was solved, that entire day's messages, throughout the fleet, could be decoded.
There are other things that one must do. One must avoid using stereotyped language. If every message starts with "Today's orders are to go to location XYZ and patrol for surface shipping", it becomes easier to decrypt. The people at Bletchley were quite good at guessing the German's writing style, and could make guesses (called "cribs") of what they might be talking about. A common way to avoid intentional or unintentional use of stereotyped language is to start each message with a nonsense sentence. This is similar to what at present is called "word salad" by email spammers to evade spam filters.
The Nazis used word salad, but they also made a costly mistake. They routinely ended each message with "HH", for "Heil Hitler". This foolish bit of vanity was helpful to the British.
There is another problem. The movement of the rotors meant that simple letter frequency analysis, which plays an important part in solving cryptograms in magazines ("This message has a lot of m's; let's guess that m corresponds to e.") won't work. But one can still do frequency analysis on the letters in a corresponding position in the messages, since they all used the same key. That is, if today's messages often have m appearing in the 15th position, one could guess that those were e's in the 15th position, since everyone's rotors would have been in the same position at that point. While utilizing this information would have been much harder than ordinary substitution ciphers, it was still a weakness.
To avoid this weakness, an extra trick was developed. Instead of just setting the rotors and plugboard according to that day's instructions in the code book, the procedure was this:
- Insert the rotors, and set them and the plugboard according to today's key.
- Make up a random 3-letter sequence, say, KES. (This is called a "session key", and is routinely used in modern internet security.)
- Type that message twice (KESKES) into the Enigma, getting say, HRMPLB.
- Set the rotors to KES, and encrypt the rest of the message.
- Transmit HRMPLB followed by the encrypted message.
Now the part of the message that is encrypted the same way by all submarines is only 6 letters long; too short for frequency analysis.
At the receiving end, one sets the rotors as per the daily key, types in the first 6 letters of the received message, HRMPLB, and gets back KESKES. After noting that the same 3 letters are repeated (the reason for sending it twice is for extra reliability; a mistake here would make the whole message unreadable) set the rotors to KES and decrypt the rest of the message.
The 4th Rotor
Later in the war, the Nazis inceased security by upgrading the machines to use a 4th rotor, but they committed an incredible blunder. It took some time to equip the entire fleet with the new machines, since individual submarines had to be given one the next time they were in port. During this transition period, the operational instructions were for those submarines with the new machine to leave the 4th rotor in position zero. This made it compatible with the older 3-rotor machines. On one occasion, a submarine operator accidentally sent a message with the 4th rotor in a non-zero position. When the he realized the mistake, he set the rotor back to zero and sent the exact same message again.
The British knew that a 4th rotor was coming, but did not know how it was wired. This would have been an extremely serious problem, and might have shut down their decryption efforts for some time. But, when they were engaged in their routine breaking of that day's traffic, they noticed that a message was gibberish. They also noticed that it was of exactly the same length as the following message. They correctly guessed what had happened, and, by comparing the messages, were able to deduce how the 4th rotor was wired.
Breaking the Code
Breaking this code began before the war, in Poland. Mathematician Marian Rejewski was able to figure out how the rotors were wired, apparently just by analyzing encrypted messages. The Polish intelligence service was later able to steal a machine from Germany and "reverse engineer" it in detail. After Poland was overrun by Nazi Germany in the early stages of the war, the decrypting effort moved to England.
Breaking this code was a life-or-death matter for the British. They gathered the brightest mathematicians and puzzle solvers, including, famously, Alan Turing and Gordon Welchman, into a facility at Bletchley Park. They built the most sophisticated computing devices that were available at the time, which were electromechanical. Completely electronic computers would have been enormously faster, but the technology at the time could not provide electronic computers that would have worked reliably enough to do the job. The computers were called "bombes", and were basically devices to spin Enigma rotors as fast as possible, trying out different keys while working on "cribs".
At the height of the operation, they were routinely solving keys, generally by about noon each day. They then retroactively decoded that morning's messages, and continued decoding through the day. They sent huge amounts of data to the war department each day. The Nazis apparently never realized that this was happening.
The breakthrough enabled the Allies to anticipate German military maneuvers, although sometimes the Allies would allow an attack to occur successfully in order to avoid signaling to the Germans that their code had been broken. The Allied code-breaking effort was known as "Ultra", as in "ultra-secret".
At the end of the war, Allied General Dwight Eisenhower said that Ultra was "decisive" to the Allied victory over Germany. British Prime Minister Winston Churchill also declared, "It was thanks to Ultra that we won the war." The breaking of the German codes prevented it from completely blockading Britain with U-boats and enabled the Allied forces to make key strategic decisions throughout the war.