Skip to content

Commit

Permalink
describe calculating of rs and gs
Browse files Browse the repository at this point in the history
  • Loading branch information
lubeskih committed Sep 7, 2019
1 parent 462d3c0 commit 33e4db9
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 24 deletions.
68 changes: 44 additions & 24 deletions docs/EOFM.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ The basic Enigma machine had been exhibited in 1923, soon after its invention, a

The German cryptographic authorities had modified it in a different way to create the machine which, though bearing the original name of Enigma, was much more effective than the commercially available device.

The underlying principle of an Enigma machine cipher is that of letter substitution, meaning that each letter of our plaintext (undeciphered message) is substituted by another letter.
The underlying principle of an Enigma machine cipher is that of letter substitution, meaning that each letter of a plaintext (undeciphered message) is substituted by another letter.

It used electrical wirings to perform automatically a series of alphabetical substitutions. An Enigma machine would be used in a fixed state only for enciphering _one_ letter, and then the outermost (fast) rotor would move round by one place, creating a new set of connections between the input and the output.

For any Enigma, in any state, it would be true if `A` were enciphered into `E`, then in that same state, `E` would be enciphered as `A`. The substitution alphabets resulting from an Enigma state would always be _swappings_. However, the Enigma was associated with a grave weakness, in that the substitutions thus performed were always of this very special kind, with the particular feature that **no letter could ever be enciphered into itself**.

The receiver of the message had only to set up the machine in exactly the same way as the sender, and feed in the cipher-text, to recover the plain-text.

That being said, the machine had only mechanized the basic operations of substitution and adding on, in such a way that a more complex system came within practical grasp. The Enigma did nothing that could not have been done by the looking up of tables in books, but enabled the work to be done more quickly and accurately.
That being said, the machine had only mechanized the basic operations of substitution, in such a way that a more complex system came within practical grasp. The Enigma did nothing that could not have been done by the looking up of tables in books, but enabled the work to be done more quickly and accurately.

In all cipher systems one assumes that the message has been intercepted. The objective is then to make it impossible, or at any rate very difficult and time-consuming, for the interceptor to decrypt the message. The ciphers it produced were supposed to be unbreakable even by someone in possession of the machine.

<h3 style="background-color: #2b303b; color: white; padding: 3px 5px 3px 5px; display: inline-block">A Current's Path</h3>

When a button is depressed on the Enigma, a current, typically from a battery, starts its journey throughout the mechanical parts of the encryption device. The following paragraphs represent the current's path in order. The first stop is at the Keyboard. Take a moment to loo at this curcuit diagram before proceeding.
When a button is depressed on the Enigma, a current, typically from a battery, starts its journey throughout the mechanical parts of the encryption device. The following paragraphs represent the current's path in order. The first stop is at the Keyboard. Take a moment to look at this circuit diagram before moving on.

<figure>
<img src="img/curcuit-diagram.jpg"></img>
Expand All @@ -76,28 +76,60 @@ The plugboard is similar to an old-fashioned telephone switch board that has ten

#### Entry Wheel

The current entry wheel connects the plugboard to the rotor assembly. If the plugboard is not present, the entry wheel instead connects the keyboard and lampboard to the rotor assembly. The military Enigma connects the keys in straight alphabetical order: A -> A, B -> B and so on. The static rotor simply turns wires into contacts.
The current entry wheel connects the plugboard to the rotor assembly. If the plugboard is not present, the entry wheel instead connects the keyboard and lampboard to the rotor assembly. The military Enigma connects the keys in straight alphabetical order: `A => A`, `B => B` and so on. The static rotor simply turns wires into contacts.

#### Rotors

The rotors are the heart of the Enigma machine. Each rotor is a disc, which has an electrical contact pins arranged in a circle on one face; and circular plates (electrical contacts) on the other (the pins and contacts represent the alphabet — typically the 26 letters A–Z).

When the rotors are mounted side-by-side on the spindle, the pins of one rotor rested against the plate contacts of the neighboring rotor, forming an electrical connection.
When the rotors are mounted side-by-side on the spindle, the pins of one rotor rest against the plate contacts of the neighboring rotor, forming an electrical connection.

Inside the body of the rotor, 26 wires are randomly connected each pin on one side to a contact on the other. This is where the 'magic' happens, which is why the rotors are also called 'scramblers'.

##### Ring-settings (Ringstellung):

The rotors had to be marked in some way on the outside so that the different positions could be identified. However, here entered yet another element of complexity. Each rotor was encircled by a ring bearing the 26 letters, so that with the ring fixed in position, each letter would label a rotor position (In fact, the letter would show through a window at the top of the machine).

However, the position of the ring, relative to the wirings, would be changed each day. The wirings might be thought of as labelled by numbers from 1 to 26, and the position of the ring by the letters A to Z appearing in the window. So a ring-setting would determine where the ring was to sit on the rotor, with perhaps the letter G on position 1, H on position 2, and so forth (see the illustrations bellow).

It is important to keep in mind that the ring setting only affects the
wiring, it doesn't affect the turnover which still happens at the same
letters.

Since the rotation is triggered by a ratchet and pawl mechanism, every time a key is depressed, one or more rotors rotate by one place.

As this ring rotated with its rotor, a notch machined into it would eventually align itself with the pawl, allowing it to engage with the ratchet, and advance the rotor on its left.

The advancement of a rotor other than the left-hand one is called a turnover. This was achieved by a ratchet and pawl mechanism.
The advancement of a rotor other than the left-hand one is called a turnover.

