Handout 7 PDF
Handout 7 PDF
1 Introduction
2 RSA
CSc 466/566 Algorithm
Example
Correctness
Computer Security Security
3 GPG
4 Elgamal
7 : Cryptography — Public Key Algorithm
Version: 2012/02/15 16:15:24
Example
Department of Computer Science
Correctness
University of Arizona Security
5 Diffie-Hellman Key Exchange
[email protected]
c 2012 Christian Collberg
Copyright
Diffie-Hellman Key Exchange
Example
Correctness
Christian Collberg Security
6 Summary
1/83 Introduction 2/83
1 Encrypt M = 6882326879666683.
2 Break up M into 3-digit blocks:
m = h688, 232, 687, 966, 668, 003i
1 Decrypt each block:
Note the padding at the end.
3 Encrypt each block: m1 = c1d mod n
= 15701019 mod 3337
c1 = m1e mod n
= 688
= 68879 mod 3337
= 1570
We get:
c = h1570, 2756, 2091, 2276, 2423, 158i
(3, n)
Show the result of encrypting M = 4 using the public key or
(e, n) = (3, 77) in the RSA cryptosystem. (16385, n)
as his RSA public key if he wants people to encrypt messages
for him from their cell phones.
As usual, n = pq, for two large primes, p and q.
What is the justification for Alice’s advice?
We have
C = M e mod n
M = C d mod n.
1 Generate an RSA key-pair using p = 17, q = 11, e = 7.
To show correctness we have to show that decryption of the
2 Encrypt M = 88.
ciphertext actually gets the plaintext back, i.e that, for all
3 Decrypt the result from 2. M<n
C d mod n = (M e )d mod n
= M ed mod n
= M
We have that
φ(n) = φ(pq) = φ(p)φ(q)
By Euler’s theorem we have that
Assume that M is not relatively prime to n, i.e. M has some
M kφ(n) mod q = M kφ(p)φ(q) mod q
factor in common with n, since M < n.
= (M kφ(p) )φ(q) mod q
There are two cases:
1 M is relatively prime with q and M = ip, or = 1
2 M is relatively prime with p and M = iq. Thus, for some integer h
We consider only the first case, the second is similar. M kφ(n) = 1 + hq
Multiply both sides by M
M · M kφ(n) = M(1 + hq)
M kφ(n)+1 = M + Mhq
✞ ☎
Name : RSA−640
http://www.rsa.com/rsalabs/node.asp?id=2093
Digits : 193
✞ ☎ 310741824 04 9 00 4 37 2 13 5 07 5 00 3 58 8 85 6 79 3 0 03 7 34 6 02 2 84 2 72 7 54 5 72 0 16 1 94 8 82
Name : RSA−576 320644051 80 8 15 0 45 5 63 4 68 2 96 7 17 2 32 8 67 8 2 43 7 91 6 27 2 83 8 03 3 41 5 47 1 07 3 10 8 50
Digits : 174 1919548529 0 07 3 37 7 2 48 2 27 8 35 2 57 4 23 8 64 5 40 1 46 9 17 3 66 0 24 7 76 5 23 4 66 0 9
188198812 92 0 60 7 96 3 83 8 69 7 23 9 46 1 65 0 43 9 8 07 1 63 5 63 3 79 4 17 3 82 7 00 7 63 3 56 4 22 ✝ ✆
988859715 23 4 66 5 48 5 31 9 06 0 60 6 50 4 74 3 04 5 3 17 3 88 0 11 3 03 3 96 7 16 1 99 6 92 3 21 2 05
7340318795 50 6 56 9 96 22 1 30 5 16 87 5 93 0 76 5 02 57 0 59
✝ ✆ The factoring research team of F. Bahr, M. Boehm, J. Franke,
T. Kleinjung continued its productivity with a successful
On December 3, 2003, a team of researchers in Germany and
factorization of the challenge number RSA-640, reported on
several other countries reported a successful factorization of
November 2, 2005.
the challenge number RSA-576.
The factors are:
The factors are ✞ ☎
✞ ☎ 1634733645 80 9 25 3 84 8 44 3 13 3 88 3 86 50 9 08 5 98 4 17 8 36 7 00 3 30
39807508642 4 06 4 93 7 39 7 12 55 0 05 5 03 8 64 91 1 99 0 64 3 62 9231218111 08 5 23 8 93 3 31 00 1 04 5 08 1 51 2 12 11 8 16 7 51 1 57 9
34252670840 6 38 5 18 95 7 59 4 63 88 9 57 2 61 7 68 58 3 31 7
1900871281 66 4 82 2 11 3 12 6 85 15 7 39 3 54 1 39 7 54 7 18 9 67 8 99 68
47277214610 7 43 5 30 2 53 6 22 30 7 19 7 30 4 82 24 6 32 9 14 6 95 5154936666 38 5 39 0 88 0 27 10 3 80 2 10 4 49 8 95 7 19 1 26 14 6 55 7 1
30209711645 9 85 2 17 11 3 05 2 07 11 2 56 3 63 5 90 39 7 52 7 ✝ ✆
✝ ✆
The effort took approximately 30 2.2GHz-Opteron-CPU years
according to the submitters, over five months of calendar time.
RSA 29/83 RSA 30/83
✞ ☎
Name : RSA−704
Digits : 212 ✞ ☎
740375634 79 5 61 7 12 8 28 0 46 7 96 0 97 4 29 5 7 31 4 25 9 31 8 88 8 92 3 12 8 90 8 49 3 62 3 2 63 8 97 Name : RSA−1536
276503402 82 6 62 7 68 9 19 9 64 1 96 2 51 1 78 4 3 99 5 89 4 33 0 50 2 12 7 58 5 37 0 11 8 96 8 0 98 2 86 Digits : 463
733173273 10 8 93 0 90 0 5 52 5 05 1 16 8 77 0 6 32 9 90 7 23 9 63 8 07 8 6 71 0 08 6 09 6 96 2 5 37 9 34 6 50 5 63 7 96 3 5 9 184769970 32 1 17 4 14 7 43 0 68 3 56 2 0 20 0 16 4 40 3 01 8 54 9 33 8 66 3 4 1 0 1 71 4 71 7 85 7 74 9 10 6 5 1
696711161 24 9 85 9 33 7 68 4 30 5 43 5 7 44 5 85 6 16 0 61 5 44 5 71 7 94 0 5 2 2 2 97 1 77 3 25 2 46 6 09 6 0 6
Name : RSA−768 469460712 49 6 23 7 20 4 42 0 22 2 69 7 5 67 5 66 8 73 7 84 2 75 6 23 8 95 0 8 7 6 4 67 8 44 0 93 3 28 5 15 7 4 9
Digits : 232 657884341 50 8 84 7 55 2 82 9 81 8 67 2 6 45 1 33 9 86 3 36 4 93 1 90 8 08 4 6 7 1 9 90 4 31 8 74 3 81 2 83 3 6 3
123018668 45 3 01 1 77 5 51 3 04 9 49 5 8 38 4 96 2 72 0 77 2 85 3 56 9 59 5 33 4 7 92 1 97 3 22 4 52 1 51 7 2 502795470 28 2 65 3 29 7 80 2 93 4 91 6 1 55 8 11 8 81 0 49 8 44 9 08 3 19 5 4 5 0 0 98 4 83 9 37 7 52 2 72 5 7 0
640050726 36 5 75 1 87 4 52 0 21 9 97 8 6 46 9 38 9 95 6 47 4 94 2 77 4 06 3 84 5 9 25 1 92 5 57 3 26 3 03 4 5 525785919 44 9 93 8 70 0 73 6 95 7 55 6 8 84 3 69 3 38 1 27 7 96 1 30 8 92 3 0 3 9 2 56 9 69 5 25 3 26 1 62 0 8 2
373154826 85 0 79 1 70 2 61 2 21 4 29 1 3 46 1 67 0 42 9 21 4 31 1 60 2 22 1 2 4 0 4 79 2 74 7 37 7 94 0 80 6 6 5 3676490316 03 6 55 1 37 14 4 79 1 39 3 23 47 1 69 5 66 9 88 06 9
351419597459 85 69 0 21 43 41 3
Name : RSA−2048
Name : RSA−896 Digits : 617
Digits : 270 251959084 75 6 57 8 93 4 94 0 27 1 83 2 4 00 4 83 9 85 7 14 2 92 8 21 2 62 0 4 0 3 2 02 7 77 7 13 7 83 6 04 3 6 6
412023436 98 6 65 9 54 3 85 5 53 1 36 5 3 32 5 75 9 48 1 79 8 11 6 99 8 44 3 2 7 9 8 28 4 54 5 56 2 64 3 38 7 6 4 202070759 55 5 62 6 40 1 85 2 58 8 07 8 4 40 6 91 8 29 0 64 1 24 9 51 5 08 2 1 8 9 2 98 5 59 1 49 1 76 1 84 5 0 2
455652484 26 1 98 0 98 8 70 4 23 1 61 8 4 18 7 92 6 14 2 02 4 71 8 88 6 94 9 2 5 6 0 93 1 77 6 37 5 03 3 42 1 1 3 808489120 07 2 84 4 99 2 68 7 39 2 80 7 2 87 7 76 7 35 9 71 4 18 3 47 2 70 2 6 1 8 9 63 7 50 1 49 7 18 2 46 9 1 1
098239748 51 5 09 4 49 0 91 0 69 1 02 6 9 86 1 03 1 86 2 70 4 11 4 88 0 86 6 9 7 0 5 64 9 02 9 03 6 53 6 58 8 6 7 650776133 79 8 59 0 95 7 00 0 97 3 30 4 5 97 4 88 0 84 2 84 0 17 9 74 2 91 0 0 6 4 2 45 8 69 1 81 7 19 5 11 8 7 4
4337317208 1 31 0 41 0 51 9 08 6 4 25 4 79 3 28 2 60 1 39 1 25 7 62 4 03 3 94 6 37 3 26 9 39 1 612151517 26 5 46 3 22 8 22 1 68 6 99 8 7 54 9 18 2 42 2 43 3 63 7 25 9 08 5 1 4 1 8 65 4 62 0 43 5 76 7 98 4 2 3
387184774 44 7 92 0 73 9 93 4 23 6 58 4 8 23 8 24 2 81 1 98 1 63 8 15 0 10 6 7 4 8 1 04 5 16 6 03 7 73 0 60 5 6 2
Name : RSA−1024 016196762 56 1 33 8 44 1 43 6 03 8 33 9 0 44 1 49 5 26 3 44 3 21 9 01 1 46 5 7 5 4 4 45 4 17 8 42 4 02 0 92 4 6 1
Digits : 309 651572335 07 7 87 0 77 4 98 1 71 2 57 7 2 46 7 96 2 92 6 38 6 35 6 37 3 28 9 9 1 2 1 54 8 31 4 38 1 67 8 99 8 8 5
135066410 86 5 99 5 22 3 34 9 60 3 21 6 2 78 8 05 9 69 9 38 8 81 4 75 6 05 6 6 7 0 2 75 2 44 8 51 4 38 5 15 2 6 5 0404453640 2 35 2 73 8 19 5 13 7 86 3 65 6 43 9 12 1 20 1 03 9 71 2 28 2 21 2 0 7 2 03 5 7
106048595 33 8 33 9 40 2 87 1 50 5 71 9 0 94 4 17 9 82 0 72 8 21 6 44 7 15 5 1 3 7 3 68 0 41 9 70 3 96 4 19 1 7 4 ✝ ✆
304649658 92 7 42 5 62 3 93 4 10 2 08 6 4 38 3 20 2 11 0 37 2 95 8 72 5 76 2 3 5 8 5 09 6 43 1 10 5 64 0 73 5 0 1
508187510 67 6 59 4 62 9 20 5 56 3 68 5 5 29 4 75 2 13 5 00 8 52 8 79 4 16 3 7 7 3 2 85 3 39 0 61 0 97 5 05 4 4 3
34999811150 05 69 7 72 36 8 90 92 75 6 3
✝ ✆
RSA 31/83 RSA 32/83
RSA Security: How to use RSA Outline
1 Introduction
2 RSA
Algorithm
Example
Correctness
Two plaintexts M1 and M2 are encrypted into ciphertexts C1 Security
and C2 . 3 GPG
But, RSA is deterministic! 4 Elgamal
Algorithm
If C1 = C2 then we know that M1 = M2 !
Example
Also, side-channel attacks are possible against RSA, for Correctness
example by measuring the time taken to encrypt. Security
5 Diffie-Hellman Key Exchange
Diffie-Hellman Key Exchange
Example
Correctness
Security
6 Summary
RSA 33/83 GPG 34/83
gpg is a public domain implementation of pgp. Please select what kind of key you want:
Supported algorithms: (1) RSA and RSA (default)
(2) DSA and Elgamal
Pubkey: RSA, RSA-E, RSA-S, ELG-E, DSA (3) DSA (sign only)
Cipher: 3DES, CAST5, BLOWFISH, AES, AES192, (4) RSA (sign only)
AES256, TWOFISH, CAMELLIA128, Your selection? 1
CAMELLIA192, CAMELLIA256 What keysize do you want? (2048)
Key is valid for? (0)
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, Key does not expire at all
SHA512, SHA224 Real name: Bobby
Compression: Uncompressed, ZIP, ZLIB, BZIP2 Email address: [email protected]
Comment: recipient
http://www.gnupg.org . You need a Passphrase to protect your secret key.
Enter passphrase: Bob rocks
Repeat passphrase: Bob rocks
Encryption Decryption
Bob can sign his message before sending it to Alice: Alice can now decrypt the message and check the signature:
> gpg -se --recipient alice --armor message
> gpg --decrypt message.asc
You need a passphrase to unlock the secret key for
user: "Bobby (recipient) <[email protected]>" You need a passphrase to unlock the secret key for
2048-bit RSA key, ID 9974031B, created 2012-02-12 user: "Alice (sender) <[email protected]>"
2048-bit RSA key, ID B901E082,
Enter passphrase: Bob rocks created 2012-02-12 (main key ID 4EC8A0CB)
Goal: Read a message encrypted with gpg. . . Goal: Read a message encrypted with gpg. . .
Goal: Read a message encrypted with PGP Goal: Read a message encrypted with PGP. . .
Alice has
Alice has computed K1 = Y x mod p
X = g x mod p = (g y )x mod p
K1 = Y x mod p. = (g x )y mod p
= X y mod p
Bob has computed
Bob has
Y = g y mod p
K2 = X y mod p. K2 = X y mod p
= (g x )y mod p
= X y mod p
⇒ K1 = K2 .
Diffie-Hellman Key Exchange 75/83 Diffie-Hellman Key Exchange 76/83
Diffie-Hellman Security Diffie-Hellman: Man-In-The-Middle attack
1 Alice :
The security of the scheme depends on the hardness of solving 1 Send X = g X mod p to Bob.
the discrete logarithm problem. 2 Eve :
Generally believed to be hard. 1 Intercept X = g x mod p from Alice.
Diffie-Hellman Property : 2 Pick a number t in Zp .
3 Send T = g t mod p to Bob.
Given
p, X = g x , Y = g y 3 Bob :
1 Send Y = g y mod p to Alice
computing
K = g xy mod p 4 Eve :
1 Intercept Y = g y mod p from Bob.
is thought to be hard. Pick a number s in Zp .
2
3 Send S = g s mod p to Alice.
Acknowledgments
7 http://homes.cerias.purdue.edu/~crisn/courses/cs355_Fall_2008/lect18.pdf
Summary 83/83