Download presentation
Presentation is loading. Please wait.
Published byKelley Jefferson Modified over 8 years ago
1
CS/COE 1501 Recitation RSA Encryption/Decryption Extended Euclidean Algorithm Digital Signatures
2
Say Alice wants to send a message to Bob 1.Looks up Bob’s public key 2.Convert the message into an integer: m 3.Compute the ciphertext c as: c = m e (mod n) 4.Send c to Bob RSA Encryption
3
Bob can simply: 1.Compute m as: 2.m = c d (mod n) 3.Convert m into Alice’s message RSA Decryption
4
What are public/private keys? How messages encrypted? How are messages decrypted? How are keys generated? Why is it secure? RSA Cryptosystem
5
What are public/private keys? Public Key = (e, n) Private Key = (d, n) How messages encrypted? c = m e (mod n) How are messages decrypted? m = c d (mod n) How are keys generated? RSA Cryptosystem
6
How are keys generated?
7
1. Choose two prime number p and q p=3, q=11 2. Compute n = p * q n=3*11=33 3. Compute φ(n) φ(n) = φ(p) * φ(q) = (p - 1) * (q - 1) φ(n)=(3-1)*(11-1)=20 4. Choose e such that 1 < e < φ(n), GCD(e, φ(n)) = 1 i.e., e and φ(n) are co-prime We can choose e=3, verify that 1<3< φ(n) =20, 3 and 20 are co- prime An Example
9
Encryption: c = m e (mod n) Decryption: m = c d (mod n) Public Key=(e,n)=(3,33) Private Key=(d,n)=(7,33) Alice said “hello” 7, 4, 11, 11, 14 Encrypt msg: 7 3 mod 33, 4 3 mod 33, 11 3 mod 33, 11 3 mod 33, 14 3 mod 33 Encrypted msg: 13, 31, 11, 11, 5 An Example
10
Encryption: c = m e (mod n) Decryption: m = c d (mod n) Public Key=(e,n)=(3,33) Private Key=(d,n)=(7,33) Bob receive 13, 31, 11, 11, 5 Decrypt msg: 13 7 mod 33, 31 7 mod 33, 11 7 mod 33, 11 7 mod 33, 5 7 mod 33 Decrypt msg: 7, 4, 11, 11, 14 -> ‘hello’ An Example
11
Challenges
12
d = e -1 mod(φ(n)) Means that d = 1/e mod(φ(n)) Means that e * d = 1 (mod φ(n)) Now, this can be equivalently stated as e * d = z * φ(n) + 1 For some z Can further restate this as: e * d - z * φ(n) = 1 Or similarly: 1 = φ(n) * (-z) + e * d How can we solve this? Hint: recall that we know GCD(φ(n), e) = 1 Determine d
13
GCD(a, b) = i = as + bt Let: a = φ(n) b = e s = -z t = d i = 1 GCD(φ(n), e) = 1 = φ(n) * (-z) + e * d We can compute d in linear time! Determine d
14
Extended Euclidean Algorithm
15
We know GCD(a,b)=GCD(b, a%b) Suppose we are computing the GCD(a,b) a*x + b*y = gcd Suppose we already know the GCD(b, a %b), and we find x 1 and y 1 b*x 1 +(a%b)*y 1 =gcd Associate the two formular a%b=a-(a/b)*b gcd= b*x 1 +(a-(a/b)*b)*y 1 = b*x 1 +a*y 1 -(a/b)*b*y 1 = a*y 1 +b*(x 1 -a/b*y 1 ) x=y 1 y=x 1 -a/b*y 1 Extended Euclidean Algorithm
16
public static int[] ExtendedEuclid(int a, int b) { int[] ans = new int[3]; int q; if (b == 0) { /* If b = 0, then we're done... */ ans[0] = a; ans[1] = 1; ans[2] = 0; } else { /* Otherwise, make a recursive function call */ q = a/b; ans = ExtendedEuclid (b, a % b); int temp = ans[1] - ans[2]*q; ans[1] = ans[2]; ans[2] = temp; } return ans; } Extended Euclidean Algorithm
17
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978 2 3 4 5 6
18
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781 2 3 4 5 6
19
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 2 3 4 5 6
20
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 2 3 4 5 6
21
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821 3 4 5 6
22
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 278213 3 4 5 6
23
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 3 4 5 6
24
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 32115 4 5 6
25
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 321151 4 5 6
26
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 3211516 4 5 6
27
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 3211516 4 6 5 6
28
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 3211516 4 62 5 6
29
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 3211516 4 623 5 6
30
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 3211516 4 623 563 6
31
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 3211516 4 623 5632 6
32
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 3211516 4 623 56320 6
33
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 3211516 4 623 56320 630
34
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 3211516 4 623 56320 630NaN
35
Extended Euclidean Algorithm
36
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 3211516 4 623 56320 630NaN
37
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 3211516 4 623 56320 630NaN 310
38
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 19978121 27821315 3211516 4 623 56320 630NaN 310
39
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163 4 6233 563203 630NaN 310
40
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163 4 6233 563203 630NaN 310
41
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163 4 6233 5632030 630NaN 310
42
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163 4 6233 5632030 630NaN 310
43
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163 4 6233 56320301 630NaN 310
44
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163 4 6233 56320301 630NaN 310
45
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163 4 6233 56320301 630NaN 310
46
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163 4 62331 56320301 630NaN 310
47
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163 4 62331-2 56320301 630NaN 310
48
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163 4 62331-2 56320301 630NaN 310
49
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163 4 62331-2 56320301 630NaN 310
50
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163-2 41562331-2 56320301 630NaN 310
51
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163-23 41562331-2 56320301 630NaN 310
52
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163-23 41562331-2 56320301 630NaN 310
53
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 278213153 32115163-23 41562331-2 56320301 630NaN 310
54
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 2782131533 32115163-23 41562331-2 56320301 630NaN 310
55
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213 2782131533-11 32115163-23 41562331-2 56320301 630NaN 310
56
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213-11 2782131533-11 32115163-23 41562331-2 56320301 630NaN 310
57
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213-1114 2782131533-11 32115163-23 41562331-2 56320301 630NaN 310
58
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213-1114 2782131533-11 32115163-23 41562331-2 56320301 630NaN 310
59
Find the Bézout numbers and GCD of 99 and 78 Rowaba/ba%bdst 199781213-1114 2782131533-11 32115163-23 41562331-2 56320301 630NaN 310
60
Exercise
61
Hash Functions
62
For Crypto Hash Functions, Output Should Appear Random
63
Digital Signatures – Public Key Cryptography
64
Creating a Digital Signature
65
Digital Signatures Often Use Commutative Operations
67
Plaintext sent by sender
68
Digital Signatures Often Use Commutative Operations Plaintext sent by sender Cryptotext sent by sender using sender’s private key
69
Digital Signatures Often Use Commutative Operations Plaintext sent by sender Cryptotext sent by sender using sender’s private key Sender’s public key
70
Digital Signatures Often Use Commutative Operations Plaintext sent by sender Cryptotext sent by sender using sender’s private key Sender’s public key =
71
Digital Signatures Often Use Commutative Operations Plaintext sent by sender Cryptotext sent by sender using sender’s private key Sender’s public key = Plaintext recovered matches
72
Because Public-Key crypto can be computationally expensive, often the crypto operations are performed on the securely hashed version of the message rather than the original: Digital Signatures and Hashes
73
Because Public-Key crypto can be computationally expensive, often the crypto operations are performed on the securely hashed version of the message rather than the original: Digital Signatures and Hashes Received: HASH ALGORITHM
74
Because Public-Key crypto can be computationally expensive, often the crypto operations are performed on the securely hashed version of the message rather than the original: Digital Signatures and Hashes Received: HASH ALGORITHM
75
Because Public-Key crypto can be computationally expensive, often the crypto operations are performed on the securely hashed version of the message rather than the original: Digital Signatures and Hashes Received: HASH ALGORITHM Compute
76
Because Public-Key crypto can be computationally expensive, often the crypto operations are performed on the securely hashed version of the message rather than the original: Digital Signatures and Hashes Received: HASH ALGORITHM Compute =
77
Because Public-Key crypto can be computationally expensive, often the crypto operations are performed on the securely hashed version of the message rather than the original: Digital Signatures and Hashes Received: HASH ALGORITHM Compute = Match. Signature Verified.
78
Adam J. Lee’s slides from CS 1653 http://www.csee.umbc.edu/~chang/cs203.s09/exteuclid.shtml Acknowledgements
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.