PURPLE · Volume 4

PURPLE — Volume 4 — Inside the Type 97 — Sixes, Twenties and Stepping Switches

Four telephone stepping switches, two plugboards and a stepping rule: how the Foreign Ministry's Type B machine enciphered, traced through the wiring tables that SIS recovered without ever seeing one

4.1 About This Volume

This volume takes PURPLE apart. It describes the Japanese machine as far as its makers’ intentions can be recovered, then the machine as SIS reconstructed it: the stepping switch that does the enciphering, the six-letter and twenty-letter halves, the wiring tables, and the rule that decides which switch moves after each letter. It ends by tracing the first letters of the most famous PURPLE message, Part 1 of the 14-part message of 6–7 December 1941 (Volume 7), through every switch.

Two cautions apply throughout. First, almost everything known in detail about PURPLE is known from the American analog, not from a Japanese machine; the SIS cryptanalysts never saw one, and only a fragment survives (Volume 9). Freeman, Sullivan and Weierud, whose 2003 Cryptologia paper is the standard technical account, say so plainly: “the internal components of the PURPLE machine which we present are actually the components that were used in the U.S. Army Signal Intelligence Service (SIS) recreation, or analog, of the original machine” (FSW, p. 3). Because the analog deciphered real traffic, its logic is certainly the Japanese machine’s; its hardware, numbering and plugboard layout were not. Second, every worked example here comes from this unit’s simulator, 03-outputs/tools/purple_sim.py, which reproduces the published decipherment of Part 1 letter for letter (its self-test is described in Volume 11).

Figure 1 — Two of the three stepping switches (marked 6 and 5) in the PURPLE fragment recovered from the Japanese embassy in Berlin, now at the National Cryptologic Museum. Each switch is a stack of contact l…
Figure 1 — Two of the three stepping switches (marked 6 and 5) in the PURPLE fragment recovered from the Japanese embassy in Berlin, now at the National Cryptologic Museum. Each switch is a stack of contact levels — the fanned leaves are the bank contacts and wipers — driven round together by a magnet and ratchet; the three switches of one twenties stage were ganged on a common drive. — Photo: Arnold Reinhold, CC BY-SA 4.0, https://commons.wikimedia.org/wiki/File:Purple_code_machine_fragment_stepping_switches_6%265.agr.jpg

4.2 The Japanese Machine

The Japanese called it the 97-shiki ōbun injiki (九七式欧文印字機), the “Type 97 printing machine for European characters”, and, in Foreign Ministry use, Angōki Taipu B, the Type B cipher machine (FSW, p. 1). The 97 is the imperial year 2597, which is 1937. Japanese and English secondary accounts credit its design to the Navy Technical Research Institute, with Kazuo Tanabe as chief designer and Masaji Yamamoto and Eikichi Suzuki as engineers, and say that it was Suzuki who proposed using telephone stepping switches in place of RED’s troublesome half-rotor (Wikipedia, “Type B Cipher Machine”; Japanese Wikipedia, 九七式欧文印字機). Neither account is well sourced, and the names are given here as attributions rather than established fact. The Japanese Navy’s own Type 97 machines, CORAL and JADE, were relatives built on the same switch technology (Volume 9).

The machine reached the major embassies late in 1938 and went into service on 20 February 1939 (Volume 3). Like RED, it was a desk-sized unit between two electric typewriters: the operator typed on one, and the other printed the result. Between them sat a plugboard on each side and the cipher unit itself. The Japanese machines were destroyed at their embassies when the war ended; the largest known surviving piece is the Berlin fragment, one stage of three stepping switches (Wikipedia).

Figure 2 — The Berlin fragment from the front: three stepping switches side by side on one frame, their magnet covers on top and their strapping packed into the frame below. This is one twenties stage of a Ja…
Figure 2 — The Berlin fragment from the front: three stepping switches side by side on one frame, their magnet covers on top and their strapping packed into the frame below. This is one twenties stage of a Japanese Type 97 — the only original PURPLE hardware known to survive. — Photo: Arnold Reinhold, CC BY-SA 4.0, https://commons.wikimedia.org/wiki/File:Purple_code_machine_fragment_front.agr.jpg

4.3 The Stepping Switch

