0% found this document useful (0 votes)
13 views8 pages

RSA + Diffe Helman Key Notes CNS

Computer networking important topics for placement
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
13 views8 pages

RSA + Diffe Helman Key Notes CNS

Computer networking important topics for placement
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 8
@ 44 The RSA Algorithm @(,o ~ 4.4.1 Introduction The RSA algorithm is the most popular and proven asymm tric ke tographic senita hens \ discuss that, let us have a quick overview of prime ni mbers, as they form the basis of the RS algorithm. " zi Am A prime number is the one that is divisible only by 1 and itself. For instance, 3 is a prime numba, because it can be divided only by I or 3. However, 4 is not a prime number, because other than by Lal 4, it can also be divided by 2. Similarly, 5, 7, 11, 13, 17, ... are prime numbers, whereas 6, 8,9, 10,11 .. are non-prime numbers. A quick observation can also be made that a prime number above 2 must, an odd number (because all even numbers are divisible by 2, therefore, all even numbers fron! onwards are non-prime). ic Key Algorithms, Digital Signatures and RSA 157 Bank's private key FFig.42 Use of a public key-private key pair by a bank The RSA algorithm is based numbers together, but it is extre: are based on very Targe (made simple (unlike the symmetric k ‘BSAiis the selecti lowever, thi ion and gener: blic and private keys. _ et us ROW understand h 2 mi ow the. public and private keys are generated, using them, how we can perform encrypt decryption in RSANThe whole process is shown in Fig, 4.3- ( Choose two large prine nunbers p and Q. Calculate N= Px Q. Select the public key (i.e. the Sneryption key) E such that it is Rot a factor of (P= 1) and(Q 1), Select the private key (i.e, the decryption ke; equation is true: Y) D such that the following © x £) mod (P - 1) x (Q =H) =a For encryption, calculate the Cipher text ct T= TE nod Wy from the plain text PT as follows. Send CT as the Cipher text. to the receiver ELE EFFie42. mn, Wass = ———___ 4.4.2 Examples of RSA Let us take an example of this process to understand the concepts. For ease of reading, we shay, the example values along with the algorithm steps. This is shown in Fig. 4.4. Win — | 1. Choose two Targe prime nunbers P and Q. 2. Calculate N= P x 0. We have, N= 7x17 = 119 tion key) E such that it is not a factor 3. Select the public key (i.e. the encryp' of (P- 1) x (Q- 1D — © Let us find 7-1) x 7-1 © The factors of 96 are 2. 2. 2. 2. 2x3) Fe nave to choose E such that none of the factors of £ is 2 and TAS Stew examples. we cannot choose as 4 (because it has 2 as 2 3 te 5 TS checause it has 3 as a factor), 6 (because it has 2 and 3 both as 6 x 16 ~ %6. 2, and 3 (because 96 = 2x 2x2x2x factors) eens cose E as 5 (it cosd have been any other nunber that does not its factors as 2 and 3) following 4, Select the private Key (i.e. the decryption key) D such that the f equation is true: a (Dx £) mod (P- Dx @- Dal [et us substitute the values of E, P and Q in the equation ie have: (D x5) mod (7-1) x (17 -D = 1 That is, (D x 5) mod (6) x (16) = 1 That is. (D x 5) mod (96) = 1 take 0 = 77. Then the following is true After some calculations. Tet us (77 x 8) mod (96) = 385 mod 96 = 1. which is what we wanted For encryption, calculate the cipher text CT from the plain text PT as follows: cT = PTE mod N Tat us assume that we want to encrypt plain text 10. Then we have: CT = 10° nod 119 = 100000 mod 119 = 40 6. Send CT as the cipher text to the receiver. Send 40 as the cipher text to the receiver: For decryption, calculate the plain text PT from the cipher text CT as follows: PT = CT? mod N ‘© We perform the following: © PT = CT nod N # That = 4077 is, PT = 4077 mod 119 = 10, which was the original plain text of step 5. FFig.4.4 Example of RSA algorithm Asymmetr i __— Asymmetric Key Algorithms, Digital Signatures and RSA = a stake te same example slightly differently. 1 ye shall take P= 7 and Q = 17, 1 Wereore, N=PXQET x 17 =119, 2 Ke we ca Se (P~1)X (Q~1)=6 x 16=96. The factors of 96 are 2, 2,2, 2, 2 and 3. Therefore, 3. AS ablic Key E must not have a factor of 2 and 3. Let us choose the public key value of Eas 5. he private key D such that (D x E) mod (P ~ 1) x (Q~ 1) = I. Let us choose D as 77, we can see that (5 x 77) mod 96 = 385 mod 96 = 1, which satisfies our condition. select th ppecause based on these values, let us consider an encryption and decryption process as shown in Nov ere, A is the sender and B is the receiver. As we can see, here we use an encoding scheme of Fi ng alphabets a5 A=1,B=2,...,Z=26. Let us assume that we want to encrypt a single alphabet coool is scheme, with B’s public key as 77 (known to A and B) and B's private key (known only to fsité The description follows Fig. 4.5. i ayes Encryption algorithm using Decryption a 5 igorthm using the public key the private key 1. Encode the original original 41. Raise the number to Gharactr using A=1, the power, neve 17. 2. Raise the number to eee the power E, here 5. A48, ond ont te here 5. remainder. The resulting number is 3. Divide the result by y 119 and get the eae ' remainder. The 3. Decode the original resulting number is character using the cipher text = Bete. Fi e [Fe a4 aT F B LF les |" | Resuit modulo 119 == Result modulo 118 oe = 41 _ FFig.4.5 Example of the RSA algorithm This works as follows, assuming that the sender A wants to send a single character F to the receiver B.We have chosen such a simple case for the ease of understanding. Using the RSA algorithm, the character F would be encoded as follows: : 1. Use the alphabet-numbering scheme (i.e. 1 for A, 2 for B, 3 for C and so on). As per this rule, for F, we would have 6. Therefore, first, F would be encoded to 6. 2. Raise the number to the power of N, ie. 6° 3. Now calculate 6° modulo 119, which is 41. This is the encrypted information to be sent across the network, Atthe receiver's end, the number 41 is decrypted to get back the original letter F as follows: 1. Rai Raise the number to the power of N, ie. 41°, ie. 4177. —— - awe” " 2.6.2 Diffie-Hellman Key Exchange/Agreement Algorithm Introduction Whitefield Diffie and Martin Hellman devised an amazing solution to the problem of key agreement or key exchange in 1976. This solution is called as ind fie-Hellman Key Exchange/ Hies,-who want to communicate Agreement Algorithm. The beauty of this scheme is that the two pi securely, can agree on a symmetric key using this technique. This key can then be used for encryption/ decryption, However, we must note that Diffie-Hellman key exchange algorithm can be used only for key agreement, but not for encryption or decryption of messages. Once-both the parties agree on the key to be used, they need to use other symmetric key encryption algorithms.}we shall discuss some of those =a subsequently) for actual encryption or decryption of message’) Although the Diffie-Hellman key exchange algorithm is based on mathematical principles, itis quite simple to understand. We shall first describe the steps in the algorithm, then illustrate its use with a simple example and then discuss the mathematical basis for it. Description of the Algorithm Let us assume that Alice and Bob want to agree upon a key to be Used for encrypting/decrypting messages that would be exchanged between them. ‘Then, the Diffie- Hellman key exchange algorithm works as shown in Fig. 2.49. Firstly, Alice and Bob agree on two large prime numbers, n and g. These two integers need notbe best secret. Alice and Bob can use an insecure channeltoagreeon them 2. Alice chooses another large random number x, and calculates Asuch that: Azgmodn 3. Alice sends the number Ato Bob. 4. Bobindependently chooses another large random integer y and calculates B such that: B=g/modn 5. Bob sends the number B toAlice. 6. Anow computes the secret hey K1 as follows: Ki=B%modn 7. Bnow computes the secrethey K2as follows: K2=A! modn F Fig. 2.49 Diffie-Hellman key exchange algorithm This is shown diagrammatically in Fig. 2.50. Alice Bob Alice and Bob agree rs x ‘on two prime — Sa numbers, n and g. hag modn B= 9! modn 8 u x 2 & 5 Ki=B*modn ‘As it tums out, Kt = K2 = K. K thus becomes the shared symmetric key between Alice and Bob. F Fig. 2.50 Diffie-Hellman key exchange illustrated It might come as a surprise, but KI is actually equal to K2! This means that KI = K2 = K is the symmetric key, which Alice and Bob must keep secret and can henceforth use for encrypting/decrypting their messages with. The mathematics behind this is quite interesting. We shall first prove it and then examine it. Example of the Algorithm Let us take a small example to prove that the Diffie-Hellman works in practical situations. Of course, we shall use very small values for ease of understanding. In real life, these values are very large. The process of key agreement is shown in Fig. 2.51. Cryptograph oT Lriptograpin Concepts and Techniques Sy 1. Firstly, Alice ang Bob aaree on two large prime numbers, n and g. These two integers neednotbe Keptsecrel. Alicoand Bobcat uee fechante ‘an insecure channel to agree on them, Letn=11,9=7, Letx=3. Then, we have, A=7> Mod 11 =343 mod 11 =2. Alice sends the number to Bob, -————"" Alice sends 2to Bob, eo Bob | Bobipdependently chooses anothertarge random integer y and calculates B such that: B= modn Lety=6. Then, wehave, B= 7° mod 11 = 117649 mod 1 =4, Bob sends the number BtoAlice. Bob sends 4 toAlice, Lomesends4 toAlice, | ‘Anow computes the secretkey K1 as follows: K1=B%modn We have, K2=28 mod 11 =64mod 11=9, FFig.251 Example of Diffie-Hellman key exchange Having taken a look at the actual proof of Diffie-Hellman key exchange algorithm, let us now think about the mathematical theory behind it. Fig. 4.50 Knapsack example lar 4.8 Some Other Algorithms dw» ' oo Let us discuss some other public key algorithms. a 2 oi w an 4.8.1 Elliptic Curve Cryptography (ECC) og bo Introduction RSA is the most prominent algorithm used in public key me techniques f encryption and digital signatures. Over the years, the key lengths for RSA have been increasing. Ti puts considerable burden on RSA, Another public gaining popular the last few years, His called as ul : = like RSA, ECC offers the same level of secur ie and, therefore, We Shall just have: for smaller key sizes. 1 overview Of this technique. iptic Curves An cllipti nofmal-curve drawin as pi has points, Bach point Gan be desig coordinate, just like any other graph. ~point can be designated as (4,-9), wl ivis 4 nits on the right hand idle of ‘the x-axis from the center a shown it Consider an elliptic curve (E) with a point P, Now, generate-a random number d, Lét we have Q= d xP. Mathematics says that 1, P.and Q are public values * aind the challenge isto find d, This is called as elliptic FFig.4.51 Point with rference'o-xandy| curve te logarithm problem, As long as the “curve is big enough, it is almost impossible to find d. Thus, E, P, Q together form the public key a8! is the corresponding private’key. ; = SS

You might also like