Enigma Home Page
US 6812 Bombe Report
Bombe Simulator in Python
|
Introduction
This software, in Python language, emulates in text mode,
a Turing/Welchman three rotors Bombe. This model allows you
to find the daily key for messages encrypted with the Enigma I
or M3 which only uses three rotors.
I wrote another simulator but in C language which is 100 times
faster. Question: Is this program in Python of interest?
Yes, because the source code is much easier to read. On the
other hand, since it is written in Python, it can run on any
system that has the Python interpreter installed.
Algorithm
- We build the electric circuit from the menu given
in argument. This circuit is composed of a series of
Enigmas linked together and linked to the input register
and the Test Register which displays the Stecker associated
with this register in the event of a Stop.
- Big loop on Grundstellung (from AAA to ZZZ). For each GrundStellung
(For one Walzenlage given as argument):
- The registers are reset (absence of current)
- We advance the rotors
- Current is injected into the input register(s).
As a result,
electricity flows throughout the circuits. If the Grundstellung
does not correspond to a Stop, all 26 elements that make up the
Test Register are activated by the electric current. We then
move on to the next GrundStellung. If the Test Register contains
only one element activated by the electric current or if all
elements are activated except one, we have a Stop, I.E. a
plausible position which can correspond to the sought solution.
- If there is a Stop, the Bombe stops if the program is running
in Debug mode. In this mode, in addition, each Grundstellung
tested is displayed. If the Debug mode is not active only the
Stop are displayed but the program continues (we go to the next
GrundStellung).
Remarks:
- Most often, only one register is used (The Test Register).
- There is no option regarding the use of the Diagonal Board.
This one is automatically used if the main wiring is connected to one
of its entry points.
Tips:
- At each Grundstellung tested, I loop 20
times to simulate the flow of electricity in the different Enigmas
and the cables that connect them. In reality, electricity flows
instantaneously.
- To simulate the passage of current everywhere, I run the Enigmas
first in one direction and then in the other direction. Unfortunately,
this doubles the calculation time.
- I use a lot of registers. Thus, I use a register
to connect each Enigma to another Enigma. In the real Bombe, the
Enigmas were connected together simply by cables. Registers were
actually used associated with the "Machine Gun". We could thus know
a large part of the steckers and not only the stecker shown by the
Test Register. In my software, if the Debug mode is activated,
we display all registers (this emulate the Machine Gun).
Download the program and untar it
On Windows or Linux, you can download my program with the CURL command:
$ curl -O http://www.jfbouch.fr/crypto/enigma/bombe/BOMBE_PY.tar
$ tar -xf BOMBE_PY.tar
$ cd BOMBE_PY
$ more README.txt
Show syntax
Just activate my program with no arguments:
$ python3 turing_welchman.py
Usage:
-h Online Help
-d Debug
-D a:1,d:2 Diagonal Board
letter 'a' linked to register '1', ...
-W X,Y,Z The Walzenlage, default: -W I,II,III
-U UKW The Reflector, default: B
-T l[,...] The terminal letter(s) (A by default)
-i r[,...] The Input Register(s) (1 by default)
-M menu The menu, list of blocs. One bloc:
input_register:Grund:output_register,...
for example:
-M 01:ZZA:02,02:ZZB:03,03:ZZC:01
Note: The input register is the first register
-I XYZ The indicator position
by default, the first entry of the menu
A simple example
I use the Ellsbury menu described in the page dedicated to
my simulator in C (link).
The program displays for each Stop:
- The Walzenlage
- The GrundStellung
- The Stecker associated with the Entry letter
$ cat MENUS/ellsbury_01.sh
#!/bin/sh
# Ellsbury menu
python3 turing_welchman.py\
-i 1 \
-T A \
-W II,I,III \
-D E:1,B:2,A:3,H:4,D:5 \
-M 1:ZZA:2,2:ZZC:3,3:ZZF:4,4:ZZG:1,1:ZZB:5,5:ZZI:2,5:ZZH:3,1:ZZE:4
$ sh MENUS/ellsbury_01.sh
stop II,I,III BGX, E:X
|