Cipher Utility

From Caesar to Enigma: A History of Military Cryptography

Two thousand years of military codes and the people who broke them.

Overview

Armies have always needed to send orders that the enemy could intercept but not read, and that need drove most of the progress in cryptography before computers. Each new cipher held until someone found a way to break it, and then the codemakers had to try again.

WhenWhat happened
c. 50 BCJulius Caesar shifts the letters of his military messages
1467Leon Battista Alberti describes the first polyalphabetic cipher
1553The keyword cipher later named after Vigenère is published
1861 to 1865Telegraph ciphers in the American Civil War
1863Friedrich Kasiski publishes a general attack on keyword ciphers
1917British codebreakers read the Zimmermann Telegram
1918Arthur Scherbius patents the rotor machine later sold as Enigma
1932Polish mathematicians break the German army Enigma

Caesar and the Spartan scytale

Caesar's letter shift

The Roman historian Suetonius wrote that Julius Caesar replaced each letter of his private and military messages with the letter three places further along the alphabet. The method needed no equipment, only an agreed shift, so a commander could encrypt and decrypt quickly in the field. A captured messenger carried text that looked like nonsense to anyone who didn't know the trick.

The weakness is that there are only 25 possible shifts, so anyone who suspects a shift cipher can try them all. The Caesar cipher article walks through the method and the attack.

The scytale

Ancient Greek writers describe the Spartans using a scytale: a strip of leather or parchment wound around a rod of a set thickness. The sender wrote along the rod, then unwound the strip, which left the letters in a scrambled order. The receiver wound it around a rod of the same thickness to read it. The scytale is a transposition cipher: it changes the order of the letters and leaves the letters themselves alone.

Renaissance ciphers with more than one alphabet

Alberti's idea

In a single-alphabet cipher such as Caesar's, the same plain letter always becomes the same cipher letter, so the letter frequencies of the language show through. Around 1467 the Italian architect Leon Battista Alberti described a cipher disk that switched between several cipher alphabets during a message. A letter could then be encrypted in different ways at different points, which breaks the simple link between plain and cipher letters.

The Vigenère cipher

The best-known version of this idea uses a keyword to choose a Caesar shift for each letter. Giovan Battista Bellaso published it in 1553, and it was later credited to the French diplomat Blaise de Vigenère, whose name stuck. Here is ATTACKATDAWN with the keyword CIPHER:

Plain:  ATTACKATDAWN
Key:    CIPHERCIPHER
Cipher: CBIHGBCBSHAE

The first A becomes C and the second becomes H, because a different key letter sits above each one. The cipher had a reputation as "le chiffre indéchiffrable", the unbreakable cipher, until Friedrich Kasiski published a method in 1863 for finding the keyword length. Once you know the length, the message splits into a handful of Caesar ciphers, and each of those falls to letter counting. The Vigenère article covers the attack in detail.

The telegraph and the First World War

The American Civil War

The telegraph let commanders send orders across hundreds of miles within minutes, but the wires could be tapped. The Union army used route ciphers, which wrote the words of a message into a grid and read them out in a prearranged order, with code words standing in for names and places. The Confederacy relied largely on the Vigenère cipher with a few fixed keywords, and Union telegraph clerks were able to read many of the messages they intercepted.

The Zimmermann Telegram

In January 1917 the German foreign minister Arthur Zimmermann sent an encrypted telegram to the German ambassador in Mexico. British codebreakers in the Admiralty's Room 40 decrypted it. It opened like this:

We intend to begin on the first of February unrestricted submarine warfare. We shall endeavor in spite of this to keep the United States of America neutral. In the event of this not succeeding, we make Mexico a proposal of alliance...

Britain passed the text to the United States, where its publication helped turn opinion toward entering the war, which the US did in April 1917.

The Enigma machine

The First World War showed that hand ciphers could not keep up with the volume of military traffic. The German engineer Arthur Scherbius patented a rotor cipher machine in 1918 and sold it commercially as Enigma during the 1920s. The German navy and army adopted modified versions in the late 1920s.

How Enigma works

Pressing a key sends an electric current through a plugboard, then through three rotors (four in a later navy model), into a reflector, and back through the rotors and plugboard to light a lamp showing the cipher letter.

  • Each rotor is a wired disk that swaps every letter for another.
  • The rotors step forward like a car's odometer as you type, so the substitution changes with every key press. Typing AAAA produces four different letters.
  • The plugboard swaps pairs of letters before and after the rotors.
  • The rotor order, starting positions, ring settings and plugboard pairs were changed every day from printed key sheets.

Because of the reflector, the machine is its own inverse: typing the ciphertext on a machine with the same settings gives back the plain text. The same reflector means a letter can never be encrypted as itself, and that detail turned out to matter a great deal.

The number of settings

For the army machine with three rotors chosen from five and ten plugboard cables, the commonly quoted count of possible daily settings is about 159 quintillion:

PartPossibilitiesHow
Rotor order (3 of 5)605 × 4 × 3
Rotor starting positions17,57626³
Plugboard (10 pairs)150,738,274,937,250ways to pick 10 pairs from 26 letters
Total158,962,555,217,826,360,000product of the three

Nobody could try that many keys by hand, and the Germans trusted the machine accordingly. Enigma was broken anyway, through mathematics, machines and the habits of the people using it.

How Enigma was broken

The Polish Cipher Bureau

In 1932 Marian Rejewski, a young mathematician at the Polish Cipher Bureau, worked out the wiring of the army Enigma rotors using permutation theory, helped by documents a French intelligence source had obtained. With Henryk Zygalski and Jerzy Różycki he then developed ways to recover the daily settings. They built a device called the cyclometer to catalogue rotor patterns, perforated sheets now known as Zygalski sheets, and in 1938 the bomba, an electromechanical machine that searched for settings.

In July 1939, weeks before Germany invaded Poland, the Poles shared their results, including replica machines, with British and French intelligence.

Bletchley Park

The British Government Code and Cypher School at Bletchley Park turned the Polish work into a large operation that by the end of the war employed thousands of people. Alan Turing and Gordon Welchman designed the British bombe, which tested rotor settings against a guessed piece of plain text much faster than any person could. The intelligence produced this way was code-named Ultra. Bletchley also built Colossus, the first programmable electronic digital computer, though it was used against a different German cipher, the Lorenz teleprinter cipher, rather than Enigma. Turing's part in all this is told in How Alan Turing changed cryptography.

Operator mistakes

The bombes needed a crib: a guess at some words in the message. Operators made cribs easy to find.

  • Routine messages followed fixed formats. Weather reports often contained WETTERVORHERSAGE (weather forecast) in predictable places.
  • Since Enigma never encrypted a letter as itself, a crib could only sit at positions where none of its letters matched the cipher letters below it. That ruled out many positions at once.
  • Some operators chose lazy message settings such as AAA or three letters in a row on the keyboard.
  • The same message was sometimes sent twice under different settings, or resent after an error, which gave the codebreakers two versions to compare.

What breaking Enigma changed

Ultra helped the Allies in the Battle of the Atlantic by showing where U-boat groups were waiting, so convoys could be routed around them. In North Africa it revealed the sailing times of the convoys supplying Rommel's army. Before D-Day, decrypts confirmed that the Germans still expected the main landing near Calais. How much it shortened the war is debated; an estimate of about two years is often quoted.

The story also left lessons that cryptographers still apply. Kerckhoffs's principle, set out in 1883, says a system must stay secure even if the enemy knows exactly how it works. Enigma's designers had not counted on the Poles reconstructing the machine. A huge number of keys did not help when the way the machine was used gave so much away, and operator habits and fixed message formats did as much damage as any flaw in the design.

Try it on Cipher Utility

Further reading