Code

How Turing Helped Win World War II

How Turing Helped Win World War II

Free Python course ➞ A mini-course for beginners and experienced coders. Four cool projects in the portfolio, live communication with the speaker. Click and find out what you can learn in the course.

Learn more

World War II became not only a large-scale military conflict but also an arena of intellectual struggle. Preparations for this confrontation began long before its outbreak. As early as February 23, 1918, German engineer Arthur Scherbius patented a rotor cipher machine, founding the company Scherbius & Ritter together with his colleague Richard Ritter. They actively sought opportunities to implement their technology in the German navy, army, and Foreign Ministry. Innovative encryption techniques played a key role in strategic intelligence and the security of military communications, underscoring the importance of intellectual advances during the war.

Five years later, Scherbius and Ritter became members of the board of directors of Chiffriermaschinen AG, which introduced an improved model of the cipher machine under the brand name Enigma A. The company began actively promoting this product in various markets, which contributed to the growth of its popularity and strengthening its position in the industry.

A German Enigma captured during the fighting Photo: ImagineerInc / Shutterstock

From 1925, the German Navy began to show interest in the third-generation Enigma, purchasing it under the name Funkschlüssel C. On July 15, 1928, the German Army introduced a military version of the device, known as Enigma G. In the 1930s, Enigma was upgraded to the more compact Enigma I, also known as the Wehrmacht Enigma. This marked the beginning of its successful use at the front and by various branches of the armed forces.

About 100,000 Enigma machines were produced, including various modifications. There were special versions for military intelligence, such as the improved Model G, known as the Abwehr Enigma, and for submarines – the Model M4, also called the Triton. Models were also produced for the German allies, including the Italian Model D and the Japanese Model T, known as the Tirpitz.

After the war, the victorious powers continued to sell captured German Enigma machines to developing armies in the Third World. These devices retained their reputation as reliable encryption tools and remained in use until the end of the 20th century. This is explained by the fact that the Enigma, despite its apparent simplicity and ease of use, had an incredible variability of combinations, which for a long time made it virtually impossible to decipher.

Electrics, mechanics and no fraud

Each Enigma was a complex combination of mechanical and electrical components. This unique system provided a high level of encryption, which made it one of the most famous message encryption machines in history. Due to its design, the Enigma could generate many different codes, which significantly complicated the deciphering process. The mechanical device worked in conjunction with electrical circuits, which made it possible to achieve a high degree of security for transmitted information.

The mechanical part of the device includes a keyboard, a set of rotors arranged along a shaft, and a stepping mechanism. This mechanism ensures the movement of one or more rotors when keys are pressed.

The electrical circuit connects the keyboard, switchboard, lamps, and rotors, using sliding contacts to ensure a reliable connection. This approach allows for efficient control of the devices and ensures stable operation of the entire system.

The operating principle of all models is shown in the simplified diagram below. In fact, the mechanism includes 26 light bulbs, keys, connectors, and electrical circuits located inside the rotors.

Enigma diagram Illustration: Wikimedia Commons

Current from power supply 1 was directed through keyboard switch 2 to patch panel jack 3, where it was reconnected between the keyboard and the fixed input wheel 4. The current then passed through a circuit consisting of three rotors 5 in the military model or four in the naval model, and entered reflector 6. The current then returned back through the rotors and the input wheel along a modified route (follow the red arrow). It then moved through jack S, which connected to jack D, and passed through another switch 9, causing the lamp to light. Thus, the letter "A" was transformed into the letter "D." This process illustrates how mechanics and electronics interact to transmit coded information.

A Three-Letter Word

To successfully decipher an Enigma-encoded message, the sender and receiver devices had to be configured identically. This meant that key parameters had to be completely identical: rotor configurations, initial positions, reflector settings, and other important elements. Strict adherence to these conditions ensured that the encoded message could only be correctly deciphered by someone with access to identical Enigma settings.

  • the order of the rotors;
  • their initial positions;
  • plugboard connections.

The settings, known as daily cipher keys, were agreed upon in advance and recorded in special codebooks. Even if intelligence agents managed to gain access to these secret daytime keys, the cipher remained unbreakable, making its protection virtually impenetrable.

Without information about the configuration scheme, the number of possible configurations even for the Wehrmacht's three-rotor Enigma is approximately 10^114 (380 bits). If you have access to all the settings, the number of configurations is reduced to 76 bits, which is equal to 1023. This certainly simplifies the task significantly, but try to estimate for yourself how long it would take to manually try all these combinations.

The Enigma code used only 26 letters of the Latin alphabet, which made it unique. Other symbols were replaced with rare combinations. For example, spaces could simply be omitted, periods were replaced with "X", and commas with "ZZ". Military jargon was also used: the letter "Q" was used instead of the "CH" in the words "ACHT" (eight) or "RICHTUNG" (direction), leading to the spellings "AQT" and "RIQTUNG." Zeros were replaced by the notations "CENTA" for two zeros, "MILLE" for three, and "MYRIA" for four. This approach to encryption significantly complicated the decryption of messages and emphasized the secrecy of military communications.

To complicate cryptanalysis, messages were limited to 250 characters. Longer texts were broken into sections, each of which was encrypted with a separate key. Additionally, ciphers were periodically filled with meaningless fragments—a set of random letters and arbitrarily inserted words. This created the illusion of security, and the Germans were confident throughout the war that their messages were accessible only to them. However, this was a mistaken belief.

The Beginning of Glorious Deeds

The first interceptions of Enigma ciphers began in 1926. In January 1929, a commercial version of this cipher machine ended up at Warsaw customs, causing concern at the German embassy. Embassy representatives urgently requested its return, which caused wariness among the Poles. As a result, Enigma was returned to its owners only after it was examined by cryptanalysts from the AVA company at the request of the Polish Cipher Bureau.

Several years after the beginning of contacts with French intelligence officers, known as experts in the field of cryptography, Agent Asche, also known as Hans-Thilo Schmidt, an employee of the Cipher Bureau of the German Ministry of Defense, contacted. Disappointed that his homeland had failed to appreciate his efforts during World War I and had preferred to promote his less talented brother Rudolf, Hans decided to take revenge. His plan was not only for revenge, but also for the opportunity to make money using his skills and knowledge in the field of encryption and cryptography.

Hans-Thilo Schmidt with his wife Charlotte Photo: Library of Congress

In November 1931, a significant event took place at the Grand Hotel in the Belgian town of Verviers. A fellow Berliner and a French agent, Rudolph Lemoine, known by the call sign Rex, met there. During this meeting, a set of old Enigma encryption machine daytime keys was handed over, which, according to his official duties, were to be destroyed. In addition, an operating manual for the military version of the Enigma was provided. For this information, the agent received 10,000 marks, which is equivalent to approximately 50,000 dollars in today's dollars. This incident highlights the importance of encryption technologies in military conflicts and their influence on the course of history.

Schmidt's vigorous activity did not arouse much enthusiasm among his former enemies in France and Great Britain. The keys he handed over were considered of little interest for cryptographic research. Fortunately, Captain Gustave Bertrand, head of Section D of French intelligence, had contacts with Polish intelligence. Given their success in deciphering, he decided to hand over the Enigma documents to the Poles. The Polish team set to work, which was an important step in the cryptographic struggle of that era.

It was the "Bomb"

In December 1932, Schmidt's codebooks came into the hands of Marian Rejewski, a Polish mathematician and employee of the Cipher Bureau in Warsaw. After analyzing these materials, Rejewski was able to identify differences in the internal wiring of the military version of the Enigma cipher machine from the previously studied commercial model. This discovery allowed him to create an exact copy of the cipher machine, which was an important step towards its decipherment.

From the Enigma manual, Rejewski learned an important detail: the operator was not allowed to use the daytime key to encrypt messages. Instead, he had to create a so-called Spruchschlüssel—an arbitrary three-letter sequence that was sent twice using the daily key. The operator would then change the device settings to match the Spruchschlüssel and send the message itself. These measures provided an additional layer of security during the encryption process.

In practice, it looked like this. Suppose the current daily encryption key is GBL, and the operator created the Spruchschlüssel—KYG. The operator sets the rotors to GBL and enters the sequence KYGKYG, resulting in an output such as QZKBLX. He then sets the rotors to KYG and enters the actual encryption. The receiving end performs the reverse steps to decrypt the message.

It is unclear why the Spruchschlüssel was repeated twice. Perhaps this was done to detect distortions. However, it was here that a serious vulnerability emerged: in approximately every eighth message, one of the repeated letters in Spruchschlüssel was encrypted with identical symbols. This led to the formation of so-called female pairs, where the first letter matched the fourth (e.g., SVKSAZ), the second matched the fifth (e.g., DAWLAQ), or the third matched the sixth (e.g., RTXEAX). It's important to consider this vulnerability when analyzing encryption, as it can significantly facilitate the process of decrypting messages.

Marian Adam Rejewski, late 1943 - 1944 Photo: U.S. National Cryptologic Museum

Rejewski concluded, based on probability theory, that there are only three rotors. This means that the number of possible arrangements is limited. It is important to understand that each rotor combination affects the level of encryption security. Different rotor arrangement methods can significantly alter the decryption process and increase the level of information security. Understanding probability theory in this context allows for a more effective approach to cryptography and data security.

The Enigma machine uses 26 letters. This allows for the creation of many different three-letter combinations. The total number of such combinations can be calculated by multiplying the number of letters by itself three times. Thus, the total number of three-letter combinations that can be formed from 26 letters is 26 to the power of 3. This means that there are 17,576 unique three-letter combinations. Each of these combinations can be used to create unique codes or messages, making Enigma a powerful encryption tool.

The total number of possible combinations is an important aspect in various fields, including mathematics, statistics, and computer science. These combinations can be used to solve a variety of problems, such as data analysis, gaming, encryption, and more. Understanding the number of combinations allows one to better estimate the probability of events and optimize processes. The more elements or variations there are, the greater the number of unique combinations that can be created. This knowledge can be useful both in scientific research and in practical applications, such as the development of algorithms and strategies.

The Poles, taking advantage of procedural errors made by the Germans, developed a cyclometer—a device consisting of two Enigma machines connected in series with rotors offset by three notches. Using this device, they were able to try all possible combinations and create a complete catalog. According to Rejewski, this work was labor-intensive and took over a year, but once completed, the daily keys could be determined in just 15 minutes. This breakthrough in cryptanalysis significantly sped up the process of deciphering messages, which had a huge impact on the course of World War II.

Later, the Poles developed a device known as the "Bomba," which allowed them to quickly run through all 17,576 rotor combinations from AAA to ZZZ in approximately two hours. Using six "Bombas" with different rotor settings ensured that any message encoded by the Enigma could be deciphered in the shortest possible time. This innovation was a major step in cryptanalysis and significantly accelerated the decryption process during World War II.

Schematic of the Polish "Bomba" Image: Wikimedia Commons