The part that made PURPLE unlike every cipher machine before it came from the telephone exchange. A stepping switch — in British practice a uniselector — connects one input to one of a row of outputs and moves to the next output each time its magnet is pulsed. It descends from the automatic exchange that Almon Strowger patented in 1891 (US Patent 447,918), which routed a call by stepping a wiper up and round a bank of contacts (FSW, p. 2). The single-motion rotary version used in PURPLE has no up-and-down travel: it only rotates.

Its anatomy is simple. A bank of fixed contacts is arranged in a semicircular arc, 25 contacts to a row, and several rows — levels — are stacked one above another, insulated from each other. A shaft through the centre carries one wiper per level, a springy finger that rests on one contact of its row. Every wiper is fixed to the same shaft, so all levels move together. An electromagnet pulls an armature, which cocks a pawl against a ratchet wheel on the shaft; when the magnet releases, a spring drives the pawl and the wipers advance one contact. Telephone-type switches of this pattern step on the release of the pulse, not on its arrival; the British Post Office called them “reverse action” (P.O. Educational Pamphlet Telephones 3/2). The wiper is double-ended: when one end leaves contact 25, the other end arrives at contact 1, so a 25-point switch steps round 1, 2, …, 25, 1, 2, … forever without needing to be reset. That endless cycle of 25 positions is exactly what a cipher machine needs. (The Telephones section of this site describes the exchange switches themselves, in Telephone Switching History, Volume 3.)

Freeman, Sullivan and Weierud describe the model that mattered: one with “six levels of switches and 25 contacts per level. Each level had a separate input, so that six inputs could simultaneously be connected to one of 25 outputs” (FSW, p. 2). A six-level switch can therefore carry six letters at once, each on its own level, each to its own contact; to make a cipher, the contacts are wired so that at every position the six wipers land on six different outputs. That is a permutation of six letters, and the switch holds 25 of them, one per position.

Figure 3 — Stepping switches inside PURPLE Analog No. 1 at the National Cryptologic Museum: commercial American six-level, 25-point telephone switches. In the SIS analog each twenties stage used four of these…
Figure 3 — Stepping switches inside PURPLE Analog No. 1 at the National Cryptologic Museum: commercial American six-level, 25-point telephone switches. In the SIS analog each twenties stage used four of these moving as one; the coil springs are the drive springs that advance the wipers when the magnet releases. — Photo: Arnold Reinhold, CC BY-SA 4.0, https://commons.wikimedia.org/wiki/File:PURPLE_analog_number_1_stepping_switches_2.jpg

The difference from a rotor is the whole point. A rotor’s 26 alphabets are all the same wiring seen at 26 rotations, so each is a shifted copy of the next, and that relationship is what Rowlett and Kullback had exploited against RED. A stepping switch’s 25 alphabets are 25 separate wiring jobs, as unrelated as the person who wired them chose. “This was a new concept for the SIS cryptographers,” Freeman, Sullivan and Weierud write; “All of these machines, however, had a cyclic operation of some sort” (FSW, p. 16).

4.4 The Machine in Outline

PURPLE keeps RED’s division of the alphabet. The 26 letters reach the cipher unit through an input plugboard, which assigns six of them — any six, chosen daily — to the sixes and the other twenty to the twenties. The two groups never mix: “any sixes letter was only replaced by itself or another sixes letter. Similarly, twenties letters were only substituted among themselves” (FSW, p. 5).

  • The sixes go through a single six-level, 25-point stepping switch. It steps after every letter.
  • The twenties go through three stepping switches in series, each with 20 levels and 25 positions. After every letter exactly one of the three steps.
  • The outputs of the sixes switch and of the last twenties switch go to an output plugboard, plugged the same way as the input one, and on to the printing typewriter.
