91av

Alan Turing: Codebreaking and code-making

During the second world war, Alan Turing cracked Nazi coded messages and devised the Delilah machine, which could securely encode voice messages
Reconstructed: the Bombe machine’s dials, used to break Nazi Enigma codes

During the second world war, Alan Turing was recruited by the Allies to crack the coded messages used by the Nazis. At first they seemed near-impossible to decipher, but using a combination of mathematics and engineering, he and his colleagues found a way, and so shaped the course of the war.

During this period, Turing also devised a portable machine called Delilah that could securely encode a voice message. It was based on a special form of arithmetic and was years ahead of its time.

My, My, My, Delilah

Turing is often associated with breaking codes, but in 1943 he also spent time making them. At the secret UK government laboratory at Hanslope Park in Buckinghamshire, Turing led the development of a portable device for speaking securely with another person. It was named Delilah and could be used to scramble a telephone or radio conversation.

Delilah was revolutionary because the scrambling system was very hard to break, yet was portable. By contrast, the secure phone system that linked the British prime minister at 10 Downing Street to the US president in the White House was so large that it had to be installed in the basement of the Selfridges store on London’s Oxford Street. Called SIGSALY, it weighed 50 tonnes and required thousands of watts of power. Other, smaller voice scramblers were insecure and easily decoded by the Nazis.

Delilah worked by combining the speech to be scrambled with what sounded like random noise, similar to an untuned radio. When put together, all an eavesdropper would hear was noise, but by careful synchronisation between two Delilah machines at either end, it was possible to filter out the random noise and hear the original speech.

The system relied on two techniques that are common in modern codes: the creation of an apparently random stream of numbers, and modular arithmetic.

Delilah generated a sequence of numbers that both the sender and receiver could reproduce from a secret key (a way of setting the machine known only to them). By sampling the waveform of the voice to be transmitted – just as modern computers sample music to produce numbers that are stored on a CD or in an MP3 music file – the voice became a stream of numbers. These could then be enciphered by adding each number to a corresponding number from the random sequence. At the other end, a subtraction of the same random number would reveal the original number, which could then be used to reproduce the voice waveform.

What made this secure was that the addition and subtraction was not applied using standard linear arithmetic, but instead a special form called “modular arithmetic”.

Modular arithmetic works a bit like a clock, on which at some point the numbers wrap around (see diagram). On a clock, once you pass 12 (or 24) the numbers begin again. When the numbers used to encode information wrap around in this way, it becomes hard to determine what numbers were used in any calculation just by looking at the answer.

For example, consider how the time 2200 is 3 hours before 0100, but it is also 27 hours before 0100, and 51 hours before 0100 and so on. This wrap-around means that there is an infinity of numbers for any addition or subtraction making it very hard for a codebreaker to determine which one was used.

Cracking Nazi Codes

When studying at Princeton University in 1936, Turing wrote to his mother saying that he had discovered a way to use mathematics to encrypt messages. Three years later, he was back in the UK using his skills to break Nazi codes. His efforts at the British military intelligence base significantly affected the course of the second world war.

At Bletchley, Turing was known universally as “The Prof”. He quickly became arguably the most important code breaker there. Most famously, he helped decipher the messages created by the Nazi’s Enigma coding machines. To do so, he and his colleagues had to use a combination of insight, intelligent guesses and clever engineering.

An Enigma machine employed rotating wheels that assigned each typed letter to a different coded letter of the alphabet. A second machine at the receiver’s end would reverse the process, deciphering the message.

Enigma messages were impossible to crack by brute force, using either raw manpower or simple mechanical calculators, because of the huge number of “keys” used. A key is the crux of any code system: it is a secret “password” agreed on by two people communicating in code. In the case of Enigma, the key consisted of the way each machine was set up before a message was transmitted. Both sender and receiver would arrange their wheels in a pre-agreed fashion, as well as arranging a plugboard similar to that used in a telephone exchange. Depending on whether three or four wheels were used, that meant there were 26x26x26 (17,576) or 26x26x26x26 (456,976) possible keys. And the additional variations in the plugboard settings made messages even more secure.

“Enigma messages were impossible to crack using raw manpower or simple mechanical calculators”

For the Allies, breaking Enigma was essential to winning the battle of the Atlantic and stemming the huge loss of ships and people inflicted by Nazi submarines. It was a particularly difficult task, because the German navy’s U-boats used the four-wheel Enigma, and changed the key frequently. Working with Gordon Welchman, Turing devised a scheme that could reduce the number of possible keys that needed to be tried. It relied on cleverly chosen “cribs” – essentially guesses at part of the contents of a message. A codebreaker might, for example, guess that the message contained the name of a city or a particular ship. That name would be a crib.

Turing and Welchman designed a machine called the Bombe, which was capable of running through the possible keys of an Enigma machine, checking for a match between a crib and a portion of the encrypted message. In other words, if the name of a ship was indeed part of a secret message, the Bombe was capable of spotting it. The Bombe was able to quickly identify which keys were likely candidates because it incorporated shortcuts based on the mathematics of Enigma machines that had been captured. The Bombe’s wheel and plugboard settings could then be used to decipher the rest of message.

Turing’s work at Bletchley reached far beyond Enigma and the Bombe. The Nazis were using a high-speed encrypted teleprinter system that the British called Tunny for the most secret messages. Mathematician Bill Tutte determined, in a brilliant insight, how the machine worked without ever having seen one. Turing then developed a scheme to attack the Tunny cipher, called Turingismus, and by 1943, high-level messages between Hitler and his top commanders were being read. Others, including engineer Tommy Flowers, went on to build Colossus, an early computer that operated at lightning speeds to decipher Tunny.

In 1943, Turing moved over to the secret base at Hanslope Park, Buckinghamshire, to work on a system for secure speech communications called Delilah. Only recently have the full details of this endeavour been declassified (see “My, my, my, Delilah”)

Alan Turing: Codebreaking and code-making

More from 91av

Explore the latest news, articles and features