Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science University of KwaZulu-Natal Pietermaritzburg Campus Semester 1, 2013 Tong-Viet (UKZN) MATH236 Semester 1, 2013 1 / 14
Table of contents The birth of public key cryptography 1 The RSA cryptosystem 2 Key generation Encryption and Decryption Tong-Viet (UKZN) MATH236 Semester 1, 2013 2 / 14
The birth of public key cryptography The birth of cryptography Diffie and Hellman proposed the idea of a public-key cryptosystem in a paper in 1976. Such a system would work in the following fashion: A public-key cryptosystem is an asymmetric-key cryptosystem, i.e., it is not computationally feasible to compute a decryption key K D from the corresponding encryption key K E Suppose Alice wants to use a (hypothetical) public-key cryptosystem. She begins by generating a pair of keys , which we denote pri(Alice) and pub(Alice) Anyone who wants to send her a message can encrypt it using her public key. But only Alice, using her private key, can decrypt such a message Suppose that Bob, another user of the system, wants to send Alice an encrypted message. Tong-Viet (UKZN) MATH236 Semester 1, 2013 3 / 14
The birth of public key cryptography Example 1 Bob looks up Alice’s public key, pub(Alice) 2 Bob encrypts the message using pub(Alice) and send the encrypted message to Alice using an open channel (e.g., by email) 3 Alice decrypts the encrypted message using her private key pri(Alice) Tong-Viet (UKZN) MATH236 Semester 1, 2013 4 / 14
The birth of public key cryptography public key cryptograph We can think of the encryption function in a public key cryptosystem as a trapdoor one-way function with trapdoor information being the private key Someone who knows pri(Alice) can decrypt a message encrypted using pub(Alice), but without this knowledge the task is computationally infeasible The security of a public-key crypto system depends on the function E and D used for encryption and decryption, respectively. They should have the following properties: Tong-Viet (UKZN) MATH236 Semester 1, 2013 5 / 14
The birth of public key cryptography Properties of encryption and decryption functions 1 For a given plaintext P , and public key pub(A), it should be easy to compute the corresponding ciphertext C = E pub ( A ) ( P ) 2 If only the ciphertext C is known, it should be computationally infeasible to find the plaintext P 3 If the ciphertext C and the private key pri(A) are known, it should be easy to compute the plaintext P = D pri ( A ) ( C ) 4 It should be easy to generate pairs (pub(A),pri(A)) of public and private keys so that too many such pairs exist for an enemy to construct a look-up table Tong-Viet (UKZN) MATH236 Semester 1, 2013 6 / 14
The RSA cryptosystem Introduction The RSA cryptosystem was invented by R ives, S hamir and A dleman in 1976 They are researchers at MIT Notice that Clifford Cocks, a British mathematician, came up with the same idea in 1973 The RSA is not widely used for general purposes of encryption and decryption of long message as the processes of encryption and decryption in public-key cryptosystems are slower than the corresponding operations in a symmetric-key cryptosystem The public-key cryptosystems are widely used to encrypt keys for symmetric-key cryptosystems-like DES Tong-Viet (UKZN) MATH236 Semester 1, 2013 7 / 14
The RSA cryptosystem Key generation The mechanics of RSA: key generation Suppose that Alice wants to use the RSA system. She must first generate a key-pair-pri(Alice) and pub(Alice). 1 Alice picks two large primes p and q of roughly the same size. She computes their product n = pq ( public modulus ) and also the Euler function φ ( n ) = ( p − 1)( q − 1) 2 Alice then selects a random integer e , 1 < e < φ ( n ) such that gcd( e , φ ( n )) = 1 3 She computes the inverse d of e in Z φ ( n ) , i.e., ed ≡ 1 (mod φ ( n )) 4 Finally, she sets pri(Alice)=(n,d) and pub(Alice)=(n,e) 5 Since the modulus n in Alice’s private key is the same n in her public key, we shall think of the private key as just the number d and write pri(Alice)=d. Tong-Viet (UKZN) MATH236 Semester 1, 2013 8 / 14
The RSA cryptosystem Key generation The mechanics of RSA: key generation Example 1 Suppose that Alice chooses p = 47 and q = 59 2 Then n = pq = 2773 and φ ( n ) = ( p − 1)( q − 1) = 2668 3 Alice now chooses a number e such that 1 < e < 2668 and gcd( e , 2668) = 1 4 She chooses e = 17 , a small prime number, with 17 ∤ 2668 5 Find e − 1 = 17 − 1 in Z 2668 6 d = e − 1 = 157 (using Extended Division Algorithm) 7 Thus pri(Alice)= d = 157 and pub(Alice)= (2773 , 17) . Tong-Viet (UKZN) MATH236 Semester 1, 2013 9 / 14
The RSA cryptosystem Encryption and Decryption The mechanics of RSA: encryption and decryption Suppose that Bob wants to send an encrypted message to Alice 1 Bob looks up pub(Alice)=(n,e) 2 Bob represents his message, M, as an integer in the interval [0 , n − 1] If M is too large, he divides it into blocks and then encrypts each block separately 3 Bob encrypts M into ciphertext C by the rule C = M e mod n 4 To decrypt the ciphertext C Alice receives from Bob, she uses her private key pri(Alice)=d to find M = C d mod n. Tong-Viet (UKZN) MATH236 Semester 1, 2013 10 / 14
The RSA cryptosystem Encryption and Decryption Representing the alphabet with numbers Table: An alphabet with spaces letter number letter number letter number letter number space 00 g 07 n 14 u 21 a 01 h 08 o 15 v 22 b 02 i 09 p 16 w 23 c 03 j 10 q 17 x 24 d 04 k 11 r 18 y 25 e 05 l 12 s 19 z 26 f 06 m 13 t 20 Tong-Viet (UKZN) MATH236 Semester 1, 2013 11 / 14
The RSA cryptosystem Encryption and Decryption The mechanics of RSA: encryption and decryption Suppose that Bob wants to send the message ‘pay me’to Alice He first encodes the message as numbers to keep the spaces, he use the coding scheme as in the previous thable The message is encoded as: 160125001305 Alice’s public key is ( n , e ) = (2773 , 17) In order to use the RSA system, Bob breaks the message into blocks so that each block is an element of Z 2773 , so Bob breaks the message up into blocks of length 4 1601 2500 1305 Tong-Viet (UKZN) MATH236 Semester 1, 2013 12 / 14
The RSA cryptosystem Encryption and Decryption The mechanics of RSA: encryption and decryption Now Bob encrypts each block M separately, each time producing an encrypted block C according to the rule C = M e mod n The first block is 1601 , so we compute 1601 17 mod 2773 1601 2 4 +1 mod 2773 = (1601 2 ) 2 3 · 1601 mod 2773 = (949 2 ) 2 2 · 1601 mod 2773 = (2149 2 ) 2 · 1601 mod 2773 = (1156 2 ) · 1601 mod 2773 = = 2523 · 1601 mod 2773 = 1835 mod 2773 Tong-Viet (UKZN) MATH236 Semester 1, 2013 13 / 14
The RSA cryptosystem Encryption and Decryption The mechanics of RSA: encryption and decryption The process is repeated for the other blocks in the message, yielding the ciphertext: 1835 0521 0813 Bob sends Alice this ciphertext After receiving the message from Bob, Alice uses her private key pri(Alice)=d=157 to decrypt For each block C , she computes M = C d mod n For example, the first block 1835 157 mod 2773=1601 mod 2773. Tong-Viet (UKZN) MATH236 Semester 1, 2013 14 / 14
Recommend
More recommend