Download presentation
Presentation is loading. Please wait.
1
Topic 24: Finding Prime Numbers, RSA
Cryptography CS 555 Topic 24: Finding Prime Numbers, RSA
2
Recap Number Theory Basics Abelian Groups
π ππ = πβ1 πβ1 for distinct primes p and q π π = β€ N β π π₯ mod N = π [π₯ πππ π π΅ ] mod N
3
RSA Key-Generation KeyGeneration(1n)
Step 1: Pick two random n-bit primes p and q Step 2: Let N=pq, π π =(πβ1)(πβ1) Step 3: β¦ Question: How do we accomplish step one?
4
Can we do this in polynomial time?
Bertrandβs Postulate Theorem For any n > 1 the fraction of n-bit integers that are prime is at least 1 3π . GenerateRandomPrime(1n) For i=1 to 3n2: pβο {0,1}n-1 pο 1 πβ² if isPrime(p) then return p return fail Can we do this in polynomial time?
5
Bertrandβs Postulate Theorem For any n > 1 the fraction of n-bit integers that are prime is at least 1 3π . GenerateRandomPrime(1n) For i=1 to 3n2: pβο {0,1}n-1 pο 1 πβ² if isPrime(p) then return p return fail Assume for now that we can run isPrime(p). What are the odds that the algorithm fails? On each iteration the probability that p is not a prime is 1β 1 3π We fail if we pick a non-prime in all 3n2 iterations. The probability of failure is at most 1β 1 3π 3 π 2 = 1β 1 3π 3π π β€ π βπ
6
isPrime(p): Miller-Rabin Test
We can check for primality of p in polynomial time in π . Theory: Deterministic algorithm to test for primality. See breakthrough paper βPrimes is in Pβ Practice: Miller-Rabin Test (randomized algorithm) Guarantee 1: If p is prime then the test outputs YES Guarantee 2: If p is not prime then the test outputs NO except with negligible probability.
7
The βAlmostβ Miller-Rabin Test
Input: Integer N and parameter 1t Output: βprimeβ or βcompositeβ for i=1 to t: a ο {1,β¦,N-1} if π πβ1 β mod N then return βcompositeβ Return βprimeβ Claim: If N is prime then algorithm always outputs βprimeβ Proof: For any aβ{1,β¦,Nβ1} we have π πβ1 = π π π =1 πππ π
8
The βAlmostβ Miller-Rabin Test
Need a bit of extra work to handle Carmichael numbers. Input: Integer N and parameter 1t Output: βprimeβ or βcompositeβ for i=1 to t: a ο {1,β¦,N-1} if π πβ1 β 1 mod N then return βcompositeβ Return βprimeβ Fact: If N is composite and not a Carmichael number then the algorithm outputs βcompositeβ with probability 1β 2 βπ‘
9
Back to RSA Key-Generation
KeyGeneration(1n) Step 1: Pick two random n-bit primes p and q Step 2: Let N=pq, π π =(πβ1)(πβ1) Step 3: Pick e > 1 such that gcd(e, π π )=1 Step 4: Set d=[e-1 mod π π ] (secret key) Return: N, e, d How do we find d? Answer: Use extended gcd algorithm to find e-1mod π π .
10
(Plain) RSA Encryption
Public Key: PK=(N,e) Message mβ β€ N EncPK(m)= π π mod N Remark: Encryption is efficient if we use the power mod algorithm.
11
(Plain) RSA Decryption
Public Key: SK=(N,d) Ciphertext cβ β€ N DecSK(c)= π π mod N Remark 1: Decryption is efficient if we use the power mod algorithm. Remark 2: Suppose that mβ β€ N β and let c=EncPK(m)= π π mod N DecSK(c)= π π π mod N = π ππ mod N = π [ππ πππ π π΅ ] mod N = π1 mod N =π
12
RSA Decryption Public Key: SK=(N,d) Ciphertext cβ β€ N
DecSK(c)= π π mod N Remark 1: Decryption is efficient if we use the power mod algorithm. Remark 2: Suppose that mβ β€ N β and let c=EncPK(m)= π π mod N then DecSK(c)= π Remark 3: Even if mβ β€ N β β€ N β and let c=EncPK(m)= π π mod N then Use Chinese Remainder Theorem to show this
13
Factoring Assumption Let GenModulus(1n) be a randomized algorithm that outputs (N=pq,p,q) where p and q are n-bit primes (except with negligible probability negl(n)). Experiment FACTORA,n (N=pq,p,q) ο GenModulus(1n) Attacker A is given N as input Attacker A outputs pβ > 1 and qβ > 1 Attacker A wins if N=pβqβ.
14
Factoring Assumption Necessary for security of RSA.
Not known to be sufficient. Experiment FACTORA,n (N=pq,p,q) ο GenModulus(1n) Attacker A is given N as input Attacker A outputs pβ > 1 and qβ > 1 Attacker A wins (FACTORA,n=1) if and only if N=pβqβ. βπππ π΄ βπ (negligible) s.t Pr FACTORA,n=1 β€π(π)
15
RSA-Assumption RSA-Experiment: RSA-INVA,n
Run KeyGeneration(1n) to obtain (N,e,d) Pick uniform yβ β€ N β Attacker A is given N, e, y and outputs xβ β€ N β Attacker wins (RSA-INVA,n=1) if π₯ π =y mod N βπππ π΄ βπ (negligible) s.t Pr RSAβINVA,n =1 β€π(π)
16
(Plain) RSA Discussion
We have not introduced security models like CPA-Security or CCA-security for Public Key Cryptosystems However, notice that (Plain) RSA Encryption is stateless and deterministic. ο Plain RSA is not secure against chosen-plaintext attacks Plain RSA is also highly vulnerable to chosen-ciphertext attacks Attacker intercepts ciphertext c of secret message m Attacker generates ciphertext cβ for secret message 2m Attacker asks for decryption of cβ to obtain 2m Divide by 2 to recover original message m
17
(Plain) RSA Discussion
However, notice that (Plain) RSA Encryption is stateless and deterministic. ο Plain RSA is not secure against chosen-plaintext attacks In a public key setting the attacker does have access to an encryption oracle Encrypted messages with low entropy are vulnerable to a brute-force attack
18
(Plain) RSA Discussion
Plain RSA is also highly vulnerable to chosen-ciphertext attacks Attacker intercepts ciphertext π= π π mod N Attacker asks for decryption of π 2 π mod N and receives 2m. Divide by two to recover message As above example shows plain RSA is also highly vulnerable to ciphertext-tampering attacks See homework questions ο
19
Mathematica Demo es/Lecture24Demo.nb Note: Online version of mathematica available at (reduced functionality, but can be used to solve homework bonus problems)
20
Next Class Read Katz and Lindell 8.3, 11.5.1
Discrete Log, DDH + Attacks on Plain RSA
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.