Electro-mechanical machines fitted with movable rotors were able to produce long random keystreams, thus allowing to encrypt messages by using polyalphabetic substitution ciphers.
The main idea that lies behind rotor machines is relatively simple. One can imagine a simple device, similar to a typewriter, with a number of keys used to input text. The number of keys may differ, however usually there are 26 to 32 characters.
Simple substitution cipher
Each keystroke produces an output character, depending of the internal construction of the machine. In the simplest case, if only wires are used (without any rotors), each input key will be mapped to one specific output character.
For example, if someone pressed K in the keyboard, the machine would always produce C.
As a result, the machine would encrypt the messages by using a simple substitution cipher.
Adding a rotor
Having a simple substitution machine, one can imagine adding an additional internal rotor with an internal wiring. The rotor will rotate with a gear, each time after a keystroke. As a result, after pressing the same letter twice, it will be encoded differently due to different internal wiring.
For example, if someone pressed KK in the keyboard, the machine would produce CB (because the wiring changed after the first keystroke, due to the rotor movement).
The internal wiring of the rotor should be kept secret, however we may expect that over time the enemy will discover its design. It will make it easier for them to break the cipher but it won't compromise the security altogether.
To decode a ciphertext the receiver would need a machine with the same rotor. Adding the rotor caused the encryption to become a stronger polyalphabetic substitution cipher.
Make it difficult
To improve the security, one could add more rotors. The output of one rotor would be connected to the input of the second rotor. Similarly, the second rotor output would be connected to the third one, and so on. The strength of the encryption depends on several factors:
- the number of rotors inside the machine.
- the size of each rotor.
- the number of rotor types (with different internal wirings).
Each rotor would contain a different internal wiring. The substitution performed by each rotor should be unknown for the enemy. To make cryptanalysis more difficult and to ensure that the wiring inside each rotor changes with different frequency, the discs should rotate with different speeds.
Additionally, depending on the design of the machine, some additional features may be added to the machine, to ensure that the produced substitution is as random as possible (for example, an additional fixed substitution that does not depends on the rotors).
Some rotor machines (most notably Enigma) were designed to be symmetrical. That means that encrypting the same message twice (with the same settings), would produce the original message.