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.

Slides:



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

Digital Signatures Good properties of hand-written signatures: 1. Signature is authentic. 2. Signature is unforgeable. 3. Signature is not reusable (it.
Primality Testing Patrick Lee 12 July 2003 (updated on 13 July 2003)
Session 5 Hash functions and digital signatures. Contents Hash functions – Definition – Requirements – Construction – Security – Applications 2/44.
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.
and Factoring Integers (I)
PKZIP Stream Cipher 1 PKZIP PKZIP Stream Cipher 2 PKZIP  Phil Katz’s ZIP program  Katz invented zip file format o ca 1989  Before that, Katz created.
1 Efficient Algorithms for Elliptic Curve Cryptosystems Original article by Jorge Guajardo and Christof Paar Of WPI ECE Department Presentation by Curtis.
Remote Timing Attacks -Rashmi Kukanur. Agenda  Timing Attacks  Case Study : –David Brumley –Dan Boneh  Defenses.
The RSA Cryptosystem and Factoring Integers (II) Rong-Jaye Chen.
Factoring 1 Factoring Factoring 2 Factoring  Security of RSA algorithm depends on (presumed) difficulty of factoring o Given N = pq, find p or q and.
RC4 1 RC4 RC4 2 RC4  Invented by Ron Rivest o “RC” is “Ron’s Code” or “Rivest Cipher”  A stream cipher  Generate keystream byte at a step o Efficient.
Hellman’s TMTO 1 Hellman’s TMTO Attack. Hellman’s TMTO 2 Popcnt  Before we consider Hellman’s attack, consider simpler Time-Memory Trade-Off  “Population.
How cryptography is used to secure web services Josh Benaloh Cryptographer Microsoft Research.
Cryptography and Network Security Chapter 9. Chapter 9 – Public Key Cryptography and RSA Every Egyptian received two names, which were known respectively.
CMSC 414 Computer and Network Security Lecture 6 Jonathan Katz.
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.
Session 6: Introduction to cryptanalysis part 1. Contents Problem definition Symmetric systems cryptanalysis Particularities of block ciphers cryptanalysis.
Public Key Algorithms 4/17/2017 M. Chatterjee.
Side-Channel Attack: timing attack Hiroki Morimoto.
Cryptography and Network Security Chapter 9 5th Edition by William Stallings Lecture slides by Lawrie Brown.
RSA Question 2 Bob thinks that p and q are primes but p isn’t. Then, Bob thinks ©Bob:=(p-1)(q-1) = Á(n). Is this true ? Bob chooses a random e (1 < e
Tallinn University of Technology Quantum computer impact on public key cryptography Roman Stepanenko.
Lecture 6: Public Key Cryptography
Topic 18: RSA Implementation and Security
The RSA Algorithm Rocky K. C. Chang, March
Hellman’s TMTO 1 Hellman’s TMTO Attack. Hellman’s TMTO 2 Popcnt  Before we consider Hellman’s attack, consider simpler Time-Memory Trade-Off  “Population.
Cryptography Lecture 8 Stefan Dziembowski
FINITE FIELDS 7/30 陳柏誠.
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.
9th IMA Conference on Cryptography & Coding Dec 2003 More Detail for a Combined Timing and Power Attack against Implementations of RSA Werner Schindler.
Digital Signatures A primer 1. Why public key cryptography? With secret key algorithms Number of key pairs to be generated is extremely large If there.
CS526: Information Security Prof. Sam Wagstaff September 16, 2003 Cryptography Basics.
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.
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.
Cryptography and Network Security Chapter 9 - Public-Key Cryptography
Data Security and Encryption (CSE348) 1. Lecture # 12 2.
CHES 2002 Presented at the workshop CHES 2002, August 13-15, 2002, Redwood Shores, California, USA.
Slide 1 Vitaly Shmatikov CS 380S Timing Attacks. slide 2 Reading uKocher. “Timing Attacks on Implementations of Diffie-Hellman, RSA, DSS, and Other Systems”
Alternative Wide Block Encryption For Discussion Only.
Cryptography 1 Crypto Cryptography 2 Crypto  Cryptology  The art and science of making and breaking “secret codes”  Cryptography  making “secret.
Sliding Windows Succumbs to Big Mac Attack Colin D. Walter
Cryptography and Network Security Public Key Cryptography and RSA.
Precise Bounds for Montgomery Modular Multiplication and Some Potentially Insecure RSA Moduli Colin D. Walter formerly: (Manchester,
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.
M IST : An Efficient, Randomized Exponentiation Algorithm for Resisting Power Analysis Colin D. Walter formerly: (Manchester, UK)
M IST : An Efficient, Randomized Exponentiation Algorithm for Resisting Power Analysis Colin D. Walter (Manchester, UK)
Ch1 - Algorithms with numbers Basic arithmetic Basic arithmetic Addition Addition Multiplication Multiplication Division Division Modular arithmetic Modular.
Precise Bounds for Montgomery Modular Multiplication and Some Potentially Insecure RSA Moduli Colin D. Walter formerly: (Manchester,
Remote Timing Attacks are Practical David Brumley Dan Boneh [Modified by Somesh.
1/16 Seeing through M IST given a Small Fraction of an RSA Private Key Colin D. Walter Comodo Research Lab (Bradford, UK)
WISA 2007 Jeju Island, Korea, 27th – 29th Aug 2007 Longer Randomly Blinded RSA Keys may be Weaker than Shorter Ones Colin D. Walter
9.1 Primes and Related Congruence Equations 23 Sep 2013.
0x1A Great Papers in Computer Security Vitaly Shmatikov CS 380S
Cryptography Lecture 14 Arpita Patra © Arpita Patra.
By Marwan Al-Namari & Hafezah Ben Othman Author: William Stallings College of Computer Science at Al-Qunfudah Umm Al-Qura University, KSA, Makkah 1.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
Copyright © Zeph Grunschlag, RSA Encryption Zeph Grunschlag.
1 The RSA Algorithm Rocky K. C. Chang February 23, 2007.
Cryptography services Lecturer: Dr. Peter Soreanu Students: Raed Awad Ahmad Abdalhalim
Key Exchange in Systems VPN usually has two phases –Handshake protocol: key exchange between parties sets symmetric keys –Traffic protocol: communication.
Introduction to Cryptography
Cryptography Lecture 16.
RSA Implementation Attacks
Presentation transcript:

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 (mod N)  Digital signature o Hash M then sign  In protocols, sign M itself: S = M d (mod N)

RSA Attacks 3 Implementation Attacks  Attacks on RSA implementation o Not attacks on RSA algorithm per se  Timing attacks o Exponentiation is very expensive computation o Try to exploit differences in timing for different private key bits  Glitching attack o Induced errors may reveal private key

RSA Attacks 4 Modular Exponentiation  Attacks we discuss arise from specific details of modular exponentiation  For efficiency, modular exponentiation uses some combination of o Repeated squaring o Chinese Remainder Theorem (CRT) o Montgomery multiplication o Sliding window o Karatsuba multiplication  Next, we briefly discuss each of these

RSA Attacks 5 Repeated Squaring  Modular exponentiation example o 5 20 = = 25 mod 35  A better way: repeated squaring o 20 = base 2 o (1, 10, 101, 1010, 10100) = (1, 2, 5, 10, 20) o Note that 2 = 1  2, 5 = 2  2 + 1, 10 = 2  5, 20 = 2  10 o 5 1 = 5 mod 35 o 5 2 = (5 1 ) 2 = 5 2 = 25 mod 35 o 5 5 = (5 2 ) 2  5 1 = 25 2  5 = 3125 = 10 mod 35 o 5 10 = (5 5 ) 2 = 10 2 = 100 = 30 mod 35 o 5 20 = (5 10 ) 2 = 30 2 = 900 = 25 mod 35  No huge numbers and it’s efficient o In this example, 5 steps vs 20 for naïve method

RSA Attacks 6 Repeated Squaring  Repeated Squaring algorithm // Compute y = x d (mod N) // where, in binary, d = (d 0,d 1,d 2,…,d n ) with d 0 = 1 s = x for i = 1 to n s = s 2 (mod N) if d i == 1 then s = s  x (mod N) end if next i return s

RSA Attacks 7 Sliding Window  A simple time memory tradeoff for repeated squaring  Instead of processing each bit…  …process block of n bits at once o Use pre-computed lookup tables o Typical value is n = 5

RSA Attacks 8 Chinese Remainder Theorem  Chinese Remainder Theorem (CRT)  We want to compute, say, C d (mod N) where N = pq  With CRT, we compute C d modulo p and modulo q, then “glue” them together  Two modular reductions of size N 1/2 o As opposed to one reduction of size N  CRT provides significant speedup

RSA Attacks 9 CRT Algorithm  We know C, d, N, p and q  Want to compute C d (mod N) where N = pq  Pre-compute d p = d (mod (p  1)) and d q = d (mod (q  1))  And pre-compute a and b such that a = 1 (mod p) and a = 0 (mod q) b = 0 (mod p) and b = 1 (mod q)

RSA Attacks 10 CRT Algorithm  We have d p, d q, a and b satisfying d p = d (mod (p  1)) and d q = d (mod (q  1)) a = 1 (mod p) and a = 0 (mod q) b = 0 (mod p) and b = 1 (mod q)  Given C and want to find C d (mod N)  Compute:  And:  Solution is:

RSA Attacks 11 CRT Example  Suppose N = 33, p = 11, q = 3 and d = 7 o Then e = 3, but not needed here  Pre-compute d p = 7 (mod 10) = 7 and d q = 7 (mod 2) = 1  Also, a = 12 and b = 22 satisfy conditions  Suppose we are given C = 5 o That is, we want to compute C d = 5 7 (mod 33) o Find C p = 5 (mod 11) = 5 and C q = 5 (mod 3) = 2 o And x p = 5 7 = 3 (mod 11), x q = 2 1 = 2 (mod 3)  Easy to verify: 5 7 = 3   2 = 14 (mod 33)

RSA Attacks 12 CRT: The Bottom Line  Looks like a lot of work  But it is actually a big “win” o Provides a speedup by a factor of 4  Any disadvantage? o Factors p and q of N must be known o Violates “trap door” property? o Factors only for private key operations

RSA Attacks 13 Montgomery Multiplication  Very clever method to reduce work in modular multiplication o And therefore in modular exponentiation  Consider computing ab (mod N)  Expensive part is modular reduction  Naïve approach requires division  In some cases, no division needed…

RSA Attacks 14 Montgomery Multiplication  Consider product ab = c (mod N) o Where modulus is of form N = m k  1  Then there exist c 0 and c 1 such that c = c 1 m k + c 0  Can rewrite this as c = c 1 (m k  1) + (c 1 + c 0 ) = c 1 + c 0 (mod N)  In this case, if we can find c 1 and c 0, then no division is required in modular reduction

RSA Attacks 15 Montgomery Multiplication  For example, consider 3089 (mod 99) 3089 = 30  = 30(100  1) + ( ) = 30  99 + ( ) = 119 (mod 99)  Only one subtraction required to compute 3089 (mod 99)  In this case, no division needed

RSA Attacks 16 Montgomery Multiplication  Montgomery analogous to previous example o But Montgomery works for any modulus N o Big speedup for modular exponentiation  Idea is to convert to “Montgomery form”, do multiplications, then convert back o “Montgomery multiplication” is highly efficient way to do multiplication and modular reduction o In spite of conversions to and from Montgomery form, this is a BIG win for exponentiation

RSA Attacks 17 Montgomery Form  Consider ab (mod N)  Choose R = 2 k with R > N and gcd(R,N) = 1  Also, find R and N so that RR  NN = 1  Instead of a and b, we work with a = aR (mod N) and b = bR (mod N)  The numbers a and b are said to be in Montgomery form

RSA Attacks 18 Montgomery Multiplication  Given a = aR (mod N), b = bR (mod N) and RR  NN = 1  Compute ab = (aR (mod N))(bR (mod N)) = abR 2  Then, abR 2 denotes the product ab without any additional mod N reduction  Note that abR 2 need not be divisible by R due to the mod N reductions

RSA Attacks 19 Montgomery Multiplication  Given a = aR (mod N), b = bR (mod N) and RR  NN = 1  Then ab = (aR (mod N))(bR (mod N)) = abR 2  Want ab to be in Montgomery form o That is, want abR (mod N), not abR 2 o Note that RR = 1 (mod N)  Looks easy, since abR 2 R = abR (mod N)  But, want to avoid costly mod N operation o Montgomery algorithm provides clever solution

RSA Attacks 20 Montgomery Multiplication  Given abR 2 and RR  NN = 1 and R = 2 k  Want to find abR (mod N) o Without costly mod N operation (division)  Note: “ mod R ” and division by R are easy o Since R is a power of 2  Let X = abR 2  Montgomery algorithm on next slide

RSA Attacks 21 Montgomery Reduction  Have X = abR 2, RR  NN = 1, R=2 k  Want to find abR (mod N)  Montgomery reduction m = (X (mod R))  N (mod R) x = (X + mN)/R if x  N then x = x  N // extra reduction end if return x

RSA Attacks 22 Montgomery Reduction  Why does Montgomery reduction work? o Recall that input is X = abR 2 o Claim: output is x = abR (mod N)  Carefully examine main steps of Montgomery reduction algorithm: m = (X (mod R))  N (mod R) x = (X + mN)/R

RSA Attacks 23 Montgomery Reduction  Given X = abR 2 and RR  NN = 1 o Note that NN =  1 (mod R)  Consider m = (X (mod R))  N (mod R) o In words: m is product of N and remainder of X/R  Therefore, X + mN = X  (X (mod R)) o Implies X + mN divisible by R o Since R = 2 k, division is simply a shift  Consequently, it is trivial to compute x = (X + mN)/R

RSA Attacks 24 Montgomery Reduction  Given X = abR 2 and RR  NN = 1 o Note that RR = 1 (mod N)  Consider x = (X + mN)/R  Then xR = X + mN = X (mod N)  And xRR = XR (mod N)  Therefore x = xRR = XR = abR 2 R = abR (mod N)

RSA Attacks 25 Montgomery Example  Suppose N = 79, a = 61 and b = 5  Use Montgomery to compute ab (mod N)  Choose R = 10 2 = 100 o For human readability, R is a power of 10 o For computer, choose R to be a power of 2  Then a = 61  100 = 17 (mod 79) b = 5  100 = 26 (mod 79)

RSA Attacks 26 Montgomery Example  Consider ab = 61  5 (mod 79) o Recall that R = 100 o a = aR = 17 (mod 79) and b = bR = 26 (mod 79)  Euclidean Algorithm gives 64   79 = 1  Then R = 64 and N = 81  Monty reduction to determine abR (mod 79)  First, X = ab = 17  26 = 442 = abR 2

RSA Attacks 27 Montgomery Example  Given X = ab = abR 2 = 442  Also have R = 64 and N = 81  Want to determine abR (mod 79)  By Montgomery reduction algorithm m = (X (mod R))  N (mod R) = 42  81 = 3402 = 2 (mod 100) x = (X + mN)/R (mod R) = (  79)/100 = 600/100 = 6 (mod 100)  Verify: abR = 61  5  100 = 6 (mod 79)

RSA Attacks 28 Montgomery Example  Have abR = 6 (mod 79)  But this number is in Montgomery form  Convert to non-Montgomery form o Recall RR = 1 (mod N) o So abRR = ab (mod N)  For this example, R = 64 and N = 79  Find ab = abRR = 6  64 = 68 (mod 79)  Easy to verify ab = 61  5 = 68 (mod 79)

RSA Attacks 29 Montgomery: Bottom Line  Easier to compute ab (mod N) directly, without using Montgomery algorithm!  However, for exponentiation, Montgomery is much more efficient o For example, to compute M d (mod N)  To compute M d (mod N) o Convert M to Montgomery form o Do repeated (cheap) Montgomery multiplications o Convert final result to non-Montgomery form

RSA Attacks 30 Karatsuba Multiplication  Most efficient way to multiply two numbers of about same magnitude o Assuming add is much cheaper than mult  For n -bit number o Karatsuba work factor: n o Ordinary long multiplication: n 2  Based on a simple observation

RSA Attacks 31 Karatsuba Multiplication  Consider the product (a 0 + a 1  10)(b 0 + b 1  10)  Naïve approach requires 4 multiplies to determine coefficients: a 0 b 0 + (a 1 b 0 + a 0 b 1 )10 + a 1 b 1  10 2  Same result with just 3 multiplies: a 0 b 0 + [(a 0 + a 1 )(b 0 + b 1 )  a 0 b 0  a 1 b 1 ]10 + a 1 b 1  10 2

RSA Attacks 32 Karatsuba Multiplication  Does Karatsuba work for bigger numbers?  For example c 0 + c 1  10 + c 2  c 3  10 3 = C 0 + C 1  10 2  Where C 0 = c 0 + c 1  10 and C 1 = c 2 + c 3  10  Can apply Karatsuba recursively to find product of numbers of any magnitude

RSA Attacks 33 Timing Attacks  We discuss 3 different attacks  Kocher’s attack o Systems that use repeated squaring but not CRT or Montgomery (smart cards)  Schindler’s attack o Repeated squaring, CRT and Montgomery (no real systems are known)  Brumley-Boneh attack o CRT, Montgomery, sliding windows, Karatsuba (as used in openSSL)

RSA Attacks 34 Kocher’s Attack  Attack on repeated squaring o Does not work if CRT or Montgomery used o In most applications, CRT and Montgomery multiplication are used o Some resource-constrained devices only use repeated squaring  This attack designed for smartcards

RSA Attacks 35 Repeated Squaring  Repeated Squaring algorithm // Compute y = x d (mod N) // where, in binary, d = (d 0,d 1,d 2,…,d n ) with d 0 = 1 s = x for i = 1 to n s = s 2 (mod N) if d i == 1 then s = s  x (mod N) end if next i return s

RSA Attacks 36 Kocher’s Attack: Assumptions  Repeated squaring algorithm is used  Timing of multiplication s  x (mod N) in algorithm varies depending on s and x o That is, multiplication is not constant-time  Trudy can accurately emulate timings given putative s and x  Trudy can obtain accurate timings of private key operation, C d (mod N)

RSA Attacks 37 Kocher’s Attack  Recover private key bits one (or a few) at a time o Private key: d = d 0,d 1,…,d n with d 0 = 1 o Recover bits in order, d 1,d 2,d 3,…  Don’t need to recover all bits o Can efficiently recover low-order bits when enough high-order bits are known o Coppersmith’s algorithm

RSA Attacks 38 Kocher’s Attack  Suppose bits d 0,d 1,…,d k  1, are known  We want to determine bit d k  Randomly select C j for j=0,1,…,m-1, obtain timings T(C j ) for C j d (mod N)  For each C j emulate steps i=1,2,…,k-1 of repeated squaring  At step k, emulate d k = 0 and d k = 1  Variance of timing difference will be smaller for correct choice of d k

RSA Attacks 39 Kocher’s Attack  For example o Suppose private key is 8 bits o That is, d = (d 0,d 1,…,d 7 ) with d 0 = 1  Trudy is sure that d 0 d 1 d 2 d 3  {1010,1001}  Trudy generates random C j, for each… o She obtains the timing T(C j ) and o Emulates d 0 d 1 d 2 d 3 = 1010 and d 0 d 1 d 2 d 3 = 1010  Let  i be emulated timing for bit i o Depends on bit value that is emulated

RSA Attacks 40 Kocher’s Attack  Private key is 8 bits  Trudy is sure that d 0 d 1 d 2 d 3  {1010,1001}  Trudy generates random C j, for each…  Define  i to be emulated timing for bit i o For i > m let  i…m be shorthand for  i +  i+1 + … +  m  Trudy tabulates T(C j ) and  0…3 blah  She computes variances o Smaller variance “wins”  See next slide for fictitious example…

RSA Attacks 41 Kocher’s Attack  Suppose Trudy obtains timings  For d 0 d 1 d 2 d 3 = 1010 Trudy finds E(T(C j )   0…3 ) = 6 and var(T(C j )   0…3 ) = 1/2  For d 0 d 1 d 2 d 3 = 1001 Trudy finds E(T(C j )   0…3 ) = 6 and var(T(C j )   0…3 ) = 1  Kocher’s attack implies d 0 d 1 d 2 d 3 = 1010

RSA Attacks 42 Kocher’s Attack  Why does small variance win? o More bits are correct, so less variance  More precisely, define o  i is emulated timing for bit i o t i is actual timing for bit i  Assume var(t i ) = var(t) for all i o u is measurement “error”  In the previous example, o Correct case: var(T(C j )   0…3 ) = 4var(t) + var(u) o Incorrect case: var(T(C j )   0…3 ) = 6var(t) + var(u)

RSA Attacks 43 Kocher’s Attack: Bottom Line  Simple and elegant attack o Provided only repeated squaring used o Limited utility—most RSA use CRT, Monty, etc.  Why does this fail if CRT, etc., used?  Timing variations due to CRT, Montgomery, etc., included in error term u  Then var(u) would overwhelm variance due to repeated squaring o We’ll see precisely why this is so later…

RSA Attacks 44 Schindler’s Attack  Assume repeated squaring, Montgomery algorithm and CRT are all used  Not aimed at any real system o Optimized systems also use Karatsuba for numbers of same magnitude and “long” multiplication for other numbers o Schindler’s attack will not work in such cases  But this attack is an important stepping stone to next attack (Brumley-Boneh)

RSA Attacks 45 Schindler’s Attack  Montgomery algorithm

RSA Attacks 46 Schindler’s Attack  Repeated squaring

RSA Attacks 47 Schindler’s Attack  CRT is also used o For each mod N reduction, where N = pq o Compute mod p and mod q reductions o Use repeated squaring algorithm on previous slide for both  Trudy chooses ciphertexts C j o Obtains accurate timings of C j d (mod N) o Goal is to recover d

RSA Attacks 48 Schindler’s Attack  Takes advantage of “extra reduction”  Suppose a = aR (mod N) and B random o That is, B is uniform in {0,1,2,…,N  1}  Then Schindler determined that

RSA Attacks 49 Schindler’s Attack  Repeated squaring aka square and multiply o Square: s = Montgomery(s,s) o Multiply: s = Montgomery(s,t)  Probability of extra reduction in “multiply”:  Probability of extra reduction in “square”:

RSA Attacks 50 Schindler’s Attack  Consider using CRT  First step is  Where  Suppose in this computation there are k 0 multiples and k 1 squares  Expected number of extra reductions:

RSA Attacks 51 Schindler’s Attack  Expected extra reductions:  Discontinuity at every integer multiple of p

RSA Attacks 52 Schindler’s Attack  How to take advantage of this?  If chosen ciphertext C 0 is close to C 1 o By continuity, timing T(C 0 ) close to T(C 1 )  However, if C 0 < kp < C 1, then  T(C 0 )  T(C 1 )  is “large” due to discontinuity  Note: total number of extra reductions include those for factors p and q o Discontinuities at all multiples of p and q

RSA Attacks 53 Schindler’s Attack: Algorithm  Select initial value x and offset   Let C i = x + i  for i = 0,1,2,…  Compute t i = T(C i+1 )  T(C i ) for i = 0,1,2,…  Eventually, “bracket” a multiple of p o That is, C i < kp < C i+1 o Detect this since t i is large  Then compute gcd(n,N) for all C i  n  C i+1 o gcd(kp,N) = p and gcd(n,N) = 1 otherwise

RSA Attacks 54 Schindler’s: Bottom Line  Clever attack: repeated squaring, Montgomery multiplication and CRT o Crucial insight: extra reductions in Montgomery algorithm create timing issue  However, attack not applicable to any real- world implementation o Optimized implementations also use Karatsuba o Karatsuba tends to counteract timing difference caused by extra reduction

RSA Attacks 55 Brumley-Boneh Attack  CRT, Montgomery multiplication, sliding windows and Karatsuba  Optimized RSA implementations use all of these  Attack is robust o Works against OpenSSL over a network o Network timing variations are large  The ultimate timing attack (to date)

RSA Attacks 56 Brumley-Boneh Attack  Designed to attack RSA in OpenSSL o Highly optimized implementation o CRT, repeated squaring, Monty multiply, sliding window (5 bits) o Karatsuba multiply for numbers of same magnitude; long multiply otherwise  Kocher’s attack fails due to CRT  Schindler’s attack fails due to Karatsuba  Brumley-Boneh extend Schindler’s attack

RSA Attacks 57 Brumley-Boneh Attack  RSA in OpenSSL has two timing issues o Montgomery extra reductions o Karatsuba versus long multiplication  These 2 tend to counteract each other o More extra reductions (slower) occur when Karatsuba multiply (faster) is used o Fewer extra reductions (faster) occur when long multiply (slower) is used

RSA Attacks 58 Brumley-Boneh Attack  Consider C, the Montgomery form of C  Suppose C is close to p with C > p o Number of extra Montgomery reductions is small o C (mod p) is small, so long multiply is used  Suppose C is close to p with C < p o Number of extra Montgomery reductions is large o C (mod p) also close to p, so Karatsuba multiply  What to do?

RSA Attacks 59 Brumley-Boneh Attack  Two timing effects: Montgomery extra reductions and Karatsuba effect o Each dominates at different points in attack  Implies Schindler’s could not recover bits where Karatsuba effect dominates  Brumley-Boneh recovers factor p of modulus N = pq one bit at a time o Analogous to Kocher’s, but unlike Schindler’s

RSA Attacks 60 Brumley-Boneh Attack: Step 1  Denote bits of p as p = (p 0,p 1,p 2,…,p n ) o Where p 0 = 1  Suppose p 1,p 2,…,p i  1 have been determined  Choose C 0 = (p 0,p 1,…, p i  1,0,0,…,0)  Choose C 1 = (p 0,p 1,…, p i  1,1,0,…,0)  Note o If p i is 1, then C 0 < C 1  p o If p i is 0, then C 0  p < C 1

RSA Attacks 61 Brumley-Boneh Attack: Step 2  Obtain decryption times T(C 0 ) and T(C 1 )  Let  =  T(C 0 )  T(C 1 )   If C 0 < p < C 1 then  is large  p i = 0  If C 0 < C 1 < p then  is small  p i = 1 o Previous  used to set large/small thresholds  Works provided that extra reduction or Karatsuba dominates at each step o See next slide…

RSA Attacks 62 Brumley-Boneh Attack: Step 2  If p i = 1 then C 0 < C 1 < p o Extra reductions are about the same o Karatsuba multiply used since mod p magnitudes are same o Expect  to be “small”  If p i = 0 then C 0 < p < C 1 o If extra reduction dominate, T(C 0 )  T(C 1 ) > 0 o If Karatsuba vs long dominates, T(C 0 )  T(C 1 ) < 0 o In either case, expect  to be “large”

RSA Attacks 63 Brumley-Boneh Attack: Step 3  Repeat steps 1 and 2  Recover bits p i+1,p i+2,p i+3,…  When half of bits of p recovered, use Coppersmiths algorithm to factor N  Then d easily recovered

RSA Attacks 64 Brumley-Boneh Attack: Real-World Issues  In OpenSSL, sliding windows used o Greatly reduces number of multiplies o Statistical methods must be used—repeated measurements, test nearby values, etc.  OpenSSL attack over a network o Statistical methods needed o Attack is surprisingly robust  Over realistic network, 1024-bit modulus factored with 1.4M chosen ciphertexts

RSA Attacks 65 Brumley-Boneh: Bottom Line  A major cryptanalytic achievement  Surprising that it is robust enough to overcome network variations  Resulted in changes to OpenSSL o And other RSA implementations  Brumley-Boneh is a realistic threat!

RSA Attacks 66 Preventing Timing Attack  Several methods have been suggested  Best solution is RSA Blinding  To decrypt C generate random r then Y = r e C (mod N)  Decrypt Y then multiply by r  1 (mod N) : r  1 Yd = r  1 (r e C) d = r  1 rC d = C d (mod N)  Since r is random, Trudy cannot obtain timing info from choice of C o Slight performance penalty

RSA Attacks 67 Glitching Attack  Induced error reveals private key  CRT leads to simple glitching attack  A single glitch may allow Trudy to factor the modulus!  A realistic threat to smartcards o And other systems where attacker has physical access (e.g., trusted computing)

RSA Attacks 68 Glitching Attack  Consider CRT for signing M  Let M p = M (mod p) and M q = M (mod q)  Let d p = d (mod (p  1)) and d q = d (mod (q  1))  Sign: S = M d (mod N) = ax p + bx q (mod N) a = 1 (mod p) and a = 0 (mod q) b = 0 (mod p) and b = 1 (mod q)

RSA Attacks 69 Glitching Attack  Trudy forces a single error to occur  Suppose x q computed in place of x q o But x p computed correctly o That is, error in M q or x q computation  “Signature” is S = ax p + bx q (mod N)  Trudy knows error has occurred since (S) e (mod N)  M

RSA Attacks 70 Glitching Attack  Trudy has forced an error  Trudy has S = ax p + bx q (mod N) o a = 1 (mod p) and a = 0 (mod q) o b = 0 (mod p) and b = 1 (mod q)  Then S (mod p) = x p = (M (mod p)) d (mod (p  1)) o Follows from definitions of x p and a

RSA Attacks 71 Glitching Attack  Trudy has forced an error, so that S (mod p) = x p = (M (mod p)) d (mod (p  1))  It can be shown (S) e = M (mod p) o That is, (S) e  M = kp for some k  Also, (S) e  M (mod q) o Then (S) e  M not a multiple of the factor q  Therefore, gcd(N, (S) e  M) reveals nontrivial factor of N, namely, p or q

RSA Attacks 72 Glitching: Bottom Line  Single glitch can break some systems  A realistic threat  Even if probability of error is small, advantage lies with attacker  Glitches can also break some RSA implementations where CRT not used

RSA Attacks 73 Conclusions  Timing attacks are real! o Serious issue for public key (symmetric key?)  Glitching attacks also serious in some cases  These attacks not traditional cryptanalysis o Here, Trudy does not play by the “rules”  Crypto security—more than strong algorithms o Also need “strong” implementations o Good guys must think outside the box o Attackers will exploit any weak link