Monday, October 21, 2019

UKWD added to Mega Enigma, an Universal Enigma Machine Simulator

This simulator already had 5 UKWD rewirable reflectors, 4 were available to be used with the M3 machine, the other with the KD. The D reflector wiring can be changed in the field. The 5 reflectors included are examples of known wirings used at some point in time.A mechanism was needed to change the actual wiring of the reflector in this simulator.

Adding an item now to the menu system is easier than developing it from scratch. It is just a matter of inserting an item in the existing menu system. The UKWD sub menu has two special features, it is skipped if the currently selected machine did not have a D reflector, and the user cannot leave that menu until the pairs specified are correct.

The UKWD pairs can be displayed in two notations, Bletchley Park (BP)  and the German notation used in the official key sheets (UD). Complicating things is the fact that both notations run in different directions and that a different pair of letters are missing from each, B-O from BP notation and J-Y from UD notation.

The simulator uses BP notation internally to calculate the path through the rotors, but it gives the option to show the UKWD pairs in both UD and BP notations. This led to the following gems:

const __FlashStringHelper *BPTOUD = F("A-ZXWVUTSRQPON-MLKIHGFEDCB");

const __FlashStringHelper *UDTOBP = F("AZYXWVUTS-RQPNMLKJIHGFED-C");

The first string comes straight from the Crypto Museum pages.

Starting with the black letters in the outside (BP notation), it records the blue letters on the inside (UD notation).

The second string was pre-computed for this project instead of dynamically generating it for each search. Starting with the blue letters in the inside, it records the black letters on the outside.

Precomputing the UDTOBP string makes translating different pair of wires with the same initial letter (C-W and C-T) as easy as doing three table lookups. Notice that C-W(BP) bridges contacts 2-22 and C-T(UD) bridges 24-7. They are completely different wires, they are grouped by the initial letter for convenience only.

Some work remains to be done to check the validity of the reflector pairs and to allow editing the pairs in UD mode.

Read more about the Umkehrwalze D (UKW-D) here:

Delve into the code to make this work here:
of particular interest are:
 EnigmaGUI.ino: case 2 in doMenu()
 Enigma.ino: translateBPtoUD() function

This project's Hackaday.IO page:

Daniel Palloks Universal Enigma:
The authors are very grateful for this simulator, as it provided the rotor strings and it is used extensively to check the accuracy of Mega Enigma results.

No comments :

Post a Comment