Sunday, April 23, 2017

Glossary of Enigma Terms



Descriptions of and documents about the Enigma machine refer to a number of terms. This can be confusing, especially when both English and German terms are used. Here is a list I put together of some of the most common terms, and a brief definition of each of them.




BP - Bletchley Park.
Begleitbuch - A record book that accompanied each Enigma unit.
Bomba - A machine designed by the Polish Cipher Bureau to break Enigma ciphers.
Bombe - An electro-mechanical device developed at Bletchley Park by Alan Turing and others to break Enigma ciphers.
Cipher text - the encrypted form of a message.
Clear text - The original, unencrypted, text of a message.
Crib -  A section of plain text thought to correspond to the ciphertext.
ETW - Entrittswalze.
Entrittwalze - Entry stator.
Entry stator - stationary entry wheel.
Greek wheel - The fourth rotor of the M4, which could be one of two identified with the Greek letters Beta and Gamma. Also known as Griechenwalze (Greek wheel) or Zusatswalze (additional wheel).
Griechenwalze - See Greek wheel.
Ground Setting - Rotor start position.
Grundstellung - German for "ground setting".
Kennegruppe - Message discriminant (plural Kenngruppen). Groups to identify the key to the receiver. Part of a key sheet.
Lampboard - The Enigma board containing the 26 alphabetic lamps.
Letter blocks - Grouping of an encrypted message in letters, usually 4 or 5 characters per block.
M3 - German Navy version of the Enigma.
M4 - Four rotor version of the Enigma used by the German Navy for U-boat traffic.
Plain text - See clear text.
Plugboard - The front panel board with 26 plugs which could be jumpered by 10 cables.
Reflector - Non-rotating wheel which returned connections back into the rotors.
Reflector Wheel - Reflector.
Reversing drum - See Reflector.
Ring Setting - The ring settings are used to change the position of the internal wiring relative to the rotor.
Ringstellung - German for "ring setting".
Rotor -  Rotatable disc with 26 electrical contacts arranged in a circle joining one face to another in a scrambled pattern.
Rotor period - Number of keystrokes for a complete cycle (e.g. 26x25x26 = 16900 for a 3 rotor Enigma).
Schreibmax - An optional printer attachment for the Enigma.
Static wheel - See Entry stator.
Static rotor - See Entry stator.
Stator - See Entry stator.
Stecker - Plug.
Steckerbrett - Plug board (sometimes referred to as "steckerboard").
Steckerverbindungen - Plug board connections.
Stop characters - Symbols (typically an "X"), used to separate words in a message.
Thin reflectors - Reflectors used with the Greek wheels.
UKW - See Umkehrwalze.
Umkehrwalze - Reflector (German for reversing drum).
Walzen - Wheels or rotors.
Walzenlage - German for "wheel order", referring to rotors.
Wheel Order - The order or the three or four rotors.
Zusatzwalze - See Greek wheel.

References


  1. http://enigma.louisedade.co.uk/help.html
  2. http://www.cryptomuseum.com/crypto/enigma/glossary.htm
  3. http://www.intelligenia.org/glossary.htm

Saturday, April 22, 2017

Commercially Available Enigma Machine Kits

I did some research on Enigma kita on the market. Not counting simulators and mechanical replicas, I found three curently available electronic replica kits. The information below summarizes the different units.




Name: MeinEnigma
Website: http://www.meinenigma.com
Price: TBD
Accessories: TBD
Notable Features:

Arduino-based, 4 alphanumeric LEDs, keyboard, lamps, plugboard, sound, turnable rotors, real-time clock.




Name: Enigma-E
Website: http://www.cryptomuseum.com/kits/index.htm
Price: 150 Euro
Accessories: Case, UhrBox
Notable Features:

Microprocessor (PIC)-based, 4 digit alphanumeric display, 26 keys, LEDs, plugboard.




Name: S&T GeoTronics Enigma Mark 4 (also called OpenEnigma)
Website: http://www.stgeotronics.com/Kits_c8.htm
Price: US$300
Accessories: Plugboard, cables, case, bare PCB
Notable Features:

Arduino-based, 4 alphanumeric LEDs, keyboard, LEDs, cover plate.


Friday, April 14, 2017

The MeinEnigma Enigma Machine Kit - Message Encoding Example

In this blog post I'll give an example of how to encode or encrypt a message using MeinEnigma.

The first step is to choose the daily keysheet to use. You will need to share this with anyone who wants to decrypt the message. We will use one from here.

This is for an Enigma M3. As I write this the date is April 13, 2017 and the entry for today is:

|Day |UKW| Rotors   |Ringsetting|         Plugboard            |     Keygroup    |
----------------------------------------------------------------------------------
| 13 | B | V VIII I | 11 05 15 | BO CW DV EI GP HJ KX MR QU YZ | STL TEM MDJ RLQ |

We set the MeinEnigam settings as per the code sheet:

Model: M3
Reflector: UKWB
Rotor: 5,8,1
Plugboard: BO CW DV EI GP HJ KX MR QU YZ
Rotor Rings: K E O (11=K, 05=E, 15=O)

Now this is our plain text message to encrypt:

WHO PLAYED ALAN TURING IN THE 2014 FILM THE IMITATION GAME?

We split the plain text into 5 letter groups. Spell out numbers as characters and use the Enigma abbreviations for punctuation (common ones are X for period, ZZ for comma, and FRAGE or FRAQ for a question mark). Pad the end of the message with extra characters to fill out the last group. This is the result:

WHOPL AYEDA LANTU RINGI NTHET WENTY FOURT EENFI LMTHE IMITA TIONG AMEFR AQXXX

Now choose two random three letter groups, known as trigrams. I picked JJT and VER.

The first trigram is the rotor start position, so set them to JJT.

Now type the second trigram, VER, using the keyboard and note the result: GBG. This is the encrypted message key.

Set the rotor start positions to the second trigram, VER.

Type in the plain text message and note down the encrypted result. This is what I obtained:

CSJTO WFAFF EEQYX TQCED PFQOR ATBGC JFKSP CAAQV PUCVZ SDRAM LLBGL YQNXO EZTPW

Assuming we want to write the message the way a number of people on the Internet, including tye Enigma World Code Group forum user do, we need to create a message header as follows:
  • Start with [EWCG2017] if this is for the Enigma World Code Group
  • Write the current time as 24 hour UTC time, e.g. 2117
  • Indicate how many parts are in the message followed by tle, e.g. 1tle
  • Indicate which part this is, followed by tl, e.g. 1tl
  • List how many characters are in this part of the message: 65
  • The randomly selected rotor start position: JJT
  • The encrypted message key: GBG
Look at the daily keysheet and under Keygroup, pick one of the listed three letter trigrams, say STL. Add two random letters: ZZ. This becomes the first group of the encoded message.
Putting the header and encrypted groups togther. this is the full encrypted message:

[EWCG2017]
2117 1tl 1tl 65 JJT GBG
STLZZ CSJTO WFAFF EEQYX TQCED PFQOR ATBGC JFKSP CAAQV PUCVZ SDRAM LLBGL YQNXO EZTPW

If you follow the decoding procedure from my earlier blog post, you can decode the message back to the original plain text.



On a related note, I've updated my Quick Reference  to include the above example of encrypting a message. I've also added tables listing the Arduino port usage and the I2C devices and addresses of the MeinEnigma hardware.

The MeinEnigma Enigma Machine Kit - Message Decoding Using Serial Commands

As a follow-on to my last blog post that described how to decrypt a real message, here is a transcript of the serial port commands that will decode the same message. Characters I typed are shown in bold.

!MODEL:M3
%MODEL:M3  

!GROUPSIZE:5
%GROUP:5

!UKW:UKWB
%UKW: UKWB 

!ROTOR:1,5,3
%ROTOR:    I -   V - III

!RING:X,U,E
%RING: - X U E 

!PLUGBOARD:AT BG CN EP FI HQ JS KZ OU XY
%PLUGBOARD: AT BG CN EP FI HQ JS KZ OU XY 

!START:XTS
%START: - X T S 

WWK
>JZU

!START:JZU
%START: - J Z U 

FXBLJ PVARC AUEFD IQKFE VYCXN FRBBE HJJAN JDCRI GMJZC MSTAL WFSPB
>WITHS OMEME SSAGE SCAPT UREDI NMAYO FNINE TEENF ORTYA SWEDI SHMAT 

YUNFG UUDYL DZJIG XQCSK QPURI EKMVO PDWKG IXBLH RVLYQ LBAPT PWGNU UGINK
>HPROF ESSOR SPENT TWOWE EKSTO DECIP HERED ANDRE VERSE ENGIN EERED ANEAR 

