Xor. Isomorphisms. CS70: Lecture 9. Outline. Is public key crypto possible? Cryptography... Public key crypography.

Similar documents
CS70: Lecture 8. Outline.

Discrete Mathematics & Mathematical Reasoning Multiplicative Inverses and Some Cryptography

Cryptography. 2. decoding is extremely difficult (for protection against eavesdroppers);

MA/CSSE 473 Day 9. The algorithm (modified) N 1

Fermat s little theorem. RSA.

Mathematics Explorers Club Fall 2012 Number Theory and Cryptography

Lecture 32. Handout or Document Camera or Class Exercise. Which of the following is equal to [53] [5] 1 in Z 7? (Do not use a calculator.

Linear Congruences. The solutions to a linear congruence ax b (mod m) are all integers x that satisfy the congruence.

p 1 MAX(a,b) + MIN(a,b) = a+b n m means that m is a an integer multiple of n. Greatest Common Divisor: We say that n divides m.

Public Key Cryptography Great Ideas in Theoretical Computer Science Saarland University, Summer 2014

Algorithmic Number Theory and Cryptography (CS 303)

Cryptography, Number Theory, and RSA

Data security (Cryptography) exercise book

Introduction. and Z r1 Z rn. This lecture aims to provide techniques. CRT during the decription process in RSA is explained.

The Chinese Remainder Theorem

Public Key Encryption

The number theory behind cryptography

Application: Public Key Cryptography. Public Key Cryptography

L29&30 - RSA Cryptography

Diffie-Hellman key-exchange protocol

Classical Cryptography

Discrete Mathematics and Probability Theory Spring 2018 Ayazifar and Rao Midterm 2 Solutions

Cryptography CS 555. Topic 20: Other Public Key Encryption Schemes. CS555 Topic 20 1

The Chinese Remainder Theorem

Introduction to Modular Arithmetic

Distribution of Primes

Number Theory/Cryptography (part 1 of CSC 282)

Calculators will not be permitted on the exam. The numbers on the exam will be suitable for calculating by hand.

1 Introduction to Cryptology

Assignment 2. Due: Monday Oct. 15, :59pm

Modular Arithmetic: refresher.

Number Theory and Security in the Digital Age

Introduction to Cryptography CS 355

DUBLIN CITY UNIVERSITY

Math 319 Problem Set #7 Solution 18 April 2002

6. Find an inverse of a modulo m for each of these pairs of relatively prime integers using the method

CHAPTER 2. Modular Arithmetic

Cryptography Made Easy. Stuart Reges Principal Lecturer University of Washington

Public Key Cryptography

Public-key Cryptography: Theory and Practice

EE 418: Network Security and Cryptography

Overview. The Big Picture... CSC 580 Cryptography and Computer Security. January 25, Math Basics for Cryptography

Public-Key Cryptosystem Based on Composite Degree Residuosity Classes. Paillier Cryptosystem. Harmeet Singh

Solution: Alice tosses a coin and conveys the result to Bob. Problem: Alice can choose any result.

MA 111, Topic 2: Cryptography

NUMBER THEORY AMIN WITNO

Algorithmic Number Theory and Cryptography (CS 303)

Calculators will not be permitted on the exam. The numbers on the exam will be suitable for calculating by hand.

Wilson s Theorem and Fermat s Theorem

Final exam. Question Points Score. Total: 150

Number Theory - Divisibility Number Theory - Congruences. Number Theory. June 23, Number Theory

Math 412: Number Theory Lecture 6: congruence system and

Solutions for the Practice Final

MA/CSSE 473 Day 13. Student Questions. Permutation Generation. HW 6 due Monday, HW 7 next Thursday, Tuesday s exam. Permutation generation

Cryptography Math 1580 Silverman First Hour Exam Mon Oct 2, 2017

Applications of Fermat s Little Theorem and Congruences

Lecture 8. Outline. 1. Modular Arithmetic. Clock Math!!! 2. Inverses for Modular Arithmetic: Greatest Common Divisor. 3. Euclid s GCD Algorithm

TMA4155 Cryptography, Intro

The congruence relation has many similarities to equality. The following theorem says that congruence, like equality, is an equivalence relation.

Related Ideas: DHM Key Mechanics

Example Enemy agents are trying to invent a new type of cipher. They decide on the following encryption scheme: Plaintext converts to Ciphertext

High-Speed RSA Crypto-Processor with Radix-4 4 Modular Multiplication and Chinese Remainder Theorem

Cryptography Lecture 1: Remainders and Modular Arithmetic Spring 2014 Morgan Schreffler Office: POT 902

CMPSCI 250: Introduction to Computation. Lecture #14: The Chinese Remainder Theorem David Mix Barrington 24 February 2012

CMPSCI 250: Introduction to Computation. Lecture #14: The Chinese Remainder Theorem David Mix Barrington 4 October 2013

Example Enemy agents are trying to invent a new type of cipher. They decide on the following encryption scheme: Plaintext converts to Ciphertext

MAT Modular arithmetic and number theory. Modular arithmetic

Discrete Square Root. Çetin Kaya Koç Winter / 11

MAT 302: ALGEBRAIC CRYPTOGRAPHY. Department of Mathematical and Computational Sciences University of Toronto, Mississauga.

An interesting class of problems of a computational nature ask for the standard residue of a power of a number, e.g.,

#27: Number Theory, Part II: Modular Arithmetic and Cryptography May 1, 2009

Math 127: Equivalence Relations

MAT199: Math Alive Cryptography Part 2

A4M33PAL, ZS , FEL ČVUT

Primitive Roots. Chapter Orders and Primitive Roots

Collection of rules, techniques and theorems for solving polynomial congruences 11 April 2012 at 22:02

Number Theory for Cryptography

EFFICIENT ASIC ARCHITECTURE OF RSA CRYPTOSYSTEM

Modular Arithmetic. Kieran Cooney - February 18, 2016

Problem Set 6 Solutions Math 158, Fall 2016

Midterm practice super-problems

Security Enhancement and Speed Monitoring of RSA Algorithm

CMath 55 PROFESSOR KENNETH A. RIBET. Final Examination May 11, :30AM 2:30PM, 100 Lewis Hall

Number Theory. Konkreetne Matemaatika

The Chinese Remainder Theorem

Exam 1 7 = = 49 2 ( ) = = 7 ( ) =

DTTF/NB479: Dszquphsbqiz Day 30

6.2 Modular Arithmetic

Number-Theoretic Algorithms

Math 255 Spring 2017 Solving x 2 a (mod n)

SOLUTIONS TO PROBLEM SET 5. Section 9.1

Practice Midterm 2 Solutions

Drill Time: Remainders from Long Division

b) Find all positive integers smaller than 200 which leave remainder 1, 3, 4 upon division by 3, 5, 7 respectively.