Figure 4 — The SIS schematic of the PURPLE analog, as redrawn by Freeman, Sullivan and Weierud from the NSA Historical Cryptographic Collection drawing (NARA RG457, NR 3204). Deciphering, the input typewriter…
Figure 4 — The SIS schematic of the PURPLE analog, as redrawn by Freeman, Sullivan and Weierud from the NSA Historical Cryptographic Collection drawing (NARA RG457, NR 3204). Deciphering, the input typewriter's 26 leads go through the input plugboard; six leads go to the sixes switch, twenty to twenties switch #3, then #2, then #1, and both groups return through the output plugboard to the output typewriter. The original drawing labels the twenties switches "Special Sel" and the sixes "Master-6". — W. Freeman, G. Sullivan and F. Weierud, "PURPLE Revealed", Cryptologia 27 (2003), Fig. 2, https://cryptocellar.org/pubs/PurpleRevealed.pdf

The numbering of the twenties switches needs a warning. SIS numbered them #3, #2, #1 in the deciphering direction — the input meets #3 first and the output leaves from #1 — while the Japanese numbered them the other way. Nobody could have learned this from cryptanalysis; it came out because the Japanese occasionally sent new switch settings inside enciphered messages (FSW, p. 7, note 3). The SIS numbering is the one used in the published tables, in the US key notation and in this unit.

Enciphering uses the same wires the other way round. In the analog, the typewriters were simply swapped: the plaintext typewriter fed the #1 end and the ciphertext came out of #3. Because a stepping switch’s level-to-contact connections conduct both ways, running current backwards through a switch applies the inverse of its permutation, and the cipher undoes itself. The machine could also be run “in reverse” deliberately — enciphering in decipher mode — which the Japanese sometimes did (FSW, p. 7).

Figure 5 — The deciphering path in block form, with the first letter of Part 1 of the 14-part message traced through it. Ciphertext Z is plugged to machine letter X, which is twenties input 19; switch #3 at p…
Figure 5 — The deciphering path in block form, with the first letter of Part 1 of the 14-part message traced through it. Ciphertext Z is plugged to machine letter X, which is twenties input 19; switch #3 at position 6 sends 19 to 1, #2 at 24 sends 1 to 19, #1 at 1 sends 19 to 20; output 20 is machine letter Z, plugged to typewriter letter F. — Diagram drawn for this series (03-outputs/diagrams/diagrams_B.py); path from purple_sim.py, matching Freeman, Sullivan & Weierud (2003) Fig. 18

4.5 The Sixes

The sixes switch wires each of its six inputs — machine letters A, E, I, O, U, Y, the vowels in the SIS naming, though after 1934 the plugboard could put any letters there — to one of six output buses at each of its 25 positions. Its complete wiring, as recovered by SIS and printed by Freeman, Sullivan and Weierud from the US Navy’s R.I.P. 77 manual, is short enough to give in full. Each row is a position; each column an input; each entry the output that input reaches. This is the deciphering direction; enciphering uses the inverse of each row.

Table 1 — The Sixes

Position1 (A)2 (E)3 (I)4 (O)5 (U)6 (Y)
1213546
2635214
3154623
4432165
5361452
6216534
7654213
8361452
9542631
10453216
11214563
12546321
13312645
14425136
15162354
16543612
17625341
18234156
19123564
20316425
21651243
22136425
23645132
24461253
25524361

Sixes switch, decipher mode (FSW, Fig. 6, from R.I.P. 77 p. A5-2). Bold entries are inputs that reach their own output.

The table repays a close look, because its regularities are evidence of design.

  • It is balanced. Each input reaches one output five times and the other five outputs four times each, and each output likewise receives one input five times. Freeman, Sullivan and Weierud tabulate this as their Figure 5: “each row and each column contains exactly one position with five output connections.” Somebody chose these 25 permutations from the 720 possible ones with care.
  • It never repeats a connection on successive positions. No input reaches the same output at two neighbouring positions, including the wrap from 25 back to 1. The same is true of all three twenties switches. Because only one twenties switch moves per letter, PURPLE “will never encipher the same plaintext letter to the same ciphertext letter twice in succession” (FSW, p. 19). The SIS analysts had already noticed the effect in the traffic: two identical plaintext letters in sequence were never represented by two identical ciphertext letters (CQ 1984–85, p. 70).
  • Letters can encipher as themselves. Unlike Enigma, PURPLE can turn a letter into itself. In the sixes table, 25 of the 150 cells are identities — one in six. With the input and output plugboards plugged identically, a sixes letter enciphers as itself about 16.6 per cent of the time, a fact that made matching guessed English text to ciphertext much easier (FSW, p. 22).

The sixes’ weakness is obvious from the table’s size. With only 25 alphabets, repeated every 25 letters, the sixes of a message can be attacked like a short-period polyalphabetic cipher. SIS was reading the sixes of most PURPLE messages by April 1939, within two months of the machine’s introduction (CQ, p. 68).

4.6 The Twenties

The twenties are where PURPLE’s strength lay. Each of the three twenties switches is wired, like the sixes, so that its 20 inputs reach 20 different outputs at each of its 25 positions — 500 bank-to-bus connections per switch. The full tables are too large to print here (the simulator and Volume 11 carry them), but they share the sixes’ disciplined construction. In each twenties switch, every input reaches every output at least once, and every input reaches exactly five outputs twice; every output, likewise, has exactly five doubled connections (FSW, p. 9). One curiosity stands out: position 20 of switch #1 is the identity, every input going straight to the output of the same number. “This cannot be a statistical anomaly,” Freeman, Sullivan and Weierud write, and suggest it belonged to some test function, though no combination of #2 and #3 completes an identity path.

Because the three switches are in series, the permutation applied to a twenties letter is the product of three. At any moment, the machine’s twenties alphabet depends on the positions of all three switches, giving 25 × 25 × 25 = 15,625 distinct settings. Freeman, Sullivan and Weierud counted identity encipherments over all of them with their simulator: 15,610 of 312,500 letter-positions, or 4.99 per cent, close to the one-in-twenty that chance predicts (FSW, p. 22). This unit’s simulator reproduces both of those counts exactly.

The cost was wiring. The analog needed “almost 2,000 wired connections”: 150 for the sixes and 500 for each twenties switch, a tangle Freeman, Sullivan and Weierud quote Deavours and Kruh calling “a ‘rat’s nest’ of wiring surrounding each switch” (FSW, p. 7).

4.6.1 Twenty levels from six-level parts

No 20-level, 25-point switch was available off the shelf, so each twenties “switch” was built from several smaller ones driven together. In the SIS analog, each twenties switch was four six-level switches “moved as one”, and the sixes switch carried a second six-level section that moved with it and “controlled the stepping of the twenties switches and also the lamps which indicated the switch position” (FSW, p. 5). The Cryptologic Quarterly history gives the total as thirteen switches of 25 points: one for the sixes and twelve for the twenties, “three banks of four switches each” (CQ, p. 71). The Japanese machine solved the same problem differently: the Berlin fragment shows a twenties stage made from three switches geared together, described in the English secondary literature as seven-level switches, which gives 21 levels for 20 letters (Wikipedia).

4.7 Stepping

Which switch steps when is the last piece of the machine, and it is subtle enough to have puzzled the analysts for months. Freeman, Sullivan and Weierud state the rule:

The motion of the sixes switch is straightforward, advancing one position after each letter is enciphered. … For the twenties, one switch moves after each letter is enciphered. A ‘fast’ switch advances one position after each letter is enciphered, unless the sixes switch has reached the 25 position. In this case, the ‘middle’ switch advances while the ‘fast’ switch does not. If the ‘middle’ switch has also reached the 25 position, then the ‘slow’ switch will advance when the sixes reaches 24, followed (on the next encipherment) by the ‘middle’ switch.

— FSW, p. 15

Put as a decision made after each letter, from the positions the switches stand at before anything moves:

  1. The sixes switch always steps.
  2. If the sixes stands at 24 and the middle switch at 25, the slow switch steps.
  3. Otherwise, if the sixes stands at 25, the middle switch steps.
  4. Otherwise the fast switch steps.

The positions must be read before stepping — “latched”, in Brian Neal’s simulator, which notes “This is crucial!” (purple package). In the analog, the decision was made by contacts on the sixes switch’s second section: at positions 24 and 25 they diverted the stepping pulse from the fast switch’s magnet to another switch’s.

