Professional Documents
Culture Documents
14 Applications of Number Theory
14 Applications of Number Theory
Theory
CS 202
Epp section 10.4
Aaron Bloomfield
Let n = 105
Iteration 1: a = 92: 92104 mod 105 = 1
Iteration 2: a = 84: 84104 mod 105 = 21
Therefore, 105 is composite
Let n = 101
Source: http://en.wikipedia.org/wiki/Fermat_primality_test
10
RSA
Stands for the inventors: Ron Rivest, Adi Shamir
and Len Adleman
Three parts:
Key generation
Encrypting a message
Decrypting a message
11
The number of
bits of the prime
14
15
16
18
We choose e = 85
85 = 5*17
gcd (85, 10176) = 1
Thus, 85 and 10176 are relatively prime
20
We choose d = 4669
4669*85 mod 10176 = 1
http://www.cs.virginia.edu/cgi-bin/cgiwrap/asb/modpow
21
Result: 4669
22
23
The keys
We have n = p*q = 10379, e = 85, and d = 4669
The public key is (n,e) = (10379, 85)
The private key is (n,d) = (10379, 4669)
Thus, n is not private
Only d is private
24
Encrypting messages
To encode a message:
1. Encode the message m into a number
2. Split the number into smaller numbers m < n
3. Use the formula c = me mod n
m.modPow (e, n)
Where the object m is the BigInteger to encrypt
25
String is Go Cavaliers!!
Modified ASCII codes:
2.
41 81 02 37 67 88 67 78 75 71 84 85 03 03
3.
Encrypted message:
26
is c = me mod n
27
Decrypting messages
1. Use the formula m = cd mod n on each number
2. Split the number
character numbers
into
individual
ASCII
28
Encrypted message:
1.
2.
3.
41 81 02 37 67 88 67 78 75 71 84 85 03 03
41 81 02 37 67 88 67 78 75 71 84 85 03 03
modPow computation
1. How to compute c = me mod n or m = cd mod n?
Other means:
m = cd mod n
c = me mod n
Thus,
med m (mod p)
med m (mod q)
31
Cracking a message
In order to decrypt a message, we must compute m = cd
mod n
n is known (part of the public key)
c is known (the ciphertext)
e is known (the encryption key)
32
Signing a message
Recall that we computed:
d*e mod (p-1)(q-1) = 1
Note that d and e are interchangable!
You can use either for the encryption key
34
Signing a message
To sign a message:
1. Write a message, and determine the MD5 hash
2. Encrypt the hash with your private (encryption) key
3. Anybody can verify that you created the message
because ONLY the public (encryption) key can
decrypt the hash
4. The hash is then verified against the message
35
36
37
38
Man-in-the-middle attack:
Normal RSA communication
What is your public key?
My public key is 12345
What is your public key?
My public key is 67890
Heres message encrypted with 12345
Heres a response encrypted with 67890
39
40
Elliptic curves
41
Quantum computers
A quantum computer could (in principle) factor n in
reasonable time
This would make RSA obsolete!
Shown (in principle) by Peter Shor in 1993
You would need a new (quantum) encryption algorithm to encrypt your
messages
Sources
Wikipedia article has a lot of info on RSA and the
related algorithms
Those articles use different variable names
Link at http://en.wikipedia.org/wiki/RSA
43