#### Transcript N - FSU Computer Science

CIS 5371 Cryptography 7. Asymmetric encryption- 1 Public Key Cryptography Alice Bob Alice and Bob want to exchange a private key in public. Public Key Cryptography The Diffie-Hellman protocol Let p is a large prime and ποππβ . ο¬ The order β of π is a factor of π β 1. ο¬ ππβ has a generator for any factor h of π β 1. ο¬ p is called a safe prime if h = 2q, with q a prime. Public Key Cryptography The Diffie-Hellman protocol Alice ga mod p Bob gb mod p The private key is: gab mod p where p is a prime and g is a generator of Zp* Example ο‘ p = 43, g = 3, ο‘ Alice and Bob share (p,g) = (43,3). ο‘ Alice picks her (secret) exponent: a random a = 8 οU [0:42]. ο‘ Alice sends Bob: 38 οΊ 25 (mod 43). ο‘ Bob picks his (secret) exponent: a random b = 37οU [0:42]. ο‘ Bob sends Alice: 337 οΊ 20 (mod 43). ο‘ The secret key agreed between the two is: 9 οΊ 208 οΊ 2537 (mod 43). Man-in-the-middle attack β’ Alice picks a οU Zp* and sends Malice (βBobβ): ga (mod p) β’ Malice (βAliceβ) picks m ο Zp* and sends Bob: gm (mod p) β’ Bob picks b οU Zp* and sends Malice (βBob) Bob: gb (mod p) β’ Malice (βBobβ) sends Alice: gm (mod p) β’ Alice computes: k1 ο¬ (gm)a (mod p) β’ Bob computes: k2 ο¬ (gm)b (mod p) The Computational Diffie-Hellman Problem, CDH β’ INPUT β The description of a finite cyclic group πΊ of prime order q β A generator element π of πΊ β ππ , ππ ο πΊ, for some integers 0 < π, π < π. β’ OUTPUT β πππ The Computational Diffie-Hellman Assumption β’ A CDH solver is a PPT algorithm that solves the CDH problem. β’ The CDH Assumption is that, for any CDH solver there exists a negligible function negl such that: β for an arbitrary instance of the CDH problem, the CDH solver will succeed with probability ο£ negl for all sufficiently large inputs. The Decisional Diffie-Hellman Problem, DDH β’ INPUT β The description of a finite cyclic group G of prime order q β A generator element g of G β ga, gb, gc ο G, for some integers 0 < a,b,c< q. β’ OUTPUT β 1 ---Decision that gc = gab or β 0 ---Decision that gc οΉ gab The Decisional Diffie-Hellman Assumption β’ A DDH solver is a PPT algorithm that solves the DDH problem. β’ The DDH Assumption is that, for any DDH solver, there exists a negligible function negl such that: β for an arbitrary instance of the DDH problem, the DDH solver will succeed with probability ο£ negl for all sufficiently large inputs. The Discrete Logarithm Problem The Discrete Logarithm Problem -- DL β’ INPUT β The description of a finite cyclic group πΊ of order π (say ππβ ) β A generator element π of πΊ β h ο G. β’ OUTPUT β The unique integer π < π such that β = ππ πππ π. We call the integer π the discrete logarithm of β in base π and write: π = ππππ β πππ π. The Discrete Logarithm Assumption β’ A DL solver is a PPT algorithm that solves the DL problem. β’ The DL Assumption is that, for any DL solver, there exists a negligible function negl such that: β for an arbitrary instance of the DL problem, the DDH solver will succeed with probability ο£ negl for all sufficiently large inputs. The RSA cryptosystem Alice performs the following steps ο Choose p, q large primes with |p| ο» |q|. ο Compute N = pq. ο Compute οͺ (N) = (p-1)(q-1). ο ο Choose a random integer e < οͺ (N) such that gcd(e,οͺ (N)) = 1 and compute the integer d such that ed = 1 (mod οͺ (N)). Make (N,e) the public key, keep (N,d) as private key, and discard p,q and οͺ (N). The RSA cryptosystem Encryption Let m < N be the confidential message that Bob wants to send to Alice. β’ β’ Bob creates the ciphertext: c ο¬ ππ (πππ π). Bob sends Alice: c Decryption To decrypt the ciphertext c Alice computes: π β π π (πππ π). Check We have: ο¬ ed οΊ 1 (mod οͺ (N)) , so ed οΊ 1 + tοͺ (N). Therefore, ο¬ Dd (Ee (m)) οΊ (me)d οΊ m ed οΊ m tοͺ(N)+1 οΊ (mοͺ(n))t ο΄ m οΊ 1ο΄m οΊ m mod n Example β’ Let p = 101, q = 113. Then N = 11413. β’ οͺ (N) = 100 x 112 = 11200 = 26527 β’ For encryption use e = 3533. β’ Alice publishes: N = 11413, e = 3533. β’ Suppose Bob wants to encrypt: 9726. β’ Bob computes 97263533 mod 11413 = 5761 β’ Bob sends Alice the ciphertext 5761. β’ To decrypt it Alice computes the plaintext: 57616597 (mod 11413) = 9726 Implementation 1. 2. 3. 4. 5. Generate two large primes: p,q N ο pq and π π = (p-1)(q-1) Choose random e: with 1 < e < οͺ (N) & gcd(e,οͺ (N))=1 π β π β1 πππ π(π) The public key is (N,e) and the private key is (N,d) Cost In ππ : ο ο Cost of a modular multiplication (xο΄y) mod n is O (k2), where k = log2n Cost of a modular exponentiation xz (mod n) is O (k2 log2z) = O (k2 log2 n) Cryptanalysis of Public-key cryptosystems Active attacks on cryptosystems β’ Chosen-Plaintext Attack (CPA): β The attacker chooses plaintexts and obtains the corresponding ciphertexts: the task of the attacker is successful if he can decrypt a (new) target ciphertext. β’ Chosen-Ciphertext Attack (CCA1): β The attacker chooses a number of ciphertexts and obtains the corresponding plaintexts: the task of the attacker is successful if he can decrypt a (new) target ciphertext. β’ Adaptive Chosen-Ciphertext Attack (CCA2): β This is a CCS1 attack in which the attacker can adaptively choose ciphertexts: the task of the attacker is successful if he can decrypt a (new) target ciphertext. The RSA Problem β’ INPUT β N = pq with p,q prime nmbers. β e an integer such that gcd(e,(p-1)(q-1)) =1 β c ο ZN . β’ OUTPUT β The unique integer m ο ZN such that me οΊ c (mod N ) The RSA Assumption β’ An RSA solver is a PPT algorithm that solves the RSA problem. β’ The RSA Assumption is that, for any RSA solver, there exists a negligible function negl such that: β for an arbitrary instance of the RSA problem, the RSA solver will succeed with probability ο£ negl for all sufficiently large inputs. The Integer Factorization Problem The IF Problem (IF) β’ INPUT β N an odd composite integer with at least two distinct prime factors. β’ OUTPUT β A prime p such that p | N. The IF Assumption β’ An integer factorizer is a PPT algorithm that solves the IF problem. β’ The IF Assumption is that, for any IF solver, there exists a negligible function negl such that: β for an arbitrary instance of the IF problem, the IF solver will succeed with probability ο£ negl for all sufficiently large inputs. Security of RSA 1. Relation to factoring. If Factoring is easy then the RSA problem is easy: recovering the plaintext m from an RSA ciphertext c is easy if factoring is possible The converse is likely not to be true. β’ β’ Relation between factoring and the RSA problem 3. β’ β’ If Factoring is easy then the RSA problem is easy. The converse is likely not to be true. The Rabin cryptosystem Alice performs the following steps ο Choose p, q large primes with |p| = |q|. ο Compute n = pq. ο Pick a random integer b οU Zn* ο Make (n,b) public key, keep (p,q) as private key. The Rabin cryptosystem Encryption Let m ο Zn* be the confidential message that Bob wants to send to Alice. β’ β’ Bob creates the ciphertext: c ο¬ m(m+b) (mod n). Bob sends Alice: c Decryption To decrypt the ciphertext c Alice solves the quadratic equation: m2 + bm βc οΊ 0 (mod n), for m < n. The Rabin cryptosystem Decryption From elementary mathematics: π = βπο± Ξ 2 where ο = b2 +4c (mod n). Since m was chosen in Zn*, ο must be in QRn . Notice that if p,q are such that p οΊ q οΊ 3 (mod 4), then it is easier to compute square roots modulo N, as we shall see below. Remarks β’ β’ β’ Suppose p οΊ q οΊ 3 (mod 4), n = pq. Let y οΊ π₯ 2 (mod p). Then: (ο± y ( p ο«1) / 4 ) 2 οΊ y ( p ο«1) / 2 οΊ y ( p ο1) / 2 ο΄ y οΊ y (mod p ) because, π¦ (πβ1)/2 β‘ π₯ 2 (πβ1)/2 β‘ π₯ πβ1 β‘ 1 (πππ π) Remarks (continued) β’ It follows that: ο± y ( pο«1) / 4 (mod p) β’ β’ β’ is a square root of y modulo p. A similar argument applies for the other prime q. So we get the quadratic residues modulo p and modulo q. We then get the quadratic residue modulo n by using the Chinese Remainder Theorem. Example Suppose n = 77. Then e(x) = x 2 (mod 77) d(y) = y (mod 77) Suppose Bob wants to decrypt y = 23 ο± 23( 7 ο«1) / 4 οΊ ο±2 2 οΊ ο±4 mod7 (11ο«1) / 4 ο± 23 οΊ ο±1 οΊ ο±1 mod11 3 Example, continued Using the Chinese Remainder Theorem we compute the 4 square roots of 23 modulo 77 to be: ο± 10 (mod 77), ο± 32 (mod 77) The Rabin Problem β’ INPUT β N = pq with p,q prime numbers. β y οΊ x 2 (mod N), x ο ZN* β’ OUTPUT β z ο ZN* such that z οΊ x 2 (mod N). Security of Rabin 1. Relation to factoring. Recovering the plaintext m from a Rabin ciphertext c is easy if the IF problem is easy. 3. Relation between factoring and the Rabin problem β’ β’ Under CPA attacks the Rabin system is secure iff the IF problem is hard. Under CCA attacks the Rabin problem is completely insecure. Security of Rabin Under CCA attacks the Rabin system is completely insecure. Proof: We show this for the case when π = 0. The adversary picks an π and computes π β‘ π2 πππ π . Then he gets its decryption πβ². This is one of the 4 square roots of π, and with probability ½, gcd πβ² ο±π, π = π or q. Then the adversary can decrypt any ciphertext. The ELGamal cryptosystem Alice performs the following steps ο Choose a large random primes p. ο Compute a random multiplicative generator g ο Zp* ο Pick x οU Zp-1 as private key ο Compute the public key y ο gx (mod p). ο Make (p,g,y) public key, and keep (p,x) as private key. The ElGamal cryptosystem Encryption Let m < p be the confidential message that Bob wants to send to Alice. Bob picks k οU Zp-1 and computes the ciphertext (c1, c2) β’ c1 ο gk (mod p). β’ c2 ο yk m (mod p). Decryption To decrypt the ciphertext (c1, c2) Alice computes m ο c2/c1x (mod p). The ElGamal cryptosystem Check: π1π₯ β‘ (ππ )π₯ β‘ π¦ π β‘ π2 /π πππ π . Example Use p = 43, g =3, m = 14, x = 7, y = 37. Aliceβs private key: x = 7 Aliceβs public key: (p,g,y) = (43,3,37). Encryption with k = 26: β’ c1 = gk (mod p) = 326 (mod 43) =15. β’ c2 = yk m (mod p) = 3726 ×14 (mod 43) =31 . Decryption: m = c2/c1x (mod p) = 31/157 (mod 43) = 14 . Security of ElGamal Relation to the DL. Recovering the plaintext m from an ElGamal ciphertext c is easy if the DL problem is easy. 1. 2. ELGamal and the CDH problem For messages that are uniformly distributed, the ElGamal encryption system is secure against CPAs iff the CDH problem is hard. Security of ElGamal For messages that are uniformly distributed, the ElGamal encryption system is secure against CPAs iff the CDH problem is hard. Security of ElGamal Proof: Suppose there exists an oracle that breaks ElGamal with non negligible probability ο₯ > 0. Then since π = π2 /π1π₯ (πππ π) can be computed, π2 /π = π ππππ π¦ ππππ π1 (πππ π) can also be computed. For an arbitrary CDH instance π, π, π1 = π¦, π2 = π1 , take π, π, π1 as the ElGamal public key and π1 , π2 as ciphertext. Then the oracle outputs π2 /π = π ππππ π1 ππππ π2 (πππ π) which is a solution for the CDH instance.