David Kauchak CS52 – Spring 2015

Slides:



Advertisements
Similar presentations
CSE331: Introduction to Networks and Security Lecture 19 Fall 2002.
Advertisements

The Integers and Division. Outline Division: Factors, multiples Exercise 2.3 Primes: The Fundamental Theorem of Arithmetic. The Division Algorithm Greatest.
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
Week 3 - Friday.  What did we talk about last time?  AES  Public key cryptography.
hap8.html#chap8ex5.
22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
1 The RSA Algorithm Supplementary Notes Prepared by Raymond Wong Presented by Raymond Wong.
RSA ( Rivest, Shamir, Adleman) Public Key Cryptosystem
Public Key Cryptography
Public Encryption: RSA
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
Theory I Algorithm Design and Analysis (9 – Randomized algorithms) Prof. Dr. Th. Ottmann.
WS Algorithmentheorie 03 – Randomized Algorithms (Public Key Cryptosystems) Prof. Dr. Th. Ottmann.
RSA Encryption Caitlin O’Dwyer. What is an RSA Number? An RSA number n is a number s.t. n=pq Where p and q are distinct, large, prime integers.
Codes, Ciphers, and Cryptography-RSA Encryption
1 Introduction to Codes, Ciphers, and Cryptography Michael A. Karls Ball State University.
Lecture 15 Lecture’s outline Public algorithms (usually) that are each other’s inverse.
9/2/2015Discrete Structures1 Let us get into… Number Theory.
Introduction to Modular Arithmetic and Public Key Cryptography.
MATH 224 – Discrete Mathematics
RSA Public Key Algorithm. RSA Algorithm history  Invented in 1977 at MIT  Named for Ron Rivest, Adi Shamir, and Len Adleman  Based on 2 keys, 1 public.
RSA and its Mathematics Behind
Discrete Mathematics CS 2610 March 17, Number Theory Elementary number theory, concerned with numbers, usually integers and their properties or.
10/1/2015 9:38:06 AM1AIIS. OUTLINE Introduction Goals In Cryptography Secrete Key Cryptography Public Key Cryptograpgy Digital Signatures 2 10/1/2015.
Extended Euclidean Algorithm Presented by Lidia Abrams Anne Cheng.
Prelude to Public-Key Cryptography Rocky K. C. Chang, February
Implementing RSA Encryption in Java
Improving Encryption Algorithms Betty Huang Computer Systems Lab
Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 31.
Modular Arithmetic with Applications to Cryptography Lecture 47 Section 10.4 Wed, Apr 13, 2005.
A Method for Obtaining Digital Signatures and Public-key Cryptosystems
Elements of Coding and Encryption Continuation 1.
RSA Public Key Crypto System. About RSA Announced in 1977 by Ronald Rivest, Adi Shamir, and Leonard Adleman Relies on the relative ease of finding large.
RSA Prepared by: SITI ZAINAH ADNAN
© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Chapter 28 Number.
MA/CSSE 473 Day 10 Primality testing summary Data Encryption RSA.
Algebra of RSA codes Yinduo Ma Tong Li. Ron Rivest, Adi Shamir and Leonard Adleman.
The RSA Algorithm. Content Review of Encryption RSA An RSA example.
RSA and its Mathematics Behind July Topics  Modular Arithmetic  Greatest Common Divisor  Euler’s Identity  RSA algorithm  Security in RSA.
22C:19 Discrete Structures Integers and Modular Arithmetic Fall 2014 Sukumar Ghosh.
1 Network and Computer Security (CS 475) Modular Arithmetic and the RSA Public Key Cryptosystem Jeremy R. Johnson.
RSA The algorithm was publicly described in 1977 by Ron Rivest, Adi Shamir, and Leonard Adleman at MIT Partly used for PGP (Pretty Good Privacy) to encrypt.
Lecture 6.1: Misc. Topics: Number Theory CS 250, Discrete Structures, Fall 2011 Nitesh Saxena.
ENCRYPTION TAKE 2: PRACTICAL DETAILS David Kauchak CS52 – Spring 2015.
1 Section Congruences In short, a congruence relation is an equivalence relation on the carrier of an algebra such that the operations of the algebra.
CS Modular Division and RSA1 RSA Public Key Encryption To do RSA we need fast Modular Exponentiation and Primality generation which we have shown.
CS 4803 Fall 04 Public Key Algorithms. Modular Arithmetic n Public key algorithms are based on modular arithmetic. n Modular addition. n Modular multiplication.
Ch1 - Algorithms with numbers Basic arithmetic Basic arithmetic Addition Addition Multiplication Multiplication Division Division Modular arithmetic Modular.
Week 4 - Wednesday.  What did we talk about last time?  Finished DES  AES.
Primality Testing. Introduction The primality test provides the probability of whether or not a large number is prime. Several theorems including Fermat’s.
Lecture 3.1: Public Key Cryptography I CS 436/636/736 Spring 2015 Nitesh Saxena.
AF2. Turn off your phones Primes, gcd, some examples, reading.
RSA Cryptosystem Great Theoretical Ideas In Computer Science S. Rudich V. Adamchik CS Spring 2006 Lecture 8Feb. 09, 2006Carnegie Mellon University.
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Intro to Cryptography ICS 6D Sandy Irani. Cryptography Intro Alice wants to send a message to Bob so that even if Eve can see the transmitted information,
RSA Algorithm Date: 96/10/17 Wun-Long Yang. Outline Introduction to RSA algorithm RSA efficient implementation & profiling.
Cryptography By: Nick Belhumeur. Overview What is Cryptography? What is Cryptography? 2 types of cryptosystems 2 types of cryptosystems Example of Encryption.
Encryption Take 2: Practical details
David Kauchak CS52 – Spring 2016
Chapter Applications of Number Theory Some Useful Results
Advanced Algorithms Analysis and Design
MA/CSSE 473 Day 10 Data Encryption RSA.
Number Theory and Euclidean Algorithm
Rivest, Shamir and Adleman
Analysis of the RSA Encryption Algorithm
Systems Architecture I
CSE 321 Discrete Structures
Lecture 3.1: Public Key Cryptography I
Presentation transcript:

