mariuscomper.ukRomână

Enigma, 1932–1939

The cables that did not matter

The Germans fitted Enigma with a panel of cables that multiplied the number of keys by more than a hundred billion. A 27-year-old Polish mathematician, Marian Rejewski, found a measurement the cables could not change. Below are a working Enigma, a real German message from 1941 and Rejewski's attack, run on your own device.

A machine that rewires itself at every letter

Enigma looks like a typewriter with lamps instead of paper. You press one letter and another lights up. Between key and lamp, the current passes through the plugboard, through three rotors with 26 contacts on each face, turns back in a reflector and returns by a different route. With every key press the right-hand rotor moves on one position, so the same letter typed twice usually comes out differently.

The reflector has two consequences. The machine works both ways: anyone who starts from the same position and types the ciphertext gets the plain text back. And no letter can ever be enciphered as itself. Try it: AAAAA with rotors I, II, III, reflector B and everything at A gives BDZGO.

A
A
A

You typed

Lit up

Type on the keys above or on your own keyboard. The diagram follows the current: yellow on the way in, blue on the way back. The thin lines are the wires inside the rotors in their present position; they move with every key press.

The rotors were the factory's secret. The cables were the day's secret. With six pairs of letters connected, as the German army used in the early 1930s, the plugboard could be wired in 100,391,791,500 ways. With ten pairs, the number reached by 1939, in 150,738,274,937,250 ways. For anyone trying every key in turn, the cables were the wall.

The plugboard on the front of the machine
Each cable swaps two letters, on the way in and on the way out. Bob Lord, Wikimedia Commons, CC BY-SA 3.0

A message from 7 July 1941

The machine above is not an approximation. On 7 July 1941, two weeks after the invasion of the Soviet Union, a radio network of Army Group North sent a message in two parts. That day's key was recovered by Geoff Sullivan and Frode Weierud and published in their study of this army group's Enigma traffic: rotors II, IV, V, rings 02 21 12, reflector B and ten cables. Press the button and your machine decrypts it letter by letter.

II IV V · 02 21 12 · B · AV BS CG DL FU HZ IN KM OW RX

What the radio picked up

What lights up (X means a space)

That was the easy part: with the key in hand, anyone could read it. Rejewski's question, nine years earlier, was how to find the key when you do not have it.

The slip: a key typed twice

Rejewski joined the Polish army's Cipher Bureau on 1 September 1932, with two other mathematicians, Jerzy Różycki and Henryk Zygalski. By the end of the year he had reconstructed the internal wiring of the three rotors and the reflector, helped by documents sold to the French by Hans-Thilo Schmidt, a German official: among them, the daily keys for September and October 1932. With a copy of the machine, Poland still needed each day's key.

The German procedure of the time had a weakness. All operators on a network started from the same position for the day. Each chose three letters for his own message, say KYG, and typed them twice, KYGKYG, to make sure they survived radio interference. The six enciphered letters that came out, such as QZKBLX, went at the start of the message. The operator then turned his rotors to KYG and enciphered the text.