RWYYI IFCQC XZSRZ MDQBM JHUNY LVLXN OAEVZ WSVAT FTVZT YOECZ HEOTB UUAPG
>LYVER SIONO FTHES IEMEN SANDH ALSKE TFIFT YTWOA LSOKN OWNAS THEGE HEIMF

UHIDK GMNGR ADTEO IISNA ZOHZC WJWNP HLCPH PBTOW
>ERNSC HREIB ERXWH ATWAS HISNA MEQUE STION MARKX

Thursday, April 13, 2017

The MeinEnigma Enigma Machine Kit - Message Decoding Example

Let's look at an example of decoding a real message using MeinEnigma.

While there are examples of real messages (1) from Word War II available on the Internet, they tend to be in German and contain a lot of military technical terms and abbreviations, making even the decrypted plain text hard to understand. I'll instead use a message that was posted as one of the monthly challenges on the Enigma World Code Group Forum, a group of Enigma enthusiasts. I've chosen one (2) that was about a year old, to avoid making this too much of a "spoiler".

Here is the encrypted message, which follows a standard format that you can read about on the forum:

[EWGC2016]
XTS WWK
YNUAL FXBLJ PVARC AUEFD IQKFE VYCXN FRBBE HJJAN JDCRI GMJZC MSTAL WFSPB
YUNFG UUDYL DZJIG XQCSK QPURI EKMVO PDWKG IXBLH RVLYQ LBAPT PWGNU UGINK
RWYYI IFCQC XZSRZ MDQBM JHUNY LVLXN OAEVZ WSVAT FTVZT YOECZ HEOTB UUAPG
UHIDK GMNGR ADTEO IISNA ZOHZC WJWNP HLCPH PBTOW

This was the monthly challenge for May 2016. The forum posting listed that this was encrypted for an Enigma model M3 with UKW B reflector.

First, we need to look up the keysheet (3) for May 2016 from the codebook that is used for these monthly challenges. Here is the entry for the 1st day of May 2016 (the columns are in German for authenticity with the original code books):

 ------------------------------------------------------------------------------
|Tag |Walzenlage|Ringstellung|      Steckerverbindungen      |   Kenngruppen   |
--------------------------------------------------------------------------------
| 01 | I  V III |  24 21 05  | AT BG CN EP FI HQ JS KZ OU XY | VWX YNU GUJ GGB |

We now have everything we need to decode the message. We turn on the MeinEnigma, and after starting up it prompts "model". We rotate the leftmost rotor to select M3:


Turning the function switch to the right, it prompts "reflector" and we can turn the left rotor to select UKWB:


Turning the switch clockwise once more, it prompts for "rotor" and we set it to 153, based on the table entry under Walzenlage that says I V III.


One more click clockwise, and we need to set the plugboard. We can either physically connect the cables or use the virtual plugboard set using the rotors. The second rotor selects the cable (from 1 to 10) and the third and fourth select the two letters to connect. Here are the first two connections using the virtual plugboard:

We need to do this for all 10 cable pairs listed in the table: AT BG CN EP FI HQ JS KZ OU XY

We now turn the function switch clockwise once more to the final "run" position.

First we need to set the rotor rings or Ringstellung. In the table they are listed as 24 21 05. The corresponding letters are X U E (24 = X, 21 = U, 05 = E).

For each of the three rotors, we need to rotate it until we see the decimal point lit up. This is the current ring position. We then hold down the corresponding button and rotate the rotor to the desired letter, and then release the button. We do this for all three rotors, at which point it should display XUE with all three decimal points lit up:


We now need to set the rotor start positions to the first "key" in the message itself, XTS:


The next step in the process is to enter the second "key" in the message, WWK, by typing the characters and noting the encrypted characters that are displayed.


If you followed the instructions correctly up to now, these three characters should have converted to J, Z, U. These are the rotor start positions that we need to use to decrypt the rest of the message. So we set the rotors to JZU:


As a check that we are using the correct code book entry, we are supposed to take the first three letters of the first character block, YNUAL, and confirm that YNU is one of the groups or Kenngruppen listed in the table, and in fact this is the case. The last two characters, AL, are ignored and are just there to complete the 5 character group.

Finally we are ready to enter and decode the message itself. We type in each letter of the message, omitting the first code group, i.e.

FXBLJ PVARC AUEFD IQKFE VYCXN FRBBE HJJAN JDCRI GMJZC MSTAL WFSPB
YUNFG UUDYL DZJIG XQCSK QPURI EKMVO PDWKG IXBLH RVLYQ LBAPT PWGNU UGINK
RWYYI IFCQC XZSRZ MDQBM JHUNY LVLXN OAEVZ WSVAT FTVZT YOECZ HEOTB UUAPG
UHIDK GMNGR ADTEO IISNA ZOHZC WJWNP HLCPH PBTOW