MITOCW watch?v=3v5von-onug

ElGamal Public-Key Encryption and Signature

LECTURE 3: CONGRUENCES. 1. Basic properties of congruences We begin by introducing some definitions and elementary properties.

DUBLIN CITY UNIVERSITY

Modular Arithmetic and Doomsday

MODULAR ARITHMETIC II: CONGRUENCES AND DIVISION

Transcription:

CS70: Lecture 9. Outline. 1. Public Key Cryptography 2. RSA system 2.1 Efficiency: Repeated Squaring. 2.2 Correctness: Fermat s Theorem. 2.3 Construction. 3. Warnings. Cryptography... m = D(E(m,s),s) Alice Secret s E(m,s) E(m,s) Eve Bob Example: One-time Pad: secret s is string of length m. m = 10101011110101101 s =... E(m,s) bitwise m s. D(x,s) bitwise x s. Works because m s s = m!...and totally secure!...given E(m,s) any message m is equally likely. Disadvantages: Shared secret! Uses up one time pad..or less and less secure. Message m Isomorphisms. Bijection: f (x) = ax (mod m) if gcd(a,m) = 1. Simplified Chinese Remainder Theorem: There is a unique x (mod mn) where x = a (mod m) and x = b (mod n) and gcd(n,m) = 1. Bijection between (a (mod n),b (mod m)) and x (mod m)n. Consider m = 5, n = 9, then if (a,b) = (3,7) then x = 43 (mod 45). Consider (a,b ) = (2,4), then x = 22 (mod 45). Now consider: (a,b) + (a,b ) = (0,2). What is x where x = 0 (mod 5) and x = 2 (mod 9)? Try 43 + 22 = 65 = 20 (mod 45). Is it 0 (mod 5)? Yes! Is it 2 (mod 9)? Yes! Isomorphism: the actions under (mod 5), (mod 9) correspond to actions in (mod 45)! Public key crypography. m = D(E(m,K ),k) Private: k E(m,K ) Alice Public: K E(m,K ) Eve Bob Message m Everyone knows key K! Bob (and Eve and me and you and you...) can encode. Only Alice knows the secret key k for public key K. (Only?) Alice can decode with k. Is this even possible? Xor Computer Science: 1 - True 0 - False 1 1 = 1 1 0 = 1 0 1 = 1 0 0 = 0 A B - Exclusive or. 1 1 = 0 1 0 = 1 0 1 = 1 0 0 = 0 Note: Also modular addition modulo 2! {0,1} is set. Take remainder for 2. Property: A B B = A. By cases: 1 1 1 = 1.... Is public key crypto possible? We don t really know....but we do it every day!!! RSA (Rivest, Shamir, and Adleman) Pick two large primes p and q. Let N = pq. Choose e relatively prime to (p 1)(q 1). 1 Compute d = e 1 mod (p 1)(q 1). Announce N(= p q) and e: K = (N,e) is my public key! Encoding: Decoding: mod (x e,n). mod (y d,n). Does D(E(m)) = m ed = m mod N? Yes! 1 Typically small, say e = 3.

Iterative Extended GCD. Example: p = 7, q = 11. N = 77. (p 1)(q 1) = 60 Choose e = 7, since gcd(7,60) = 1. egcd(7,60). Confirm: 119+120 = 1 d = e 1 = 17 = 43 = (mod 60) 7(0) + 60(1) = 60 7(1) + 60(0) = 7 7( 8) + 60(1) = 4 7(9) + 60( 1) = 3 7( 17) + 60(2) = 1 Encryption/Decryption Techniques. Public Key: (77,7) Message Choices: {0,...,76}. Message: 2! E(2) = 2 e = 2 7 128 (mod 77) = 51 (mod 77) D(51) = 51 43 (mod 77) uh oh! Obvious way: 43 multiplications. Ouch. In general, O(N) or O(2 n ) multiplications! Repeated squaring. Notice: 43 = 32 + 8 + 2 + 1. 51 43 = 51 32+8+2+1 = 51 32 51 8 51 2 51 1 (mod 77). 4 multiplications sort of... Need to compute 51 32...51 1.? 51 1 51 (mod 77) 51 2 = (51) (51) = 2601 60 (mod 77) 51 4 = (51 2 ) (51 2 ) = 60 60 = 3600 58 (mod 77) 51 8 = (51 4 ) (51 4 ) = 58 58 = 3364 53 (mod 77) 51 16 = (51 8 ) (51 8 ) = 53 53 = 2809 37 (mod 77) 51 32 = (51 16 ) (51 16 ) = 37 37 = 1369 60 (mod 77) 5 more multiplications. 51 32 51 8 51 2 51 1 = (60) (53) (60) (51) 2 (mod 77). Decoding got the message back! Repeated Squaring took 9 multiplications versus 43. Recursive version. Repeated Squaring: x y RSA is pretty fast. (define (power x y m) (if (= y 1) (mod x m) (let ((x-to-evened-y (power (square x) (/ y 2) m))) (if (evenp y) x-to-evened-y (mod (* x x-to-evened-y) m ))))) Claim: Program correctly computes x y. Base: x 1 = x (mod m). x y = x 2(y/2)+ mod (y,2) = (x 2 ) y/2 x y mod 2 (mod m). The program computes the last expression using a recursive call with x 2 and y/2. Note: y/2 is integer division. Repeated squaring O(logy) multiplications versus y!!! 1. x y : Compute x 1,x 2,x 4,...,x 2 logy. 2. Multiply together x i where the (log(i))th bit of y (in binary) is 1. Example: 43 = 101011 in binary. x 43 = x 32 x 8 x 2 x 1. Modular Exponentiation: x y mod N. All n-bit numbers. Repeated Squaring: O(n) multiplications. O(n 2 ) time per multiplication. = O(n 3 ) time. Conclusion: x y mod N takes O(n 3 ) time. Modular Exponentiation: x y mod N. All n-bit numbers. O(n 3 ) time. Remember RSA encoding/decoding! For 512 bits, a few hundred million operations. Easy, peasey.

Decoding. Always decode correctly? Correct decoding... Want: (m e ) d = m ed = m (mod N). Want: (m e ) d = m ed = m (mod N). Another view: d = e 1 (mod (p 1)(q 1)) ed = k(p 1)(q 1) + 1. Consider... a p 1 1 (mod p). = a k(p 1) 1 (mod p) = a k(p 1)+1 = a (mod p) versus a k(p 1)(q 1)+1 = a (mod pq). Similar, not same, but useful. a p 1 1 (mod p). Proof: Consider S = {a 1,...,a (p 1)}. All different modulo p since a has an inverse modulo p. S contains representative of {1,...,p 1} modulo p. (a 1) (a 2) (a (p 1)) 1 2 (p 1) mod p, Since multiplication is commutative. a (p 1) (1 (p 1)) (1 (p 1)) mod p. Each of 2,...(p 1) has an inverse modulo p, solve to get... a (p 1) 1 mod p. Always decode correctly? (cont.) a p 1 1 (mod p). Lemma 1: For any prime p and any a,b, a 1+b(p 1) a (mod p) Proof: If a 0 (mod p), of course. Otherwise a 1+b(p 1) a 1 (a p 1 ) b a (1) b a (mod p)...decoding correctness... Lemma 1: For any prime p and any a,b, a 1+b(p 1) a (mod p) Lemma 2: For any two different primes p,q and any x,k, x 1+k(p 1)(q 1) x (mod pq) Let a = x, b = k(p 1) and apply Lemma 1 with modulus q. x 1+k(p 1)(q 1) x (mod q) Let a = x, b = k(q 1) and apply Lemma 1 with modulus p. x 1+k(p 1)(q 1) x (mod p) x 1+k(q 1)(p 1) x is multiple of p and q. RSA decodes correctly.. Lemma 2: For any two different primes p,q and any x,k, x 1+k(p 1)(q 1) x (mod pq) Theorem: RSA correctly decodes! Recall D(E(x)) = (x e ) d = x ed x (mod pq), where ed 1 mod (p 1)(q 1) = ed = 1 + k(p 1)(q 1) x ed x k(p 1)(q 1)+1 x (mod pq). x 1+k(q 1)(p 1) x 0 mod (pq) = x 1+k(q 1)(p 1) = x mod pq.

Construction of keys.... Security of RSA. Much more to it... 1. Find large (100 digit) primes p and q? Prime Number Theorem: π(n) number of primes less than N.For all N 17 π(n) N/lnN. Choosing randomly gives approximately 1/(lnN) chance of number being a prime. (How do you tell if it is prime?... cs170..miller-rabin test.. Primes in P). For 1024 bit number, 1 in 710 is prime. 2. Choose e with gcd(e,(p 1)(q 1)) = 1. Use gcd algorithm to test. 3. Find inverse d of e modulo (p 1)(q 1). Use extended gcd algorithm. All steps are polynomial in O(logN), the number of bits. Security? 1. Alice knows p and q. 2. Bob only knows, N(= pq), and e. Does not know, for example, d or factorization of N. 3. I don t know how to break this scheme without factoring N. No one I know or have heard of admits to knowing how to factor N. Breaking in general sense = factoring algorithm. If Bobs sends a message (Credit Card Number) to Alice, Eve sees it. Eve can send credit card again!! The protocols are built on RSA but more complicated; For example, several rounds of challenge/response. One trick: Bob encodes credit card number, c, concatenated with random k-bit number r. Never sends just c. Again, more work to do to get entire system. CS161... Signatures using RSA. RSA Other Eve. Verisign: k v, K v [C,S v (C)] C = E(S V (C),k V )? [C,S v (C)] [C,S v (C)] Amazon Browser. K v Certificate Authority: Verisign, GoDaddy, DigiNotar,... Verisign s key: K V = (N,e) and k V = d (N = pq.) Browser knows Verisign s public key: K V. Amazon Certificate: C = I am Amazon. My public Key is K A. Versign signature of C: S v (C): D(C,k V ) = C d mod N. Browser receives: [C,y] Checks E(y,K V ) = C? E(S v (C),K V ) = (S v (C)) e = (C d ) e = C de = C (mod N) Valid signature of Amazon certificate C! Security: Eve can t forge unless she breaks RSA scheme. Public Key Cryptography: D(E(m,K ),k) = (m e ) d mod N = m. Signature scheme: E(D(C,k),K ) = (C d ) e mod N = C Get CA to certify fake certificates: Microsoft Corporation. 2001..Doh.... and August 28, 2011 announcement. DigiNotar Certificate issued for Microsoft!!! How does Microsoft get a CA to issue certificate to them... and only them?

Summary. Public-Key Encryption. RSA Scheme: E(x) = x e (mod N). D(y) = y d (mod N). Repeated Squaring = efficiency. Fermat s Theorem = correctness. Good for Encryption and Signature Schemes.