0% found this document useful (0 votes)
47 views

Crypto Unit-Iii CSIT

Uploaded by

Ashish Maharjan
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)
47 views

Crypto Unit-Iii CSIT

Uploaded by

Ashish Maharjan
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/ 15
EN Crrprography Reference Note Unit-T1T Asymmetric Ciphers Primality Testing = A primality testing is an algorithm to test whether a given number is prime or not. - Aprime number is a number (1) which is divisible by 1 and itself. For e.g, 2, 3, 5,7 Miller-Rabin Primatity Testing = Used to test the primality of large numbers. - To test whether a given number ‘n’ is prime or not, Miller Rabin algorithm works as follows: 1. Writen —1 = 2*m, where mis odd. 2. Choose a random number a; 1 Two properties of prime number given by Rabin-Miller: Property 1: If p is prime and a is a positive integer less than p, then a” mod p = lif and only if either amod p = 1oramod p=—1modp =p—-1 Property 2: Let p be a prime number greater than 2. We can then write p — 1 = 24k, with k > Oand qas odd. Let a be any integer such that 1 < a < p — 1 then one of the following conditions is true © atmodp=1 tg; © One of the number a4, a?4,a4, 2®'4 is congruent to 1 mod p Fermat's Little Theorem Fermat's theorem states that: if p is prime and a is a positive integer uot divisible by p, then a1 = 1(mod p) ,p = 5 then 3 = 1(mod 5) Ega= Alternatively, a? = a(mod p) Eg. a=3,p =5 then 3° = 3(mod 5) Note: The first form of theorem requires that ‘a’ be relatively prime to ‘p’, but second form does not. Collegenote Prepared By: Jayanta Poudel MEN Csprography Reference Note Euler Totient Function = denoted by $(n). ~ Iris defined as the mumber of positive integer less than n, which are relatively prime to n. Eg p10) =? Here, n = 10 Numbers less than 10 are: {1, 2, 3,4, 5, 6,7, 8,9} Now, Numbers relatively prime to 10 are: {1, 3, 7, 9} (10) = = If p is prime number then, (p) = Eg o(7)=7-1=6 = Let p and q are two prime numbers such that p + q and n = pq, then (n) = (p- 1)(4- 1) Eg. (15) =? 15 =3x5 $(15) = G-1)G-1) =2*4=8 Euler’s Theorem Euler's theorem states that if “a” and ‘n’ are co-prime positive integers then, a® = 1(mod n) Altematively, ®t = a(mod n) Where, (n)is Buler’s totient function. Eg @ = 3,n = 10, (10) = 4 then, 34 = 1(mod 10) or 3° = 3(mod 10) Integer ‘a’ is said to be a primitive root of prime number “p" if at mod p,a? mod py -.....-- at mod p are distinct and consists of integers from 1 to p — 1 in some permutation. Sol": Here, a 2 mod 5 2? mod 5 23 mod 5 2* mod 5 Here, all values are distinet and consists of integers 1 to 4 «2s primitive root of andp =5 Collegenote Prepared By: Jayanta Poudel GEN Crpvosraphy Reference Note Sol Here, a = 3 and p = 7 3! mod 7 = 3mod7 =3 3? mod 7 =9 mod 7 =2 38 mod 7 =27 mod 7 =6 3* mod 7 = 81 mod 7 =4 3° mod 7 = 243 mod 7 = 5 36 mod 7 = 729 mod 7 = 1 Here, all values are distinct and consists of integers 1 to 6. «3 is primitive root of 7. Sot: Here, a = 2andp =7 2 mod 7 2? mod 7 2 mod 7 2* mod 7 Repeat 22 is not primitive root of 7 Discrete Logarithm Consider a primitive root “a” for a prime number ‘p’. For any integer p, following relation satisfies; b = r(mod p) If we can find a unique exponent such that = a'(mod p) Then 1 is called discrete logarithm of the number b for the base a mod p and denoted as dloga »(b) =i Eg a=3andp=7 Suppose b 4(mod 7) 3°(mod 7) + dlogs7(8) =0 Collegenote Prepared By: Jayanta Poudel EEN Crsprography Reference Note Publi Key Cryptosystems Asymmetric (Public-key) algorithms rely on one key for encryption and a different but related key for decryption. These algorithms have the following important characteristic: = Itis computationally infeasible to determine the decryption key given only knowledge of the cryptographic algorithm and the encryption key + Either of the two related keys can be used for eneryption, with the other used for decryption, A public-key encryption scheme has six ingredients: + Plaintext: This is the readable message or data that is fed into the algorithm as input, «Encryption algorithm: The encryption algorithm performs various transformations on the plaintext. + Public and private keys: This is a pair of keys that have been selected so that if one is used for encryption, the other is used for decryption. The exact transformations performed by the algorithm depend on the public or private key that is provided as input. + Ciphertext: This is the scrambled message produced as output. It depends on the plaintext and the key. Fora given message, two different keys will produce two different ciphertexts, + Decryption algorithm: This algorithm accepts the ciphertext and the matching key and produces the original plaintext. Joy Q “ 9 Mike Alice Alice's public Alice's private key key ‘Transmitted 9 ciphertext Q Plaintext Plaintext ‘ape Encryption algorithm Decryption algorithm output (eit RSA) (reverse of encryption algorithm) The essential steps are the following 1. Each user generates a pair of keys to be used for the encryption and decryption of messages. 2. Each user places one of the two keys it a public register or other accessible file. This is the public key. The companion key is kept private. As above figure, each user maintains @ collection of public keys obtained from others. 3. If Bob wishes to send a confidential message to Alice, Bob encrypts the message using Alice's public key. 4, When Alice receives the message, she decrypts it using her private key. No other recipient can decrypt the message because only Alice knows Alice's private key. Collegenote Prepared By: Jayanta Poudel EES Crprosraphy Reference Note Public-Key Cryptosystem for Secrecy There is some source A that produces a message in plaintext, X = [X,,Xo,.....Xq)-The M elements of X are letters in some finite alphabet. The message is intended for destination B B generates a related pair of keys: a public key, PUp, and a private key, PR». PR, is known only to B, whereas PU, is publicly available and therefore accessible by A. With the message X and the encryption key PU, as input, A forms the ciphertext ¥ = [Ye Yuk: Y = E(PUp,X) The intended receiver, in possession of the matching private key, is able to invert the transformation X = D(PR,,Y) Public-Key Cryptosystem: Authentication In this case, A prepares a message to B and encrypts it using 4's private key before transmitting it. B can decrypt the message using 4's public key. Because the message was encrypted using A's private key, only A could have prepared the message. Therefore, the entire encrypted message serves as a digital signature, In addition, it is impossible to alter the message without access to A's private key, so the message is authenticated both in terms of source and in terms of data integrity. Figure show the use of public-key encryption to provide authentication: Collegenote Prepared By: Jayanta Poudel MEE Crprosraphy Reference Note Public-Key Cryptosystem: Authentication and Secrecy It is, however, possible to provide both the authentication function and confi- dentiality by a double use of the public-key scheme: Z = E(PUp,E(PRq,X)) X = D(PUq,D(PRp,Z)) In this case, we begin as before by encrypting a message, using the sender's private key. This provides the digital signature. Next, we encrypt again, using the receiver's public key. The final ciphertext can be decrypted only by the intended receiver, who aloue has the matching private key. Thus, confidentiality is provided. The disadvantage of this approach is that the public-key algorithm, which is complex, must be exercised four times rather than two in each communication. Source A Destination B Sor: ‘Conventional Encryption Public-Key Encryption ‘Needed 19 Work: [Needed to Work: 1. The same algorithm with the same key is used | 1, One algorithm is used for encryption and for encryption and decryption. decryption with a pair of Keys one for encryption 2. The sender and receiver must share the and one for decryption. algorithm and the key. 2 The sender and receiver must each have one of the matched pair of keys (not the same one). [Neaded for Security: oe 1. The key must be kept seeret. Neotel for Seow 2. It must be impossible or at least impractical to decipher a message if no other information is available. 3. Knowledge of the algorithm plus samples of ciphertext must be insufficient to determine the key. 1. One of the two keys must be kept secret. 2. It must be impossible or at least impractical ipher a message if no other informat is available. 3. Knowledge of the algorithm plus one of the keys plus samples of ciphertext must be insufficient to determine the other key. Collegenote Prepared By: Jayanta Poudel EN Crsprography Reference Note Applications of Public Key Cryptography Public-key systems are characterized by the use of a cryptographic algorithm with two keys, one held private and one available publicly. Depending on the application, the sender uses either the sender's private key or the receiver's Public key, or both, to perform some type of cryptographic function, In broad terms, we can classify the use of Public-key cryptosystems into three categories: + Encryption/decryption: The sender encrypts a message with the recipient's Public key. + Digital signature: The sender "signs" a message with its private key. Signing is achieved by a cryptographic algorithm applied to the message or to a small block of data that is a funetion of the message. + Key exchange: Two sides cooperate to exchange a session key. Several different approaches are possible, involving the Private key(s) of one or both parties. Distribution of Public Keys Public key can be distributed in 4 ways: Public announcement, Publicly available directory, Public-key authority, and Public-key certificates, 1. Public Announcement: Here the public key is broadcasted to everyone. Major weakness of this method is forgery. Anyone can create a key claiming to be someone else and broadcast it. Until forgery is discovered can masquerade as claimed user 2. Publicly Available Directory: In this type, the public key is stored at a public directory. Directories are trusted here, with properties like Participant Registration, access and allow to modify values at any time, contains entries like {name, public-key}. Directories can be accessed electronically still vulnerable to forgery or tampering, "Secon vo NN Fig: Publie-key publication A D> 3. Public Key Authority: It is similar to the directory but, improve security by tightening control over distribution of keys from directory. It requires users to know public key for the directory. Whenever the keys are needed, a real-time access to directory is made by the user to obtain any desired public key securely. 4. Public Certification: This time authority provides a certificate (which binds identity to the public key) to allow key exchange without real-time access to the public authority each time. The certificate is accompanied with some other info such as period of validity, rights of use ete. All of this content is signed by the trusted Public-Key or Certificate Authority (CA) and it can be verified by anyone possessing the authority's public-key. Collegenote Prepared By: Jayanta Poudel EEL Crprosraphy Reference Note Diffe- [ellman (D-H) Key Exchan; Diffe-Hellman key exchange is a cryptographic protocol that allows two parties that have no prior knowledge of each other to jointly establish a shared secret key over an insecure communication channel, Steps J. Generate two global public elements p and g, where p is prime number and g < p is timitive root of p. User A select random integer X4 < p and computes ¥, = g*4mod p. User B select random integer X,

