Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M3 reflector bug in "plugboard" code. #8

Open
donfroula opened this issue Jan 29, 2019 · 0 comments
Open

M3 reflector bug in "plugboard" code. #8

donfroula opened this issue Jan 29, 2019 · 0 comments

Comments

@donfroula
Copy link

donfroula commented Jan 29, 2019

Per http://users.telenet.be/d.rijmenants/en/enigmatech.htm#reflector:

=====================

"During the Second World War two types of reflector, B and C, were used.

Both had 26 spring-loaded contacts on the right side.

The four-rotor Kriegsmarine Enigmas used special thin reflectors, also called B and C, but with wiring that was different from the wiring of the three-rotor Wehrmacht and Luftwaffe reflectors.

However, if the thin Kriegsmarine reflector B was used together with the fourth Beta rotor in A-position and A-ringsetting or the C reflector with Gamme rotor, these reflectors were compatible with the three-rotor versions, enabling communication between different machine types."

======================

So, if the M4 is used with the B fourth rotor with rings and start position at "A", along with the Thin B M4 reflector, coding results should be identical with the M3 model and regular B reflector.

This works in the current Open Enigma code, but only because, in M3 mode, the wiring is routed through the (hidden) fourth rotor in default "A" positions and the thin "B" reflector, in "compatibility mode" as it were. This makes it unnecessary to code the unique normal M3 "B" reflector wiring in the forward rotor wiring table, even though the array has room for three reflector wiring sets.

Where this does NOT work in the current code is the case where the M3 is using the normal wide M3 C reflector. The current code routes the letter through the (hidden) Beta rotor and M4 thin B reflector, which doe NOT produce the equivalent result as an M3 using the M3 wide C reflector.

A hack to get around this if the correct M3 wide C reflector values are desired is to first put the machine in default M4 mode, set the Gamma rotor and C thin reflector, then switch to M3 mode and the C reflector. This produces the correct M3 encoding.

This is really ugly, as it depends upon setting the M4 in a compatible M3 mode, then switching to M3 mode which uses the M4 compatibility functionality to produce a correct M3 result.

A better way would be to encode the correct M3 B and C rotor settings in lines 156 and 160 of the current code. Then, the logic at line 494 where the reflector is applied would need to change to include the "behavior" variable in the index to access the correct portion of the array, rather than always choosing the first 26 reflector mapping values. The placeholders in the array are already there for this.

Also. the fourth rotor should not be used for encoding M3 traffic, as this assumes the ring and start positions are always at "A". The operator could change these, in M4 mode, then switch to M3 mode, not realizing the non-default M4 fourth rotor settings are screwing up the reflector operation. M4 settings should not be affecting M3 operation.

=====================================
Example - All setting at power-up defaults, no plugs, except for changing fourth rotor and reflector settings as indicated
Examples are the encoding of my name, DON.

M4 with B fourth rotor and B (thin) reflector: MIO
M3 with B (wide) reflector (should be same as above): MIO = CORRECT!

M4 with G fourth rotor and C (thin) reflector: TQE
M3 with C (wide) reflector (should be same as above): YLJ - INCORRECT!

M3 with C (wide) reflector, after changing modes from M4, where G rotor and C reflector were chosen: TQE - CORRECT!, but M4 settings should not be affecting M3 operation.

=====================================

Correct M3 and M4 reflector values (from http://users.telenet.be/d.rijmenants/en/enigmatech.htm#reflector):

M3 with "wide" reflectors

  • Reflector B = YRUHQSLDPXNGOKMIEBFZCWVJAT
  • Reflector C = FVPJIAOYEDRZXWGCTKUQSBNMHL

M4 with "thin" reflectors

  • Reflector B Thin = ENKQAUYWJICOPBLMDXZVFTHRGS
  • Reflector C Thin = RDOBJNTKVEHMLFCWZAXGYIPSUQ

My changes fix the M3 UKW-C bug and makes the settings for M3 reflectors independent of M4 fourth rotor and M4 reflector selections. I added the M3 "wide" reflector definitions into the reflector arrays (lines 161 and 166) and changed the "Run" mode reflector operation to index into the reflector array to access the correct reflector values depending upon the current model "behavior" variable (line 503).

I also made the fourth rotor to and from reflector transformations conditional upon being in "behaviors" 0 and 1, the M4 modes. They are now skipped completely in M3 mode (lines 492, 500, 507, and 515).

I used the new M3 B and C "wide" reflector definitions found here:

http://users.telenet.be/d.rijmenants/en/enigmatech.htm

Contact me for the plugboard code, with fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant