1
$\begingroup$

According to wikipedia: BDZGO is the expected outcome when doing the enigma chipher on the letters AAAAA with rotors I,II,III and reflector B.

ABCDEFGHIJKLMNOPQRSTUVWXYZ | Alphabet

EKMFLGDQVZNTOWYHXUSPAIBRCJ | Rotor I wiring
AJDKSIRUXBLHWTMCQGZNPYFVOE | Rotor II wiring
BDFHJLCPRTXVZNYEIWGAKMUSQO | Rotor III wiring

YRUHQSLDPXNGOKMIEBFZCWVJAT | Reflector B wiring
ABCDEFGHIJKLMNOPQRSTUVWXYZ | Reflector B wiring

If we now track the first A:

A-E | etw to rotor I
E-A | rotor I to rotor II
A-B | rotor II to rotor III
B-R | Reflector B
R-X | rotor III to rotor II
X-V | rotor II to rotor I
V-I | rotor I to etw

So the output is I instead of B, where is my mistake?

$\endgroup$
0

1 Answer 1

3
$\begingroup$

As I noted in this earlier answer to a related question, the rotor permutations in your example are written using a shorthand notation that only shows the output alphabet of the permutation, with the implicit assumption that the input alphabet is always ABCDEFGHIJKLMNOPQRSTUVWXYZ. That is to say, your rotor descriptions:

EKMFLGDQVZNTOWYHXUSPAIBRCJ | Rotor I wiring
AJDKSIRUXBLHWTMCQGZNPYFVOE | Rotor II wiring
BDFHJLCPRTXVZNYEIWGAKMUSQO | Rotor III wiring

actually describe the following permutations:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ | Rotor I
EKMFLGDQVZNTOWYHXUSPAIBRCJ

ABCDEFGHIJKLMNOPQRSTUVWXYZ
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ | Rotor II
AJDKSIRUXBLHWTMCQGZNPYFVOE

ABCDEFGHIJKLMNOPQRSTUVWXYZ
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ | Rotor III
BDFHJLCPRTXVZNYEIWGAKMUSQO

Also, there are two other issues with your example encryption:

  • You're applying the rotor permutations in the wrong order; the rotors are conventionally listed from left to right, but the wiring from the input/output to the reflector goes from right to left. So in your example, rotor III should actually be applied first, then rotor II and finally rotor I (and then the reflector and the inverse rotors in the opposite order).

  • The rotors are stepped before each letter is encrypted. So if you start with all rotors in the A position, when the first letter of the message is encrypted the rightmost rotor (i.e. rotor III here) will have already rotated into the B position. This means you have to shift the letter right by one step in the alphabet before it enters the rotor, and back left by one step after it leaves the rotor.

Put all together, the correct path of the first letter is:

  1. ABDC (rotor III in position B)
  2. CCDD (rotor II in position A)
  3. DDFF (rotor I in position A)
  4. FS (reflector B)
  5. SSSS (rotor I in position A, reverse)
  6. SSEE (rotor II in position A, reverse)
  7. EFCB (rotor III in position B, reverse)

For each rotor, there are effectively three permutations to apply: an alphabet shift to the rotor's current position (i.e. 0 steps for position A, 1 step for position B, 2 steps for position C, etc.), the fixed rotor wiring permutation and finally the reverse shift back from the rotor's position.

In the list above, I've used a dotted arrow ⤑ for the shifts and a solid arrow → for the rotor wiring permutations (and a two-headed arrow ↔ for the reflector). In this example, two of the three rotors are still in position A, so for them, the shifts have no effect, but I've shown them anyway for completeness. Also, just by chance, the wiring in rotor I happens to map the letter S to itself.

$\endgroup$
3
  • $\begingroup$ Any idea why this could produce incorrect results after 100 letters? $\endgroup$
    – b3nj4m1n
    Jun 13, 2019 at 16:24
  • $\begingroup$ @b3nj4m1n: Almost certainly because you got some detail of the wheel stepping wrong. That's the only thing in the Enigma machine that changes in the middle of a message. Perhaps you forgot to implement double stepping? $\endgroup$ Jun 13, 2019 at 16:31
  • $\begingroup$ You're right. It works now. Thanks for your help. $\endgroup$
    – b3nj4m1n
    Jun 13, 2019 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.