ZAdamMac / python-enigma

A simple module which adds Enigma Machine-emulating functionality to your python projects. A pypi release is forthcoming.
https://www.arcanalabs.ca
Apache License 2.0
9 stars 6 forks source link

[BUG] Module May not Be M4/Enigma Compliant #4

Closed ZAdamMac closed 4 years ago

ZAdamMac commented 5 years ago

Describe the bug User Michael Zimmermann michael_zimmermann@gmx.de reported that he was having trouble decrypting a known-plaintext message generated on an original Enigma M4. This message was originally produced during the war and is fully decryptable using other emulation platforms.

To Reproduce Steps to reproduce the behavior:

  1. Create an enigma machine instance with the appropriate settings (detailed below)
  2. Set the wheelpack correctly.
  3. Parse the encrypted message.
  4. If reproducing, the wrong plaintext is sent.

Expected behavior A new key should be generated and written to configuration, and that key should be used throughout the rest of the backup process.

Log/Console Output Where possible, add the output of the Logs or Console when the problem occurs.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

Reflector: C Greek: B Wheels: 568 Wheel positions: YOSZ Rings: AAEL Plugs: AE BF CM DQ HU JN LX PR SZ VW

Message indicator groups: DUHF TETO

Ciphertext (without indicator groups): LANOTCTOUARBBFPMHPHGCZXTDYGAHGUFXGEWKBLKGJWLQXXTGPJJAVTOYJFGSLPPQIHZFXOEBWIIEKFZLCLOAQJULJOYHSSMBBGWHZANVOIIPYRBRTDJQDJJOQKCXWDNBBTYVXLYTAPGVEATXSONPNYNQFUDBBHHVWEPYEYDOHNLXKZDNWRHDUWUJUMWWVIIWZXIVIUQDRHYMNCYEFUAPNHOTKHKGDNPSAKNUAGHJZSMJBMHVTREQEDGXHLZWIFUSKDQVELNMIMITHBHDBWVHDFYHJOQIHORTDJDBWXEMEAYXGYQXOHFDMYUXXNOJAZRSGHPLWMLRECWWUTLRTTVLBHYOORGLGOWUXNXHMHYFAACQEKTHSJW

Plaintext:

KRKRALLEXXFOLGENDESISTSOFORTBEKANNTZUGEBENXXICHHABEFOLGENDENBEFEHLERHALTENXXJANSTERLEDESBISHERIGXNREICHSMARSCHALLSJGOERINGJSETZTDERFUEHRERSIEYHVRRGRZSSADMIRALYALSSEINENNACHFOLGEREINXSCHRIFTLSCHEVOLLMACHTUNTERWEGSXABSOFORTSOLLENSIESAEMTLICHEMASSNAHMENVERFUEGENYDIESICHAUSDERGEGENWAERTIGENLAGEERGEBENXGEZXREICHSLEITEIKKTULPEKKJBORMANNJXXOBXDXMMMDURNHFKSTXKOMXADMXUUUBOOIEXKP

ZAdamMac commented 5 years ago

We've eliminated configuration issues. However, Michael found a mention in an old article that the Engima steps prior to encoding. This is the opposite of how my system steps (stepping after encoding).

It should be relatively trivial to change this behaviour and test.

ZAdamMac commented 5 years ago

It's worthwhile noting as well that the M4 used "UKW C Thin" from the default catalogue, not the normal C reflector.

ZAdamMac commented 4 years ago

I had a chance to review some other similar implementations in source and I can confirm, absolutely, that the wheels need to step first.

This still does not directly solve the issue, so I now need to determine if the wheels are stepping correctly. Gross.

ZAdamMac commented 4 years ago

Recent changes merged to master resolved this issue. Full blog post on the "why" forthcoming, but in general, the following changes were made: