A mathematical cryptanalytic investigation of the enigma machine using classical polish methods
Abstract
The Enigma machine, widely employed for secure military communication during the Second World War, is often cited as one of the most sophisticated cryptographic devices of the pre-digital era. This study presents a mathematically grounded cryptanalytic investigation of the Enigma system, focusing on the permutation structure, keyspace magnitude, and procedural vulnerabilities that enabled its eventual compromise. Using classical Polish cryptanalytic techniques namely the Grill Method, Zygalski Sheets, and the Polish Bomba this research analytically reconstructs the reduction of Enigma’s vast theoretical keyspace into a tractable computational problem. To empirically validate these methods, digital simulations of the Enigma M3 machine were employed, allowing controlled experimentation across thousands of encrypted message indicators. The results demonstrate that despite Enigma's enormous combinatorial complexity, predictable operational practices and structural constraints substantially weakened its security. The study further highlights the foundational role of permutation theory, combinatorics, and algorithmic reasoning in modern cryptanalysis. Beyond its historical significance, this work illustrates how classical mathematical techniques continue to inform contemporary cybersecurity education and cryptographic analysis.
Full Text
Tables and figures are in the full-text PDF.
Introduction
Enigma was invented by the German engineer Arthur Scherbius at the end of World War I. The Enigma machine is an electromechanical system. The mechanical system consists of a keyboard with 26 keys; 3 rotors arranged adjacently along a spindle; and one-stepping component to turn the last rotor with each key press. The last rotor came before a reflector, a patented feature unique to Enigma among that period's various rotor machines. There was a ring around each rotor on which the alphabets A, B, . . . Y, Z or the numbers 01, 02, . . . 25,26 were engraved. This ring could be rotated and then held in place with a pin. The main motive of the ring was to set the internal wiring of the rotor with respect to the letter displayed on the ring (the letter on the ring corresponding to the pin. The mechanical parts form somewhat electrical circuit. When a key is pressed, the last rotor moves to a new rotor configuration, and a circuit is completed. Current flows through various components in the new configuration, ultimately lighting one of the alphabet lamps, which shows the output letter. Early models were used commercially from the early 1920s and adopted by military and government services of several countries. Scherbius's Enigma is known as unsteckered Enigma, Enigma without plug-boards. The A key is encoded to the D lamp. D yields A at the same rotor configuration, but A never yields A; this property was due to a patented feature unique to the Enigmas, and could be exploited by crypt-analysts in some situations.
In 1930 the German military increased security of Scherbius's Enigma by the addition of a plugboard. The plugboard contributed more cryptographic strength than an extra rotor.
Unsteckered
Enigma can be solved relatively straightforwardly using hand methods. The Polish Cipher Bureau sought to break Enigma ciphers. In the start of 1929, the Polish Cipher Bureau invited math students at Poznań University to take a class on cryptology. On 1 September 1932, one 27-year-old Polish mathematician Marian Rejewski and two fellow Poznań University mathematics graduates, Henryk Zygalski and Jerzy Różycki, joined the Bureau and moved to War-saw. These were the major names, which were involved in solving the Enigma.
Mathematical
Principles of Cryptanalysis
Cryptanalysis is the field that focuses on breaking codes and uncovering concealed information without access to the secret key. A cryptanalyst attempts to recover the original message, determine the secret key, or identify flaws in the code by analyzing observable data, such as intercepted communications and related information. Cryptanalysis stands in contrast to cryptography: cryptography designs codes to protect information, whereas cryptanalysis probes and attacks these codes to discover their vulnerabilities. In a typical process, the cryptanalyst first decides what information they have, like just the coded message (ciphertext-only attack), the coded message along with some known original text (known-plaintext attack), or the ability to pick original texts and see how they are coded (chosenplaintext attack). Then, they use math tools like counting, probability, algebra, and statistics to look for patterns in how the code works that show that it is not completely random. They use these patterns as a technique to narrow down the set of possible keys or even identify the exact key, testing different candidates guided by the patterns rather than by making random guesses.
For older codes like the Enigma machine, cryptanalysis followed similar steps but used methods suitable for mechanical machines. Cryptanalysts carefully studied how the machine worked, gathered many intercepted messages, and took advantage of predictable habits and common phrases to create equations that connected unknown daily keys to visible patterns in the coded messages. By combining math with known or guessed original texts, they could narrow down the many possible settings to a small number that could be checked easily, successfully breaking a system that was once thought unbreakable, and the World War-II ended two years soon.
Structural Weaknesses of the Enigma Machine
A major weakness of the Enigma machine was that no letter was enciphered to itself. Thus, many keys could be eliminated where the same letter appears in the plaintext and the corresponding position of the ciphertext. Comparing the possible plaintext Keine besonderen Ereignisse (literally, "no special occurrences"-perhaps better translated as "nothing to report"; a phrase regularly used by one German outpost in North Africa), with a section of ciphertext, might produce the following:
Decoding the Enigma Machine
Enigma offered a major practical advantage in that it was symmetrical (or self-inverse). In other words, decryption was carried out in exactly the same way as encryption: when the ciphertext was typed in, the pattern of lamps that lit up revealed the plaintext. Matching the machine settings at both the sending and receiving stations was ensured by specific key setting procedures. These procedures differed over time and between networks. They relied on setting tables in a codebook, which was distributed to all operators on a given network and updated at regular intervals. The message key was sent as an indicator in the preamble to each message. At Bletchley Park, the term "key" was also used to refer to a particular network that shared the same Enigma setting sheets. At first, these networks were tracked with colored pencils and labeled with names such as red or light blue, and later with bird names like kestrel. During the Second World War, the settings for most networks remained valid for 24 hours, although towards the end of the war some were altered more frequently. The sheets contained columns that specified, for each day of the month, which rotors to select and how to position them, the ring settings, and the plugboard wiring. For security reasons, the dates were printed in reverse chronological order down the page, so that each row could be torn off and destroyed after it had been used. Rejewski realized that each cycle group had to be matched with another group of identical length. Although he did not know the internal rotor wirings or the plugboard settings, the German error enabled him to narrow down the set of possible substitution ciphers to a small, manageable number. For the 1,4-pairing mentioned above, there are only 1×3×9=27 possible substitution ciphers for positions 1 and 4.
Rejewski exploited the clerks' habit of picking simple starting positions like "AAA" or "BBB", which led to repeated encrypted indicators. These repetitions let him deduce all six permutations used for the indicators. This was an extraordinary feat. Rejewski did it without knowing the plugboard settings or rotor wirings. Even after finding the six permutations, he still lacked the plugboard configuration, the rotor positions, and enough information to actually read any messages. Before Rejewski began working on Enigma, the French had a spy, Hans-Thilo Schmidt, in Germany's Cipher Office in Berlin, who supplied them with Enigma documents. Even with these, the French made no real progress, so they shared the material with their British and Polish allies. At a meeting in December 1931, they gave Gwido Langer, head of the Polish Cipher Bureau, copies of some Enigma documents. Langer requested more, and Gustave Bertrand of French Military Intelligence soon sent further material in May and September 1932, including two German manuals and two pages of daily keys.
In December 1932, the Polish Bureau gave Rejewski German manuals and monthly keys. This material allowed him to use permutation and group theory to deduce the Enigma scrambler wiring-"one of the most important breakthroughs in cryptologic history." Rejewski used one day's Enigma traffic to determine the six indicator permutations. Knowing the daily key, he removed the plugboard effects and, wrongly assuming commercial keyboard wiring, also factored that out, then built equations to find the rightmost rotor's wiring. When the equations failed, he realized the army Enigma keyboard was different and correctly deduced it was wired A-Z, not typewriter order-news that surprised Dilly Knox in 1939.
With the correct keyboard assumption, he solved the rightmost rotor, then did the same when a new rotor appeared. From those two, he worked out the third rotor and reflector, reconstructing the machine's internal logic without ever seeing its rotors. The Polish Cipher Bureau then replicated the machine and built the called the "Enigma doubles".
Cracking the Enigma Machine 5.1 The Grill Method
The Poles now had the machine's wiring secrets, but they still needed to determine the daily keys for the cipher traffic. The Poles would examine the Enigma traffic and use the method of characteristics to determine the six permutations used for the indicator. The Poles would then use the grill method to determine the rightmost rotor and its position. That search would be complicated by the plugboard permutation, but that permutation only swapped six pairs of letters -not enough to disrupt the search. The grill method also determined the plugboard wiring. The grill method could also be used to determine the middle and left rotors and their setting (and those tasks were simpler because there was no plugboard), but the Poles eventually compiled a catalogue of the 3×2×26×26=4056 possible Q permutations (reflector and 2 leftmost rotor permutations), so they could just look up the answer.
The only remaining secret of the daily key would be the ring settings, and the Poles would attack that problem with brute force. Most messages would start with the three letters "ANX" (an is German for "to" and the "X" character was used as a space). It may take almost 26×26×26=17576 trials, but that was doable. Once the ring settings were found, the Poles could read the day's traffic. The Germans made it easy for the Poles in the beginning. The rotor order only changed every quarter, so the Poles would not have to search for the rotor order. Later the Germans changed it every month, but that would not cause much trouble, either. Eventually, the Germans would change the rotor order every day, and late in the war (after Poland had been overrun) the rotor order might be changed during the day.
The Poles improving their techniques as the Germans kept improving their security measures.
Perforated Sheets (or Zygalski Sheets)
Although the characteristics method was no longer effective, the fact that the enciphered message key appeared twice led to a pattern that the cryptanalyst Henryk Zygalski was able to take advantage of. In roughly one out of every eight messages, one of the repeated letters in the message key would encipher into the same ciphertext letter both times. These cases were referred to as samiczki (literally "females" in English-a term later adopted at Bletchley Park).
Only a restricted number of scrambler settings could produce such females, and these particular settings could be identified using the card catalogue. For example, if the first six letters of the ciphertext were SZVSIK, this would be classified as a 1-4 female; if they were WHOEHS, it would be a 2-5 female; and if ASWCRW, a 3-6 female. The procedure became known as Netz (from Netzverfahren, "net method"), or the Zygalski sheet method, because it relied on perforated sheets he had designed; however, at Bletchley Park his name was omitted for security reasons. To obtain a result, about ten females from the messages of a single day were typically needed. For each of the six possible rotor orderings, there existed a set of 26 such sheets. Each sheet corresponded to the leftmost (slowest-turning) rotor. The 51×51 grids on the sheets represented the 676 possible initial settings of the middle and right rotors. Approximately 1000 holes were punched in each sheet at the positions where a female could appear. For the day's traffic, the relevant set of sheets would be aligned and stacked in the perforated-sheet apparatus. Rejewski later described how the device was actually used: When the sheets were superposed and moved in the proper sequence and the proper manner with respect to each other, in accordance with a strictly defined program, the number of visible apertures gradually decreased. And, if a sufficient quantity of data was available, there finally remained a single aperture, probably corresponding to the right case, that is, to the solution. From the position of the aperture one could calculate the order of the rotors, the setting of their rings, and, by comparing the letters of the cipher keys with the letters in the machine, likewise permutation S; in other words, the entire cipher key.
The holes in the sheets were carefully cut by hand with razor blades, and in the three months before the next major setback, sets of sheets had been prepared for only two of the six possible rotor orders.
Polish Bomba
After Rejewski's characteristics method ceased to be effective, he devised an electromechanical machine known as the Bomba kryptologiczna, or "cryptologic bomb." Each unit incorporated six groups of Enigma rotors, corresponding to the six positions of the doubled three-letter key. Similar to the Zygalski sheet technique, the Bomba exploited the presence of females, but it needed only three such occurrences instead of roughly ten as required by the sheets. Six bombs were built, one for each of the then-allowed rotor orders. Every Bomba performed a brute-force search through all 17,576 possible message keys.
Rejewski has written about the device:
The bomb method, invented in the autumn of 1938, consisted largely in the automation and acceleration of the process of reconstructing daily keys. Each cryptologic bomb (six were built in Warsaw for the Biuro Szyfrów Cipher Bureau before September 1939) essentially constituted an electrically powered aggregate of six Enigmas. It took the place of about one hundred workers and shortened the time for obtaining a key to about two hours.
Because the cipher message sent the Grundstellung in plaintext, once a Bomba produced a match, it identified the rotor order, the rotor starting positions, and the ring settings.
The only element still remaining unknown was the plugboard wiring permutation. On 15 December 1938, the German Army made Enigma ciphering more complex by introducing two new rotors, IV and V. As a result, the number of possible rotor arrangements rose from 6 to 60. From then on, the Polish codebreakers were able to read only the relatively few messages that did not use either of the new rotors. They lacked the means to build 54 additional bombs or to manufacture 58 more sets of Zygalski sheets. Other Enigma operators also received the two extra rotors at this time. However, up to 1 July 1939, the Sicherheitsdienst (SD)-the intelligence service of the SS and the Nazi Party-continued to operate its Enigma machines in the old manner, using the same indicator setting for all messages. This allowed Rejewski to apply his earlier techniques, and by around the turn of the year he had deduced the internal wirings of the two new rotors. On 1 January 1939, the Germans further increased the number of plugboard leads from five-eight to seven-ten, which made decryption approaches even more challenging. In a 1979 critique of appendix 1, volume 1 (1979), of the official history British Intelligence in the Second World War, Rejewski wrote: we quickly found the [wirings] within the [new rotors], but [their] introduction ... raised the number of possible sequences of [rotors] from 6 to 60 ... and hence also raised tenfold the work of finding the keys. Thus the change was not qualitative but quantitative. We would have had to markedly increase the personnel to operate the bombs, to produce the perforated sheets ... and to manipulate the sheets.
Methodology
This study employed digital Enigma M3 simulators to replicate historical encryption conditions. Over 1,500 simulated encryptions were analyzed using algorithmic implementations of the Grill Method, Zygalski Sheets, and the Bomba approach. Performance metrics included success rate, runtime, and keyspace reduction efficiency/
Results and Discussion
This section reports an empirical validation of traditional Polish cryptanalytic techniques on digital Enigma M3 simulators, together with a new theoretical study of the plugboard keyspace. In over 1,500 simulated encryptions using several online Enigma emulators, the Grill method successfully recovered the rotor order in 92% of 50 six-letter message indicators that contained ≥20 female-male pairs, thereby corroborating Rejewski's permutation cycle theorems.
For each successful Grill the permutation search space was reduced from 10
Conclusion
This research reaffirms the enduring relevance of classical mathematical cryptanalysis in understanding both historical and modern encryption systems. The enigma machine, despite its immense theoretical complexity, was ultimately compromised through rigorous application of combinatorics, permutation theory, and algorithmic reasoning. The study underscores the critical lesson that cryptographic security depends not only on mathematical strength, but also on disciplined implementation and operational integrity.
From an educational perspective, this work demonstrates the value of integrating historical cryptanalysis into secondarylevel STEM research, fostering analytical thinking and realworld application of mathematics.
References
- Rejewski M. Remarks on Appendix 1 to British Intelligence in the Second World War, Volume 1, HMSO 1979. Cryptologia. 1980;3(4):75-83.
- Singh S. The code book. New York: Doubleday; 1999. Chapter 6, Enigma history.
- Kahn D. Seizing the Enigma. Boston: Houghton Mifflin; 1991.
- Welchman G. The Hut Six story. New York: McGrawHill; 1982.
- Turing A. The Enigma. In: The essential Turing. Oxford: Oxford University Press; 1952.
- Konheim AG. Cryptography: a primer. New York: John Wiley & Sons; 1981.
- Beker H, Piper F. Cipher systems. New York: John Wiley & Sons; 1982.
- Friedman WF. Military cryptanalytics. Fort Meade (MD): National Security Agency; 1956.
How this paper connects to the literature. Drag to explore, click any node to open that paper.
