You are on page 1of 19

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 1 / 19

Modern Cryptography

Matt Valeriote

McMaster University

6/03/2017

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 2 / 19


Private Key Cryptography

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 3 / 19


Public Key Cryptography

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 4 / 19


Public Key Cryptography
Such a system was first proposed by Diffie and Hellman in 1976.

Rivest, Shamir, and Adelman (RSA) introduced in 1978 a workable


system.

RSA is the most popular public key cryptosystem in use today.


Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 5 / 19
Arithmetic Preliminaries

Prime Number: A number n is prime if its only divisors are 1 and n.


Examples: 2, 3, 5, 7, 11, 13, 17, . . .
Fact #1: There are an infinite number of primes.
Fact #2: Every number can be factored as a product of prime numbers.
Example: 120 = 2 · 2 · 2 · 3 · 5.

Challenges
Which of the following are primes?

34, 51, 101, 1, 273

Factor the following numbers:

2, 310, 13, 013, 11, 663, 12, 119

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 6 / 19


Arithmetic Preliminaries

Answers
Only 101 is prime.

34 = 2 · 17, 51 = 3 · 17, 1273 = 19 · 67

2, 310 = 2 · 3 · 5 · 7 · 11,
13, 013 = 7 · 11 · 13 · 13,
11, 663 = 107 · 190,
12,119 is prime.

Two numbers are said to be relatively prime if they have no common prime
divisors, e.g. 6 and 35 are relatively prime.
The greatest common divisor (gcd) of two numbers is the largest number
that divides into both of them. The gcd of 60 and 42 is 6.

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 7 / 19


How Difficult is it?

We all know how to quickly and efficiently add, subtract, multiply, and
divide any two numbers.
Fact #3: There is a fast way to find the greatest common divisor of two
numbers (Euclidean method).
Fact #4: There is a fast way to to test if a number is prime (AKS method)
and to generate large primes.
Fact #5: There is no known fast way to factor large numbers.

It is surprisingly difficult!
A recent factoring speed record involved an international research team
factoring a 232-digit number. The team used hundreds of processors and
over 2 years of intensive work to factor the number. On a single fast PC, it
would have taken 1,500 years to factor the number.
Using current technology, it would take over 3 trillion years (more than 200
times the age of the universe) to factor a 620 digit number.

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 8 / 19


Clock Arithmetic

Example (What time is it?)


Suppose that the current time is 9 o’clock. What time will it be in 4 hours?
Answer: 9 + 4 = 13 o’clock, but we reduce by 12 to get the answer 1
o’clock.
More formally, 9 + 4 ≡ 1 mod 12.
Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 9 / 19
Modular Arithmetic

Definition (Modular Addition and Multiplication)


Let a, b, r , n be natural numbers with r < n.
Two natural numbers a and b are congruent modulo n, written
a ≡ b mod n if (a − b) is a multiple of n.
For example, 13 ≡ 1 mod 12, 38 ≡ 13 mod 5, 2 6≡ 5 mod 2.
The sum of a and b mod n is equal to r if a + b ≡ r mod n.
So, 2 + 3 ≡ 1 mod 2 and 25 + 102 ≡ 2 mod 5
The product of a and b mod n is equal to r if a · b ≡ r mod n.
So, 2 · 3 ≡ 0 mod 2 and 4 · 102 ≡ 3 mod 5

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 10 / 19


Modular Arithmetic

We can also define modular exponentiation in a similar manner.


For example, 23 ≡ 2 mod 3, 30010 ≡ 1 mod 11.
Fact #6: It is easy to compute ab modulo n.

Challenges
Compute the following:
33 mod 12. Since 33/12 has remainder 9 then 33 ≡ 9 mod 12.
99 mod 12
123 + 456 mod 21
123 · 456 mod 21
215 mod 10
260 mod 10
887 mod 187.

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 11 / 19


Modular Arithmetic

Answers
Compute the following:
99 ≡ 3 mod 12 (since 99/12 has remainder 3).
123 + 456 ≡ 12 mod 21 (123 + 456 = 579 and 579/21 has remainder 12).
(alternate) 123 ≡ 18 mod 21 and 456 ≡ 15 mod 21, so
123 + 456 = 18 + 15 = 33 ≡ 12 mod 21.
123 · 456 ≡ 18 · 15 ≡ 270 mod 21 and 270 ≡ 18 mod 21.
215 = 32768 ≡ 8 mod 10
260 = 1152921504606846976 ≡ 6 mod 10.
(alternate) 230 = (215 )(215 ) ≡ 8 · 8 = 64 ≡ 4 mod 10 and so
260 = (230 )(230 ) ≡ 4 · 4 = 16 ≡ 6 mod 10
887 ≡ 11 mod 187.

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 12 / 19


RSA Step #1: Key Generation

Alice’s Keys
Select two large prime numbers p and q at random.
Compute the system modulus n = p · q and m = (p − 1)(q − 1).
Choose at random a number e with 1 < e < m that is relatively prime to m.
Find a number d with e · d ≡ 1 mod m and with 0 ≤ d < m.
Alice’s Public Encryption Key is the pair (e, n).
Alice’s Private Decryption Key is the triple (d , p, q ).

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 13 / 19


Step #2: Encrypting Bob’s message to Alice

The Encryption Algorithm


Suppose that Bob wants to securely send to Alice a text message.
First, he digitizes it according to some simple method.
For example, each letter could be represented by a number between 01
and 26 (and “space” as 00).
The message “hello alice” is digitized as M = 0805121215000112090305.
Bob computes the number y < n such that M e ≡ y mod n and sends y to
Alice.
Note: for this to work, M must be less than n.
Since Alice has published her public key, then Bob (or anyone else) can
securely send a message to Alice using this method.

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 14 / 19


Step #3: Decrypting Bob’s message

The Decryption Algorithm


Once Alice has received Bob’s encrypted message y she can use her
private key to decrypt the message.
The decrypted message is equal to y d modulo n, i.e., M ≡ y d mod n.

Correctness of the RSA cryptosystem


Euler’s Theorem can be used to prove that when one computes y d mod n, then
the answer will be M, the original message.

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 15 / 19


A Simple Example

Suppose that Alice selects the prime numbers p = 17 and q = 11.


Then n = 187 and m = (17 − 1)(11 − 1) = 160 = (25 )(5).
The number e = 7 is relatively prime to 160 (any odd number less than
160 that is not a multiple of 5 would work).
Find the number d < 160 with d · e ≡ 1 mod 160. d = 23 works (since
23 · 7 = 161 ≡ 1 mod 160).
Alice’s public key is (7, 187).
Her private key is (23, 17, 11).

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 16 / 19


A Simple Example, Continued

Suppose that Bob wants to securely send the number M = 88 to Alice


using her public key (7, 187).
He computes M e mod n or 887 mod 187. 887 ≡ 11 mod 187.
Bob sends the number y = 11 to Alice.
To decrypt Bob’s message, Alice uses her private key (23, 17, 11) to
compute y d mod n, or 1123 mod 187.
The answer is 88!!!

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 17 / 19


How to break the RSA system

Suppose that Eve has intercepted the number y , Bob’s encrypted


message to Alice.
Eve also knows Alice’s public key (e, n) (since everyone does).
If Eve could find the prime factors of n, namely p and q, then she could
easily compute the number d since she already knows the number e and
she can compute m = (p − 1)(q − 1).
Once Eve has computed d, then she can decrypt the message M that
Bob sent to Alice by computing y d mod n.
So if Eve has a fast method for factoring very large numbers, then she can
easily decrypt messages sent using the RSA cryptosystem.

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 18 / 19


Conclusion

The RSA system is the most popular crypto system and is used to secure
internet traffic and other forms of communication.
Using present technology, keys consisting of 600 digits are considered
secure.
As technology advances, it is easy to maintain security by increasing key
sizes.
The discovery of a fast method for factoring large numbers will make the
RSA system obsolete.
A big open problem in mathematics/computer science is whether or not
there is a fast factoring method.
Warning: If private keys are not managed properly, then any system,
including RSA, is not very useful.

Matt Valeriote (McMaster University) Modern Cryptography 6/03/2017 19 / 19

You might also like