espionage codebreaking: mathematics of

66
Codebreaking: Mathematics of Espionage Duke TIP Academic Adventures

Upload: others

Post on 03-Nov-2021

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Espionage Codebreaking: Mathematics of

Codebreaking: Mathematics of Espionage

Duke TIP Academic Adventures

Page 2: Espionage Codebreaking: Mathematics of

Petals Around the Rose

Page 3: Espionage Codebreaking: Mathematics of

Third Person IntroductionsIntroduce the person sitting next you by saying the following.● Name

● Hometown

● Favorite Food

Page 4: Espionage Codebreaking: Mathematics of

Human Machine

Page 5: Espionage Codebreaking: Mathematics of

Rules and Expectations● Be Respectful● Participate● Don’t Talk When Someone Else Is● Don’t Shout Out Answers● Thinking > Answers● Have Fun

Page 6: Espionage Codebreaking: Mathematics of

Finishing EarlyEveryone works at a different pace. If you happen to finish something early, please raise your hand and let me know. You may get to be my assistant!

Page 7: Espionage Codebreaking: Mathematics of

Warm UpWhat does the following message say?

NVVK TVYUPUN

Page 8: Espionage Codebreaking: Mathematics of

Warm Up

GOOD MORNING

Page 9: Espionage Codebreaking: Mathematics of

What is Cryptography?• Cryptography is the practice and study of

techniques and algorithms for secure information.

• Like any field of study, cryptography comes with its own set of terminology.

Page 10: Espionage Codebreaking: Mathematics of

Cryptography TerminologyPlaintext: message to be sent.Ciphertext: unintelligible text.Encryption: plaintext to ciphertext.Decryption: ciphertext to plaintext.Cipher: encryption and decryption.Key: used to encrypt and decrypt.Mono-alphabetic: letters are sent to exactly 1 letter.Poly-alphabetic: may send 1 letter to 2 or more letters.

Page 11: Espionage Codebreaking: Mathematics of

Cryptography Preprocessing• All punctuation and spaces are removed and all

letters are capitalized. This is done so messages are more difficult to break.

• For example, consider:I need help! → INEEDHELP

Page 12: Espionage Codebreaking: Mathematics of

Cryptography PreprocessingWords are then typically converted to strings of number using the following scheme.

Page 13: Espionage Codebreaking: Mathematics of

Historical Overview

Page 14: Espionage Codebreaking: Mathematics of

Historical Overview

Page 15: Espionage Codebreaking: Mathematics of

Substitution CiphersA substitution cipher is a method of encrypting by which units of plaintext are replaced with ciphertext, according to a fixed system. We will consider the following three examples.● Pigpen Cipher● Atbash Cipher● Caesar Cipher

Page 16: Espionage Codebreaking: Mathematics of

Pigpen Cipher

Page 17: Espionage Codebreaking: Mathematics of

Pigpen Cipher1. Encrypt a message using the Pigpen cipher and

trade with a partner to decrypt their message.2. How could you figure out a message said if you

did not know the key?3. Do you think the Pigpen cipher provides a secure

way to send secret messages? How could you make it more secure?

Page 18: Espionage Codebreaking: Mathematics of

Atbash Cipher

A B C D E F G H I J K L M

Z Y X W V U T S R Q P O N

Page 19: Espionage Codebreaking: Mathematics of

Atbash Cipher1. Encrypt a message using the Atbash cipher and

trade with a partner to decrypt their message.2. How could you figure out a message said if you

did not know the key?3. Do you think the Atbash cipher provides a secure

way to send secret messages? Why or why not? How could you make it more secure?

Page 20: Espionage Codebreaking: Mathematics of

Caesar Cipher

Page 21: Espionage Codebreaking: Mathematics of

Caesar Cipher1. Create a cipher wheel.2. Encrypt a message using the Caesar cipher and trade with a partner

to decrypt their message (do not give them the key).3. How many different Caesar ciphers are there?4. Shifting by 29 is the same as shifting by what? Shifting by 37 is the

same as shifting by what? What is the relationship between these numbers?

5. What happens when you do a Caesar cipher more than once?6. Do you think the Caesar cipher provides a secure way to send

secret messages? Why or why not? How could you make it more secure?

Page 22: Espionage Codebreaking: Mathematics of

Caesar Cipher● There are 26 distinct Caesar ciphers.

● Shifting by 29 is the same as shifting by 3 and shifting by 37 is the same as shifting by 11.

● If you do the Caesar cipher more than once, you simply add the keys together.

Page 23: Espionage Codebreaking: Mathematics of

Substitution Cipher

Page 24: Espionage Codebreaking: Mathematics of

Substitution Cipher1. Encrypt a message using a substitution cipher and trade with a partner to

decrypt their message.2. Are all Caesar ciphers also substitution ciphers? Are all substitution ciphers

also Caesar ciphers?3. How many different substitution ciphers are there?4. If a bad guy could test each substitution cipher in 1 second, what is the longest

amount of time it would take them to figure out what your message was?5. How many substitution ciphers would a bad guy have to test per second to

figure out the message to test all possible ciphers in 1 hour? Do you think this is possible?

6. Do you think substitution ciphers provide a secure way to send secret messages? Why or why not?

Page 25: Espionage Codebreaking: Mathematics of

Substitution Cipher● A Caesar cipher is a substitution cipher, but a substitution

cipher is not necessarily a Caesar cipher.

● There are 26! = 4.0329146✕1026 different substitution ciphers.

● It would take 1.2788288✕1019 years.

● They would have to test 1.1202541 ✕ 1023 per second.

Page 26: Espionage Codebreaking: Mathematics of

Lunch

Page 28: Espionage Codebreaking: Mathematics of

Vigenere Cipher

Page 29: Espionage Codebreaking: Mathematics of

Vigenere Cipher

Page 30: Espionage Codebreaking: Mathematics of

Vigenere Cipher1. Encrypt a message using the Vigenere cipher and trade with a

partner to decrypt their message.2. Which cipher is more secure, the Caesar cipher or the Vigenere

cipher? Explain.3. How many possible Vigenere ciphers with a keyword of length 3

are there? Length 4? Length 5?4. Give an example of a Vigenere cipher that will give the same result

as using a Caesar cipher with 13 as the key.5. Suppose LETSGOPACK was encrypted using a Vigenere cipher

and the result was YGLMTQHUPM. What keyword was used?

Page 31: Espionage Codebreaking: Mathematics of

Vigenere Cipher● Vigenere cipher is more secure, since it is polyalphabetic.

● There are 263 = 17,576 keywords of length 3, 264 = 456,976 keywords of length 4, and 265 = 11,881,376 keywords of length 5.

● N, NN, NNN, etc. would all result in shifting every letter 13.

● The keyword NCSU was used.

Page 32: Espionage Codebreaking: Mathematics of

Introduction to Binary

Page 33: Espionage Codebreaking: Mathematics of

Introduction to Binary1. Using the cards provided, represent the following

numbers.2. Represent your age, the day you were born, and

your shoe size using using the cards provided.3. What is the largest number you can represent

with five cards? Can you represent all whole numbers smaller than this number?

Page 34: Espionage Codebreaking: Mathematics of

Introduction to BinaryThe largest number you can represent with 5 cards is 31 and each number less than 31 can also be represented using the cards.

Page 35: Espionage Codebreaking: Mathematics of

Expanded Decimal NotationHow can we write the number 723 in expanded decimal notation?

Page 36: Espionage Codebreaking: Mathematics of

Expanded Decimal NotationHow can we write the number 723 in expanded decimal notation?

723 = 7 ✕ 102 + 2 ✕ 101 + 3 ✕ 100

Page 37: Espionage Codebreaking: Mathematics of

Decimal to Binary

Page 38: Espionage Codebreaking: Mathematics of

Binary to Decimal

Page 40: Espionage Codebreaking: Mathematics of

Binary AlphabetAs a class, will will convert the numbers 0 through 25 to binary so that we have a binary alphabet.

0 1 2 3 4 5 6 7 8 9 10 11 12

13 14 15 16 17 18 19 20 21 22 23 24 25

Page 41: Espionage Codebreaking: Mathematics of

Binary AlphabetAs a class, will will convert the numbers 0 through 25 to binary so that we have a binary alphabet.

0 1 2 3 4 5 6 7 8 9 10 11 12

00000 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100

13 14 15 16 17 18 19 20 21 22 23 24 25

01101 01110 01111 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001

Page 42: Espionage Codebreaking: Mathematics of

Logical Operators

AND OR XOR

Page 43: Espionage Codebreaking: Mathematics of

XORWe typically use exclusive or in our everyday language. For example, if your meal comes with soup or salad, that means you either get soup or salad, but not neither soup or salad or not both soup and salad.

Page 44: Espionage Codebreaking: Mathematics of

XORXOR (exclusive or) is an operation, ⨁, between the numbers 1 and 0 with the following properties.

● 1 ⨁ 1 = 0● 1 ⨁ 0 = 1● 0 ⨁ 0 = 0

Page 45: Espionage Codebreaking: Mathematics of

XOR CipherWe can encrypt using the XOR cipher similar to how the Vigenere cipher works. Let’s say we wanted to encrypt the message DOG using the key 101101110111101.

Page 46: Espionage Codebreaking: Mathematics of

XOR CipherFirst we need to convert DOG to binary by converting each letter to its respective binary representation.

D → 3 → 00011O → 14 → 01110G → 6 → 00110

So, DOG can be represented as 000110111000110.

Page 47: Espionage Codebreaking: Mathematics of

XOR CipherWe then use the XOR operations between our plaintext and the key.

How would we decrypt this message?

0 0 0 1 1 0 1 1 1 0 0 0 1 1 0

⨁ 1 0 1 1 0 1 1 1 0 1 1 1 1 0 1

1 0 1 0 1 1 0 0 1 1 1 1 0 1 1

Page 48: Espionage Codebreaking: Mathematics of

XOR CipherWe decrypt the ciphertext by using the XOR operation again between the ciphertext and the key.

Why does this work?

1 0 1 0 1 1 0 0 1 1 1 1 0 1 1

⨁ 1 0 1 1 0 1 1 1 0 1 1 1 1 0 1

0 0 0 1 1 0 1 1 1 0 0 0 1 1 0

Page 49: Espionage Codebreaking: Mathematics of

XOR Cipher1. Encrypt a message using the XOR cipher and

trade with a partner to decrypt their message.2. How are the XOR and Vigenere ciphers similar?

How are they different?3. How many keys of length 3 are there? Length 4?

Length 5?4. What would happen if you used the same key

2017 times? 2018 times?

Page 50: Espionage Codebreaking: Mathematics of

XOR Cipher● The XOR and Vigenere ciphers are both polyalphabetic, but

the XOR cipher has less possible keys.

● There are 23 = 8 keys of length 3, 24 = 16 keys of length 4, and 25 = 32 keys of length 5.

● Using the same key 2017 times would be the same as encrypting once and using the same key 2018 times would result in the plaintext.

Page 51: Espionage Codebreaking: Mathematics of

Transposition CiphersA transposition cipher is a method of encryption by which the positions held by units of plaintext are shifted according to a regular system. We will consider the following three examples.● Column Transposition● Rail Fence Cipher● Route Cipher

Page 52: Espionage Codebreaking: Mathematics of

Column TranspositionWEAREDISCOVEREDFLEEATONCEQKJEU

↓EVLNEWIREEESEAQACDTKDEECUROFOJ

1 2 3 4 5 6

W E A R E D

I S C O V E

R E D F L E

E A T O N C

E Q K J E U

5 1 2 3 6 4

E W E A D R

V I S C E O

L R E D E F

N E A T C O

E E Q K U J

Page 53: Espionage Codebreaking: Mathematics of

Column Transposition1. Encrypt a message using the column

transposition cipher and trade with a partner to decrypt their message.

2. How could you figure out a message said if you did not know the key?

3. How many possible keys are there if 3 columns are used? 4 columns? 5 columns?

Page 54: Espionage Codebreaking: Mathematics of

Column TranspositionThere are 3! = 6 keys for 3 columns, 4! = 24 keys for 4 columns, and 5! = 120 keys for 5 columns.

Page 55: Espionage Codebreaking: Mathematics of

Rail Fence Cipher

DNETLEEDHESWLXFTAAX

D . N . . . E . . . T . . . L . .

. E . E . D . H . E . S . W L . X .

. . F . . . T . . . A . . . A . . . X

Page 56: Espionage Codebreaking: Mathematics of

Rail Fence Cipher1. Encrypt a message using the rail fence cipher and

trade with a partner to decrypt their message.2. How could you figure out a message said if you

did not know the key?3. Do you think the rail fence cipher provides a

secure way to send secret messages? How could you make it more secure?

Page 57: Espionage Codebreaking: Mathematics of

Route CipherWEAREDISCOVEREDFLEEATONCEJX

↓EJXCTEDECDAEWRIORFEONALEVSE

W R I O R F E O E

E E S V E L A N J

A D C E D E T C X

Page 58: Espionage Codebreaking: Mathematics of

Route Cipher1. Encrypt a message using the route cipher and

trade with a partner to decrypt their message.2. How could you figure out a message said if you

did not know the key?3. Which cipher is more secure, the route cipher, the

rail fence cipher, or the column transposition cipher?

Page 59: Espionage Codebreaking: Mathematics of

Scytale

Page 60: Espionage Codebreaking: Mathematics of

Scytale1. Encrypt a message using a scytale and trade with

a partner to decrypt their message.2. How could you figure out a message said if you

did not know the key?3. Do you think encrypting messages using a

scytale is secure? How could you make it more secure?

Page 61: Espionage Codebreaking: Mathematics of

Create a Cipher1. Create your own cipher that can be used to send

and receive secret messages.2. Is your cipher secure? Would you use it to send

private information? 3. Can your cipher be represented mathematically?4. How would explain your cipher to someone (who

knows nothing about cryptography) over the phone?

Page 62: Espionage Codebreaking: Mathematics of

Cipher Presentations

Page 63: Espionage Codebreaking: Mathematics of

Playfair Cipher

Page 64: Espionage Codebreaking: Mathematics of

Playfair Cipher1. Encrypt a message using the Playfair cipher and

trade with a partner to decrypt their message.2. How could you figure out a message said if you

did not know the key?3. Do you think the Playfair cipher provides a

secure way to send secret messages? How could you make it more secure?

Page 65: Espionage Codebreaking: Mathematics of

Steganography

Page 66: Espionage Codebreaking: Mathematics of

Certificates and Evaluation1. Fill out the evaluation for Duke TIP.2. Write down what you liked and didn’t like about

the class on a blank sheet of paper.3. Receive your certificate.4. Celebrate!