Log in

No account? Create an account

Previous Web | Next Web

Personal: Enigma machine simulation

An enigma machine is an electro-mechanical encryption device developed by a polish inventor in the 1920s or 30s. It was used as the backbone of encrypted morse transmission by the Nazi war machine in ww2.

There were two types of enigma machine in use in ww2. These were a three 'rotor' version and a special four 'rotor' version, used exclusively by the U-Boat fleet.

Components in an enigma
An enigma machine looks somewhat like a typewriter. It is housed in a wood and metal case (these actually look rather lush).

The enigma comprises:

  • A keyboard of alphabetical characters only

  • A set of lamps, each labelled with a letter. These are normally 'off'

  • The rotors. These are the core element of the encryption mechanism. A rotor is a toothed wheel which contains 26 cross-wired contacts, labelled A to Z.

  • A 'plug-board'. This is a set of 26 double contacts on the front of the machine, and is used, along with a set of wires (with double plugs on each end), to redirect the output from the rotors to different destination characters. Plugging points are labelled 1 to 26

Five rotors are supplied, each with different internal cross-wiring.

An Enigma is prepared for use by placing a selection of rotors on the rotor bar and inserting this in the rotor enclosure. The rotors are then set to their initial positions and the plugboard is wired.

During ww2, the Enigma settings for each day changed. All communication posts equipped with Enigma also had a book of settings for each day. Both Enigma and the settings books, as well as other standard communication books, such as the German navy's short-weather-signals-codebook, were closely guarded and were destroyed if it looked likely that the position were to be captured. As a consequence, very few Enigmas were captured by Allied forces, and even fewer U-Boat Enigmas.

Three rotor Enigma
A three rotor Enigma was the standard design.

Four rotor Enigma
These used the standard five rotots, but used four of them, multiplying the complexity of decrypting the Enigma ciphertext by a further 26. U-Boat Enigma was notorious at Bletchley Park.


The otherall design of Enigma is described earlier. I'm going into a theory about the electrical wiring of the rototrs here.

To work, so far as I can figure, an Enigma must be wired as follows (I'm fairly sure this is accurate, I'm working from memory here):
   +----{ rotor bay }----+
   |                     |
   |                 ---------
  --- NvDC           OXXXOXXXX  Plug 
   -                 XXXOXXXOX  board
   |                 ---------
   |                     |
   +----{   bulbs   }----+

Further, so far as I can figure (and this is where I step into theory), the rotors are wired as follows:
       +---+    +---+    +---+
       |   |----|   |----|   |----> P
       | R |----| R |----| R |----> l
       | o |----| o |----| o |----> u
power  | t |----| t |----| t |----> g
-------| o |----| o |----| o |----> b
 in    | r |----| r |----| r |----> o
       |   |----|   |----|   |----> a
       | 1 |----| 2 |----| 3 |----> r
       |   |----|   |----|   |----> d
       +---+    +---+    +---+

In other words, there is a single power in to the rotor bay. The wiring of the rotor routes the power signal to one out of twenty-six contacts on it's 'out' side. The twenty-six rotor 1-'outs' are straight-wired to 26 rotor 2-'ins', and the same between rotor's 2 and 3. Rotor 3's 'out'-side is straight-wired to the plug board.... contact one goes to A, etc.

The plugboard provides additional routing of the power signal, through a set of rotor-side contacts, a set of wires and a set of bulb-side contacts. This is achived using double plugs on each end of a twin-core piece of wire. The twin is wired as follows:

Rotor           +--+           +--+         Bulb 
out ------< ----|\ |           | /|---- >-- connection
                | }|===========|{ |
Bulb -----< ----|/ |           | \|---- >-- Rotor out
connection      +--+           +--+

The rotor-side and bulb-side contacts are combined in the double-plug. The wire allows power to flow from a rotor-out to the wired bulb-in. This works for both contacts.

This allows for outputs to be swapped, so a rotor-bay output of 'A' can result in a bulb 'Z' lighting up.

It is NOT mandatory for all the plugboard contacts to be in use... indeed, if I remember correctly, there are not actually enough wires supplied to acheive a full wiring of the plugboard.

The sockets for the double-plugs must therefore contain a 'make' feature, so that if a plug is not inserted in the socket, the power is routed from the rotor-out to the bulb path.

   Rotor [ ]               Rotor [O]
    Bulb [ ]                Bulb [O]

      No plug -                 Plug -
     power flows             power flows
     from rotor              through the
      to bulb                wire to the

I guess this is probably acheived using a simple mechanical action, much like the contact cover in a UK mains socket is a simple mechanical device invoving the earth pin... when the longer earth pin is pushed in, it moves the cover on the over contacts out of the way, allowing them to be pushed home.

I imagine that pushing the plug into the socket would push on a spring mounted conductor that normal rests against the bulb and rotor contacts. If the plug is absent, the contacts touch the conductor, creating a circuit. If the plug is inserted, the conductor is pushed off one (or possibly both) of the contacts. Removing the plug causes the spring to return the conductor to the contact.

While it may not work exactly like this, the mechanics are irrelevent for the simulation... this is a possible way that Enigma may really work.
      |  |      || ||
      ----*     || ||*
      no plug    plug

I would imagine that to increase the complexity of the Enigma encryption on a day-to-day basis, the actual number of wires in use was changed as well as the cross-wiring itself.

I plan to build a software-simulation of an Enigma machine.

This will be a Java-applet (so I can put it on the web easily).

The idea is to model a three rotor Enigma.

Initial development will get the actual 'machine' working... then I'll make a nice pretty front-end with rotors and bulbs that light and keys that press... A user will enter text to encrypt in a text-box. There will be a 'Go' button. When this is pressed, the program will then write the text-to-encipher to another box (besically dropping spelling, puncutation, etc. and possibly adding dummy characters (a german operator trick to make life even harder for interceptors)). It will then go through the text-to-encipher, pressing the enigma buttons and recording the lights at the bottom, adding in the 5-character groupings that are usually used to write down Enigma output.


Lets say that the following is the input text:
Let's use Enigma!
The text-to-encipher will be:
The ciphertext could be:
Or more properly
kaqtp aggms oaeqt

The simulator will be object-oriented...

Key objects include:

  • a rotor class

  • a machine class

Each rotor will have a 'number', which will reference an internal table to allocate the internal cross-wiring.

Each machine will contain an set of three rotors and a plugboard.

The program should be easy to make into a four wheel Enigma, we just add another rotor to the machine class. This will probably be a software option anyway... that way we can build a 26 rotor Enigma just as easily as a 1 rotor one.... although the GUI will probably only be built to handle the standard and U-Boat Enigmas.

Once we have a working Enigma, it should be no real hardship to write a much bigger "ASCII-Enigma"... the idea being that we can use the 256 character standard ASCII codepage as the basis for a modern Enigma.. and we use, say 128 rotors instead of the three or four of a real-life Enigma.