Topic 24: Finding Prime Numbers, RSA

Slides:



Advertisements
Similar presentations
RSA and Public Key Cryptography Oct Nathanael Paul.
Advertisements

Number Theory Algorithms and Cryptography Algorithms Prepared by John Reif, Ph.D. Analysis of Algorithms.
CS555Topic 191 Cryptography CS 555 Topic 19: Formalization of Public Key Encrpytion.
22C:19 Discrete Structures Integers and Modular Arithmetic
BY : Darshana Chaturvedi.  INTRODUCTION  RSA ALGORITHM  EXAMPLES  RSA IS EFFECTIVE  FERMAT’S LITTLE THEOREM  EUCLID’S ALGORITHM  REFERENCES.
Public Key Encryption Algorithm
Introduction to Modern Cryptography Lecture 6 1. Testing Primitive elements in Z p 2. Primality Testing. 3. Integer Multiplication & Factoring as a One.
Primality Testing By Ho, Ching Hei Cheung, Wai Kwok.
22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
Lecture 3.3: Public Key Cryptography III CS 436/636/736 Spring 2012 Nitesh Saxena.
7. Asymmetric encryption-
RSA ( Rivest, Shamir, Adleman) Public Key Cryptosystem
The RSA Cryptosystem and Factoring Integers (II) Rong-Jaye Chen.
Asymmetric Cryptography part 1 & 2 Haya Shulman Many thanks to Amir Herzberg who donated some of the slides from
Cryptography Lecture 11: Oct 12. Cryptography AliceBob Cryptography is the study of methods for sending and receiving secret messages. adversary Goal:
and Factoring Integers
Theory I Algorithm Design and Analysis (9 – Randomized algorithms) Prof. Dr. Th. Ottmann.
The RSA Algorithm Based on the idea that factorization of integers into their prime factors is hard. ★ n=p . q, where p and q are distinct primes Proposed.
1 CIS 5371 Cryptography 8. Asymmetric encryption-.
Topic 18: RSA Implementation and Security
Lecture 3.2: Public Key Cryptography II CS 436/636/736 Spring 2014 Nitesh Saxena.
1 AN EFFICIENT METHOD FOR FACTORING RABIN SCHEME SATTAR J ABOUD 1, 2 MAMOUN S. AL RABABAA and MOHAMMAD A AL-FAYOUMI 1 1 Middle East University for Graduate.
Cryptography Dec 29. This Lecture In this last lecture for number theory, we will see probably the most important application of number theory in computer.
1 Lect. 13 : Public Key Encryption RSA ElGamal. 2 Shamir Rivest Adleman RSA Public Key Systems  RSA is the first public key cryptosystem  Proposed in.
MA/CSSE 473 Day 11 Primality testing summary Data Encryption RSA.
Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 31.
Attacking RSA Brian Winant Reference “Twenty Years of Attacks on the RSA Cryptosystem” By Dan Boneh In Notices of the American Mathematical.
Primality Testing. Introduction The primality test provides the probability of whether or not a large number is prime. Several theorems including Fermat’s.
Discrete Mathematical Structures: Theory and Applications 1 Cryptography (advanced extra curricular topic)  Cryptography (from the Greek words Kryptos,
Lecture 6. RSA Use in Encryption to encrypt a message M the sender: – obtains public key of recipient PU={e,n} – computes: C = M e mod n, where 0≤M
Lecture 5 Asymmetric Cryptography. Private-Key Cryptography Traditional private/secret/single key cryptography uses one key Shared by both sender and.
MA/CSSE 473 Day 9 Primality Testing Encryption Intro.
Revision. Cryptography depends on some properties of prime numbers. One of these is that it is rather easy to generate large prime numbers, but much harder.
Public Key Cryptography
Chapter Applications of Number Theory Some Useful Results
Topic 26: Discrete LOG Applications
CS 2210:0001Discrete Structures Modular Arithmetic and Cryptography
Introduction to Cryptography
PUBLIC-KEY ENCRYPTION Focusing on RSA
B504/I538: Introduction to Cryptography
Randomness and Computation: Some Prime Examples
RSA and El Gamal Cryptosystems
Public Key Cryptosystems - RSA
Homework 3 As announced: not due today 
Cryptography Lecture 26.
Course Business Homework 3
Topic 11: Authenticated Encryption + CCA-Security
CS/COE 1501 Recitation RSA Encryption/Decryption
Topic 25: Discrete LOG, DDH + Attacks on Plain RSA
Topic 30: El-Gamal Encryption
Topic 3: Perfect Secrecy
Topic 7: Pseudorandom Functions and CPA-Security
Cryptography Lecture 25.
Analysis of the RSA Encryption Algorithm
Recap Plain RSA Public Key (pk): N = pq, e such that GCD e,
Course Business Homework 4 Released Bonus Problems (10 Points)
Where Complexity Finally Comes In Handy…
Symmetric-Key Cryptography
Where Complexity Finally Comes In Handy…
Introduction to Algorithms Second Edition by
Introduction to Cryptography
Cryptography Lecture 22.
Oblivious Transfer.
Cryptography Lecture 20.
Cryptography Lecture 21.
Cryptography Lecture 21.
刘振 上海交通大学 计算机科学与工程系 电信群楼3-509
Cryptography Lecture 25.
Where Complexity Finally Comes In Handy…
Presentation transcript:

Topic 24: Finding Prime Numbers, RSA Cryptography CS 555 Topic 24: Finding Prime Numbers, RSA

Recap Number Theory Basics Abelian Groups 𝜙 𝑝𝑞 = 𝑝−1 𝑞−1 for distinct primes p and q 𝜙 𝑁 = ℤ N ∗ 𝑔 𝑥 mod N = 𝑔 [𝑥 𝑚𝑜𝑑 𝝓 𝑵 ] mod N

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?

Can we do this in polynomial time? Bertrand’s Postulate Theorem 8.32. 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?

Bertrand’s Postulate Theorem 8.32. 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𝑛 𝑛 ≤ 𝑒 −𝑛

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. https://www.cse.iitk.ac.in/users/manindra/algebra/primality_v6.pdf

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 𝑚𝑜𝑑 𝑁

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 −𝑡

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 𝜙 𝑁 .

(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.

(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 =𝑚

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

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’.

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 ≤𝜇(𝑛)

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 ≤𝜇(𝑛)

(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

(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

(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 

Mathematica Demo https://www.cs.purdue.edu/homes/jblocki/courses/555_Spring17/slid es/Lecture24Demo.nb Note: Online version of mathematica available at https://sandbox.open.wolframcloud.com (reduced functionality, but can be used to solve homework bonus problems)

Next Class Read Katz and Lindell 8.3, 11.5.1 Discrete Log, DDH + Attacks on Plain RSA