Sei sulla pagina 1di 5

Discrete Mathematics 2003

Lecture 37, 22-October-2003

Introduction
Last lecture we looked at secret key encryption We will now look at public key encryption Before describing this method, well introduce some elementary concepts in number theory (which is the study of the natural nos 1, 2, 3, ) A natural number p other than 1 is prime if its only positive divisors are 1 and p Thus the primes are 2, 3, 5, 7, 11, 13, 17, 19, Two natural nos are coprime (or relatively prime) if they have no common factor other than 1 i.e. if no number other than 1 divides into both nos Thus 4 & 7 are coprime, but 9 & 12 are not 1

Modulo Arithmetic
If a and m are natural nos, the expression a mod m means the remainder when a is divided by m Thus 3 mod 2 = 1, 5 mod 7 = 5, 20 mod 4 = 0, 20 mod 7 = 6, 55 mod 20 = 15, etc a mod m is read as a modulo m An important property of modulo arithmetic is: (a b) mod m = [(a mod m) (b mod m)] mod m This can be used to evaluate c mod m, if c is a large number that can be factored into a b
2

Example of Modulo Arithmetic


Example: 300 mod 14 can be found by 2 methods Method 1: Divide 14 into 300, and see what the remainder is Method 2: Since 300 = 30 10, then 300 mod 14 = [(30 mod 14) (10 mod 14)] mod 14 = (2 10) mod 14 = 20 mod 14 =6 Note that the 2nd method doesnt require any 3 complicated division of numbers

Discrete Mathematics 2003

Lecture 37, 22-October-2003

More Examples of Modulo Arithmetic


Since 300 = 20 15, the 2nd method can be applied in another way: 300 mod 14 = [(20 mod 14) (15 mod 14)] mod 14 = (6 1) mod 14 = 6 mod 14 = 6 (as before!) Example: Find 211 mod 7 without calculating 211 Soln: Use 211 = 23 23 23 22 = 8 8 8 4 Now, 8 mod 7 = 1 and 4 mod 7 = 4, so 211 mod 7 = (1 1 1 4) mod 7 = 4 mod 7 = 4
4

Modulo Arithmetic (continued)


Exercise: Find 211 mod 7 by using 211 = 25 25 21 Example: Find 58 mod 23 Solution: 58 = 52 52 52 52 = 25 25 25 25, so 8 5 mod 23 = (2 2 2 2) mod 23 = 16 mod 23 = 16 Exercise: Use shortcuts to find (a): 800 mod 17 (b): 410 mod 9
5

Privacy with Public Key Encryption


In public key encryption there are 2 types of keys a private key & a public key The private key is kept by the receiver The public key is announced by the receiver to anyone who wants it (e.g. the sender of the message or anyone else!) Thus there are no security issues associated with the distribution of keys When A wants to send a message to B, A encrypts the message using Bs public key B decrypts the message using their private key
6

Discrete Mathematics 2003

Lecture 37, 22-October-2003

Diagram of Public Key Encryption

(Diagram from Foundations of Computer Science by Behrouz A. Forouzan, Brooks/Cole, 2003, p. 309)
7

Public Key Encryption (cont)


In public key encryption, the encryption & decryption algorithms are not the inverse of each other An intruder who gains access to the encrypted message will know the encryption & decryption algorithms, and the public key However, in practice, they will be unable to decipher the message in a realistic time frame without knowing the private key
8

The RSA Algorithm


The most common public key encryption method in use today is known as the RSA algorithm For example, encryption methods based on the RSA algorithm are used by web browsers such as Internet Explorer (see the next slide for the About Internet Explorer window) The term RSA refers to the names of the developers (in 1977) of the algorithm, Ronald Rivest, Adi Shamir & Leonard Adleman We will describe how the algorithm works a description is also given (but using slightly more technical language) on pages 236-8 of the text 9

Discrete Mathematics 2003

Lecture 37, 22-October-2003

Key Generation for RSA


1. A key centre (which generates & distributes keys) chooses 2 distinct large prime nos p & q, and multiplies them: n = pq. (In practice, p & q are very large, e.g. 100-200 decimal digits each) 2. The number m = (p 1)(q 1) is then calculated 3. A natural number x (between 1 and m) is chosen so that x & m are coprime 4. Then the centre computes an integer y so that xy = 1 mod m. (y can be found using a method known as the Euclidean algorithm that can be performed very efficiently on a computer) 5. The participant gets the 2 nos x & n as their public key, & the nos y & n as their private key 11

Sending Messages with RSA


Once a participant has their public & private keys, they receive a message as follows: 1. The sender obtains the receivers public key 2. The message to be encrypted is converted to a string of bits by the sender, broken into substrings of the same length, then each substring (which is an integer a that must be < n) is encrypted using the formula C = ax mod n. Here C is the number which represents the ciphertext version of the plaintext a.
12

Discrete Mathematics 2003

Lecture 37, 22-October-2003

Sending Messages with RSA (cont)


3. The receiver then deciphers each ciphertext character C back to a plaintext character P by P = C y mod n. This formula requires knowledge of the private key, which is known only to the receiver. Example of Key Generation: Generate public & private keys based on the prime nos p = 3, q = 11. (Select x = 3 as a number coprime with m.) Example of Sending a Message: Use the keys just found to encrypt the message i (which corresponds to the no. 9), then show the correct message is recovered after decryption 13

Potrebbero piacerti anche