Sunday, April 16, 2017

Sunday, April 2, 2017

My entry for RC2017/04, An Enigma Machine Z30 Simulator running on a Kim 1 / Uno

Just noticed this years retrochallenge is up!

Here is the entry page:

  1. Your name (or alias);
  2. Your Twitter handle (if applicable);
  3. Your blog location (for project updates); and
  4. A brief synopsis of your project.

And here is my entry:

1) Arduino Enigma

2) @ArduinoEnigma


4) There are some cool kids out there making electronic versions of the Enigma Machine. They mostly seem to be some sort of microcontroller wired to 4x fourteen segment displays and pushbuttons to move the rotors and type the message to encrypt. I wanted to do the same but without rolling a custom PCB. A KIM Uno was laying around, having been used only to develop a 53 byte clock program. The idea was born to use the KIM to simulate an Enigma Machine. This 6502 program implements a 1930s encryption machine in a 1970s computer. It turns a KIM Uno into the cheapest physical enigma machine simulator out there.

The original, lever stepping only version was 703 bytes including the menu to change the encryption settings. The v2 gear and lever stepping enigma engine has already been optimized to be smaller than v1. The v2 menu system gained a third function to set the stepping mode. After optimizations, the feature richer v2 is now only 11 bytes bigger than v1.

The goal for this retrochallenge is to further optimize the code so its total size is smaller than v1.

For a bit of background, three rare, numbers only, Enigma Z30 were found in Sweden, an article in Cryptologia "Enigma Z30 retrieved" describes the wheel wiring. This machine can only encrypt numbers and the rotors have only 10 positions, it is thus perfect to be simulated in a KIM.Based on the published wheel wiring and some reasonable assumptions based on the architecture of other enigma machines, a 6502 program was written. The program has two parts, the core enigma functionality, the user being responsible for changing the machine settings via direct RAM manipulation using the KIM monitor and a menu system for a user friendly way of changing the machine settings. After learning that two versions of the machine existed, one with double stepping anomaly prone lever stepping and another with odometer like geared stepping, the program and its menu system ware modified to also support gear stepping.

Below are some demo videos of v1.

I had been looking for an excuse to make a new video of v2 showing the new F3 mode to select the stepping mechanism type and to shave a few more bytes off.

RC2017/04, here we come...

Sunday, March 26, 2017

Enigma Z30 Machine Simulator v2.0 Released

In time for the Vintage Computer Festival East (March 31-April 2), the Enigma Z30 Machine Simulator v2.0 is being released.

This 6502 program turns the KIM Uno into the cheapest enigma machine simulator out there.

This new version supports lever and gear stepping. The stepping logic has been changed so that the machine always steps when the rotors display 9, the ring setting has no effect on the stepping point. This is consistent with other enigma machines.

An optional, but very useful menu allows the machine settings to be changed without exiting the program. This previous menu had two options, the first one changed the rotor types, the second one changed the ring settings. It now has a third option so the gear setting can be changed as well.

This version has been optimized. The machine code has more functionality and is smaller than v1. When the menu code is added, the total program size changes from 703 in v1 to 714 in v2.

The program can be entered from the images shown below. The full source code can be downloaded at:

Z30 Machine only:

Z30 Machine Menu:

For the motivation behind the creation of this machine:

For the Paper Model showing the inner workings of this machine:

The image below is taken from the Paper Model file and shows a sample path through the rotors:

To read some thoughts on the recreation and cryptanalysis of this machine: