RSA Slides by Kent Seamons and Tim van der Horst

Slides:



Advertisements
Similar presentations
CS 483 – SD SECTION BY DR. DANIYAL ALGHAZZAWI (4) Information Security.
Advertisements

CSE331: Introduction to Networks and Security Lecture 19 Fall 2002.
Attacks on Digital Signature Algorithm: RSA
Public-key Cryptography Montclair State University CMPT 109 J.W. Benham Spring, 1998.
Public Key Crytography1 From: Introduction to Algorithms Cormen, Leiserson and Rivest.
Public Encryption: RSA
Fall 2010/Lecture 311 CS 426 (Fall 2010) Public Key Encryption and Digital Signatures.
Public Key Cryptography RSA Diffie Hellman Key Management Based on slides by Dr. Lawrie Brown of the Australian Defence Force Academy, University College,
Public Key Model 8. Cryptography part 2.
Public Key Encryption and the RSA Public Key Algorithm CSCI 5857: Encoding and Encryption.
 Introduction  Requirements for RSA  Ingredients for RSA  RSA Algorithm  RSA Example  Problems on RSA.
Andreas Steffen, , 4-PublicKey.pptx 1 Internet Security 1 (IntSi1) Prof. Dr. Andreas Steffen Institute for Internet Technologies and Applications.
1 Network Security Lecture 6 Public Key Algorithms Waleed Ejaz
Great Theoretical Ideas in Computer Science.
RSA Ramki Thurimella.
1 Lecture 9 Public Key Cryptography Public Key Algorithms CIS CIS 5357 Network Security.
Midterm Review Cryptography & Network Security
BASIC CRYPTOGRAPHIC CONCEPTS. Public Key Cryptography  Uses two keys for every simplex logical communication link.  Public key  Private key  The use.
Modular Arithmetic with Applications to Cryptography Lecture 47 Section 10.4 Wed, Apr 13, 2005.
Darci Miyashiro Math 480 April 29, 2013
Public Key Cryptography. symmetric key crypto requires sender, receiver know shared secret key Q: how to agree on key in first place (particularly if.
1 Number Theory and Advanced Cryptography 5. Cryptanalysis of RSA Chih-Hung Wang Sept Part I: Introduction to Number Theory Part II: Advanced Cryptography.
RSA Slides by Kent Seamons and Tim van der Horst Last Updated: Oct 1, 2013.
CS461/ECE422 Spring 2012 Nikita Borisov — UIUC1.  Text Chapters 2 and 21  Handbook of Applied Cryptography, Chapter 8 
Algebra of RSA codes Yinduo Ma Tong Li. Ron Rivest, Adi Shamir and Leonard Adleman.
Public Key Algorithms Lesson Introduction ●Modular arithmetic ●RSA ●Diffie-Hellman.
POON TENG HIN.  RSA  Shamir’s Three-Pass Protocol  Other issues.
PUBLIC-KEY CRYPTOGRAPHY AND RSA – Chapter 9 PUBLIC-KEY CRYPTOGRAPHY AND RSA – Chapter 9 Principles Applications Requirements RSA Algorithm Description.
Public Key Cryptosystem Introduced in 1976 by Diffie and Hellman [2] In PKC different keys are used for encryption and decryption 1978: First Two Implementations.
Ch1 - Algorithms with numbers Basic arithmetic Basic arithmetic Addition Addition Multiplication Multiplication Division Division Modular arithmetic Modular.
Introduction to Cryptography Lecture 9. Public – Key Cryptosystems Each participant has a public key and a private key. It should be infeasible to determine.
Great Theoretical Ideas in Computer Science.
RSA Pubic Key Encryption CSCI 5857: Encoding and Encryption.
RSA Cryptosystem Great Theoretical Ideas In Computer Science S. Rudich V. Adamchik CS Spring 2006 Lecture 8Feb. 09, 2006Carnegie Mellon University.
Lecture 5 Asymmetric Cryptography. Private-Key Cryptography Traditional private/secret/single key cryptography uses one key Shared by both sender and.
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.
Overview Modern public-key cryptosystems: RSA
Public Key Cryptography
CS480 Cryptography and Information Security
Practical Aspects of Modern Cryptography
Visit for more Learning Resources
Chapter Applications of Number Theory Some Useful Results
Public Key Cryptosystem
Asymmetric-Key Cryptography
Lecture 5 RSA DR. Nermin Hamza.
Public-Key Cryptography RSA Rivest-Shamir-Adelmann Public-Key System
PUBLIC-KEY ENCRYPTION Focusing on RSA
Public Key Encryption and Digital Signatures
RSA and El Gamal Cryptosystems
Public-key Cryptography
The RSA Algorithm JooSeok Song Tue.
Cryptography.
Private-Key Cryptography
Real-world Security of Public Key Crypto
Number Theory and Euclidean Algorithm
ICS 353: Design and Analysis of Algorithms
The RSA Algorithm JooSeok Song Tue.
Practical Aspects of Modern Cryptography
Public-key encryption
Analysis of the RSA Encryption Algorithm
Systems Architecture I
Public Key Cryptography
Practical Aspects of Modern Cryptography
Introduction to Elliptic Curve Cryptography
PUBLIC-KEY CRYPTOGRAPHY AND RSA – Chapter 9
Introduction to Algorithms Second Edition by
Introduction to Cryptography
刘振 上海交通大学 计算机科学与工程系 电信群楼3-509
Public Key Cryptography
LAB 3: Digital Signature
Presentation transcript:

RSA Slides by Kent Seamons and Tim van der Horst Last Updated: Oct 4, 2016

Recap Number theory What is a prime number? What is prime factorization? What is a GCD? What does relatively prime mean? What does co-prime mean? What does congruence mean? What is the additive inverse of 13 % 17 ? What is the multiplicative inverse of 7 % 8 ?

Recap: Diffie-Hellman You’re trapped in your spaceship You have enough energy to send a single message to your HQ You have: HQ’s public DH values g=5, p = 875498279345… ga = 32477230478… Your AES implementation from Labs #1 & 2 An arbitrary precision calculator How can you construct your message so that it will be safe from eavesdroppers?

Asymmetric Encryption

Public Key Terminology Private Key Digital Signature You encrypt with a public key, and you decrypt with a private key You sign with a private key, and you verify with a public key

Model for Encryption with Public Key Cryptography Alice Bob Bob’s Public Key Bob’s Private Key Plaintext Ciphertext Plaintext Encryption Algorithm Decryption Algorithm

Model for Digital Signature with Public Key Cryptography Alice Bob Alice’s Private Key Alice’s Public Key Signed Document Plaintext Plaintext Signing Algorithm Signature Verification Algorithm

History of RSA Invented in 1977 by Patented until 2000 Ron Rivest Adi Shamir Leonard Adleman Patented until 2000 It’s withstood years of extensive cryptanalysis Suggests a level of confidence in the algorithm Example of successful attacks against implementations Side channel attacks Poor random number generators

Textbook RSA m = message c = ciphertext e = public exponent d = private exponent n = modulus RSA Encryption c = me % n RSA Decryption m = cd % n

The Math Behind RSA RSA encrypt/decrypt operations are simple The math to get to the point where these operations work is not so simple (at first) Fermat’s little theorem Euler’s generalization of Fermat’s little theorem

Fermat’s Little Theorem If p is prime a is relatively prime to p (co-prime) Then Fermat’s theorem states ap-1  1 (mod p) for all 0 < a < p This serves as the basis for Fermat’s primality test Euler’s generalization Which values of a aren’t co-prime to p? Pierre de Fermat (1601-1655)

Euler’s Generalization of Fermat’s Little Theorem Euler said aphi(n)  1 (mod n) phi(n) Euler’s totient function (n) The number of values less than n which are relatively prime to n Multiplicative group of integers (Zn*) RSA is interested in values of n that are the product of two prime numbers p and q n doesn’t need to be prime a must still be co-prime to n Leonhard Euler (1707-1783)

Computing phi(n) in RSA phi(n) is the number of integers between 0 and n that are co-prime to n When p * q = n, and p and q are prime, what is the phi(n)? Proof (When p * q = n) Observations 1) there are p-1 multiples of q between 1 and n 2) there are q-1 multiples of p between 1 and n These multiples are not co-prime to n Definition: phi(n) = # of values between 0 and n that are co-prime to n phi(n) = # of values between 0 and n minus # of values between 0 and n not co-prime to n phi(n) = [ n – 1] – [(p-1) + (q-1)] = [pq – 1] – (p-1) – (q-1) = pq – p – q + 1 = (p-1)(q-1) (p-1)(q-1) Why not?

RSA Euler said: aphi(n)  1 (mod n) m(p-1)(q-1)  1 (mod n) Notice: m(p-1)(q-1) * m  m(p-1)(q-1)+1  m (mod n) mphi(n)+1  m (mod n) Let e*d = k*phi(n) + 1 Then e*d  1 (mod phi(n)) Therefore med  mk*phi(n)+1  mphi(n) *mphi(n) *… * m  m (mod n) RSA Encryption me = c (mod n) RSA Decryption cd = m (mod n)

Steps for RSA Encryption Select p, q (large prime numbers) n=p*q phi(n) = (p-1)(q-1) Select integer e where e is relatively prime to phi(n) Common values for e are 3 and 65537. Why? Calculate d, where d*e = 1 (mod phi(n)) Public key is KU = {e, n} Private key is KR = {d, n} RSA encryption me = c (mod n) RSA decryption cd = m (mod n) Why is RSA Secure? Hard to factor large numbers Hard to compute d without phi(n) Discrete logs are hard (md % n) Given signature, hard to find d

RSA Usage Given me = c (mod n) and cd = m (mod n) What restrictions should be placed on m? For bulk encryption (files, emails, web pages, etc) Some try using RSA as block cipher Never, never, never encrypt data directly using RSA Inefficient Insecure Always use symmetric encryption for data, and use RSA to encrypt the symmetric key (after adding the appropriate padding) Digital signatures Do not sign the entire document - too slow Sign (“encrypt”) a hash of the document using the private key The length of the hash is < n

How do we get p, q, e, & d? What is p? What is q? What is e? How do we get it? What is q? What is e? What is the relationship of e and (p-1)(q-1)? What is d?

Multiplicative Inverses Use the extended Euclidean algorithm Based on the fact that GCD can be defined recursively If x > y, then GCD(x,y) =(recursively) GCD(y, x-y) Also if x > y, then GCD(x,y) =(recursively) GCD(y, x%y) GCD can also be used as follows: Suppose ax + by = gcd(x,y) If x is the modulus, and gcd (x,y) = 1 Then ax + by = 1 and b is y-1

Extended Euclidean algorithm GCD (120, 23) 120 / 23 = 5 r 5 23 / 5 = 4 r 3 5 / 3 = 1 r 2 3 / 2 = 1 r 1 2 / 1 = 2 r 0 1 / 0 GCD is 1, 120 and 23 are co-prime 120 / 23 = 5 r 5 => 5 = 120(1) + 23(-5) 23 / 5 = 4 r 3 => 3 = 23(1) + 5(-4) 5 / 3 = 1 r 2 => 2 = 5(1) + 3(-1) 3 / 2 = 1 r 1 => 1 = 3(1) + 2(-1) 2 / 1 = 2 r 0 => 0 = 2(1) + 1(-2) Notice the first line is a sum of products involving 120 and 23. We can derive a formula for each remainder to be a sum of products of 120,23.