(53 * 53 #53 + 53 « 53) mod 23 = (19? + 19? « 19) mod 23 > (10+ 10+ 10 + 10+ 10) = (16 * 16 +16) > (10? * 10? + 10)mod 23 => (16? + 16) mod 23 = (8+ 8+ 10) > (3 +16) = (64+ 10) mod 23 = 48 mod 23 = (18+ 10) 32 = 180 mod 23 S19 Collegenote Prepared By: Jayanta Poudel SEEM Crprography Reference Note Solution: i) Here,p = 11 &g =2 2° mod 11 = 2mod 11 =2 2? mod 11=4mod 11=4 23 mod 11 = 8mod 11=8 2* mod 11 = 16 mod 11 = 5 25 mod 11 = 32 mod 11 = 10 26 mod 11 = 64 mod 11 =9 27 mod 11 = 128 mod 11 2® mod 11 = 256 mod 11 2° mod 11 = 512 mod 11 2! mod 11 = 1024 mod 11 Here all values are distinct and consists of integers 1 to 10 (ie. 1 to p — 1). Hence, 2 is a primitive root of 11 ii) User A’s public key Yq = A’s private key Xq =? We have, Y4 = g*4mod p 9 = 24 mod 11 From this equation, X, =6, because 2° mod 11 =9 + A's private key X, =6. iii) B’s public key Yg = 3 Now, K = (¥)*4 mod p 3° mod 11 29 mod 11 2 Shared key K =3. Collegenote Prepared By: Jayanta Poudel Cryptography Reference Note Man-In-Middle Attack A man-in-middle attack is a form of eavesdropping where communication between two users is monitored and modified by an unauthorized party. Generally, the attacker actively eavesdrops by intercepting public key message exchanged and retransmit the message while replacing the requested key with his own. Diffie-Hellman key exchange is insecure against a man-in-the-middle attack. Suppose Alice and Bob wish to exchange keys aud Darth is adversary. The attack proceeds as follows: 1. Darth prepares for attack by generating two random private key’s Xp; & Xpp and then computing the corresponding public keys Yp1&¥p2. [Yp, = g*tmod p &Yp2 = g*??mod p ]. Alice transmits ¥q to Bob. Darth intercepts Y4 and transmits ¥,, to Bob. Darth also calculates K, = (¥4)*2? mod p Bob receives ¥p, and calculates K, = (Yp1)*® mod p. Bob transmits ¥, to Alice Darth intercepts ¥p and transinits ¥p> to Alice. Darth calculates K, = (¥g)** mod p. Alice receives ¥p. and calculates K, = (Yp2)*4 mod p. At this point, Bob and Alice think that they share a secret key but instead Bob and Darth share secret key K, and Alice and Darth share sectet key Kp. Example Let p=11&g=2 Let Alice's private key Xq = 5. Yq = g*4 mod p = 25 mod 11 = 10 Let Bob’s private key Xq = 3. Yq = 9*8 mod p = 2? mod 11 = Nw ABN I. Darth’s two private keys: Let Xp; = 6 &Xpp = Darth calculates Yp, = g*°! mod p = 2°mod11=9 and Yp2 = g*?? mod p = 2° mod 11 = 6 2. Alice transmits ¥; = 10 to Bob. 3. Darth intercepts Yq and transmits Yp,=9 to Bob. And Darth calculates K, = (a)*?? mod p = 10° mod 11 = 10. 4. Bobreceives ¥>, = 9 and calculates Ky = (Yp1)** mod p = 9" mod 11 = 3. 5. Bob transmits ¥, = 8 to Alice. 6. Darth intercepts Yp and transmits Yp,=6 to Alice. And Darth calculates K, = (¥g)*! mod p = 8° mod 11 = 3. 7. Alice receives ¥p2 = 6 and calculates K = (Yp2)*4 mod p = 65 mod 11 = 10. Here Bob and Darth share secret key Ki, = 3 & Alice and Darth share secret key K = 10 Collegenote Prepared By: Jayanta Poudel EEN Cryptography Reference Note - RSA algorithm is public key cryptography i.e. it works on two different keys ie. public ‘key and private key. - The public key can be known to everyone and is used for encrypting message. Message encrypted with the public key can only be decrypted using the private key. Algorithm RSA key generation: 2. Choose two distinct large prime numbers p and q. 2. Compute n = pq, nis used as modulus for both public and private keys. 3. Compute the totient: 6(n) = (p - 1)(q - 1). 4, Choose an integer e such that 1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy