# The Enigma Machine

With the Enigma, and more so the Lorenz, we start to move away from the more classical cryptographic methods, and toward the machine age. For my purposes I'll categorise both of these as 'classical'. I'll categorise Enigma as it was most definitely not a computer, and Lorenz as although a computer was designed to solve it (the Colossus) the Lorenz itself was not computer based. What is the Enigma?

The Enigma machine is probably one of the most famous cryptographic machines in history - it was famously broken at Bletchley Park after initial work by the Polish.

The enigma machine itself is quite straightforward, and when used properly is extremely strong. The cryptanalysts' main breaks into the system were provided by the German operators themselves!

Let us have a closer look at the machine.

The Enigma is built into a wooden box which can be carried by a single man. Upon opening the box one is faced with a typewriter-like arrangement. Above the typewriter is an array of lamps, one lamp for each letter.

Above the lamps are some 'rotors' - these are the heart of the encryption.

When a key is pressed a lamp is illuminated. The lamp indicates the enciphered letter.

To use the machine two operators are needed. One operator types in the message, the second operator reads it off from the lamps - the enciphering is done.

In order to decipher, the machine is reset to exactly the same position and the enciphered message is typed in (this is usually done on a distant, but identically set up, machine). The original message now appears on the lamps.

The Enigma machine is 'symmetrical' - the enciphering and deciphering method is the same, but the machines must be identically set up.

How is this accomplished?

We must now ask ourselves exactly how the Enigma machine performs it's task.

In the following description it should be noted that I have reconstructed the workings from the literature, but I have never had access to the detailed diagrams. Therefore whilst I am confident that the logic is correct, the detail may, and probably will, differ from reality.

The keyboard

Let us consider the main parts of the system. First there are the keys. Each key is arranged to spring back into position when released.

The rotors

Next there is the scrambler, which consists of three 'rotors'. A rotor is simply a disk with a ring of connections on each side, one connection per character on each side. A mess of wiring within the rotor means that when a voltage is presented to a connection on one side it is then presented to some other connection on the other side. For reasons of practicality rotors were manufactured in identical sets of five different rotors - though different communication 'networks' used different, incompatible, rotors.

Each time a key is pressed the rotors progress in 'speedometer' fashion, i.e. AAA, AAB, AAC... AAY, AAZ, ABA etc. Note that the rotors are interchangable, and though three rotors are used at a time, five are typically available. Note also that the starting position and the rotor position which causes the next rotor to change position are variable... i.e. we could have the rotors progressing CDF, CDG, CEH, CEI, CEJ etc.

The reflector

Following the rotors we have the 'reflector'. After the reflector the signal goes back through the scrambler and to the lamps.

There is also an additional complicating factor, the plugboard, which will be discussed later.

The keyspace and the wiring

The security of the Enigma, like any good system, does not lie in it's workings, but lies in it's key - this will also be discussed later on.

I present to you now a circuit diagram, which will be used in the following example. Note that for the purposes of this diagram the switches are normally connected, via the bulb, to ground - and when depressed the switch is connected to the positive supply rail. This is one of the small details which could be wrong (e.g. the power supply could be reversed), but does not affect the logic.

When a key is pressed, 'A' in the above example, a high voltage is presented to an input of the first rotor. A piece of wire then presents this voltage to a terminal on the output side of the first rotor - this voltage is presented to the second, and then the third. Where it finally appears is a function of the detailed wiring of each rotor.

The voltage is then presented to the 'reflector', which is like a one sided rotor. It then appears again on a different terminal on the same side and goes back through the rotors. The voltage finally appears upon left hand side of the first rotor, where it lights a bulb.

Now the rotor(s) change position - and all the wiring changes! Hence pressing the same key again will light up, in general, a different bulb. This is a weakness which we will discuss.

The main part of the security of the Enigma lies in the very large 'keyspace'.

There are 5 rotors, of which three may be chosen and inserted into any position.

This gives us 5 ways of choosing the first rotor, 4 ways of choosing the second, and 3 ways of choosing the third - i.e. 60 ways of choosing our rotors.

Each rotor can have 26 starting positions (assuming a 26 letter alphabet). This gives an additional 263, or 17,576 ways of setting our chosen rotors. This gives us, so far, a total of 1,054,560 combinations. This is already a daunting number of keys to search through without benefit of computers - but we haven't stopped here.

Let us look at the rotors themselves.

Consider the first terminal on one side of a rotor. It can be connected to any of 26 terminals on the other side, the second can be connected to any of 25 terminals, the third to any of 24 and so on. Each rotor may be wired in 26! ways. (! is pronounced factoral, and 26! = 26x25x24..x3x2x1). This means that there are over 403,000,000,000,000,000,000,000,000 (4x1026) combinations. This is a very large number indeed. It's big. It's very big. I was going to include an example to emphasise the size of the number, but I couldn't do it justice. Let's just leave it at 'big'. Note, it's the same number of combinations as there are possible cipher alphabets in the monoalphabetic cipher, but the underlying statistics which can be made use of to crack the system are unchanged for the monoalphabet, here they are totally obscured. This is why a monoalphabet can be solved by hand, but cunning techniques are needed for the Enigma.

Fortunately the actual rotors didn't change that often due to the problems of changing many sets of rotors simultaneously - and so this did not cause as much of a problem as they might have done. However, when they DID change, it was a major headache.

The reflector could also be changed. The first terminal in the reflector could be connected to any one of 25, on the same side, the second to any one of 23 and so on. Therefore we have to multiply the possible combinations by 25x23x21... x3x2x1. This may be written as 25!/(13!x2), or 1,200,000,000,000,000 (1.2x1015) combinations.

As with the rotors, these last sets of variations upon the keys are not actually made use of on a day to day basis. True, one does come up against them if and when the rotors are changed, but on a day to day basis the rotors are reordered, not changed - so once the internal wiring of the rotors is known these leaves a 'mere' 1,054,560 ways of setting up the Enigma, trivial by today's standards! The German forces needed to increase the keyspace further. They did this by using the plugboard.

The Plugboard

The plugboard went between the keyboard and scrambler.

What the plugboard does is to effectively swap two wires over, i.e. a high voltage on wire 1 would be swapped to wire 2, and the opposite would also be true. This is done by a series of sockets and jump leads on the front of the box and a set of matching leads. One could easily model this with a set of jack sockets, wired so that if no plug is present any signal is passed straight through. (Note, I am not saying that the Enigma did this with jack sockets, merely that jack sockets provide a modern alternative).

In the above example, a high voltage presented to wire on the left hand side appears on the right hand end of wire A, as before. However, a high voltage presented to wire B will appear at the other end on wire C, and vice-versa.

For example, if pressing key A makes lamp B light without the plugboard connections, then lamp C will light with the connections.

This adds about 1015 plugboard combinations which can be set by the user. This gives 1021 user settable keys. This is an astronomical number of possible keys, and impractical to do a 'brute force' search on.

At least, that is what we might naïvely assume when coding, in practice the plugboard added little to the security, and had little, if any, effect upon the methods used at Bletchley to break the Enigma.

Weakness

It should be noted that a piece of text will never encipher as itself, no matter how often one tries. I.e. E will never encipher as E - this weakness doesn't seem too severe, but was exploited in the cryptanalysis. The reason for this quirk should be fairly obvious with a little inspection of the diagram. It's due to the fact that the 'E' switch cannot be both up and down at once, and that the reflected signal cannot return down the same wire.

Improvements

There were small changes which the German's could have made which would have completely locked the allies out of the Enigma traffic, some changes were made, but in a piecemeal fashion - allowing the allies to tackle the difficulties one at a time. I'll list the changes here, hopefully you'll see the significance of some of them straight away, and the rest when you read the text to come upon Cracking the Enigma.