David Kauchak CS52 – Spring 2015 Encryption David Kauchak CS52 – Spring 2015

Admin Assignment 6 4 more assignments: Assignment 7, due 11/13 5pm Assignments 9 & 10, due 12/9 11:59pm

Admin Midterm next Thursday Covers everything from 9/24 – 10/27 + some minor SML Will not have to write any assembly 2 pages of notes Review sessions next week (TBA)

Encryption What is it and why do we need it?

Encryption I like bananas

Encryption I like bananas

Encryption: a bad attempt I like bananas

Encryption: the basic idea I like bananas I like bananas decrypt message encrypt message send encrypted message

Encryption: a better approach the hawk sleeps at midnight

Encryption uses Where have you seen encryption used?

Encryption uses

Private key encryption I like bananas I like bananas decrypt message encrypt message send encrypted message

Private key encryption Any problems with this?

Private key encryption

Private key encryption ?

Public key encryption private key public key Two keys, one you make publicly available and one you keep to yourself

Public key encryption Share your public key with everyone

Public key encryption decrypt message encrypt message I like bananas I like bananas decrypt message encrypt message send encrypted message

Public key encryption I like bananas Only the person with the private key can decrypt! decrypt message

Modular arithmetic Normal arithmetic: a = b a is equal to b or a-b = 0 a b (mod n) a-b = n*k for some integer k or a = b + n*k for some integer k or a % n = b % n (where % is the mod operator) note that (mod n) is notation NOT the mod operator

Modular arithmetic Which of these statements are true? 12 5 (mod 7) 52 17 12 (mod 6) a-b = n*k for some integer k or a = b + n*k for some integer k or a % n = b % n (where % is the mod operator) 65 33 (mod 32)

Modular arithmetic Which of these statements are true? 12 5 (mod 7) 52 12-5 = 7 = 1*7 12 % 7 = 5 = 5 % 7 12 5 (mod 7) 92-52 = 40 = 4*10 92 % 10 = 2 = 52 % 20 52 92 (mod 10) 17-12 = 5 17 % 6 = 5 12 % 6 = 0 17 12 (mod 6) 65-33 = 32 = 1*32 65 % 32 = 1 = 33 % 32 65 33 (mod 32)

Modular arithmetic properties If: a b (mod n) then: a mod n b mod n (mod n) “mod”/remainder operator congruence (mod n)

Modular arithmetic properties If: a b (mod n) then: a mod n b mod n (mod n) More importantly: (a+b) mod n (a mod n) + (b mod n) (mod n) and (a*b) mod n (a mod n) * (b mod n) (mod n) What do these say?

Modular arithmetic Why talk about modular arithmetic and congruence? How is it useful? Why might it be better than normal arithmetic? We can limit the size of the numbers we’re dealing with to be at most n (if it gets larger than n at any point, we can always just take the result % n) The mod operator can be thought of as mapping a number in the range 0 … number-1

GCD What does GCD stand for?

Greatest Common Divisor gcd(a, b) is the largest positive integer that divides both numbers without a remainder gcd(25, 15) = ?

Greatest Common Divisor gcd(a, b) is the largest positive integer that divides both numbers without a remainder gcd(25, 15) = 5 25 15 25 5 1 15 5 3 1 Divisors:

Greatest Common Divisor gcd(a, b) is the largest positive integer that divides both numbers without a remainder gcd(100, 52) = ?

Greatest Common Divisor gcd(a, b) is the largest positive integer that divides both numbers without a remainder gcd(100, 52) = 4 100 52 100 50 25 20 10 5 4 2 1 52 13 4 2 1 Divisors:

Greatest Common Divisor gcd(a, b) is the largest positive integer that divides both numbers without a remainder gcd(14, 63) = ? gcd(7, 56) = ? gcd(23, 5) = ? gcd(100, 9) = ? gcd(111, 17) = ?

Greatest Common Divisor gcd(a, b) is the largest positive integer that divides both numbers without a remainder gcd(14, 63) = 7 gcd(7, 56) = 7 gcd(23, 5) = 1 gcd(100, 9) = 1 gcd(111, 17) = 1 Any observations?

Greatest Common Divisor When the gcd = 1, the two numbers share no factors/divisors in common If gcd(a,b) = 1 then a is relatively prime to b This a weaker condition than primality, since any two prime numbers are also relatively prime, but not vice versa

Greatest Common Divisor A useful property: If two numbers are relatively prime (i.e. gcd(a,b) = 1), then there exists a c such that a*c mod b = 1

RSA public key encryption Have you heard of it? What does it stand for?

RSA public key encryption RSA is one of the most popular public key encryption algorithms in use RSA = Ron Rivest, Adi Shamir and Leonard Adleman

RSA public key encryption Choose a bit-length k Security increase with the value of k, though so does computation Choose two primes p and q which can be represented with at most k bits Let n = pq and ϕ(n) = (p-1)(q-1) ϕ() is called Euler’s totient function Find d such that 0 < d < n and gcd(d,ϕ(n)) = 1 Find e such that de mod ϕ(n) = 1 Remember, we know one exists!

RSA public key encryption p: prime number q: prime number n = pq ϕ(n) = (p-1)(q-1) d: 0 < d < n and gcd(d,ϕ(n)) = 1 e: de mod ϕ(n) = 1 Given this setup, you can prove that given a number m: (me)d = med = m (mod n) What does this do for us, though?

RSA public key encryption p: prime number q: prime number n = pq ϕ(n) = (p-1)(q-1) d: 0 < d < n and gcd(d,ϕ(n)) = 1 e: de mod ϕ(n) = 1 private key public key (d, n) (e, n)

RSA encryption/decryption private key public key (d, n) (e, n) You have a number m that you want to send encrypted encrypt(m) = me mod n (uses the public key) How does this encrypt the message?

RSA encryption/decryption private key public key (d, n) (e, n) You have a number m that you want to send encrypted encrypt(m) = me mod n (uses the public key) Maps m onto some number in the range 0 to n-1 If you vary e, it will map to a different number Therefore, unless you know d, it’s hard to know original m was after the transformation

RSA encryption/decryption private key public key (d, n) (e, n) You have a number m that you want to send encrypted encrypt(m) = me mod n (uses the public key) decrypt(z) = zd mod n (uses the private key) Does this work?

RSA encryption/decryption encrypt(m) = me mod n decrypt(z) = zd mod n decrypt(z) = decrypt(me mod n) z is some encrypted message = (me mod n)d mod n definition of decrypt = (me)d mod n modular arithmetic = m mod n (me)d = med = m (mod n) Did we get the original message?

RSA encryption/decryption encrypt(m) = me mod n decrypt(z) = zd mod n decrypt(z) = decrypt(me mod n) z is some encrypted message = (me mod n)d mod n definition of decrypt = (me)d mod n modular arithmetic = m mod n (me)d = med = m (mod n) If 0 ≤ m < n, yes!

