1 codes, ciphers, and cryptography-ch 1 michael a. karls ball state university

29
1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

Upload: ann-harbour

Post on 14-Dec-2015

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

1

Codes, Ciphers, and Cryptography-Ch 1

Michael A. Karls

Ball State University

Page 2: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

2

Introduction

Throughout history, people have had the need to send messages to other people in secret!

Methods have been developed to disguise and break secret messages.

Page 3: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

3

Introduction (cont.)

Simon Singh has written The Code Book with two goals:

Chart the evolution of codes throughout history—just like an organism, codes evolve, with new ones being developed as old ones are broken! (Think of bacteria and antibiotics!)

Show the relevance of cryptography in the world today—the world relies on secure transmission of data to run smoothly (email, phone, cable TV, internet, online shopping, banking, military communication, law enforcement, intelligence gathering, etc.).

Page 4: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

4

Introduction (cont.)

In this course we will read and discuss Chapters 1-8 of Singh’s book and look at some of the mathematics related to cryptography, codes and ciphers!

Let’s start with some terminology.

Page 5: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

5

Definitions and Terminology

A code is a form of secret communication in which a word or phrase is replaced with a word, number, or symbol.

Example 1: A simple code for an army. “Attack at dawn” Jupiter. “The coast is clear” Tippy-toe. Each commander and soldier would have a copy

of the codes in some sort of codebook.

Page 6: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

6

Definitions and Terminology (cont.)

A cipher is a form of secret communication in which letters are replaced with a letter, number, or symbol.

Example 2: One example of a cipher is to replace each letter using the following scheme:

Plaintext: “attack at dawn” Ciphertext: “ZGGZXP ZG WZDM Send ciphertext as ZGG ZXP ZGW ZDM. Recipient would need to know how message was created.

Plaintext a b c d e f g h i j k l m n o p q r s t u v w x y z

Ciphertext Z Y X W V U T S R Q P O N M L K J I H G F E D C B A

Page 7: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

7

Definitions and Terminology (cont.)

Cryptography is the science of concealing the meaning of a message. It is also used to mean the science of anything connected with ciphers—an alternative to cryptology, which is the science of secret writing.

To encrypt a message, one conceals the meaning of the message via a code or cipher.

Similar definitions hold for encode and encipher. To decrypt a message, one turns an ecrypted message

back into the original message. Similar definitions hold for decode and decipher.

Page 8: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

8

Definitions and Terminology (cont.)

Remark: The words “cryptography” and “cryptology” come from the Greek words

(kryptos) “hidden” (logos) “word” or “reason” (graphia) “writing”

Page 9: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

9

Definitions and Terminology (cont.)

Steganography is the science of hiding the existence of a message.

“Steganography” also comes from Greek: (steganos) “covered” Both steganography and cryptography

were developed in parallel—examples of both have been found in the 5th century B.C.

Page 10: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

10

Examples of Steganography

Invisible ink (1st century A.D. – present): Use organic fluid such as lemon juice or milk to write a

message on paper. Heat the paper and the writing will turn brown. Hard-boiled eggs (16th century Italy): Mix alum and vinegar to make ink. Write on hard-boiled egg. Writing will penetrate shell and leave message on

hardened egg white surface!

Page 11: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

11

Examples of Steganography (cont.)

Square grid (grille) method (16th century Italy – 20th century)

Invented by Girolamo Cardano. Text is placed on a grid. Add in random letters to fill grid. To read message, put cover with

correct openings onto the grid. Variant: Use words instead of

letters and add in random words to fill in grid.

See Edgar Allen Poe’s article “A Few Words on Secret Writing’, Graham’s Magazine, July 1841, pp. 33-38.

    m e

  s    

s     a

  g e  

r c m e

w s t o

s k p a

b g e a

r c m e

w s t o

s k p a

b g e a

Page 12: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

12

Examples of Steganography (cont.)

Computer files (20th century – present) Add data to a file, such as a JPEG image (picture). Send via email or post to the internet on a web page. Message undetectable without appropriate software. Related idea: Watermarking is the addition of identifying information

into items such as checks. Digital watermarking is used to embed copyright information into

video, music, and text data. Note: Steganography is a great way to send a message

in secret—provided it is not found—then anyone can read the message!

Page 13: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

13

Cryptography!

We now look at cryptography—the main topic of Singh’s book (and of this course)!

Cryptography can be split into two branches—transposition ciphers and substitution ciphers.

A transposition cipher is a system of encryption in which the letters in a message are rearranged.

A substitution cipher is a system of encryption in which letters in a message are replaced with other letters or symbols.

Page 14: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

14

Examples of Transposition Ciphers

Scytale (“SITalee) (Sparta – 5th century)

Sender and receiver have batons of equal circumference.

Wrap a strip of leather around baton and write message along length of the baton.

Unroll the strip and carry! Question: How would one

decipher an intercepted scytale message?

Page 15: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

15

Examples of Transposition Ciphers (cont.) Turning Grille Method (Variant of Cardano’s

method above—used by German intelligence in South America in WWII).

Put text in an 8 x 8 grid, with 16 openings cut in an overlay grid.

When rotated 90o, 180o, 270o, all 64 spaces will be exposed exactly once.

Example from article by Stephen Fratini, Mathematics Magazine, Volume 75, #5, December 2002, pp. 389-391 (Handout).

Page 16: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

16

Examples of Substitution Ciphers

Caesar Cipher (1st Century B.C. – used by Julius Caesar to encrypt letters sent to Cicero).

Basic Idea: The cipher alphabet is the plain alphabet shifted n spaces right.

For example, if we take n = 14, we get:

Plaintext: “attack at dawn” Ciphertext: “OHHOQY OH ROKB”

Plaintext a b c d e f g h i j k l m n o p q r s t u v w x y z

Ciphertext O P Q R S T U V W X Y Z A B C D E F G H I J K L M N

Page 17: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

17

Examples of Substitution Ciphers (cont.) Keyword Cipher Use a keyword or phrase as the basis of the

encryption scheme. For example, let MATHEMATICS be the

keyword. Remove repeated letters in the keyword and add

in remaining letters of alphabet in order. MATHEMATICS MATHEICSPlaintext a b c d e f g h i j k l m n o p q r s t u v w x y z

Ciphertext M A T H E I C S B D F G J K L N O P Q R U V W X Y Z

Page 18: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

18

Examples of Substitution Ciphers (cont.) Rearrangement Cipher Rearrange letters of alphabet in any order. Thus, the Caesar and keyword ciphers are

special cases of the rearrangement cipher! Question: How many different rearrangement

ciphers are there? To answer this question, we need the

Fundamental Principle of Counting!

Page 19: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

19

Examples of Substitution Ciphers (cont.) Fundamental Principle of Counting (FPC): If there are n1 choices for item 1 n2 choices for item 2 … nm choices for item m then the number of ways to choose one of each

item is n1 x n2 x ... x nm.

Page 20: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

20

Examples of Substitution Ciphers (cont.) Example 3: How many outfits can I make

with 4 shirts, 3 pairs of pants, and 5 pairs of shoes?

# shirt choices: 4 # pants choices: 3 # shoe choices: 5 FPC => 4 x 3 x 5 = 60 outfits

Page 21: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

21

Examples of Substitution Ciphers (cont.) To figure out how many different rearrangement

ciphers there are, we can use FPC: # choices for ciphertext letter for a: 26 # choices for ciphertext letter for b: 25 … # choices for ciphertext letter for y: 2 # choices for ciphertext letter for z: 1 FPC => 26 x 25 x … x 2 x 1 = 26!, or about 4.03 x 1026

different ciphers

Page 22: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

22

Examples of Substitution Ciphers (cont.) Additive Cipher Using the idea of modular arithmetic, we can create a cipher! For any non-negative integers a and n, we define a mod

n to be the remainder when a is divided by n. Example 4: 18 mod 5 = 3, since 18 = 3 x 5 + 3 4 mod 7 = 4, since 4 = 0 x 7 + 4 28 mod 26 = 2, since 28 = 1 x 26 + 2 26 mod 13 = 0, since 26 = 2 x 13 + 0

Page 23: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

23

Examples of Substitution Ciphers (cont.) We can add and multiply numbers mod n too! Example 5: Find (27+15) mod 26 and (27 x 15) mod 26. 27+15 = 42 and 42 mod 26 = 16, so (27+15) mod 26 = 16 or 27 mod 26 = 1 and 15 mod 26 = 15, so (27+15) mod 26 = (1+15) mod 26 = 16 mod 26 = 16 27 x 15 = 405 and 405 mod 26 = 15, so (27 x 15) mod 26 = 15 or (27 x 15) mod 26 = (1 x 15) mod 26 = 15 mod 26 = 15

Page 24: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

24

Examples of Substitution Ciphers (cont.) To find (a+b) mod n: Add a to b, then find the resulting sum mod n, Or find a mod n, find b mod n, and add the

results mod n. Multiplication works in a similar fashion! Now we are ready to make an additive

cipher!

Page 25: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

25

Examples of Substitution Ciphers (cont.) First, assign 1, 2, …, 26 mod 26 to a, b, …, z. Next, choose a fixed integer m between 0 and 25. To get the ciphertext y from plaintext x, add m mod 26,

i.e., y = (x+m) mod 26. As an example, here is the additive cipher alphabet for

m=14.Plaintext a b c d e f g h i j k l m

Plaintext # 1 2 3 4 5 6 7 8 9 10 11 12 13

Ciphertext # 15 16 17 18 19 20 21 22 23 24 25 0 1

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

Plaintext n o p q r s t u v w x y z

Plaintext # 14 15 16 17 18 19 20 21 22 23 24 25 0

Ciphertext # 2 3 4 5 6 7 8 9 10 11 12 13 14

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

Page 26: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

26

Examples of Substitution Ciphers (cont.) Continuing the additive cipher example with m = 14, to encipher the

plaintext letter e, we do the following: e 5 (5+14) mod 26 = 19 mod 26 = 19 19 S Thus, plaintext e is enciphered as ciphertext S. To decipher ciphertext S, we add the additive inverse of 14 mod 26, which is

12: S 19 (19+12) mod 26 = 5 5 e Thus, ciphertext S is deciphered as plaintext e. Question: What does the additive cipher look like? Answer: Caesar cipher! (The Caesar cipher is also called the additive

cipher!)

Page 27: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

27

Notes on Ciphers

For any cipher there is an algorithm, which is a general encrypting method, and a key which specifies the exact details of the algorithm.

Example 6: For the Caesar cipher, Algorithm—shift the alphabet, Key—how many places to shift! Thus, there are 26 keys for this cipher.

Page 28: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

28

Notes on Ciphers (cont.)

The key must remain secure! If the key is found, the code will be broken. If the algorithm is known, the code can still be

secure! For a code or cipher, the greater the number of

keys, the greater the security!

Page 29: 1 Codes, Ciphers, and Cryptography-Ch 1 Michael A. Karls Ball State University

29

Notes on Ciphers (cont.)

The examples of substitution ciphers we’ve seen are called monoalphabetic substitution ciphers.

The systems we’ve seen are symmetric because sender and receiver must both know (have) the key.