Figure 6 — The stepping rule in action, eight letters either side of a slow-switch step (motion 123: #1 fast, #2 middle, #3 slow). The fast switch steps with every letter until the sixes reaches 24 with the m…
Figure 6 — The stepping rule in action, eight letters either side of a slow-switch step (motion 123: #1 fast, #2 middle, #3 slow). The fast switch steps with every letter until the sixes reaches 24 with the middle switch at 25; then the slow switch steps instead, and on the next letter, with the sixes at 25, the middle switch steps. The fast switch pauses for both. — Diagram drawn for this series (03-outputs/diagrams/diagrams_B.py) from purple_sim.py; the same sequence as Freeman, Sullivan & Weierud (2003) Fig. 10

The consequences are easy to work out. The fast switch steps on 24 letters out of every 25. The middle switch steps once every 25 letters, as the sixes passes from 25 to 1. The slow switch steps once every 625 letters. Because one and only one twenties switch moves per letter, all 15,625 combinations are visited before the twenties repeat — and the sixes, with its 25, divides that, so the whole machine’s period is 15,625 letters. Each time the middle switch steps, the fast switch holds still for one letter; the cryptanalysts saw this as “one random alphabet after every 25 characters” inserted into the run of fast-switch alphabets (FSW, Fig. 12). The Quarterly describes the same motion with four “wheels”: the sixes as the fast wheel and the three twenties as “a delayed fast wheel, a medium wheel, and a slow wheel” (CQ, p. 71).

4.7.1 Six motions

Any of the three twenties switches could be the fast one, and either of the other two the middle, giving six motions. SIS numbered them 1 to 6 and wrote each as fast–middle–slow:

Table 2 — Any of the three twenties switches could be the fast one, and either of the other two the middle, giving six motions. SIS numbered them 1 to 6 and wrote each as fast–middle–slow

Motion indicator123456
Fast, middle, slow123132213231312321

SIS motion indicators (FSW, Fig. 11). Motion 4, 231, means #2 is fast, #3 middle and #1 slow.

On the 1944 improved analog the motion was a six-position knob on the front panel. Of the 120 starting indicators the Japanese used, 20 belonged to each motion (CQ, p. 72).

Figure 7 — The stepping-order selector on the US Army's improved PURPLE analog at the National Cryptologic Museum. Its six positions, lettered A to F, are each engraved with a motion; it is set here to "B 312…
Figure 7 — The stepping-order selector on the US Army's improved PURPLE analog at the National Cryptologic Museum. Its six positions, lettered A to F, are each engraved with a motion; it is set here to "B 312" — switch 3 fast, 1 middle, 2 slow. — Photo: Daderot, CC0, https://commons.wikimedia.org/wiki/File:PURPLE_analog_stepping_order_switch.png

4.8 One Letter, Wire by Wire

Part 1 of the 14-part message was enciphered with switches at sixes 9, #1 at 1, #2 at 24, #3 at 6, motion 4 (231), written in the US notation as 9-1,24,6-23, and with the daily alphabet NOKTYU XEQLHBRMPDICJASVWGZF (Volume 12 explains how that key was derived). Its first three ciphertext letters are ZTX. Freeman, Sullivan and Weierud walk through them in their Figure 18; the simulator gives the same path, and continues it:

Table 3 — Part 1 of the 14-part message was enciphered with switches at sixes 9, #1 at 1, #2 at 24, #3 at 6, motion 4 (231), written in the US notation as 9-1,24,6-23, and with the daily alphabet NOKTYU XEQLHBRMPDICJASVWGZF (Volume 12 explains how that key was derived). Its first three ciphertext letters are ZTX. Freeman, Sullivan and Weierud walk through them in their Figure 18; the simulator gives the same path, and continues it

Switches before the letterCipherPathPlain
9-1,24,6ZZ→X→in 19 · #3 at 6: 19→1 · #2 at 24: 1→19 · #1 at 1: 19→20 · 20→Z→FF
10-1,25,6TT→O→in 4 · sixes at 10: 4→2 · 2→E→OO
11-1,1,6XX→B→in 1 · #3 at 6: 1→13 · #2 at 1: 13→12 · #1 at 1: 12→16 · 16→T→VV
12-1,2,6OO→E→in 2 · sixes at 12: 2→4 · 4→O→TT
13-1,3,6DD→M→in 10 · #3 at 6: 10→18 · #2 at 3: 18→3 · #1 at 1: 3→14 · 14→R→AA
14-1,4,6NN→A→in 1 · sixes at 14: 1→4 · 4→O→TT
15-1,5,6WW→V→in 17 · #3 at 6: 17→4 · #2 at 5: 4→3 · #1 at 1: 3→14 · 14→R→AA
16-1,6,6KK→I→in 3 · sixes at 16: 3→3 · 3→I→KK
17-1,7,6CC→P→in 12 · #3 at 6: 12→10 · #2 at 7: 10→16 · #1 at 1: 16→11 · 11→N→II
18-1,8,6CC→P→in 12 · #3 at 6: 12→10 · #2 at 8: 10→5 · #1 at 1: 5→10 · 10→M→DD

First ten letters of Part 1, deciphered by purple_sim.py --trace with key 9-1,24,6-23 and alphabet NOKTYUXEQLHBRMPDICJASVWGZF. Rows 1–3 agree with FSW, Fig. 18.

Reading down the right-hand column gives FOVTATAKID: FOV, the code group for an opening parenthesis, then the Japanese tatakidasi. Four things in this short run show the machine at work. The sixes switch advances with every letter (9, 10, 11 …) whether the letter is a six or a twenty. Switch #2, the fast switch in motion 231, advances with every letter too, passing from 25 back to 1 after the second. Switches #1 and #3 do not move: #3, the middle switch, will step for the first time after letter 17, when the sixes reaches 25. And at letter 8, ciphertext K comes out as plaintext K, one of the sixes’ identity cells — the plugging sends K to machine letter I, and at position 16 the sixes switch connects input 3 to output 3. Letters 9 and 10 show the never-repeat property from the other side: the same ciphertext C, typed twice in a row, gives two different plaintext letters, because #2 moved between them.

4.9 The Machine’s Strength, Honestly Measured

On paper PURPLE was strong. Freeman, Sullivan and Weierud count its key space for an attacker who knows the wiring but nothing else: 25 sixes positions, 25³ twenties positions, six motions and 26! plugboard orders, about 9.45 × 10³² keys (FSW, p. 31). Its twenties alphabets were unrelated to each other, so the methods that broke rotor machines had nothing to hold. Its period, 15,625 letters, was far longer than any message.

In practice four things undid it, and none was in the switches.

  1. The six–twenty split. It let the sixes be solved on their own, quickly, and the solved sixes then exposed fragments of plaintext in every message, which became cribs for the twenties.
  2. Limited starting points. Because PURPLE was hard-wired, its keys had to avoid overlaps between long messages, so the Japanese drew starting positions from a list of only 120 indicators (240 after May 1942). The same starting point recurred across many days, with only the plugboard changing.
  3. Procedure. Messages began with stereotyped numbers and phrases; English texts were sent to be handed to the US government; and the same messages went out in both RED and PURPLE (Volume 3).
  4. Keying in tens. The daily alphabets came from a book in a fixed pattern, so that once a few were recovered the rest could be predicted (Volume 12).

The Americans’ final break came from the second and fourth together: six messages with the same indicator, 59173, sent on different days, which could be converted to a common alphabet and so put in depth (Volume 5). After that, as the Quarterly puts it, “The unsolvable problem had been reduced to a mechanical exercise” (CQ, p. 75).

4.10 Built Without a Look

Everything in this volume — the 25-point switches, the 2,000 wires, the latched stepping rule — was inferred from ciphertext and guessed plaintext before any American held a piece of the real machine. NSA’s exhibit text credits Leo Rosen, an SIS engineer, with the decisive hardware insight: leafing through an electrical supply catalogue, he noticed a telephone stepping switch of six levels and 25 contacts, and ordered two built as a “six buster” to reproduce the sixes (NSA, “The Magic of Purple”). When the full analog ran, the Americans had reproduced a machine they had never seen, down to the wiring of each contact, on the evidence of its output. Volume 5 tells how that solution was reached, and Volumes 10 and 11 build one again.


Next — Volume 5: The Break — Friedman, Rowlett, Grotjan and 20 September 1940. Eighteen months against the twenties: the depth of indicator 59173, Genevieve Grotjan’s discovery, and the first deciphered PURPLE messages.

Comments (0)

  1. Loading…

Comments are held for moderation — nothing appears until approved.