We note each character that is lit and/or spoken and write them down. Here is what it should return, still shown as 5 character groups:

WITHS OMEME SSAGE SCAPT UREDI NMAYO FNINE TEENF ORTYA SWEDI SHMAT
HPROF ESSOR SPENT TWOWE EKSTO DECIP HERED ANDRE VERSE ENGIN EERED ANEAR
LYVER SIONO FTHES IEMEN SANDH ALSKE TFIFT YTWOA LSOKN OWNAS THEGE HEIMF
ERNSC HREIB ERXWH ATWAS HISNA MEQUE STION MARKX

Now we need to manually put in the spaces between words and add punctuation. The procedures for the Enigma specified a number of rules for sending punctuation, numbers, and other characters using just the alphabetic characters available. Some common abbreviations were X for period, ZZ for comma, and FRAGE or FRAQ for a question mark. This message used the more easily understood QUESTIONMARK and added an X at the end to fill out the last 5 character code group.

Adding spaces and punctuation we get this message:

WITH SOME MESSAGES CAPTURED IN MAY OF NINETEEN FORTY A SWEDISH MATH PROFESSOR SPENT TWO WEEKS TO DECIPHERED AND REVERSE ENGINEERED AN EARLY VERSION OF THE SIEMENS AND HALSKE T FIFTY TWO ALSO KNOWN AS THE GEHEIMFERNSCHREIBER. WHAT WAS HIS NAME?

I should mention that you can also perform all of the settings and decryption using the Mein Egigma serial port commands. This is less autenthic but a lot less tedious and error prone.

These monthly challenges contain a question, and if you successfully decode them you are supposed to post the answer to the forum, encrypted using the same settings.

You might want to try decoding some of the monthly challenges that are posted at the Enigma World Code Group Forum. They can be decoded using any one of the many available simulator programs, if you don't have a MeinEnigma.

I've written (4) a short Quick Reference guide for the MeinEnigma that lists the keyboard commands, serial port commands, and an example of message decoding (the same one I used here). If you acquire a MeinEnigma you may find it handy. I plan to add more content to it in the future.

References


  1. http://wiki.franklinheath.co.uk/index.php/Enigma/Sample_Messages
  2. http://enigmaworldcodegroup.freeforums.net/thread/75/enigma-challenge-2016)
  3. http://enigmaworldcodegroup.freeforums.net/thread/55/optional-2016-ewcg-codebook
  4. https://github.com/jefftranter/meinEnigma/blob/master/MeinEnigmaQuickReference.pdf

Saturday, April 8, 2017

The MeinEnigma Enigma Machine Kit - Software



In this blog post I'll discuss the software in the MeinEnigma. The controller used is the popular low-cost and easy to program Arduino series of microcontrollers. It uses an Arduino Nano, or an equivalent clone.
Software for the Arduino platform is written in a modified (slightly simplified) version of the C++ programming language, typically using the Arduino Integrated Development Environment (IDE), running on a desktop computer. The source code is compiled to ARM machine code and then downloaded to the Arduino board, usually over a USB serial port. Once on the Arduino, it resides in non-volatile EEPROM, so the program is not lost when the Arduino is powered down.


To program the MeinEnigma, you'll need to download and install the Arduino IDE on a desktop computer. Connect your computer to the Arduino Nano on the MeinEnigma using a USB cable. The MeinEnigma can be powered by the USB port, or you can leave the batteries in, if present.


Once the IDE is installed, you can easily run build, transfer, and run Arduino programs on the MeinEnigma. Most beginners start with the example program that will flash the LED built into the Arduino. Be sure to configure the IDE for the correct serial port on your computer and for an Arduino Nano. Note that running a program from the IDE will overwrite the existing MeinEnigma code on the Arduino.

To build the MeinEnigma software, download the source code from the github site (see the References section at the end of the blog post). It also has dependencies on some third party libraries that you will need to obtain and install. Check the notes in the MeinEnigma source code. At the time of writing the dependencies were an HT16K33 driver and AltSoftSerial library.

If the IDE and third party code is correctly configured, you will be able to compile the MeinEnigma code, transfer it to the Arduino, and run it.

The MeinEnigma code is quite large, currently about 4600 lines of code, and takes most of the available EEPROM space on the Arduino Nano.

There are a number of configurable options in the code to enable and disable features using DEFINEs. The application generally handles any missing hardware and will even run standalone on a standard Arduino.

As well as the Arduino code, the sound files that are played (mostly for voice messages) are stored on the MicroSD card as MP3 files. The Arduino does not have direct access to these files, but it can control the sound board and instruct it to play files. You can insert the MicroSD card in a desktop computer (using a suitable adapter to SD or USB) and modify them if desired. You can study the source code to understand which sound files are used for specific sounds.

Once you have the code running, you can make changes to customize it yourself. If you have a useful feature or bug fix, you can request to contribute it back to the official code using a git "pull request".

Here are a few possible things you could try to modify:

  • change the sound files for a different voice or language
  • change the startup message on the LEDs
  • add support for another model of Enigma

References


  1. MeinEnigma website: http://meinenigma.com
  2. Source code: https://github.com/lpaseen/meinEnigma
  3. Arduino software downloads: https://www.arduino.cc/en/main/software
  4. HT16K33 Arduino code: https://github.com/lpaseen/ht16k33
  5. AltSoftSerial Arduino library: https://github.com/PaulStoffregen/AltSoftSerial

Thursday, April 6, 2017

The MeinEnigma Enigma Machine Kit - Hardware



In this blog post I'll talk about the hardware inside the MeinEnigma. As I was not the designer, I don't know all the design intent and history behind the unit, and may make some incorrect statements, so take everything here with a grain of salt. Some hardware changes are also possible after I write this (as a user of an early beta release of the kit). For reference, my PCB is marked 2016-08-13 Rev 0.9.

If you don't have the schematics for the unit in front of you (and you likely don't unless you purchased a kit), some of this may be harder to follow. I'll try to keep things at a reasonably high level.

While the hardware design of the MeinEnigma is not open, you do receive schematics as part of the documentation and the unit was designed using all Open Source tools, including the KiCad electronic design program and LibreOffice office suite, running on the Open Source Linux platform.

The Arduino controller uses Open Source software and the MeinEnigma's firmware is free software licensed under the GNU General Public License.

Introduction


The system is built on three double-sided printed circuit boards and can accommodate either through-hole or surface mount technology parts for most of the discrete components like resistors, capacitors, diodes, and LEDs. The boards are connected together via ribbon cables.

It is a modular design where the Lamp and Key board and Plugboard could be replaced by different modules in the future or to allow it to be used for a different application. The software also works if most of the hardware is not present. In fact, the software will run on a standalone Arduino board, and still function as an Enigma machine through the serial port.

I would say this is a conservative design, in the sense that it doesn't cut corners to reduce size, cost, or reliability. There is ample space on the PCB between components, the physical size being based on the original Enigma machine.

It has no less than three fuses, uses suppressor diodes, good power supply filtering, IC sockets, and a boost converter, all of which could have been omitted or replaced with cheaper parts to bring the cost down, but reduce the quality and/or reliability.

Let's look at each of the three printed circuit boards in detail.

Main Board


The main board is the most complex of the three PCBs. I'll break the description down into its functional blocks.

Power Supply

The unit can be powered in several ways. External power is connected using screw terminals, and a battery holder is provided that accepts two AA batteries. It will operate from any external voltage from 1.5 to 4.5 volts. On my unit I measured the typical current consumption as around 250 mA, which increased quite a bit when sounds were being played.


The Arduino and other digital circuitry requires a regulated 5 volts. This is provided by a boost converter which steps the external voltage up to a constant 5 volts. The boost converter is pre-assembled on a small circuit board. These little boost converters are impressive -- they are essentially a switching power supply in a tiny package and are quite low in cost. They are much more efficient than a traditional analog regulator chip, which means less drain on the batteries.


There is a large 4700 uF filter capacitor between VCC and ground, located near the sound board, which I suspect is the most electrically noisy and power hungry component.


The function switch connects the battery when in any of the positions other than the fully counterclockwise OFF position.


The unit can also be powered from the USB port on the Arduino. This can be connected to a computer or a USB power supply. In this arrangement the unit will still be powered on, even when the function switch is in the OFF position.

It is safe to power the unit simultaneously from USB and batteries (which will happen, for example, if you connect the Arduino to a PC to program it or use the serial interface). A Schottky diode makes sure that USB power does not flow back into the boost converter. In this case there will still be some current drain on the battery to power the boost converter, so you might want to remove the batteries if you plan to power it from USB for long periods of time.


The circuitry is protected from overloads by three fuses, one in the battery circuit, one at the output of the boost converter, and one on the Arduino. These are polyfuses, a relatively new type of device which will "blow" when there is a current overload, but will reset when the power is removed and allowed to cool down for a period of time. Keep this in mind if you short something and the unit stops working. It may appear dead, but come back to life again after a period of time.

Arduino


The design is based around the low-cost Arduino microcontroller, and uses a commercially available Arduino Nano (or equivalent clone). The controller is an ATmega328 AVR chip with 32KB of flash memory, 2K of SRAM, 1K of EEPROM and runs at 16 MHz. It has 8 analog I/O pins and 22 digital I/O pins. It also has an I2C interface which is used in the MeinEnigma. The USB port provides an FTDI USB to serial interface.

The Arduino is mounted on connectors so it can be removed. Note that there is a small reset switch on the board which is handy for restarting the system.

The MeinEnigma uses all of the Arduino's I/O pins, and makes heavy use of the I2C interface to control the keyboard, LEDs, and plugboard.

Function Switch


A 6-position rotary switch controls power and the MeinEnigma's operating mode. The original Enigma had a similar rotary switch for controlling power (on, off, battery, and external power).

The mode function uses a rather ingenious circuit that only requires the use of one of the Arduino's inputs. It connects an analog input to different positions in a resistor divider and determines the switch position based on the voltage measured.

In case the user wants to mount the switch in a case, a small PCB is provided. The switch could be mounted on this PCB, and then wired back to the main PCB where holes are provided for a 5 pin header.

Sound Module and Speaker



Sounds are provided using a DFPLayer Mini sound module which is controlled by a serial interface to the Arduino. It contains a MicroSD card with MP3 files on it. Serial commands from the Arduino instruct it to play sounds on the SD card. The unit directly drives a small speaker which is mounted on the PCB. Pads are provided on the board to connect an external speaker (or two) or amplifier as well as jumpers which can be cut to disable the on-board speaker. The data sheet I found listed a power output of 3 Watts which is quite respectable.

Buzzer


Morse code output is produced by a small piezoelectric buzzer. It is not possible to control the volume in software and I found it quite loud. A workaround is to cover the hole in the top with a piece of electrical tape.

Real-Time Clock



A DS3231 real-time clock module allows the MeinEnigma to implement the clock mode feature that displays the current time. The module is controlled by the Arduino using an I2C interface and maintains the time even when the unit is powered off using a CR2032 coin battery mounted on the module.

Rotors



Rotation of the four rotors is sensed using four rotary encoders which output quadrature pulses when turned. The levels are sensed by digital inputs on the Arduino. The Arduino can determine when and how far a rotor is turned, and the direction, but not the absolute position. It is also done using interrupts so the Arduino does not have to constantly poll the encoders. The encoders uses up eight of the Arduino's I/O pins. These encoders also have a pushbutton built in to the shaft but this feature is not used.

Display


The display uses 4 16-segment alphanumeric LEDs which can display letters and numbers as well as a decimal point. Some digital gates on the board (a 7402 and a 4002) are used to handle controlling the decimal point.

The displays and the four buttons next to them are controlled by the Lamp and Key board and will be described later.

Big Red Button



The big red switch is there for fun, and as described in my previous blog post, provides a kill switch function. An interesting feature is that it works even when the unit is powered off! Two of the switch contacts connect power when it is pressed, and the other pair drive one of the Arduino's input pins.

Lamp and Key Board



This PCB is physically the largest but does not have a lot of circuitry. It has the 26 keyboard keys and 26 LEDs. These are controlled by an HT16K33 chip which is a "RAM Mapping 16*8 LED Controller Driver with keyscan" intended for just this type of application. The chip is controlled by the Arduino over the I2C bus, allowing the keys and LEDs to be controlled by only two serial lines. The keyboard scan circuitry also requires some resistors and steering diodes.

The I2C bus signals pass through this board and go to the plugboard using a 4 conductor ribbon cable.

Plugboard



The plugboard detects the arrangement of up to 13 jumper wires connecting pairs of the 26 banana jacks. It uses two MCP23017 "16-Bit I/O Expander with Serial Interface" chips. These provide GPIO pins which can be controlled over I2>/sup>C.




