The Hardware Side of Cryptography

22 June 2009

Embedding The Enigma Railway into ATMega32

Filed under: Cipher Machine, classical — Tags: , , , , , , — edipermadi @ 12:20 pm

A couple weeks ago, i have ported the implementation of Enigma Railway from PIC16F84 based to the one geared by ATMega32 running at 16 MHz. The code is rewriten from assembly to C for better understanding.

The hardware is based on ATMega8535 development board produced by innovative electronics with small changes on system frequency and microcontroller replacement. The code is compiled using codevision 1.25.3 and you may use another compiler with minor changes. The code is freely available for anyone under the GNU Public License 3.0 terms. You way use and modify it with no warranty implied.

In this post, i used the ATMega32 to continuously monitor the serial connection form PC to microcontroller (at 115200) for incoming data. Once [a-z:A-Z] characeter found, i’t will subsequentially encode the incoming character through Enigma Railway substitution cipher and pass back the result. The PC side control is hosted by Teraterm configured at 115200 8n1 with no flow control.

The code is verified against the “Enigma Railway Simulator” coded by Geoff Sullivan found here. The test vector comparison is performed by enciphering 600 of “A” characters using the same initial condition

In addition, i used several number and symbol to control the inner state of Enigma Railway Cipher Machine. The Control Character is shown at screenshot section below.

Development Board
The ATMega32 Development Board

AVR USB Programmer
The AVR USB Programmer

Menu Page
The Enigma Railway Help Menu

About Page
The Enigma Railway About Page

Licensing Page
The Enigma railway Licensing Page

Usage Page
The Enigma Railway Usage Page

Resulting Cipher
The Enigma Railway Resulting Cipher

The Enigma Railway Simulator
The Enigma railway Simulation Result

After your compiled and burned the HEX code to the chip, you can connect it to PC and type “?” (a question mark) to display those menus.

Related Stuff

Enigma Railway AVR Source Code v0.1


  1. Hi

    Great work. Could you make an AES converter for five numbers like the above ? So we can enter text in the hyperterminal (just like this text here), but encrypts with AES and outputs groups of five figures using an AVR?

    would be fantastic !

    Comment by Baz — 6 July 2009 @ 9:10 pm

    • @Baz

      Hi, thank you for your valuable inspiring suggestion. i’m just started to develop AES RS232 dongle like what you said.

      Comment by edipermadi — 9 July 2009 @ 1:55 pm

  2. […] Advanced Encryption Standard (AES)(a)(b)(c)(d), Triple Data Encryption Standard (3DES)(a)(b), Enigma(a), RC4(a), as well as less-known algorithms such as Alexander Pukall’s PC1 […]

    Pingback by Types of Cryptography for a 4-8 bit microcontroller | CL-UAT — 26 December 2014 @ 10:09 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

%d bloggers like this: