0x1A Great Papers in Computer Security Vitaly Shmatikov CS 380S

Slides:



Advertisements
Similar presentations
Side-Channel Attacks on RSA with CRT Weakness of RSA Alexander Kozak Jared Vanderbeck.
Advertisements

Spring 2000CS 4611 Security Outline Encryption Algorithms Authentication Protocols Message Integrity Protocols Key Distribution Firewalls.
Public Key Cryptosystems - RSA Receiver Sender Eavesdroppe r p q p q p q p and q prime.
Public Key Encryption Algorithm
Topics in Cryptography Lecture 7 Topic: Side Channels Lecturer: Moni Naor.
Lecture 3.3: Public Key Cryptography III CS 436/636/736 Spring 2012 Nitesh Saxena.
7. Asymmetric encryption-
Session 4 Asymmetric ciphers.
Computer Security: Computer Science with Attackers Usable Privacy and Security Fall 2009 As told by David Brumley 1.
Dr. Lo’ai Tawalbeh Summer 2007 Chapter 9 – Public Key Cryptography and RSA Dr. Lo’ai Tawalbeh New York Institute of Technology (NYIT) Jordan’s Campus INCS.
Homework #4 Solutions Brian A. LaMacchia Portions © , Brian A. LaMacchia. This material is provided without.
Remote Timing Attacks -Rashmi Kukanur. Agenda  Timing Attacks  Case Study : –David Brumley –Dan Boneh  Defenses.
RSA Attacks 1 RSA Implementation Attacks RSA Attacks 2 RSA  RSA o Public key: (e,N) o Private key: d  Encrypt M C = M e (mod N)  Decrypt C M = C d.
The RSA Cryptosystem and Factoring Integers (II) Rong-Jaye Chen.
Cryptography Lecture 11: Oct 12. Cryptography AliceBob Cryptography is the study of methods for sending and receiving secret messages. adversary Goal:
Cryptography and Network Security Chapter 9. Chapter 9 – Public Key Cryptography and RSA Every Egyptian received two names, which were known respectively.
Public Key Cryptography and the RSA Algorithm
Cryptography1 CPSC 3730 Cryptography Chapter 9 Public Key Cryptography and RSA.
Private-Key Cryptography traditional private/secret/single key cryptography uses one key shared by both sender and receiver if this key is disclosed communications.
Slide 1 Vitaly Shmatikov CS 378 Overview of Public-Key Cryptography.
Side-Channel Attack: timing attack Hiroki Morimoto.
Cryptography and Network Security Chapter 9 5th Edition by William Stallings Lecture slides by Lawrie Brown.
Slide 1 Vitaly Shmatikov CS 380S Semantic Security.
Tallinn University of Technology Quantum computer impact on public key cryptography Roman Stepanenko.
0x1A Great Papers in Computer Security
1 CIS 5371 Cryptography 8. Asymmetric encryption-.
Topic 18: RSA Implementation and Security
The RSA Algorithm Rocky K. C. Chang, March
RSA Ramki Thurimella.
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.
Public Key Encryption and the RSA Public Key Algorithm CSCI 5857: Encoding and Encryption.
9th IMA Conference on Cryptography & Coding Dec 2003 More Detail for a Combined Timing and Power Attack against Implementations of RSA Werner Schindler.
Cryptography Lecture 7: RSA Primality Testing Piotr Faliszewski.
By Yernar.  Background  Key generation  Encryption  Decryption  Preset Bits  Example.
Modular Arithmetic with Applications to Cryptography Lecture 47 Section 10.4 Wed, Apr 13, 2005.
Private-Key Cryptography  traditional private/secret/single key cryptography uses one key  shared by both sender and receiver  if this key is disclosed.
Public-Key Encryption
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
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 Public-Key Cryptography and Message Authentication.
1 Number Theory and Advanced Cryptography 5. Cryptanalysis of RSA Chih-Hung Wang Sept Part I: Introduction to Number Theory Part II: Advanced Cryptography.
Cryptography and Network Security Chapter 9 - Public-Key Cryptography
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
Side-Channel Attacks Vitaly Shmatikov CS Acoustic Information in Typing uDifferent keystrokes make different sounds Different locations on the supporting.
Slide 1 Vitaly Shmatikov CS 380S Timing Attacks. slide 2 Reading uKocher. “Timing Attacks on Implementations of Diffie-Hellman, RSA, DSS, and Other Systems”
Lecture 8 Overview. Analysis of Algorithms Algorithms – Time Complexity – Space Complexity An algorithm whose time complexity is bounded by a polynomial.
Sliding Windows Succumbs to Big Mac Attack Colin D. Walter
Cryptography and Network Security Public Key Cryptography and RSA.
Chapter 3 – Public Key Cryptography and RSA (A). Private-Key Cryptography traditional private/secret/single-key cryptography uses one key shared by both.
Scott CH Huang COM 5336 Cryptography Lecture 6 Public Key Cryptography & RSA Scott CH Huang COM 5336 Cryptography Lecture 6.
Attacking RSA Brian Winant Reference “Twenty Years of Attacks on the RSA Cryptosystem” By Dan Boneh In Notices of the American Mathematical.
Chapter 9 Public Key Cryptography and RSA. Private-Key Cryptography traditional private/secret/single key cryptography uses one key shared by both sender.
Fall 2002CS 395: Computer Security1 Chapter 9: Public Key Cryptography.
Public Key Algorithms Lesson Introduction ●Modular arithmetic ●RSA ●Diffie-Hellman.
Remote Timing Attacks are Practical David Brumley Dan Boneh [Modified by Somesh.
Cryptography and Network Security Chapter 9 Fourth Edition by William Stallings.
1/16 Seeing through M IST given a Small Fraction of an RSA Private Key Colin D. Walter Comodo Research Lab (Bradford, UK)
Introduction to Elliptic Curve Cryptography CSCI 5857: Encoding and Encryption.
By Marwan Al-Namari & Hafezah Ben Othman Author: William Stallings College of Computer Science at Al-Qunfudah Umm Al-Qura University, KSA, Makkah 1.
RSA Cryptosystem Great Theoretical Ideas In Computer Science S. Rudich V. Adamchik CS Spring 2006 Lecture 8Feb. 09, 2006Carnegie Mellon University.
Chapter 9 – Public Key Cryptography and RSA Every Egyptian received two names, which were known respectively as the true name and the good name, or the.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
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
Copyright © Zeph Grunschlag, RSA Encryption Zeph Grunschlag.
1 The RSA Algorithm Rocky K. C. Chang February 23, 2007.
Key Exchange in Systems VPN usually has two phases –Handshake protocol: key exchange between parties sets symmetric keys –Traffic protocol: communication.
Public Key Cryptography
Remote Timing Attacks are Practical
Attacks on Public Key Encryption Algorithms
Cryptographic Timing Attacks
Presentation transcript:

0x1A Great Papers in Computer Security Vitaly Shmatikov CS 380S

slide 2 Attacking Cryptographic Schemes uCryptanalysis Find mathematical weaknesses in constructions Statistical analysis of plaintext / ciphertext pairs uSide-channel attacks Exploit characteristics of implementations Power analysis Electromagnetic radiation analysis Acoustic analysis Timing analysis

slide 3 Timing Attack uBasic idea: learn the system’s secret by observing how long it takes to perform various computations uTypical goal: extract private key uExtremely powerful because isolation doesn’t help Victim could be remote Victim could be inside its own virtual machine Keys could be in tamper-proof storage or smartcard uAttacker wins simply by measuring response times

slide 4 RSA Cryptosystem uKey generation: Generate large (say, 512-bit) primes p, q Compute n=pq and  (n)=(p-1)(q-1) Choose small e, relatively prime to  (n) –Typically, e=3 (may be vulnerable) or e= =65537 (why?) Compute unique d such that ed = 1 mod  (n) Public key = (e,n); private key = d –Security relies on the assumption that it is difficult to compute roots modulo n without knowing p and q uEncryption of m (simplified!): c = m e mod n uDecryption of c: c d mod n = (m e ) d mod n = m

slide 5 How RSA Decryption Works uRSA decryption: compute y x mod n This is a modular exponentiation operation uNaïve algorithm: square and multiply

slide 6 Kocher’s Observation This takes a while to compute This is instantaneous Whether iteration takes a long time depends on the k th bit of secret exponent

Exploiting Timing Information uDifferent timing given operands uAssumption / heuristic: timings of subsequent multiplications are independent Given that we know the first k-1 bits of x … Given a guess for the k th bit of x … … Time for remaining bits independent uGiven measurement of total time can see whether there is correlation between “time for k th bit is long” and “total time is long” Exact timing Exact guess slide 7

slide 8 Outline of Kocher’s Attack uIdea: guess some bits of the exponent and predict how long decryption will take uIf guess is correct, will observe correlation; if incorrect, then prediction will look random This is a signal detection problem, where signal is timing variation due to guessed exponent bits The more bits you already know, the stronger the signal, thus easier to detect (error-correction property) uStart by guessing a few top bits, look at correlations for each guess, pick the most promising candidate and continue

D. Brumley and D. Boneh Remote Timing Attacks are Practical (USENIX Security 2003)

slide 10 RSA in OpenSSL uOpenSSL is a popular open-source toolkit mod_SSL (in Apache = 28% of HTTPS market) stunnel (secure TCP/IP servers) sNFS (secure NFS) Many more applications uKocher’s attack doesn’t work against OpenSSL Instead of square-and-multiply, OpenSSL uses CRT, sliding windows and two different multiplication algorithms for modular exponentiation –CRT = Chinese Remainder Theorem –Secret exponent is processed in chunks, not bit-by-bit

slide 11 Chinese Remainder Theorem un = n 1 n 2 …n k where gcd(n i,n j )=1 when i  j uThe system of congruences x = x 1 mod n 1 = … = x k mod n k Has a simultaneous solution x to all congruences There exists exactly one solution x between 0 and n-1 uFor RSA modulus n=pq, to compute x mod n it’s enough to know x mod p and x mod q

slide 12 RSA Decryption With CRT uTo decrypt c, need to compute m=c d mod n uUse Chinese Remainder Theorem (why?) d 1 = d mod (p-1) d 2 = d mod (q-1) qinv = q -1 mod p Compute m 1 = c d 1 mod p; m 2 = c d 2 mod q Compute m = m 2 +(qinv*(m 1 -m 2 ) mod p)*q these are precomputed Attack this computation in order to learn q. This is enough to learn private key (why?)

slide 13 Montgomery Reduction uDecryption requires computing m 2 = c d 2 mod q uThis is done by repeated multiplication Simple: square and multiply (process d 2 1 bit at a time) More clever: sliding windows (process d 2 in 5-bit blocks) uIn either case, many multiplications modulo q uMultiplications use Montgomery reduction Pick some R = 2 k To compute x*y mod q, convert x and y into their Montgomery form xR mod q and yR mod q Compute (xR * yR) * R -1 = zR mod q –Multiplication by R -1 can be done very efficiently

slide 14 Schindler’s Observation uAt the end of Montgomery reduction, if zR > q, then need to subtract q Probability of this extra step is proportional to c mod q uIf c is close to q, a lot of subtractions will be done uIf c mod q = 0, very few subtractions Decryption will take longer as c gets closer to q, then become fast as c passes a multiple of q uBy playing with different values of c and observing how long decryption takes, attacker can guess q! Doesn’t work directly against OpenSSL because of sliding windows and two multiplication algorithms

slide 15 Value of ciphertext c Decryption time q2qp Reduction Timing Dependency

slide 16 Integer Multiplication Routines u30-40% of OpenSSL running time is spent on integer multiplication uIf integers have the same number of words n, OpenSSL uses Karatsuba multiplication Takes O(n log 2 3 ) uIf integers have unequal number of words n and m, OpenSSL uses normal multiplication Takes O(nm)

slide 17 g<qg>q Montgomery effect LongerShorter Multiplication effect ShorterLonger g is the decryption value (same as c) Different effects… but one will always dominate! Summary of Time Dependencies

slide 18 Decryption time #Reductions Mult routine Value of ciphertext q 0-1 Gap Discontinuity in Decryption Time

slide 19 Normal SSL Handshake Regular client SSL server 1. ClientHello 2. ServerHello (send public key) 3. ClientKeyExchange (encrypted under public key) Exchange data encrypted with new shared key

slide 20 Attacking SSL Handshake SSL server 1. ClientHello 2. ServerHello (send public key) Attacker 3. Record time t 1 Send guess g or g hi 4. Alert 5. Record time t 2 Compute t 2 –t 1

slide 21 uInitial guess g for q between and (why?) uTry all possible guesses for the top few bits uSuppose we know i-1 top bits of q. Goal: i th bit. Set g = Set g hi = note: g<g hi –If g<q<g hi then the i th bit of q is 0 –If g<g hi <q then the i th bit of q is 1 uGoal: decide whether g<q<g hi or g<g hi <q Attack Overview

slide 22 Two Possibilities for g hi Decryption time #Reductions Mult routine Value of ciphertext q gg hi ? Difference in decryption times between g and g hi will be small Difference in decryption times between g and g hi will be large

slide 23 Timing Attack Details uWhat is “large” and “small”? Know from attacking previous bits uDecrypting just g does not work because of sliding windows Decrypt a neighborhood of values near g Will increase difference between large and small values, resulting in larger 0-1 gap uAttack requires only 2 hours, about 1.4 million queries to recover the private key Only need to recover most significant half bits of q

slide 24 Impact of Neighborhood Size zero-one gap

slide 25 Extracting RSA Private Key Montgomery reduction dominates Multiplication routine dominates zero-one gap

slide 26 Works On The Internet Similar timing on WAN vs. LAN

slide 27 Defenses uBad: require statically that all decryptions take the same time For example, always do the extra “dummy” reduction … but what if compiler optimizes it away? uBad: dynamically make all decryptions the same or multiples of the same time “quantum” Now all decryptions have to be as slow as the slowest decryption uGood: Use RSA blinding

slide 28 RSA Blinding uInstead of decrypting ciphertext c, decrypt a random ciphertext related to c Compute x’ = c*r e mod n, r is random Decrypt x’ to obtain m’ Calculate original plaintext m = m’/r mod n uSince r is random, decryption time is random u2-10% performance penalty

slide 29 Blinding Works