##### Ground-settings (Grundstellung):

The ground-settings tells the operator of the machine what position the rotors should be in when setting up the machine (the letters you see in the little windows). So, for example, if the ground-setting for the left-hand rotor is `A`, you should see the letter `A` through the left-hand little window of the machine.

###### BONUS: calculating the offset from the Ring/Ground settings

This is a basic illustration of the ground settings and ring settings of a Rotor. In the first illustration, the `Ring-setting` is set to `0`, and the `Ground-setting` is set to `A`, keep in mind that you actually see the `Ground-setting` through the little window.

So, when we have `RS` as `0` and `GS` and `A` (which also can be represented as `0`), the `OFFSET` of the Rotor would be `GS - RS`, in this case: `0`.

<img src="img/ring1.jpg">

On the second illustration, the `Rotor` has it's `Ring-setting` set to `1` (`B`), but the `Ground-setting` is on `A` (`0`), so you basically see `A` through the little window, but now the offset is not `0`!

We can still calculate the offset as: `OFFSET = GS - RS = -1`, and IF `OFFSET < 0`, `OFFSET = 26 - | OFFSET | = 25`.

<img src="img/ring2.jpg">

Now, we still have the `Ring-setting` set to `1` (`B`), but we also want to see `B` (`1`) through the little window. By doing this, we align the `Ring-setting` and the `Ground-setting`, making the offset `0`, which will be the **SAME** with the first illustration.

<img src="img/ring3.jpg">

##### Basic Enigma:

For the sake of simplicity, the diagram has been drawn for an alphabet of only eight letters, although in fact the Enigma worked on the ordinary 26-letter alphabet.

It shows the state of the machine at some particular moment in its use. The lines marked correspond to current-carrying wires.

A simple switch system at the input has the effect that if a key (say the B keys) is depressed, a current flows (as shown in the diagram by bold) lines and lights up a bulb in the output display panel (in this case, under the letter D). For the hypothetical 8-letter Enigma, the next state of the machine would be:

<figure>
<img src="img/Enigma-1.jpg"></img>
<center>
Expand All @@ -106,6 +138,8 @@ A simple switch system at the input has the effect that if a key (say the B keys
<br>
</figure>

A simple switch system at the input has the effect that if a key (say the B keys) is depressed, a current flows (as shown in the diagram by bold) lines and lights up a bulb in the output display panel (in this case, under the letter D). For the hypothetical 8-letter Enigma, the next state of the machine would be:

<figure>
<img src="img/Enigma-2.jpg"></img>
<center>
Expand All @@ -114,23 +148,9 @@ A simple switch system at the input has the effect that if a key (say the B keys
<br>
</figure>

##### Ring-settings (Ringstellung):

The rotors had to be marked in some way on the outside so that the different positions could be identified. However, here entered yet another element of complexity. Each rotor was encircled by a ring bearing the 26 letters, so that with the ring fixed in position, each letter would label a rotor position (In fact, the letter would show through a window at the top of the machine).

However, the position of the ring, relative to the wirings, would be changed each day. The wirings might be thought of as labelled by numbers from 1 to 26, and the position of the ring by the letters A to Z appearing in the window. So a ring-setting would determine where the ring was to sit on the rotor, with perhaps the letter G on position 1, H on position 2, and so forth.

It is important to keep in mind that the ring setting only affects the
wiring, it doesn't affect the turnover which still happens at the same
letters.

##### Ground-settings (Grundstellung):

The ground-settings tells the operator of the machine what position the rotors should be in when setting up the machine (the letters you see in the little windows). So, for example, if the ground-setting for the left-hand rotor is `A`, you will see the letter `A` through the little window of the machine.

#### Reflector

The reflector is the disc that stands next to the left-most rotor. As it's name says, it reflects back the received electrical current. It basically connects outputs of the last rotor in pairs redirecting current back through the rotors by a different route.
The reflector is the disc that can be found next (on the left side) to the left-most rotor. As it's name says, it reflects back the received electrical current. It basically connects outputs of the last rotor in pairs redirecting current back through the rotors by a different route.

The reflector ensured that Enigma would be **self-reciprocal**; thus, with two identically configured machines, a message could be encrypted on one and decrypted on the other. The reflector also gave Enigma the property that no letter ever encrypted to itself.

Expand Down Expand Up @@ -207,6 +227,6 @@ Also, a big **THANK YOU!** to:

- Simon (who actually built his own 3D printed Enigma machine -- check out his YouTube channel [here](https://www.youtube.com/channel/UCJqzEbh1UOpZJj3Hrv2mPZA)) from [asciimation.net](http://www.asciimation.co.nz/), for clearing up my confusion between the Grundstellung and the Ringstellung of the Enigma machine.

- My friend [Andrej Trajchevski](https://andrejt.com/), who actually gave me Andrew Hodge's book **Alan Turing: The Enigma** as a gift, which I later used for writing some parts of this manual.
- My friend [Andrej Trajchevski](https://andrejt.com/), who actually bought me Andrew Hodge's book **Alan Turing: The Enigma** as a gift, which I later used for writing some parts of this manual.

- My friend [Nikola Demerdziev](), he knows why.
Binary file added docs/img/ring1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/ring2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/ring3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- maybe draw the rotor contacts/pins
- write operating the enigma
- write better figure captions

0 comments on commit 33e4db9

Please sign in to comment.