RSA encryption: an example p: prime number q: prime number n = pq ϕ(n) = (p-1)(q-1) d: 0 < d < n and gcd(d,ϕ(n)) = 1 e: de mod ϕ(n) = 1 p = 3 q = 13 n = ? ϕ(n) = ? d = ? e = ?

RSA encryption: an example p: prime number q: prime number n = pq ϕ(n) = (p-1)(q-1) d: 0 < d < n and gcd(d,ϕ(n)) = 1 e: de mod ϕ(n) = 1 p = 3 q = 13 n = ?

RSA encryption: an example p: prime number q: prime number n = pq ϕ(n) = (p-1)(q-1) d: 0 < d < n and gcd(d,ϕ(n)) = 1 e: de mod ϕ(n) = 1 p = 3 q = 13 n = 3*13 = 39

RSA encryption: an example p: prime number q: prime number n = pq ϕ(n) = (p-1)(q-1) d: 0 < d < n and gcd(d,ϕ(n)) = 1 e: de mod ϕ(n) = 1 p = 3 q = 13 n = 39 ϕ(n) = ?

RSA encryption: an example p: prime number q: prime number n = pq ϕ(n) = (p-1)(q-1) d: 0 < d < n and gcd(d,ϕ(n)) = 1 e: de mod ϕ(n) = 1 p = 3 q = 13 n = 39 ϕ(n) = 2*12 = 24

RSA encryption: an example p: prime number q: prime number n = pq ϕ(n) = (p-1)(q-1) d: 0 < d < n and gcd(d,ϕ(n)) = 1 e: de mod ϕ(n) = 1 p = 3 q = 13 n = 39 ϕ(n) = 24 d = ? e = ?

RSA encryption: an example p: prime number q: prime number n = pq ϕ(n) = (p-1)(q-1) d: 0 < d < n and gcd(d,ϕ(n)) = 1 e: de mod ϕ(n) = 1 p = 3 q = 13 n = 39 ϕ(n) = 24 d = 5 e = 5

RSA encryption: an example encrypt(m) = me mod n n = 39 d = 5 e = 5 decrypt(z) = zd mod n encrypt(10) = ?

RSA encryption: an example encrypt(m) = me mod n n = 39 d = 5 e = 5 decrypt(z) = zd mod n encrypt(10) = 105 mod 39 = 4

RSA encryption: an example encrypt(m) = me mod n n = 39 d = 5 e = 5 decrypt(z) = zd mod n encrypt(10) = 105 mod 39 = 4 decrypt(4) = ?

RSA encryption: an example encrypt(m) = me mod n n = 39 d = 5 e = 5 decrypt(z) = zd mod n encrypt(10) = 105 mod 39 = 4 decrypt(4) = 45 mod 39 = 10

RSA encryption: an example encrypt(m) = me mod n n = 39 d = 5 e = 5 decrypt(z) = zd mod n encrypt(2) = ?

RSA encryption: an example encrypt(m) = me mod n n = 39 d = 5 e = 5 decrypt(z) = zd mod n encrypt(2) = 25 mod 39 = 32 mod 39 = 32 decrypt(32) = ?

RSA encryption: an example encrypt(m) = me mod n n = 39 d = 5 e = 5 decrypt(z) = zd mod n encrypt(2) = 25 mod 39 = 32 mod 39 = 32 decrypt(32) = 325 mod 39 = 2

RSA encryption in practice For RSA to work: 0 ≤ m < n What if our message isn’t a number? What if our message is a number that’s larger than n?

RSA encryption in practice For RSA to work: 0 ≤ m < n What if our message isn’t a number? We can always convert the message into a number (remember everything is stored in binary already somewhere!) What if our message is a number that’s larger than n? Break it into m sized chunks and encrypt/decrypt those chunks

RSA encryption in practice encrypt(“I like bananas”) = 0101100101011100 … encode as a binary string (i.e. number) 4, 15, 6, 2, 22, … break into multiple < n size numbers 17, 1, 43, 15, 12, … encrypt each number

RSA encryption in practice decrypt((17, 1, 43, 15, 12, …)) = 4, 15, 6, 2, 22, … decrypt each number 0101100101011100 … put back together “I like bananas” turn back into a string (or whatever the original message was) Often encrypt and decrypt just assume sequences of bits and the interpretation is done outside