Each jumper input has a transient voltage suppression (TVS) diode connected between and ground, to protect the MCP23017 ICs from any voltage transient or spikes, such as could be generated from static electricity when handling the cables. Below each banana plug is a dummy plug connected to ground which is there in case the user wants to use cables with two-pin jacks to more closely match the original Enigma machine.

Modifications and Future Plans

The unit has a few more features intended for future expansion or modification, described in the draft "Modder's Guide" which I had access to.

The main board has pads for an HT16K33 chip that can be used to control the buttons and display on the main board. Normally these are controlled using the chip on the Lamp / Key board, which requires the large ribbon cable to connect all of the relevant signals. With the HT16K33 on the main board, the interconnection between boards could be just a 4-wire cable for I2C and power and ground (and pins are provided for these connections).

The main board provides pins for three 4-pin connectors for I2C that could be used to expand the system to control more devices.

Pins for a small header are provided that, when shorted, will lock the machine so settings cannot be changed. This would allow you to add a locking switch in the case with a key so that, like the original Enigma, the settings could only be set by an officer with the key. The machine operator could then only set the rotors and encode/decode messages, but not be able to set or determine the machine settings.

There are additional mounting holes to accommodate a cover over the lamp board, for example to make a unit that more closely resemble the original Enigma.

There are also some jumpers provided to allow changing the I2C addresses so that the unit could support multiple Keyboard and Lamp boards or plugboards.

Summary



I hope this description of the hardware design was useful. In the next blog posting I'll talk more about the software running on the unit.

References

  1. MeinEnigma website: http://meinenigma.com
  2. Source code: https://github.com/lpaseen/meinEnigma

Wednesday, April 5, 2017

The MeinEnigma Enigma Machine Kit - Operation



In this instalment we'll look at the basic operating features of the MeinEnigma.

It should be noted that this is based on the version 0.92 software. The details of the features could change as the software is developed, and of course the user can change it by reprogramming the Arduino.

If you don't have a basic knowledge of how the original Enigma machine worked, not all of the terms used here may make sense, but I'll not to get into too many technical details.

Power On

When the rotary switch is in the fully counterclockwise position, the unit is off. With power connected (we'll assume batteries), you turn it on by rotating the function switch clockwise one position.


The unit will beep, all LEDs and displays flash on, it speaks "MeinEnigma Starting Up", and displays ENIGMA on the display.

Model


It then says "model". It will go into this state whenever the function switch is in this position. It is expecting you to select what model of Enigma to emulate. The currently supported models are:
  • EN I, the Enigma I, used by the German Army and Air Force
  • M3, the Enigma M3 used by the German Navy
  • M4, the Enigma M4 used on German U-Boats
Rotating the first (leftmost) rotor will change the selected model. You'll hear a realistic click sound from the speaker when the rotor is turned.


Also in this mode you can press certain plugboard keys to change some
settings:

C - to enter clock mode where the time is display.
K - toggle the keyboard and rotor click sounds.
L - lamp test (turn on all displays and LEDs).
M - toggle Morse code output
O - odometer, show total number of encrypted/decrypted characters.
S - display serial number
T - toggle text to speech output
V - show software version

Reflector


Turning the function switch one more position to the right goes in reflector mode. It speaks "Reflector" and allows you to select what reflector to use using the leftmost rotor. The choices depend on what Enigma model was selected.

Rotor


One more turn goes into rotor mode. It prompts "Rotor". This is where you select each rotor (either 3 or 4 depending on the Enigma model selected). Each rotor must be different, as in the real Enigma the operator would physically insert one rotor from an available set in each position.

Plugboard


On more click moves to plugboard mode. It has two modes, virtual and physical plugboard. Turning the first rotor toggles between modes.


In physical plugboard mode you physically connect wire jumpers on the plugboard. Up to 13 jumpers are supported (the kit comes with 10). The plugs swap the corresponding characters as they pass through the Enigma's (virtual) circuitry. The plugboard is actually responsible for the majority of the huge number of possible encryption settings.





In virtual plugboard mode you can make jumper connections in software without using cables. Turn the second rotor to select a jumper number from 1 to 13. Turn rotor 3 to select the letter to connect from and rotor 4 to select the letter to connect to. You can do this for up to 13 jumpers.

In the reflector, rotor, and plugboard modes, you can press any keyboard key and the corresponding LED will light as well as voice or Morse output, if enabled.

Run



Turn the function switch clockwise once more to the final position. It will say "run". You can now run the machine, but first you need to set the rotors. On the original Enigma each rotor had an internal ring which could be turned. This position is indicated by the decimal point being lit next to the corresponding rotor. To set it, turn the rotor until you see the decimal point lit. Then press the corresponding button next to the rotor, and while it is held down, turn the rotor. The position where you release the button will be the ring setting. You can do this for each rotor.



Finally, you need to set an initial rotor setting, which is done by turning each of the the rotor wheels to the desired position (without any buttons pressed).

Operation

We are finally ready to encrypt text. Press a key on the keyboard and the encrypted value of the character will be shown by an LED lighting and sound output and/or Morse code output (if enabled). Then press the key for the next character in the message and note the encrypted value. Hopefully you are writing these down!


I won't attempt to describe here how the Enigma worked, but here are two things to note: If you press the same key a second time, it encrypts to a different character. This was not a simple substitution cipher where each character was always replaced by another one (which is easily broken). Note also that the rightmost rotor advances (the letter changes) each time you encrypt a character. When the rotor has made a complete revolution, the next rotor advances one notch.



Essentially the way the Enigma machine was used was that a set of machine settings were defined for a given day. Typically a month's worth of daily settings were distributed to all of the senders and receivers of messages in some secure way (like a military courier). To send a message, the machine was set up according to the settings for that day using a table like the one below:

Destroy after use!              meinEnigma                      April 2017
                   generated on http://meinEnigma.com/keychart.php
---------------------------------------------------------------------------
|Day|UKW|       rotors     | Rings  |           Plugboard           |Start|
---------------------------------------------------------------------------
| 4 | C | Beta  VI   V   II| R Y Z T| AR CE DG FP HQ JT LU MV NY SZ | VZLY|
| 3 | C | Gamma II   III VI| B R S L| AY BF CJ DZ ET IW KN LS PU RX | LNER|
| 2 | B | Gamma VIII VII VI| G N W B| AI BZ CQ DP EF GR JK NX TW VY | YQBV|
| 1 | B | Gamma I    VII VI| L T M F| BH CT DG ES FK IV JM PU QY RX | RLAC|
---------------------------------------------------------------------------

This would include the reflector, rotors, rotor rings and initial settings, and plugboard jumpers. The operator would encrypt the message and then give it to a radio operator to send. A typical encrypted message would consist of groups of 4 or 5 characters like this:

IMYVF LTQJI MG

On the receiving end, the machine would be set up with the same daily setting, and the encrypted message entered. Because the encryption process was symmetrical, the result would be the original message.

For example, if I enter the message above using the same settings, the decrypted characters are:

ATTAC KATDA WN

Or by adding spaces in the correct places: ATTACK AT DAWN.

In practice, the process was a little more complex. There were additional characters sent at the start of a message. Numbers and punctuation were sent by spelling them out and by using abbreviations that were defined in an operating manual. You can learn all of the details of the Enigma machine by checking some of the many web sites and YouTube videos on the Internet.


The MeinEnigma has a few more features: the "big red switch" will, after removing the safety cover, erase all of the machine settings. While this is really just for fun, you can imagine a real life scenario where an Enigma machine operator might be facing capture by the enemy and need to quickly erase the machine settings. You can Google for German submarine U-559 to read about a real case of the capture of an Enigma machine and code books before they could be destroyed, which helped the Allies in breaking the Enigma cipher.


The MeinEnigma can also be controlled by a computer through the serial port available from the Arduino's USB interface. You can both control the unit as well as encrypt text. I don't have room to describe the details here, but I may do so in a future blog post and it is covered in the MeinEnigma manual. Here is an example, the output of typing the "settings" command:

!SETTINGS                                                   
fwVersion: 0.92                                             
preset: 0

Odo meter: 470
morsecode: OFF
Serial number: 16

model: EN I(Enigma I, German Army and Air Force (Wehrmacht, Luftwaffe))
reflector: UKWA 
Rotors:    I -  II - III
ringstellung: - A A A 
Plugboard: virtual - AZ 
currentWalze: - A A C 
Time is :20:54:41

You can save and load up to 15 different machine configurations over the serial port. You can load the first four by holding down one of the 4 rotor buttons on power up.

Summary



We've looked at most of the operating features of the MeinEnigma. In the next blog post I plan to say something about the hardware inside.

References


  1. MeinEnigma website: http://meinenigma.com
  2. Source code: https://github.com/lpaseen/meinEnigma
  3. MeinEnigma YouTube channel: https://www.youtube.com/channel/UC3s44doR_q1fKQ4ZMUeAlHQ