Extended Euclidean algorithm GCD (120, 23) 120 / 23 = 5 r 5 => 5 = 120(1) + 23(-5) 23 / 5 = 4 r 3 => 3 = 23(1) + 5(-4) 5 / 3 = 1 r 2 => 2 = 5(1) + 3(-1) 3 / 2 = 1 r 1 => 1 = 3(1) + 2(-1) 2 / 1 = 2 r 0 => 0 = 2(1) + 1(-2) 23 / 5 = 4 r 3 => 3 = 23 + [120(1) + 23(-5)] (-4) = 23 + (120(-4) + 23(20)) = 23(21) + 120(-4)

Extended Euclidean algorithm GCD (120, 23) 120 / 23 = 5 r 5 => 5 = 120(1) + 23(-5) 23 / 5 = 4 r 3 => 3 = 23(21) + 120(-4) 5 / 3 = 1 r 2 => 2 = 5(1) + 3(-1) 3 / 2 = 1 r 1 => 1 = 3(1) + 2(-1) 2 / 1 = 2 r 0 => 0 = 2(1) + 1(-2) 23 / 5 = 4 r 3 => 3 = 23(21) + 120(-4) 5 / 3 = 1 r 2 => 2 = [120(1)+23(-5)] + [23(21)+120(-4)](-1) = 120(5) + 23(-26)

Extended Euclidean algorithm GCD (120, 23) 120 / 23 = 5 r 5 => 5 = 120(1) + 23(-5) 23 / 5 = 4 r 3 => 3 = 23(21) + 120(-4) 5 / 3 = 1 r 2 => 2 = 120(5) + 23(-26) 3 / 2 = 1 r 1 => 1 = 3(1) + 2(-1) 2 / 1 = 2 r 0 => 0 = 2(1) + 1(-2) 3 / 2 = 1 r 1 => 1 = [23(21) + 120(-4)] + [120(5) + 23(-26)](-1) = 23(47) + 120(-9) Notice that 1 = 23*47 + 120(-9) means that 47 is the multiplicative inverse of 23 (mod 120)

Computing “d” For RSA, calculate GCD(phi(n), e) to find d using extended Euclidean algorithm (see handout on Lab #4 page) Manual iterative method for the exam Use the table method in your lab For RSA, the GCD(phi(n),e) will result in an equation of the form 1 = e*d + phi(n)*k Where d or k is negative If d is negative convert it to an equivalent positive number (mod n) using phi(n) + d

Steps for determining d Calculate phi(n) and select an e (3, 5 usually for our toy problems) Find the GCD of (phi(n), e) which should always be 1 if e is valid. If the GCD is not 1, repeat for a different value of e. Create a sum of products expression for each remainder from x/y of the form [ remainder = X(1) + y(-quotient) ] Starting from the first expression, use substitution to create an equation of the form: remainder = phi(n)*k + e(d) If d is negative, convert to a positive number d = phi(n) + d

Computing RSA Keys Example q=11 n=? phi(n)=? e=7 d=? P=3, p=7, n=21,e=5,d=5, phi(n)=12 P=5, q=11, n=55, e=3, d=27, phi(n)=40 P=11, q = 13, n=143, phi(n) = 120, e=7, d=103 P=5, q =13, n=65, phi(n)=48, e=5, d=29

Applications for Public Key Cryptosystems Algorithm Encrypt/Decrypt Digital Signature Key Exchange Diffie-Hellman No Yes RSA DSS Elliptic Curve Algorithm Encrypt/Decrypt Digital Signature Key Exchange Diffie-Hellman No Yes RSA DSS Elliptic Curve Algorithm Encrypt/Decrypt Digital Signature Key Exchange Diffie-Hellman No Yes RSA DSS Elliptic Curve Algorithm Encrypt/Decrypt Digital Signature Key Exchange Diffie-Hellman RSA DSS Elliptic Curve Algorithm Encrypt/Decrypt Digital Signature Key Exchange Diffie-Hellman No Yes RSA DSS Elliptic Curve