Enigma Machine is a family of enciphering and deciphering machines invented and used in WWI and WWII, and later hacked by scientiests including Alan Turing.
There are different versions and settings of Enigma machine, but essentially, it is such a function:
This is a mapping from input char \(x\) to output char \(E(x)\), where \(P\), \(R\), \(F\) are three other mapping functions standing for the plugboard, rotor, and reflector.
The physical plugboard is a configurable wire board that can perform a simple substitution among 26 letters. If we leave it unconfigured, the plugboard will be downgraded into an identity function. But we can always use wires to manually map any input character to some output character. \(F\) is an involution.
Rotors are physical wheels, with 26 input pins on one side, 26 output pins on the other side, and an internal mapping from input to output. There are several versions of rotors (e.g. I, II, III, etc,.) identified by their internal mappings. An Enigma machine usually consists of several rotors, with each rotor's output pins mapped to the next rotor's input pins. For any specific rotor, its internal mapping always remain the same, but mappings between subsequent rotors are constantly changing due to rotating and stepping of rotors. The internal mapping of \(R\) is involution.
Reflector can be treated as a pre-configured plugboard with 13 wires paring 26 letters. It is involution.
There are several commonly used configurations for rotors and reflectors. But number of rotors used, order of rotors, initial positions of rotors and wiring configuraion of plugboard are considerd the message key that is used to encrypt/decrypt messages. Compromising the message key is very dangerous.
The specs can be found here.
How It Works (for a standard three rotor version)
Basically, the operator setup the machine based on the message key, and then start typing the message one letter at a time. The keystroke will generate current, pass through plugboard, rotors and reflectors from right to left, and then pass back from left to right. This is specified by the mapping function described in the beginning.
Before the current pass through the rightmost rotor, it is rotated one position forward. The default position can be called position A or position 0. Forward means
(p + 1) mod 26. All the mappings described in the spec are the mappings for default positions. e.g. A machine with rotor positions (from left to right)
AAA will transform into
AAB after typing one letter.
Stepping and Double Stepping
When the rotor to the right first reach a notch position, the rotor to the left will step one position forward immediately. Notch positions are described in the spec. e.g. A machine with
AAW (RotorIII at rightmost position) will turn into
There is also a double stepping case described here.
Suppose we have a shifting function \(s(x, i)=(x+i)\%26\), and assume the internal mapping of rotor \(R\) is \(r\). Then for a rotor at position \(i\) with input \(x\), the actual input for the internal mapping \(r\) is \(s(x, i)\). Since we need to consider the position difference between rotors, I recommend normalizing the output of the whole rotor by shifting back \(i\) as if the rotor stays in default position. In this way we simplified the mapping between rotors into identity function.
Therefore, \(R(x) = s(r(s(x, i)), -i)\).
- This is an incredible Enigma machine emulator, absolutely full featured. go!
- This is a site introducing nearly everything about Enigma machine, especially the very helpful specifications. go!.