The first and fourth letters of the indicator hide the same plain letter. So do the second and fifth, and the third and sixth. Each intercepted message therefore links one letter to another, and a single case says nothing. Dozens of messages from the same day, all enciphered from the same position, fill in a whole table. Below is a day of traffic invented here, with a key chosen at random and hidden until the end.

    The first six letters of each intercepted message, in order of arrival. The day's key uses rotors I–III, reflector A and six cables, as in 1932–36.

    The fingerprint the cables cannot touch

    Rejewski followed the links like a route. From the day's table: if one indicator has A first and D fourth, and another begins with D and has Q fourth, the chain runs from A to D, then to Q, until it comes back to A. All 26 letters split into such loops. The same is done with places 2 and 5, then 3 and 6. Loops of equal length always come in pairs: a consequence of the reflector.

    Then he noticed what mattered. The cables only rename letters, on the way in and on the way out. Renaming changes which letters sit in a loop, not how many there are. The lengths of the loops depend only on the rotor order and their position. The hundred billion possible wirings drop out of the problem. You need not take my word for it: press “Other cables”.

    The loops of the day above. “Other cables” keeps the rotors, the position and the operators' chosen letters, and changes only the six cables.

    In mathematical language: a product of two permutations, conjugated by the cable permutation, keeps its cycle structure. Rejewski set out the argument in his 1980 paper in Applicationes Mathematicae.

    A year's work, a few seconds on your phone

    If the fingerprint depends only on the rotors, a list can be made in advance: for each of the 6 rotor orders and each of the 17,576 positions, the lengths of the loops. In all, 105,456 rows. The Poles built a device for it, the cyclometer: two sets of rotors wired together that lit up the loops of a position. They went through every position by hand. The job took more than a year. Once the catalogue was ready, around 1935, finding a day's key took 12–20 minutes.

    A reconstruction of Rejewski's cyclometer
    Two cable-less Enigmas wired together: a lit lamp showed the length of a loop. Szymon Pilecki, Szymon Dąbrowski, Wikimedia Commons, CC BY-SA 4.0
    0 / 105,456
      All 105,456 settings, computed on your device, then compared with the fingerprint of the day above. The list shows the rotor order and their position without the rings.

      The catalogue did not hand over the key. I computed all 105,456 rows, with reflector A, in use until 1937, and with the only movement the method assumed: the right-hand rotor. They give 21,225 distinct fingerprints. What the numbers mean depends on what you count. Of the fingerprints, 55% belong to a single setting. Of the settings, only 11% have a fingerprint of their own. If the day's key is any of the 105,456, all equally likely, then on half of all days its fingerprint is shared by at least 20 settings. The most common fingerprint, three pairs of 13-letter loops, belongs to 1,728 settings.

      The last step uses the cables. For each candidate, the rotors without cables give loops of their own. The cables must turn those into the day's loops, all three at once, with exactly six pairs. Rejewski's team did this last elimination by hand. The button under the list automates the same condition: find six cables under which every indicator decrypts to three letters repeated twice. In 1,000 simulated days a single candidate survived every time: the day's equivalent rotor position, with the true cables. The ring settings and the window position cannot be told apart at this stage; only their difference matters.

      The method had a limit. It assumed that only the right-hand rotor moves during the six letters. Published reconstructions commonly quote about 77%, that is (26 − 6)/26, counting only turnover driven by the right-hand rotor. In the full stepping model used here, the middle rotor can also move by itself at the first key press when it starts on its own notch, taking the left rotor with it. Including that case gives 20/26 × 25/26, about 74%: on roughly one day in four the fingerprint no longer matched the catalogue. The day above is chosen from the other three.

      The Germans knew none of this, but they kept changing the procedure. On 1 November 1937 they replaced the reflector, and the whole catalogue had to be recalculated from scratch. On 15 September 1938 they changed how the message key was enciphered, and the fingerprint could no longer be measured. Within two months Rejewski's bomba was ready, six linked Enigmas that found the key in about two hours; six existed by mid-November 1938. Zygalski's perforated sheets came more slowly and were never completed. On 15 December 1938 rotors IV and V arrived, and the possible orders rose from 6 to 60. On 1 January 1939 the cables rose to 7–10 pairs.

      In late July 1939, at Pyry near Warsaw, the Poles showed the British and the French everything they had: the methods, the sheets, the bomba. Each delegation then received a copy of the Polish-built machine. Five weeks later the war began.

      Through Romania to Paris

      The Cipher Bureau was evacuated from Warsaw in early September 1939. On 17 September, the day the Red Army entered Poland from the east, the staff were ordered to cross into Romania, Poland's ally. At the border a Romanian officer confiscated their vehicle and separated the military from the civilians.

      Rejewski, Różycki and Zygalski feared internment: they knew German intelligence had informers in the Romanian security police. They left on their own, on the first train south, and after a dozen or so hours reached Bucharest. At the British embassy they were told to come back in a few days. At the French embassy they introduced themselves as “friends of Bolek”, the code name of Gustave Bertrand, head of French radio intelligence. A French colonel arranged their departure. By 20 October 1939 they were at work at PC Bruno, a secret station near Paris; there, on 17 January 1940, they found the first Enigma key broken in France, the one for 28 October 1939.

      So three men who knew how to read Enigma passed through Bucharest in the autumn of 1939, in a country where, they believed, Germany had ears. Had they been stopped, there was a real risk that Germany would discover what Poland had learned.

      Marian Rejewski in Polish Army uniform, 1943–44
      Rejewski reached Britain in August 1943, after crossing the Pyrenees and spending months in Spanish prisons. photographer unknown, Wikimedia Commons, public domain

      Różycki died on 9 January 1942, when the French ship bringing him back from Algeria sank. Rejewski and Zygalski crossed the Pyrenees in January 1943, were arrested in Spain and reached England in August 1943. By then Enigma had become an exclusively British and American matter; they were kept out of it and set to work on SS hand ciphers. Rejewski returned to Poland in November 1946. For two decades he said nothing about his work, to avoid the attention of the communist government. He died in Warsaw on 13 February 1980.

      Sources and method

      The machine on the page is an Enigma I built here from the published wiring. It decrypts both parts of the 1941 message letter for letter and gives BDZGO for AAAAA; both checks run on every release, together with a comparison against a second, independent implementation.

      The catalogue was computed in full: 6 rotor orders × 17,576 positions, reflector A, only the right rotor moving, as in the cyclometer's model. The result (21,225 fingerprints, 11,578 unique, largest class 1,728) is close to, but not identical with, Alex Kuhl's 2007 reconstruction as cited by Lasry: 21,230, 11,466 and 1,771. Secondary sources even disagree on Kuhl's reflector: Lasry and colleagues say A, Christensen's 2011 review says B. I tried the conventions that might explain the gap: reflector B gives 21,153, reflector C 21,337, real rotor stepping 20,882, while positions and ring settings only renumber the rows and cannot change the counts. None reproduces Kuhl's figures, and the quoted percentages (54.40%, 92.34%) do not follow from his own totals either. The proportions are very close, though: 54.5% of fingerprints are unique, 92.1% correspond to ten positions or fewer. Without Kuhl's own implementation or full paper, the difference remains unresolved.

      The last step was simulated on 1,000 days with random keys: catalogue, then solving for the cables for every candidate, with exactly six pairs. Rings were random, so the target is the equivalent rotor position (window minus rings) and the cables; it was found every time and was the only survivor.

      Sources differ on the date of the Pyry meeting: 25 July 1939 in Kozaczuk, 26–27 July in Erskine. The page says “late July”.

      Images