Virtual M-209

The history of the Hagelin M-209

The M-209, how it was used, its internal elements, the Hagelin machines that came before it, and Bletchley Park.

The M-209 and its history

The M-209, designated CSP-1500 by the US Navy (C-48 by the manufacturer), is a portable, mechanical cipher machine used by the US military mainly in World War II, though it remained in active use through the Korean War. It was designed by the Swedish cryptographer Boris Hagelin in response to a request for a portable cipher machine, and was based on the C-38, itself an improvement of an earlier machine, the C-36.

A US Army M-209 cipher machine
US Army M-209. Image from cryptomuseum.com.

The M-209 is about the size of a lunchbox: in its final form it measures 178 × 140 × 83 mm (7 × 5.5 × 3.25 inches) and weighs around 2.7 kg. It was a brilliant achievement for pre-electronic technology.

Basic operation

Basic operation of the M-209 is fairly straightforward. Six adjustable key wheels on top of the box each show a letter of the alphabet. These six wheels make up the machine’s external key, giving a starting state, rather like an initialisation vector, for the enciphering process.

The M-209 open, with its parts labelled: oiler, screwdriver, lid retaining clip, case lock, paper strip roll, tweezers, cover, paper input and output, spare ink rolls, paper advance, letter selector, cipher/decipher knob, printer, letter counter, top lid, knee fit, cipher wheels, reset, advance knob and main axle
The parts of the M-209. Image from cryptomuseum.com.

To encipher a message, the operator sets the key wheels to a random sequence of letters. A cipher/decipher knob on the left side of the machine is set to “cipher”. A dial known as the indicator disk, or letter selector, also on the left side, is turned to the first letter of the message. The letter is enciphered by turning a hand crank, or power handle, on the right side of the machine: at the end of the cycle the cipher text letter is printed on a paper tape, the key wheels each move on one letter, and the machine is ready for the next character. On the M-209, the letter Z is enciphered to show spaces between words, as it is rarely used in American English. Repeating this for the rest of the message gives the complete cipher text, which can then be sent in Morse code or by another method. Because the starting key wheel setting is random, it also has to be sent to the receiving party; it may be encrypted with a daily key, or sent in the clear.

The M-209 automatically spaces the printed cipher text into groups of five, for easier reading. A letter counter on top of the machine shows the total number of letters encoded, and can be used as a reference point if a mistake is made in enciphering or deciphering.

Deciphering is almost the same as enciphering: the operator sets the cipher/decipher knob to “decipher” and sets the key wheels to the same sequence used for enciphering. The first letter of the cipher text is entered with the indicator disk, and the power handle is turned, moving the key wheels on and printing the decoded letter on the paper tape. When the letter Z comes up, a cam leaves a blank space in the message, putting back the original spaces. Any Zs that are missing can usually be worked out by the operator from the context.

An experienced M-209 operator might take two to four seconds to encipher or decipher each letter, so it was relatively fast.

View the M-209 manual (PDF)

Internal elements

Inside the case of the M-209, a much more complicated picture emerges. Each of the six key wheels has a small movable pin next to each letter on the wheel. Each pin can be moved to the left or right, and this affects how the machine works: the left position is inactive and the right position active.

Interior view of the M-209, showing the key wheels and the drum of bars behind them
Interior view of the M-209. Image from cryptomuseum.com.

Each key wheel has a different number of letters, and so a different number of pins. From left to right, the wheels have:

  • 26 letters, from A to Z
  • 25 letters, from A to Z, except W
  • 23 letters, from A to X, except W
  • 21 letters, from A to U
  • 19 letters, from A to S
  • 17 letters, from A to Q

These sizes were chosen to be relatively prime, so the wheels only line up the same way once every 26 × 25 × 23 × 21 × 19 × 17 = 101,405,850 enciphered letters (known as the period). Each key wheel has a slanted metal guide arm, which is moved by any pins in the active position. The positions of the pins on the key wheels make up the first part of the M-209’s internal key.

A US M-209 in use in the field
The M-209 was carried in a pouch, as shown here. (Date and location of the photo unknown.)

