creating secret messages. 2 why do we need to keep things secret? historically, secret messages were...

22
Creating Secret Messages

Post on 19-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

Creating Secret Messages

Page 2: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

2

Why do we need to keep things secret?

Historically, secret messages were used in wars and battles

For example, the Enigma cipher in WW2 Computers are nowadays used to store

lots of information about us The recent “lost CDs in the post” contained data that was not kept secret

Also need to make sure that online purchases are secure

Page 3: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

3

Terminology

Cryptography: study of creating secret codes

Plaintext: the original message Ciphertext: the message after encryption Encryption: the process of creating a

ciphertext Decryption: reversing encryption Cipher: name often given to an encryption

Page 4: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

4

A tiny bit of history

Here’s some encryption methods: Caesar cipher: apparently used in 2nd

century AD by Julius Caesar Substitution cipher: a simple version

(using pairs of letters) was used in 4th century AD

Vignere cipher: devised in the 16th century

RSA: developed in 1977 by Rivest, Shamir and Adleman – still used today

Page 5: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

5

Keys

Many encryption methods use a key The key is used to create a ciphertext Different keys give different ciphertexts

Encryption

Ciphertext

Plaintext

Page 6: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

6

Keys again

However for many encryptions, the same key is used for encryption and decryption

These are called symmetric ciphers It is important to keep the key secret

Decryption

Ciphertext

Plaintext

Page 7: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

7

The Caesar Cipher

One of the oldest and simplest ciphers The key is a letter which tells you how

much to “shift” the letters in the plaintext by

‘A’ means shift 0 places, ‘B’ shift 1 place, etckey F H N U M J W

plaintext C I P H E R

key S U A H Z W J

Page 8: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

8

Problems with the Caesar Cipher

There are only 25 possible keys so we can simply display all the possible decryptions

We can reduce the number of possible keys further by using frequency analysis

We can also look at one and two letter words to help us decode the text

Methods for analysing the text can also be used with other ciphers

Page 9: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

9

Frequency Analysis

The values below give the average frequencies of letters in English

The most common letters are E,T,A and I. The values will differ for other languages

A B C D E F G H I

6.4% 1.4% 2.7% 3.5% 10.0% 2.0% 1.4% 4.2% 6.3%

J K L M N O P Q R

0.3% 0.6% 3.5% 2.0% 5.6% 5.6% 1.7% 0.4% 4.9%

S T U V W X Y Z Oth

5.6% 7.1% 3.1% 1.0% 1.8% 0.3% 1.8% 0.2% 16.6%

Page 10: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

10

Substitution Cipher

We replace (substitute) each letter in the plaintext with a different letter

This time the key is a table of replacements

To encrypt all texts, we need a key that contains 26 letters with no repeats

Plain C D E H I N P R S T YCipher X J L A Z E V K H O M

Page 11: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

11

Plain C D E H I N P R S T YCipher X J L A Z E V K H O M

An example

THIS SENTENCE IS ENCRYPTED

OAZH HLEOLEXL ZH LEXKMVOLJ

Page 12: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

12

Plain C D E H I N P R S T YCipher X J L A Z E V K H O M

Another example

DECRYPTED

JLXKMVOLJ

Page 13: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

13

Weaknesses

We can still do frequency analysis to help to guess of the letters

The key can be quite hard to remember but we can use a word or phrase at the beginning of the cipher key to help

What is the problem with doing this?

Plain A B C D E F G H I J KCipher C R Y P T A B D E F G

Page 14: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

14

Vignère Cipher For this a key word is used. We repeat the key word and each letter of

the key word acts a key for a Caesar cipher

Cannot do a frequency analysis on the cipher text

But it is possible to guess the length of the key and the key itself

K E Y K E Y K E Y K

Plain H E L L O W O R L D

Cipher

R I J V S U Y V J N

Page 15: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

15

Weaknesses and Keys

All the examples we have seen so far use the same key for encryption and decryption (called symmetric ciphers)

If we can guess the key then we can break the cipher

It is hard to keep the key secret An alternative method is to use different

keys for encryption and decryption – this is called a asymmetric cipher

Page 16: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

16

RSA

The RSA cipher uses two keys and is much more complicated then any of the ciphers we’ve seen so far

The key used for encryption is called the public key and the key used for decryption is called the private key (which is kept secret)

To make it hard to break, one of the keys needs to be around 600 digits (2048 bits)

Page 17: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

17

Modular Arithmetic

RSA encryption uses many different Maths techniques. One is called modular arithmetic.We write 10 (mod 6) to mean “give me the remainder when 10 is divided by 6”So 10 (mod 6) = 4 (because 10 = 6 × 1 + 4) 75 (mod 9) = 3 (75 = 9 × 8 + 3) 56 (mod 12) = 8 (56 = 12 × 4 + 8) 89 (mod 10) = 9 (89 = 10 × 8 + 9)

Page 18: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

18

Primes and Factoring

For RSA, we have to pick two prime numbers, let’s say p and q.

Remember a prime number has exactly two factors (so 2 and 3 are prime, but not 1 or 4)

We have to work out the product n of the two primes so n = p × q

To find p and q from n is hard – we would have to check all the (prime) numbers up to p or q. This is what makes RSA secure.

Page 19: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

19

Keys

We now pick a public key e We find a private key d such that:

d £ e = 1 (mod (p – 1)(q – 1)) (There’s a method called the extended

Euclidean algorithm which can find this) To encrypt a number (message) M we

doMe

To decrypt, we do Cd

Page 20: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

20

Example

Pick p = 7, q = 13 so n = 7 × 13 = 91 Pick e = 5 and then d = 29

Check 5 × 29 = 145 = (2 × 6 × 12) + 1 To encrypt the number 10, we do

105 (mod 91) = 10 × 10 × 10 × 10 × 10 (mod 91) = 82

To decrypt we do8229 (mod 91) = 10

Page 21: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

21

Comments on RSA

To make RSA fast we need to be able to find powers quickly – there are methods to help us do this

The strength on RSA relies on the fact that it is generally hard to factor a very large number

By using two keys, we can keep the private key secret

There are many other “public key” methods

Page 22: Creating Secret Messages. 2 Why do we need to keep things secret? Historically, secret messages were used in wars and battles For example, the Enigma

22

Conclusions

We have seen that there are many ways in which we can keep information secret

We need to keep the decryption keys secret – in a symmetric cipher this is very difficult

It is quite easy to break some ciphers by analysing the text

Good encryption methods rely on using lots of different Maths techniques