My crypto Home Page |
IntroductionRotor Cipher MachineA type of cipher machine can use several approaches to transform the plaintext into an encrypted message. A common approach is the use of rotors. The Sigaba machine is a typical example of a rotor machine. A rotor is a device that permutes cryptographic units (usually letters of the alphabet). Each time a rotor turns (hence its name), a new permutation is created. A cipher machine equipped with several rotors can create a very high security cipher. In another web page, we describe in detail the concept of rotor. Enigma machinesEnigma machines are special. Indeed, they are equipped with a reflector that greatly complicates the encryption while simplifying its use, because encryption and decryption are identical operations. In a machine like the Sigaba, the electric current passes through several rotors. The current must be reversed to perform the decryption. In Enigma machines, the current passes through each rotor and then passes through the reflector which returns the current which passes through each rotor again but in the opposite direction. This has two consequences:
Abstract and simplified vision of the Enigma
Figure 1 shows the encryption performed by the most common version of the Enigma: The military Enigma 1. It is equipped with a static reflector (U) and then three rotors (L, M, N). The rightmost rotor is called the "fast rotor" because it turns one step before encrypting each letter. The other two rotors turn less frequently. Then a set of cables connects the last rotor to the keyboard. This is the ETW that Dilly Knox nicknamed "QWERTZU". Finally, the steckers allow several letters to be swapped two by two. The Enigma I is the machine that was broken by Rejewski and against which the Bletchley Park cryptanalysts fought the most. In fact, there are many other models, for example the commercial Enigma which does not have steckers and whose reflector is not static. The four-rotor Enigma of the German Navy. On the other hand, the British Typex machine can be considered as an Enigma composed of five rotors, two of which do not advance during encryption. Figure 2 shows our simplified Enigma. Only one rotor will be used in addition to the reflector. The other equipment (ETW, Steckers, ...) will be absent. On the other hand, only six encryption units (0,1,2,3,4,5) will be used, which will replace the 26 letters of traditional Enigmas. In the following paragraphs, we will study in details our simplified version of the Enigma.
Representing our Enigma via drawings
Figures 3 to 8 show the current flow in our simplified Enigma at the different positions of the rotor. The Enigma rotates in a trigonometry direction (counterclockwise). The operator looks at the machine seen perceptively from the right: first seeing the rotor and in the background the reflector. The red dot is attached to the rotor and allows its position to be materialized. Example of encryption: at position 2 of the rotor, if we encrypt 5 we obtain 2. At the rotor output 5 gives 5, then the reflector transforms the 5 into 3. The rotor crossed in the opposite direction transforms 3 into 2. Since encryption is equivalent to decryption, the encryption of 2 gives 5. Figure 9 shows the Enigma at various rotor positions, but unlike Figures 3 through 8, the Enigma is viewed from the side.
Using tables to represent our EnigmaEncryption by the Rotor and the Reverse RotorA table is used to represent the encryption of a rotor. The different possible tables have been described in the Rotor page. In our case, the rotor advancement is in the counterclockwise direction (trigonometric direction). In the first table above, the column headers indicate the position of the rotor. The row headers indicate the letter that we want to encrypt (0, 1, 2, 3, 4, 5). The first column indicates the wiring of the rotor at the initial position (position 0). The diagonals correspond to the wiring of the input disk, the ETW (Qwertzu). If the ETW is absent or if it corresponds to the identity permutation (A=>A, B=> B, C=> C, …, Z=>Z). Here, the diagonals correspond to the sequence 0, 1, 2, 3, 4, 5 (from top to bottom, from right to left). For example, at rotor position 4, the encryption of 2 gives 2. In the second table, we have the reverse rotor encryption table. This is used in our Enigma at the output of the reflector.
Rotor Reverse Rotor 0 1 2 3 4 5 0 1 2 3 4 5 0 0 0 2 0 1 3 0 0 0 3 0 4 5 1 1 3 1 2 4 1 1 1 4 1 5 0 1 2 4 2 3 5 2 2 2 5 2 0 1 2 2 3 3 4 0 3 3 5 3 3 1 2 3 3 0 4 5 1 4 4 0 4 4 2 3 4 4 1 4 5 2 5 5 1 5 0 5 4 5 5 2 5 3
Encryption performed by our EnigmaIn this case, we do not have two tables, but only one, because encryption is equivalent to decryption. As before, the column header indicates the rotor position and the row header specifies the encrypted or decrypted letter. For example, encrypting 5 at rotor position 2 gives 2. 0 1 2 3 4 5 0 1 4 4 5 4 3 1 0 5 3 4 2 5 2 5 3 5 3 1 4 3 4 2 1 2 5 0 4 3 0 0 1 0 2 5 2 1 2 0 3 1 Using Mathematical Permutations to Describe our EnigmaWe have the following permutations:
\( N = (0, 1, 4, 3, 5, 2) \) Here is the formula that describes the permutation performed by our Enigma at position i:
\( E_i = P^{i} \cdot N \cdot P^{-i} \cdot Q \cdot P^{i} \cdot N^{-1}
\cdot P^{-i} \)
Here are the different powers of the rotation: For example: \( E_2 = P^{2} \cdot N \cdot P^{-2} \cdot Q \cdot P^{2} \cdot N^{-1} \cdot P^{-2} = ((0 4)(1 3)(2 5)) = (4, 3, 5, 1, 0, 2) \) Notes:
Using the Python SymPy libraryPython, thanks to the SymPy library, allows you to manipulate permutations. Note: Our rotors page contains commented examples of using the SymPy library. As before:
>>> from sympy.combinatorics import Permutation >>> N = Permutation([0,1,4,3,5,2]) >>> N.array_form [0, 1, 4, 3, 5, 2] >>> N.full_cyclic_form [[0], [1], [2, 4, 5], [3]] >>> (~N).array_form [0, 1, 5, 3, 2, 4] >>> P = Permutation([1,2,3,4,5,0]) >>> P.full_cyclic_form [[0, 1, 2, 3, 4, 5]] >>> Q = Permutation([1,0,4,5,2,3]) >>> Q.array_form [1, 0, 4, 5, 2, 3] >>> Q.full_cyclic_form [[0, 1], [2, 4], [3, 5]] >>> (P*N*~P) Permutation(5)(1, 3, 4) >>> (P*N*~P).array_form [0, 3, 2, 4, 1, 5] >>> (P*(~N)*(~P)).array_form [0, 4, 2, 1, 3, 5] >>> ((P**2)*N*(P**-2)).array_form [2, 1, 3, 0, 4, 5] >>> Enigma_1 = P * N * ~P * Q * P * ~N * ~P >>> Enigma_1.array_form [4, 5, 3, 2, 0, 1] >>> Enigma_2 = (P**2) * N * (P**-2) * Q * (P**2) * ~N * (P**-2) >>> Enigma_2.array_form [4, 3, 5, 1, 0, 2] >>> Enigma_6 = (P**6) * N * (P**-6) * Q * (P**6) * ~N * (P**-6) >>> Enigma_6.array_form [1, 0, 5, 4, 3, 2] >>> Enigma_6.full_cyclic_form [[0, 1], [2, 5], [3, 4]] >>> Enigma_1.full_cyclic_form [[0, 4], [1, 5], [2, 3]] >>> Enigma_2.full_cyclic_form [[0, 4], [1, 3], [2, 5]] Using a mathematical formula to describe encryptionFor a single rotor, the formulas are given in the rotors page. For our simplified Enigma, there are several steps:
i = the rotor position x = the plaintext letter y = the ciphertext letter N = the rotor permutation = [ 0, 1, 4, 3, 5, 2] N_inv = the inverse rotor permutation = [0, 1, 5, 3, 2, 4] Q = the reflector permutation = [1, 0, 4, 5, 2, 3] Note: Using the previous formulas makes it easier to write an Enigma encryption program. Example: we encrypt the following message with the initial position (i) at -1. i = 0 1 2 3 4 5 plain = 0 1 1 0 3 2 Crypto= ?
A – encryption of 0 at position -1:
B – encryption of 1 at position 0:
C – Encryption of 1 at position 1 :
D – Encryption of 0 at position 2 :
E – Encryption of 3 at position 3:
F – Encryption of 2 at position 4: To summarize: i = 0 1 2 3 4 5 plain = 0 1 1 0 3 2 Crypto= 1 5 3 5 5 4 The result is correct. We can verify it with the cipher table of our Enigma given above. CryptanalysisWith the knowledge acquired here, mainly the mathematical vision of the Enigma, we will try to explain several methods of cryptanalysis and first of all the method used by Rejewski at the end of 1932 to find the wiring of the rotors of the Enigma used by the German army.
ReferencesBooks & Articles
Internet Links |