Behind the row of six key wheels is a cylindrical drum of 27 horizontal bars. Each bar has two movable lugs, which can be lined up with any of the six key wheels or placed in one of two “neutral” positions. An active pin tilts its guide arm forward, against the drum. The positions of the lugs make up the second part of the internal key. Because setting the internal key was so complicated, it was changed fairly rarely; changing it once a day was common in practice.

When the operator turns the power handle, the drum makes a complete turn through all 27 bars. If a lug on a bar meets the guide arm of an active key wheel, that bar slides to the left; lugs in neutral positions, or that don’t meet a guide arm, don’t affect the bar. The bars slid to the left together form a gear with a variable number of teeth, which shifts the letter being encoded: the shift equals the number of bars sticking out to the left. The resulting cipher text letter is printed on the paper tape.

After the turn is complete, a retractor pushes the bars back into place. A set of intermediate gears moves the key wheels on one position, and a locking arm latches into the drum to stop a second encoding until the indicator disk has been moved for the next letter.

This let the shift change for every letter enciphered; without it, the cipher would be a very insecure Caesar shift.

Earlier pin-and-lug machines

The C range of small mechanical cipher machines were all of a similar pin-and-lug type, developed by Boris Hagelin at AB Cryptoteknik in Stockholm, Sweden. Here are a few of the machines leading up to the M-209; the number in the name is often related to the year of development (for example, the C-35 in 1935). They are all purely mechanical, needing no battery or mains power, which made them ideal for the front line.

Hagelin C-35

The Hagelin C-35 cipher machine
The C-35 cipher machine.

The C-35 was the first mechanical pin-and-lug cipher machine developed by Boris Hagelin, originally requested by the French Army, who wanted a small pocket-sized cipher machine. It measured 6 × 4.5 × 2 inches (152.4 × 114.3 × 50.8 mm) and weighed less than 3 pounds (1.36 kg).

At the front of the machine are five pin-wheels (one fewer than on the M-209 and C-38), with 25, 23, 21, 19 and 17 steps, so the one missing is the 26-step wheel. This gives a period of 3,900,225 before the key starts to repeat.

The cage at the back is similar to the later models, but its lugs are fixed in place and can’t be moved by the operator, and it has 25 bars in total.

Hagelin C-36

Interior view of the Hagelin C-36
Interior view of the C-36. Image from cryptomuseum.com.

The C-36 was very similar to the C-35, with the same five pin-wheels and cage, but it had an outer housing and cover, and the fixed lugs were arranged slightly differently.

A later model, the C-362, had movable lugs instead of fixed ones (more like the C-38 and M-209), plus a number of other changes, such as a cross-type key for the inner lid instead of a standard Yale-type key, and a longer swing-out handle instead of the compact one.

Hagelin C-37

The Hagelin C-37 was developed around 1937 for the French market (possibly the French Navy). It has a similar cipher mechanism to its predecessor, the C-36, but is wider, and has several bigrams to the left of each letter on its much larger selector knob, which appear to include numbers and some punctuation. It also has a very different set of print wheels. For a couple of photos of this machine, and more information, see Crypto Museum: Hagelin C-37.

Hagelin C-38

Interior view of a Hagelin C-38S
Interior view of the C-38S. Image from a machine at auction at rrauction.com.

The C-38 was designed as the successor to the C-36 and was developed at the start of World War II. The M-209 (the US Navy’s CSP-1500) worked in much the same way, with a few changes to make it easier to operate and manufacture. It measures 178 × 140 × 83 mm and weighs 2.7 kg, so it could fit in a (large) coat pocket.

Exterior view of a Hagelin C-38S
Exterior view of a C-38S.

An extra pin-wheel was added to the left of the five on the earlier machines: a 26-position wheel with the letters A–Z round its edge. This gives a period of 101,405,850 before the key repeats. Machines in this class seem to have more bars in the cage at the back, 29 in most cases.

The M-209 has only 27 bars, and it may be that some models of the C-38 have interchangeable or removable bars. If you know more about the number of bars on particular models, please let me know.

