information theory - german university in cairo · 2019. 2. 27. · wassim alexan 13. fig. 9. the...

34
COMM1003 Information Theory Dr. Wassim Alexan Spring 2019 Lecture 6

Upload: others

Post on 22-Jan-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

COMM1003

Information Theory

Dr. Wassim Alexan

Spring 2019

Lecture 6

Page 2: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Symmetric Cryptography

◆ Classical ciphers

◆ Electro–mechanical ciphers

◆ Modern ciphers

Wassim Alexan 2

Page 3: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

The Enigma Machine: A Brief History

◆ The first model was invented in 1918 by a German named Albert Scherbius

◆ Scherbius tried to sell his machine to the German military but was not successful

◆ In 1920, a company called Gewerkschaft Securitas bought the patent and started manufacturing the Enigma and selling it commercially to banks and other businesses

◆ In 1925, the German military became interested in the machine, in order to encrypt military radio messages

◆ The military kept on making enhancements to the original model of the Enigma

Wassim Alexan 3

Page 4: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

The Enigma Machine

◆ The Enigma machine is an electro–mechanical device used to encrypt and decrypt messages using a concatenated form of substitution ciphers

Fig. 1. A military–grade Enigma machine, model Enigma 1, used in the late 1930s and during WWII.

Wassim Alexan 4

Page 5: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

The 6 Components of the Enigma Machine

1. A keyboard with 26 letters of the alphabet

2. A plugboard containing 26 dual sockets for the plugs (It can contain from 0 to 13 dual–wired cables)

Fig. 2. A front view of the plugboard, showing 2 swaps: A → J and S → O.

Wassim Alexan 5

Page 6: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

3. 3 rotors, mounted in a certain order

◆ Each rotor has 26 contact points that carry the electrical signal

Fig. 3. Rotors of the model Enigma I, which were functionally identical, as they had numbers (1 to 26) instead of letters.

Wassim Alexan 6

Page 7: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Fig. 4. The left side of a rotor, showing the flat (plate) electrical contacts (left). The right side of a rotor, showing the pin electrical contacts (right).

Wassim Alexan 7

Page 8: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

4. The movable rings with notches on the sides of the rotors. These rings can be rotated to any of 26 positions and each of them controls the movement of the rotor to its left

Fig. 5. Rotors and reflector on the far left.

◆ Every time a key is pressed on the keyboard, the 1st rotor rotates one position

◆ Every time the 1st rotor makes a full revolution, the 2nd rotor rotates one position

◆ Every time the 2nd rotor makes a full revolution, the 3rd rotor rotates one position

5. The reflector, which has 26 contact points that touch the contact points of the rotor to its right

Wassim Alexan 8

Page 9: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Fig. 6. The reflector of an Enigma machine.

◆ Inside the reflector are 13 pairs of wires that connect 2 contact points together

◆ The wires will carry the electric signal that is reflected back through the rotors to the plugboard

◆ The reflector does not rotate like the rotors, but in some models of the Enigma, it can be adjusted before the operator starts typing

◆ The reflector is self–reciprocal: allowing for encryption to be conveniently carried out just like the decryption

Wassim Alexan 9

Page 10: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

◆ Thus, the reflector gives the Enigma the property that no letter is ever encrypted to itself, which is a severe cryptological mistake that was later on exploited by the code breakers

Fig. 7. Operation idea.

6. 26 lights for every letter in the alphabet

Wassim Alexan 10

Page 11: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Fig. 8. The lights on an Enigma machine.

Wassim Alexan 11

Page 12: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

The Enigma Machine: An Example

◆ Assuming that you want to use the Enigma machine to encrypt some plaintext

◆ You start off by rotating the rotors to any set, for example, you set them all at 1

◆ You then plug any or all of the thirteen cables in the sockets (in practice, 10 cables were used by the Germans)

◆ You can now start encrypting your message, which starts with the letter a

◆ You type a on the keyboard, which sends an electrical signal from the keyboard to the plugboard

◆ The wire that is connected to a from one end is connected to j on the other end, which is only a label on the plugboard

◆ This signal then goes through all the rotors and into the reflector

Wassim Alexan 12

Page 13: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

The Enigma Machine: An Example

◆ The reflector sends the signal back through the rotors to the plugboard (the signal returns through different wires than before the first time)

◆ This lights up a cipher letter, for example G

◆ Keep in mind that if you press the letter a once or twice again consecutively, the light for the cipher letter G will not light up, but other (different) cipher letters will

◆ This is because every time a key is pressed on the keyboard, the first rotor makes a rotation

◆ Since the same wires are used for forward and backward legs, a major cryptographic weakness is that no letter can map to itself

Wassim Alexan 13

Page 14: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the electrical signal is passed into the set of rotors, around the reflector, and back out through the rotors again.

Wassim Alexan 14

Page 15: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

The Enigma Machine: The Key

◆ The German High Command specified a day key for the Enigma machine

◆ The keys were given out for one month ahead in a code book (see Fig. 10, next slide), and consisted of

1. The plugboard settings (the letters to be swapped)

2. The order of the placement of the rotors

3. The orientation of the rotors (the letters facing upwards, as shown in Fig. 11)

Wassim Alexan 15

Page 16: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

The Enigma Machine: The Key

Fig. 10. Part of a code book.

Wassim Alexan 16

Page 17: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

The Enigma Machine: The Key

Fig. 11. Initial setting of the rotors which define part of the key.

Wassim Alexan 17

Page 18: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

The Enigma Machine: Number of Combinations

◆ The most widely used Enigma model had 5 rotors to choose from, resulting in thousands of possible configurations

◆ In the 1st slot, there are 5 rotors to pick from, in the 2nd slot there are 4 rotors to pick from and in the 3rd slot there are 3 rotors to pick from

◆ This means 5× 4× 3 = 60 different ways to configure the 5 rotors into 3 slots

◆ There are also 26 starting positions for each rotor, so there are 26× 26× 26 = 263 = 17, 576 choices for the initial configuration of the rotors

◆ This yields 60× 17, 576 = 1, 054, 560 ways to set a commercial Enigma machine

◆ But these features describe the components of commercial Enigma machines, while military–grade machines have additional features, such as the plugboard, which allows for even more configuration possibilities

Wassim Alexan 18

Page 19: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

The Enigma Machine: Number of Combinations

◆ Since there are 26 letters in the alphabet, there are 26 ! ways to arrange the letters, but the plugboard can only make 10 pairs

◆ This allows for 20 letters to be involved with the pairings, while 6 letters are left over and thus must be divided out

◆ Also, for the 10 pairs of connected letters, the order they are in (AB or BA) does not matter , so we divide by another 10!

◆ Furthermore, we do not care about the order of the pairings, so we divide by another 210

◆ Thus, the resulting number of combinations yielded by the plugboard is

26 !6! × 10 ! × 210 = 150, 738, 274, 937, 250 (1)

Wassim Alexan 19

Page 20: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

The Enigma Machine: Number of Combinations

◆ All of the components put together yield

60× 17, 576× 150, 738, 274, 937, 250 = 158, 962, 555, 217, 826, 360, 000 (2)

ways to set a military–grade Enigma machine

Wassim Alexan 20

Page 21: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

A Quick Question!

◆ How many rotor configurations would an Enigma machine encrypter be able to select from if s/he needed to choose 3 rotors from a set of 10 rotors?

◆ Hint: The order of the rotors matters

Wassim Alexan 21

Page 22: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Solution

◆ n P r = n! / (n - r) = 10 ! / (10 - 3) ! = 720

Wassim Alexan 22

Page 23: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

The Enigma Machine: The Various Rotors

◆ Table 1 shows how the internal wiring connects the right side of the rotor (with the spring–loaded contacts) to the left side

◆ Each rotor is a substitution cipher

◆ The letters are listed as connected to the alphabet order

◆ If the first letter of a rotor is d, this means that letter a is wired to this d

Wassim Alexan 23

Page 24: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

The Enigma Machine: The Various Rotors

Table 1. A rotor wiring table for the Enigma machine.

Wassim Alexan 24

Page 25: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Exercise 1

Using Fig. 12, encrypt the following plaintext, assuming that the rotors are fixed (no rotation occurs)

alan turing

Fig. 12. An assumed inner view of the wiring of a modified Enigma machine for Exercise 1.

Wassim Alexan 25

Page 26: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Exercise 1 Solutions

By following the wiring on Fig. 12, we get the ciphertext

EIEP VXOLPK

Removing the spaces, we write it as

EIEPVXOLPK

Wassim Alexan 26

Page 27: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Exercise 2

Using Fig. 13, decrypt the following ciphertext, assuming that the rotors are fixed (no rotation occurs)

JAXVALWVBRPPAOWVEK

Fig. 13. An assumed inner view of the wiring of a modified Enigma machine for Exercise 2.

Wassim Alexan 27

Page 28: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Exercise 2 Solutions

By following the wiring on Fig. 13, we get the plaintext

heuteistdonnerstag

Removing the spaces, we get

heute ist donnerstag

which is the German language equivalent of

today is thursday

Wassim Alexan 28

Page 29: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Wassim Alexan 29

Page 30: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Fig. 14. How the Enigma machine worked.

Wassim Alexan 30

Page 31: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Wassim Alexan 31

Page 32: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Fig. 15. How the Enigma machine worked, enlarged version.

Wassim Alexan 32

Page 33: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Wolfram–Based Enigma Machine Models

◆ A Wolfram Mathematica implementation is available at http://demonstrations.wolfram.com/EncryptionWithTheEnigmaMachine/

Fig. 16. A Wolfram Mathematica implementation of the Enigma machine.

Wassim Alexan 33

Page 34: Information Theory - German University in Cairo · 2019. 2. 27. · Wassim Alexan 13. Fig. 9. The scrambling action of the Enigma rotors shown for two consecutive letters – the

Physical Enigma Machine Models

◆ Electronic replicas are sold on http://www.cryptomuseum.com/kits/enigma/

Fig. 17. An electronic replica of the Enigma machine.

Wassim Alexan 34