Symmetric and Asymmetric Key Cryptography(Part 2) By Radhika B S
Contents ● Asymmetric Key Cryptography Security Requirements ● ● Advantages ● Modes of Use ● Diffie-Hellman Key Exchange RSA Cryptosystem ● ● ElGamal Cryptosystem ● Comparison
Asymmetric Key Cryptography ● Encryption and Decryption are done using different keys Every user has a pair of keys (Public Key(e), Private Key(d)) ● 1.Alice selects key pair (e, d) 2. Sends public key e to Bob 4. Sends ciphertext C 3. Encrypts message M using e 5. Decrypts C using the private key d C = E e (M) M = D d (C)
Security Requirements ● Public Key Algorithms must have following properties Given a ciphertext C, computing the corresponding plaintext P should be ○ hard ○ Given a public key e, computing the corresponding private key d should be hard Given a private key d, it should be computationally easy to retrieve the ○ plaintext
Trap door One-way Functions f : easy Range Domain f -1 : hard f -1 : easy, given trapdoor t
Benefits of Asymmetric Key Cryptography ● Does not require secure channel to exchange keys Public key of an entity A can be used by multiple entities in the network to ● send secret messages to A ● Can be used in two ways ○ Encryption using public key : Provides Confidentiality Encryption using private key : Provides Authentication, nonrepudiation ○
Encryption Using Public Key
Encryption Using Private Key
Digital Signature ● Used to provide Authentication ○ ○ Nonrepudiation ● Requirements of a good digital signature Given a signature s of a message M, it should be hard to find an another message ○ M’ such that Signature M’ is also s ○ Easy to compute ○ Easy to verify
Diffie-Hellman Key Exchange 1.Alice and Bob agree on a prime number p and a generator g 2. Alice selects a random 2. Bob selects a random integer integer a < p and computes b < p and computes A = g a (mod p) B = g b (mod p) 3. Alice sends A to Bob 3. Bob sends B to Alice 4.Computes key K = A b (mod p) 4.Computes key K = B a (mod p)
Diffie-Hellman Key Exchange K = B a (mod p) K = A b (mod p) = (g b ) a (mod p) [ Since B = g b (mod p) ] = (g a ) b (mod p) [ Since A = g a (mod p) ] = g ab (mod p) = g ab (mod p) Given p, g, A and B, it is hard to compute a, b and hence K
Hard Problems in Asymmetric Key Cryptography ● Integer Factorization: Ex: RSA Discrete Log Problem(DLP): Ex: ElGamal ● ● Elliptic Curve Discrete Log Problem(ECDLP): Ex: Elliptic Curve Cryptosystem
RSA Cryptosystem ● Introduced in 1977 by Ron Rivest, Adi Shamir and Leonard Adleman Was independently developed by Clifford Cocks when working for UK ● intelligence agency GCHQ in 1973 and declassified in 1997 ● One of the first and most widely used public key cryptosystem ● Has 3 components Key Generation ○ ○ Encryption ○ Decryption
RSA Cryptosystem Key Generation 1. Select two large prime numbers p and q 2. Compute n = p * q 3. Calculate Ф(n) = (p-1)(q-1) 4. Select e < Ф(n) such that it is relatively prime to Ф(n) 5. Compute d such that ed ≡ 1 mod Ф(n) Public Key = (e, n) Private Key = (d, n)
RSA Cryptosystem Encryption C = M e (mod n) where M < n Decryption M = C d (mod n)
Proof of Correctness C = M e (mod n) M = C d (mod n) ed ≡ 1 mod Ф(n) ⇒ Ф(n) | (ed-1) D(E(M)) = D(M e (mod n)) ⇒ ed = Ф(n) * k + 1 = M ed (mod n) Euler’s Theorem: If m and n are = M Ф(n) * k + 1 (mod n) relatively prime, m Φ(n) (mod n)= 1 = M Ф(n) * k * M (mod n) = M(mod n)
Extended Euclidean Algorithm If g = GCD(b, c), then ∃ x, y such that bx + cy = g gcd(210, 165) 15 = 210(4) + 165(-5) 210 = 165 * 1 + 45 15 = 210(4) - 165(5) 165 = 45 * 3 + 30 15 = (210 - 165(1))(4) - 165(1) 45 = 30 * 1 + 15 15 = 45 (4) - 165(1) 30 = 15 * 2 + 0 15 = 45 - (165 - 45(3))(1) 15 = 45 - 30 (1)
An Example Key Generation Let us consider p = 3 and q = 11 1. n = p * q = 3 * 11 = 33 2. Ф(n) = (p-1)(q-1) = 2 * 10 = 20 3. Select e = 3 [GCD(3, 20) = 1] 4. By Using Extended Euclidean Algorithm we can compute d = 7 Public Key = (3, 33) Private Key = (7, 33)
An Example Encryption M = 5 C = 5 3 (mod 33) = 26 Decryption M = 26 7 (mod 33) = 5
Attacks on RSA ● Brute Force attack: Try all possible keys ● Factoring large numbers: Mathematical solution Chosen Ciphertext attacks: Exploits properties of the algorithm ● Side Channel Attacks : Use external factors ●
Factorization Problem ● RSA can be broken in 3 ways Factor n to obtain p and q. Use them to compute Ф(n). Retrieve private ○ key d by computing inverse of e(mod Ф(n)) ○ Find Ф(n) and then compute inverse of e(mod Ф(n)) ○ Directly find d All are believed to be equivalent to factorization problem ● ● No polynomial time algorithm for factoring arbitrarily large integers obtained by multiplying large prime numbers
Factorization Problem
Side Channel Attacks ● Relatively new class of attacks Traditional Attacks exploit weakness in algorithms and key ● ● Side Channel Attacks exploit weakness in the implementation ● Use external factors like time, power.. ● Attacker carefully observes the behavior of the implementation under different conditions ● Based on this, the attacker can obtain partial/full key ● Solution: Implementation should not reveal any information
ElGamal Cryptosystem ● Introduced by Taher ElGamal in 1985 * and Uses Discrete Log Problem: Given a prime number p, a generator g ∈ Z p ● an element a ≡ g x (mod p) , find the value of x. ● Based on Diffie-Hellman key exchange ● Consists of 3 components Key Generation ○ ○ Encryption ○ Decryption
ElGamal Cryptosystem Key Generation 1. Select a prime number p and its generator/primitive root g 2. To generate Alice’s key-pair, generate a random integer a, such that 1 < a < p-1 Compute A = g a (mod p) 3. 4. Alice’s public key : {p, g, A}
ElGamal Cryptosystem Encryption Bob encrypts Message M < p as follows: 1. Bob Chooses a random integer k such that 1 ≤ k ≤ p-1 Computes one-time key K = A k (mod p) 2. Computes a pair C 1 = g k (mod p) and C 2 = KM (mod p) 3. 4. Sends (C 1 , C 2 ) to Alice
ElGamal Cryptosystem Decryption a (mod p) 1. Alice computes key K = C 1 Recovers M = C 2 K -1 (mod p) 2.
An Example Key Generation P = 47 g = 5 a = 5 A = 5 5 (mod 47) = 23 Encryption Decryption k = 7 M = 21 a (mod p) = 11 5 (mod 47) = 29 K = C 1 K = A k (mod p) = 23 7 (mod 47) = 29 C 1 = g k (mod p) = 5 7 (mod 47) = 11 M = C 2 K -1 (mod p) = 45 * 13 (mod 47) = 21 C 2 = KM (mod p) = 29 * 21(mod 47) = 45
Applications ● Encryption/Decryption: To secure confidentiality of data Digital Signature: To provide authentication ● ● Key Exchange: To exchange session keys Algorithm Encryption/Decryption Digital Signature Key Exchange Diffie-Hellman No No Yes RSA Yes Yes Yes ElGamal Yes Yes Yes
Comparison Symmetric Key Cryptography Asymmetric Key Cryptography ● High encryption rate ● Only private key needs to be Keys are shorter secret ● ● Sharing secret key ● Longer key validity time ● Separate key needs to be ● Same key-pair can be used to maintained for communication communicate with multiple with each entity entities
How are they used? ● Asymmetric Key Cryptosystems are mainly used for key exchanges and digital certificates ● Symmetric Key cryptography is used for encryption of bulk data
References 1. Menezes, Alfred J., Paul C. Van Oorschot, and Scott A. Vanstone. Handbook of applied cryptography . CRC press, 1996. 2. Stallings, William. Cryptography and network security: principles and practices . Pearson Education India, 2006. 3. Menezes, Bernard L. Network Security and Cryptography . Wadsworth Publishing Company Incorporated, 2012.
Recommend
More recommend