There seem to be several models of the C-38, for particular purposes or customers. The standard model seems to be marked C-38S. For the Italian Supermarina (the Italian Navy) during WW2 there seems to have been a C-38M, but this is extremely rare (if any survived) and I haven’t seen one to know the differences.

One change between the C-38 and the M-209 seems to be the letter used as the space. On the M-209 it is Z (in cipher mode, a Z in a message prints normally, but in decipher mode a deciphered Z prints as a blank space). On the C-38S, though, it seems to be X rather than Z. (For more on how this works, see how it works.)

Here are some of the differences between the C-38 and the M-209/CSP-1500:

  • The C-38 has an adjustable letter wheel.
  • It has extra bars on the cage.
  • It has a lockable inner and outer case.
  • There are some minor mechanical changes, including a ratchet and pawl on the paper feed and a different arrangement for the letter lock.
  • There is a second button on top of the inner lid (my guess is to reset the letter count without changing the pin-wheels).
  • It has a different double-ended tool for changing the pins and lugs, mounted on a clip to the right of the machine rather than in the lid.

The C-38SX

Another version of the C-38S that seems to have been available is the C-38SX. It is similar to the standard C-38S, but with an extra setting on the cipher/decipher knob marked X.

The X setting lets the machine print the X (space) character in decipher mode. So the three settings are:

  1. C (cipher): groups the printed text into groups of 5 letters and prints the cipher letter Z.
  2. D (decipher): no longer groups the text, just printing the deciphered letters. A deciphered X isn’t printed; the paper just moves on one space.
  3. X: also doesn’t group the text for deciphering, but when a deciphered X is due to be printed, the machine actually prints the X.
Exterior view of a Hagelin C-38SX
Exterior view of a C-38SX.
Side view of a C-38SX, showing the cipher/decipher knob with its third X setting
Side view, showing the third X setting.
Interior view of a C-38SX
Interior view.
The cage of a C-38SX, with 29 bars
The 29 bars on the cage.
The C-38SX pin and lug tool
The pin and lug tool.
The C-38SX’s changeable letter selector knob
The changeable letter selector knob.

Bletchley Park

Bletchley Park worked on and broke the Hagelin machines; of particular interest was the fact that the Italian Supermarina was using the C-38.

The decrypt below, from an Ultra signal, is as it was reported to the Admiralty by the Bletchley Park Naval Section. In the serial, CX/MSS is the standard reporting code for Ultra, meaning the product of breaking high-grade Axis ciphers. The rest is particular to naval Ultra: Z means naval Ultra, TP means “teleprint”, I means Italian and GM means German Mediterranean, and the number refers to the particular decrypt. So this signal was compiled from an Italian decrypt, presumably from Hagelin, and a German Enigma decrypt, probably from the Porpoise key. TOO means time of origin, the time the message was handed to the Axis cipher clerk, rather than the time it was intercepted. This decrypt was also reported separately through SCU/SLU channels to army and air commands as ML 1324.

An Ultra signal as reported to the Admiralty by the Bletchley Park Naval Section
An Ultra signal as reported to the Admiralty by the Bletchley Park Naval Section. Document from the Bletchley Park Trust, object number D-1655-041. Select the image for the full-size version.

The images below are also from the Bletchley Park Trust, and are believed to be rebuilt Y setting books. Thomas Cheetham, a Research Officer at Bletchley Park, describes them like this:

“Our interpretation is that the 5-digit numbers are indicators referring to page (2 digits) column (1 digit) and row (2 digits) of the key book, and the 6 letters are the associated setting of the rotors in the machine (known as the Y setting). The Italians used the same Y key book for six months, while changing the other settings of the machine (termed W and X), so rebuilding the Y book BP helped identify depths which could be used to determine the W and X settings. One of the files is in alphabetical order to facilitate that process and the other is in number order to match the order of the original Italian key book.”

A Bletchley Park rebuilt Hagelin Y setting book
Bletchley Park Hagelin setting book. Select the image for the full-size version.
A second Bletchley Park rebuilt Hagelin Y setting book
Bletchley Park Hagelin setting book. Select the image for the full-size version.

Next: how does the M-209 actually work?