the enigma machine eric roberts cs 106a february 3, 2016

21
The Enigma Machine Eric Roberts CS 106A February 3, 2016

Upload: gerard-watkins

Post on 18-Jan-2018

227 views

Category:

Documents


0 download

DESCRIPTION

Cryptography—Bletchley Park I’ve twice had the opportunity to teach cryptography at Stanford in Oxford, which made it possible to visit Bletchley Park—the home of the Government Code and Cipher School (GCCS), where the Enigma code was broken. Oxford Bletchley

TRANSCRIPT

Page 1: The Enigma Machine Eric Roberts CS 106A February 3, 2016

The Enigma Machine

Eric RobertsCS 106A

February 3, 2016

Page 2: The Enigma Machine Eric Roberts CS 106A February 3, 2016

Once upon a time . . .

Page 3: The Enigma Machine Eric Roberts CS 106A February 3, 2016

Cryptography—Bletchley Park

I’ve twice had the opportunity to teach cryptography at Stanford in Oxford, which made it possible to visit Bletchley Park—the home of the Government Code and Cipher School (GCCS), where the Enigma code was broken.

OxfordBletchley

Page 4: The Enigma Machine Eric Roberts CS 106A February 3, 2016

Cryptography—Bletchley Park

In our field trips to Bletchley Park, our tour was led by Jean Valentine, who worked with the Bombe decryption machine shown in these pictures.

Page 5: The Enigma Machine Eric Roberts CS 106A February 3, 2016

The Enigma Machine

Page 6: The Enigma Machine Eric Roberts CS 106A February 3, 2016

Overview of Assignment #4Part 1: Check that a key is legal

In a letter-substitution cipher, the key must be a permutation of the alphabet, which means that it contains all the letters of the alphabet in some order. Your job in Part 1 is to add code to check that the key entered in the LetterSubstitutionCipher program is legal, as in the following sample run:

LetterSubstitutionCipher

Letter-substitution cipher.Enter 26-letter key: SHORTKEY

Plaintext: HAL 9000Ciphertext: IBM 9000

That key is illegal.Enter 26-letter key: AABCDEFGHIJKLMNOPQRSTUVWXYThat key is illegal.Enter 26-letter key: BCDEFGHIJKLMNOPQRSTUVWXYZA

Page 7: The Enigma Machine Eric Roberts CS 106A February 3, 2016

Overview of Assignment #4

L ZDRXPE A J Y BQWFV I HC T GNOMKSU

ABCDE F GH I J K LMNOPQRS T UVWXYZ| | | | | | | | | | | | | | | | | | | | | | | | | |

HKRCGNTQP I XAWUV FL DY S ZOME J B

R WA|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q| |

S|T|U|V| |

X|Y|Z|

Encryption key:

Decryption key:

Part 2: Invert a keyIn a letter-substitution cipher, the sender and receiver must use different keys, one for encryption and one for decryption. Your job in Part 2 is to write an invertKey method that determines the decryption key from the encryption key by going through the alphabet and, for each letter, figuring out what plaintext letter would have produced that letter in the ciphertext.

Page 8: The Enigma Machine Eric Roberts CS 106A February 3, 2016

Overview of Assignment #4Part 3: Simulate the Enigma Machine

Page 9: The Enigma Machine Eric Roberts CS 106A February 3, 2016
Page 10: The Enigma Machine Eric Roberts CS 106A February 3, 2016

The Enigma Rotors

Page 11: The Enigma Machine Eric Roberts CS 106A February 3, 2016

The Enigma Structure

Page 12: The Enigma Machine Eric Roberts CS 106A February 3, 2016

Operation of the Enigma Machine• Whenever the operator types a letter key on the Enigma, the

following things happen:

1. The force of the key press advances the fast rotor one position. If the indicator on the fast rotor wraps around from Z to A, that action “carries” to the medium rotor, just like the digits on an odometer. Similarly, if the medium rotor passes Z, the slow rotor advances one position.

2. An electrical signal is fed into the wire corresponding to the key, which then flows through seven letter-substitution steps:– Through the fast rotor from right to left.– Through the medium rotor from right to left.– Through the slow rotor from right to left.– Through the reflector, which turns the signal around.– Through the slow rotor from left to right.– Through the medium rotor from left to right.– Through the fast rotor from left to right and then on to the lamp.

Page 13: The Enigma Machine Eric Roberts CS 106A February 3, 2016

Encoding the Letter “A”

Page 14: The Enigma Machine Eric Roberts CS 106A February 3, 2016

The Next “A” Is Different

Page 15: The Enigma Machine Eric Roberts CS 106A February 3, 2016

What Made Enigma Vulnerable?• Early in the war, mathematicians working for the Polish

Resistance were able to smuggle Enigma machines to France and England along with a strategy for breaking the code.

• The British government established a top-secret cryptography center at Bletchley Park and staffed it with the top British mathematicians.

• The decryption team at Bletchley was able to exploit the following facts about the Enigma machine:– The encoding is symmetrical.– The Enigma machine can never map a character into itself.

• The codebreakers were also helped by the fact that the Germans were both careless and overconfident. In believing they had an unbreakable encoding machine, they failed to take adequate measures to safeguard the integrity of their communications.

Page 16: The Enigma Machine Eric Roberts CS 106A February 3, 2016

Breaking the Enigma Code• The most common technique used at Bletchley Park was the

known-plaintext attack, in which the codebreakers guess that a particular sequence of characters exists somewhere in the decoded message. A sequence of characters that you guess is part of the plaintext is called a crib.

• Breaking an Enigma message required the following steps:– Align the crib with the ciphertext to eliminate crashes in which

a letter appears to map to itself.– Create a menu recording the links between letter pairs in the

crib and ciphertext.– Identify loops in the menu at which a chain of letter pairs

cycles back to the original letter.– Use the loops in the menu to create a wiring pattern for an

electromechanical device called a Bombe that searches for settings of the Enigma rotors that produce the observed pattern.

Page 17: The Enigma Machine Eric Roberts CS 106A February 3, 2016

Step 1: Align the Crib and Ciphertext

U A E N F V R L B Z PWME PM I H F S R J X FM J KWR A X Q E ZK E I N E B E S OND E R E N E R E I G N I S S EK E I N E B E S OND E R E N E R E I G N I S S EK E I N E B E S OND E R E N E R E I G N I S S EK E I N E B E S OND E R E N E R E I G N I S S EK E I N E B E S OND E R E N E R E I G N I S S EK E I N E B E S OND E R E N E R E I G N I S S E

No crashes exist in this alignment, so it is a feasible solution.

Page 18: The Enigma Machine Eric Roberts CS 106A February 3, 2016

Step 2: Construct the MenuVK0

RE1

LI2

BN3

ZE4

PB5

WE6

MS7

EO8

PN9

MD10

IE11

HR12

FE13

SN14

RE15

JR16

XE17

FI18

MG19

JN20

KI

21

WS22

RS23

AE24

L K V

O F I H P B

Z E R J N G

A X W S M D

0

1

2

3

4

5

6

7

89

10

11 1213

14

1, 15 16

17

18

19

20

21

22

2324

VK0

RE1

LI2

BN3

ZE4

PB5

WE6

MS7

EO8

PN9

MD10

IE11

HR12

FE13

SN14

RE15

JR16

XE17

FI18

MG19

JN20

KI

21

WS22

RS23

AE24

Page 19: The Enigma Machine Eric Roberts CS 106A February 3, 2016

Step 3: Find the LoopsVK0

RE1

LI2

BN3

ZE4

PB5

WE6

MS7

EO8

PN9

MD10

IE11

HR12

FE13

SN14

RE15

JR16

XE17

FI18

MG19

JN20

KI

21

WS22

RS23

AE24

L K V

O F I H P B

Z E R J N G

A X W S M D

0

2

3

4

5

6

7

89

10

11 1213

14

1, 15 16

17

18

19

20

21

22

2324

Page 20: The Enigma Machine Eric Roberts CS 106A February 3, 2016

Enigma Decryption

Page 21: The Enigma Machine Eric Roberts CS 106A February 3, 2016

The End