Overview. Background / Context. CSC 580 Cryptography and Computer Security. March 21, 2017

Similar documents
CIS 551 / TCOM 401 Computer and Network Security

Cryptography IV: Asymmetric Ciphers

Definition: For a positive integer n, if 0<a<n and gcd(a,n)=1, a is relatively prime to n. Ahmet Burak Can Hacettepe University

basics of security/cryptography

Chapter 8 Public-key Cryptography and Digital Signatures

Public Key Algorithms

Introduction to Cryptography. Lecture 8

Cryptography CS 555. Topic 18: RSA Implementation and Security. CS555 Topic 18 1

Ma/CS 6a Class 4: Primality Testing

Lecture 1: Introduction to Public key cryptography

Number Theory & Modern Cryptography

CSE 521: Design and Analysis of Algorithms I

Introduction to Modern Cryptography. Lecture RSA Public Key CryptoSystem 2. One way Trapdoor Functions

Lecture Notes, Week 6

Asymmetric Encryption

Slides by Kent Seamons and Tim van der Horst Last Updated: Oct 1, 2013

Ma/CS 6a Class 4: Primality Testing

Topics in Cryptography. Lecture 5: Basic Number Theory

Mathematical Foundations of Public-Key Cryptography

Introduction to Modern Cryptography. Benny Chor

Introduction to Public-Key Cryptosystems:

Cryptography and RSA. Group (1854, Cayley) Upcoming Interview? Outline. Commutative or Abelian Groups

1 Recommended Reading 1. 2 Public Key/Private Key Cryptography Overview RSA Algorithm... 2

Public Key Cryptography. All secret key algorithms & hash algorithms do the same thing but public key algorithms look very different from each other.

Security Issues in Cloud Computing Modern Cryptography II Asymmetric Cryptography

Introduction to Cryptography. Lecture 6

The RSA cryptosystem and primality tests

Foundations of Network and Computer Security

Number theory (Chapter 4)

Information Security

CPSC 467b: Cryptography and Computer Security

RSA Key Generation. Required Reading. W. Stallings, "Cryptography and Network-Security, Chapter 8.3 Testing for Primality

Public Key Cryptography

Biomedical Security. Some Security News 9/17/2018. Erwin M. Bakker. Blockchains are not safe for voting (slashdot.org) : From: paragonie.

Public Key Cryptography

Public Key Cryptography

CPSC 467b: Cryptography and Computer Security

Mathematics of Cryptography

LECTURE 5: APPLICATIONS TO CRYPTOGRAPHY AND COMPUTATIONS

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

Lecture 22: RSA Encryption. RSA Encryption

CPE 776:DATA SECURITY & CRYPTOGRAPHY. Some Number Theory and Classical Crypto Systems

Cosc 412: Cryptography and complexity Lecture 7 (22/8/2018) Knapsacks and attacks

Homework 4 for Modular Arithmetic: The RSA Cipher

CPSC 467b: Cryptography and Computer Security

CIS 6930/4930 Computer and Network Security. Topic 5.2 Public Key Cryptography

Math.3336: Discrete Mathematics. Mathematical Induction

ASYMMETRIC ENCRYPTION

Introduction to Cybersecurity Cryptography (Part 4)

My brief introduction to cryptography

Public-key Cryptography and elliptic curves

Public-key Cryptography and elliptic curves

Aspect of Prime Numbers in Public Key Cryptosystem

Public-Key Cryptosystems CHAPTER 4

CPSC 467b: Cryptography and Computer Security

Lemma 1.2. (1) If p is prime, then ϕ(p) = p 1. (2) If p q are two primes, then ϕ(pq) = (p 1)(q 1).

Introduction to Cybersecurity Cryptography (Part 4)

Lecture 5: Arithmetic Modulo m, Primes and Greatest Common Divisors Lecturer: Lale Özkahya

Introduction to Modern Cryptography. Benny Chor

CIS 6930/4930 Computer and Network Security. Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography

Congruence Classes. Number Theory Essentials. Modular Arithmetic Systems

Notes for Lecture Decision Diffie Hellman and Quadratic Residues

RSA Algorithm. Factoring, EulerPhi, Breaking RSA. Çetin Kaya Koç Spring / 14

L7. Diffie-Hellman (Key Exchange) Protocol. Rocky K. C. Chang, 5 March 2015

Great Theoretical Ideas in Computer Science

Practice Final Exam Winter 2017, CS 485/585 Crypto March 14, 2017

Encryption: The RSA Public Key Cipher

Lecture 19: Public-key Cryptography (Diffie-Hellman Key Exchange & ElGamal Encryption) Public-key Cryptography

Public Key 9/17/2018. Symmetric Cryptography Review. Symmetric Cryptography: Shortcomings (1) Symmetric Cryptography: Analogy

Arithmétique et Cryptographie Asymétrique

Biomedical Security. Overview 9/15/2017. Erwin M. Bakker

during transmission safeguard information Cryptography: used to CRYPTOGRAPHY BACKGROUND OF THE MATHEMATICAL

2. Cryptography 2.5. ElGamal cryptosystems and Discrete logarithms

RSA-256bit 數位電路實驗 TA: 吳柏辰. Author: Trumen

MATH 158 FINAL EXAM 20 DECEMBER 2016

RSA. Ramki Thurimella

Lecture 7: ElGamal and Discrete Logarithms

Public Key Algorithms

University of Tokyo: Advanced Algorithms Summer Lecture 6 27 May. Let s keep in mind definitions from the previous lecture:

Network Security Technology Spring, 2018 Tutorial 3, Week 4 (March 23) Due Date: March 30

Public-Key Encryption: ElGamal, RSA, Rabin

Public-Key Cryptography. Lecture 10 DDH Assumption El Gamal Encryption Public-Key Encryption from Trapdoor OWP

Introduction to Elliptic Curve Cryptography. Anupam Datta

1 Number Theory Basics

8.1 Principles of Public-Key Cryptosystems

Introduction. will now introduce finite fields of increasing importance in cryptography. AES, Elliptic Curve, IDEA, Public Key

RSA: Genesis, Security, Implementation & Key Generation

ECE 646 Lecture 8. RSA: Genesis, Security, Implementation & Key Generation

Outline. Available public-key technologies. Diffie-Hellman protocol Digital Signature. Elliptic curves and the discrete logarithm problem

10 Modular Arithmetic and Cryptography

Linear Congruences. The equation ax = b for a, b R is uniquely solvable if a 0: x = b/a. Want to extend to the linear congruence:

Innovation and Cryptoventures. Cryptography 101. Campbell R. Harvey. Duke University, NBER and Investment Strategy Advisor, Man Group, plc

ECE596C: Handout #11

Lecture 14: Hardness Assumptions

Practice Assignment 2 Discussion 24/02/ /02/2018

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

Intro to Public Key Cryptography Diffie & Hellman Key Exchange

Introduction to Cybersecurity Cryptography (Part 5)

Theme : Cryptography. Instructor : Prof. C Pandu Rangan. Speaker : Arun Moorthy CS

TECHNISCHE UNIVERSITEIT EINDHOVEN Faculty of Mathematics and Computer Science Exam Cryptology, Friday 25 January 2019

Transcription:

CSC 580 Cryptography and Computer Security Math for Public Key Crypto, RSA, and Diffie-Hellman (Sections 2.4-2.6, 2.8, 9.2, 10.1-10.2) March 21, 2017 Overview Today: Math needed for basic public-key crypto algorithms RSA and Diffie-Hellman Next: Read Chapter 11 (skip SHA-512 logic and SHA3 iteration function) Project phase 3 due in one week (March 28) - finish it! Background / Context Recall example trapdoor function from last time: Given a number n, how many positive integers divide evenly into n? If you know the prime factorization of n, this is easy. If you don t know the factorization, don t know efficient solution How does this fit into the public key crypto model? Pick two large (e.g., 1024-bit) prime numbers p and q Compute the product n = p * q Public key is n (hard to find p and q!), private is the pair (p,q) Questions: How do we pick (or detect) large prime numbers? How do we use this trapdoor knowledge to encrypt?

Prime Numbers A prime number is a number p for which its only positive divisors are 1 and p Question: How common are prime numbers? The Prime Number Theorem states that there are approximately n / ln n prime numbers less than n. Picking a random b-bit number, probability that it is prime is approximately 1/ln(2 b ) = (1/ln 2)*(1/b) 1.44 * (1/b) For 1024-bit numbers this is about 1/710 Pick random 1024-bit numbers until one is prime takes on average 710 trials This is efficient - if we can tell when a number is prime! Primality Testing Problem: Given a number n, is it prime? Basic algorithm: Try dividing all numbers 2,..,sqrt(n) into n Question: How long does this take if n is 1024 bits? Fermat s Little Theorem To do better, we need to understand some properties of prime numbers, such as Fermat s Little Theorem: If p is prime and a is a positive integer not divisible by p, then a p-1 1 (mod p). Proof is on page 46 of the textbook (not difficult!).

Fermat s Little Theorem - cont d Explore this formula for different values of n and random a s: a (n = 221) (n = 331) (n = 441) (n = 541) 64 1 1 379 1 189 152 1 0 1 82 191 1 46 1 147 217 1 0 1 113 217 1 232 1 198 81 1 270 1 Question 1: What conclusion can be drawn about the primality of 221? Question 2: What conclusion can be drawn about the primality of 331? Primality Testing - First Attempt Tempting (but incorrect) primality testing algorithm for n: Pick random a {2,..., n-2} if 1 then return not prime else return probably prime Why doesn t this work? Primality Testing - First Attempt Tempting (but incorrect) primality testing algorithm for n: Pick random a {2,..., n-2} if 1 then return not prime else return probably prime Why doesn t this work? Carmichael numbers. a (n = 2465) Example: 2465 is obviously not prime, but Note: Not just for these a s, but = 1 for all a s that are relatively prime to n. 64 1 189 1 82 1 147 1 113 1 198 1

Primality Testing - Miller-Rabin The previous idea is good, with some modifications (Note: This corrects a couple of typos in the textbook): MILLER-RABIN-TEST(n) // Assume n is odd Find k>0 and q odd such that n-1 = 2 k q Pick random a {2,..., n-2} x = a q mod n if x = 1 or x = n-1 then return possible prime for j = 1 to k-1 do x = x 2 mod n if x = n-1 then return possible prime return composite If n is prime, always returns possible prime If n is composite, says possible prime with probability < ¼ Idea: Run 50 times, and accept as prime iff all say possible prime Question: What is the error probability? Euler s Totient Function and Theorem Euler s totient function: (n) = number of integers from 1..n-1 that are relatively prime to n. If s(n) is count of 1..n-1 that share a factor with n, (n) = n - 1 - s(n) s(n) was our trapdoor function example (n) easy to compute if factorization of n known Don t know how to efficiently compute otherwise If n is product of two primes, n=p*q, then s(n)=(p-1)+(q-1)=p+q-2 So (p*q) = p*q - 1 - (p+q-2) = p*q - p - q + 1 = (p-1)*(q-1) Euler generalized Fermat s Little Theorem to composite moduli: Euler s Theorem: For every a and n that are relatively prime (i.e., gcd(a,n)=1), a (n) 1 (mod n). Question: How does this simplify if n is prime? RSA Algorithm Key Generation: Pick two large primes p and q Calculate n=p*q and (n)=(p-1)*(q-1) Pick a random e such that gcd(e, (n)) Compute d = e -1 (mod (n)) [Use extended GCD algorithm!] Public key is PU=(n,e) ; Private key is PR=(n,d) Encryption of message M {0,..,n-1}: E(PU,M) = M e mod n Decryption of ciphertext C {0,..,n-1}: D(PR,C) = C d mod n

RSA Algorithm Key Generation: Pick two large primes p and q Calculate n=p*q and (n)=(p-1)*(q-1) Pick a random e such that gcd(e, (n)) Compute d = e -1 (mod (n)) [Use extended GCD algorithm!] Public key is PU=(n,e) ; Private key is PR=(n,d) Correctness - easy when gcd(m,n)=1: Encryption of message M {0,..,n-1}: E(PU,M) = M e D(PR,E(PU,M)) = (M e ) d mod n mod n = M ed mod n = M k (n)+1 mod n Decryption of ciphertext C {0,..,n-1}: = (M (n) ) k M mod n = M D(PR,C) = C d mod n Also works when gcd(m,n) 1, but slightly harder to show... RSA Example Simple example: p = 73, q = 89 n = p*q = 73*89 = 6497 (n) = (p-1)*(q-1) = 72*88 = 6336 e = 5 d = 5069 [ Note: 5*5069 = 25,345 = 4*6336 + 1 ] Encrypting message M=1234: 1234 5 mod 6497 = 1881 Decrypting: 1881 5069 mod 6497 = 1234 Note: If time allows in class, more examples using Python! The Discrete Log Problem For every prime number p, there exists a primitive root (or generator ) g such that g 1, g 2, g 3, g 4,, g p-2, g p-1 (all taken mod p) are all distinct values (so a permutation of 1, 2, 3,..., p-1). Example: 3 is a primitive root of 17, with powers: i 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 3 i mod 17 3 9 10 13 5 15 11 16 14 8 7 4 12 2 6 1 f g,p (i) = g i mod p is a bijective mapping on {1,.., p-1} f g,p (i) is easy to compute (modular powering algorithm) g and p are global public parameters Inverse, written dlog g,p (x) = f g,p -1 (x), is believed to be difficult to compute

Diffie-Hellman Key Exchange Assume g and p are known, public parameters Alice a random value from {1,, p-1} A g a mod p Bob b random value from {1,, p-1} B g b mod p Send A to Bob Send B to Alice S a B a mod p S b A b mod p In the end, Alice s secret (S a ) is the same as Bob s secret (S b ): S a = B a = g ba = g ab = A b = S b Eavesdropper knows A and B, but to get a or b requires solving the discrete logarithm problem! Abstracting the Problem There are many sets over which we can define powering. Example: Can look at powers of n n matrices (A 2, A 3, etc.) Any finite set S with an element g such that f g : S S is a bijection (where f g (x) = g x for all x S) is called a cyclic group Very cool math here - see Chapter 5 for more info (optional) If f g is easy to compute and f g -1 is difficult, then can do Diffie-Hellman Elliptic Curves are a mathematical object with this property In fact: f g -1 seems to be harder to compute for Elliptic Curves than Z p Consequence: Elliptic Curves can use shorter numbers/keys than standard Diffie-Hellman - so faster and less communication required! Revisiting Key Sizes From NIST publication 800-57a Issue: PK algorithms based on mathematical relationships, and can be broken with algorithms that are faster than brute force. We spent time getting a feel for how big symmetric cipher\ keys needed to be How big do keys in a public key system need to be? From NIST pub 800-57a: