< Return to Video

Is RSA a one-way function? (17 min)

  • 0:00 - 0:02
    The next question, we're going to ask:
  • 0:02 - 0:04
    is RSA really an one-way function?
  • 0:04 - 0:06
    In other words, is it really hard to
  • 0:06 - 0:08
    invert RSA without knowing the trapdoor?
  • 0:09 - 0:12
    So, if an attacker wanted to invert the RSA function,
  • 0:12 - 0:15
    well, what the attacker has, is basically the public key,
  • 0:15 - 0:19
    namely he has N and e. And now, he is given x to the e
  • 0:19 - 0:23
    and his goal is to recover x. OK, so the question really is:
  • 0:23 - 0:26
    given x to the e modulo N, how hard is it to
  • 0:26 - 0:29
    recover x? So, what we're really asking is,
  • 0:29 - 0:33
    how hard is it to compute e'th roots modulo a composite?
  • 0:34 - 0:39
    If this problem turns out to be hard, then RSA is in fact an one-way function.
  • 0:39 - 0:40
    If this problem turns out to be easy, which
  • 0:40 - 0:45
    of course we don't believe it's easy, then RSA would actually be broken.
  • 0:45 - 0:47
    So, it turns out the best algorithm for this problem
  • 0:47 - 0:50
    requires us to first factor the modulus N.
  • 0:50 - 0:52
    And then, once we factored the modulus, we have already
  • 0:52 - 0:56
    seen last week, that it's easy to compute the e'th root modulo p,
  • 0:56 - 0:58
    it's easy to compute the e'th root modulo q.
  • 0:58 - 1:02
    And, then given both those e'th roots, it's actually easy to combine them together,
  • 1:02 - 1:05
    using what's called the Chinese remainder theorem
  • 1:05 - 1:08
    and actually recover the e'th root modulo N.
  • 1:08 - 1:10
    So, once we are able to factor the modulus,
  • 1:10 - 1:13
    computing e'th roots modulo N becomes easy.
  • 1:13 - 1:15
    But, factoring the modulus, as far as
  • 1:15 - 1:17
    we know, is a very, very difficult problem.
  • 1:17 - 1:20
    But a natural question is, is it true that in
  • 1:20 - 1:23
    order to compute e'th roots modulo N, we have to
  • 1:23 - 1:26
    factor the modulus N? As far as we know, the
  • 1:26 - 1:27
    best algorithm for computing e'th roots
  • 1:27 - 1:30
    modulo N requires factorization of N.
  • 1:30 - 1:32
    But, who knows, maybe there is a short cut
  • 1:32 - 1:34
    that allows us to compute e'th roots modulo N,
  • 1:34 - 1:37
    without factoring the modulus. To show that
  • 1:37 - 1:39
    that's not possible, we have to show a reduction.
  • 1:39 - 1:40
    That is, we have to show that,
  • 1:40 - 1:42
    if I give you an efficient algorithm for
  • 1:42 - 1:44
    computing e'th roots modulo N, that
  • 1:44 - 1:48
    efficient algorithm can be turned into a factoring algorithm.
  • 1:48 - 1:51
    So, this is called a reduction. Namely, given an algorithm for
  • 1:51 - 1:53
    e'th roots modulo N, we obtain a factoring algorithm.
  • 1:53 - 1:57
    That would show that one cannot compute e'th roots modulo N
  • 1:57 - 2:00
    faster than factoring the modulus.
  • 2:00 - 2:02
    If we had such a result, it would show that
  • 2:02 - 2:06
    actually breaking RSA, in fact is as hard as factoring.
  • 2:06 - 2:08
    But, unfortunately, this is not really known at the moment.
  • 2:08 - 2:12
    In fact, this is one of the oldest problems in public key crypto.
  • 2:12 - 2:14
    So, just let me give you a concrete example.
  • 2:14 - 2:19
    Suppose, I give you an algorithm that will compute cube roots modulo N.
  • 2:19 - 2:24
    So, for any x in ZN, the algorithm will compute the cube root of x modulo N.
  • 2:24 - 2:26
    My question is, can you show that using
  • 2:26 - 2:29
    such an algorithm you can factor the modulus N?
  • 2:29 - 2:31
    And, even that is not known. What is known,
  • 2:31 - 2:34
    I'll tell you, is for example that for e equals 2,
  • 2:34 - 2:38
    that is if I give you an algorithm for computing square roots modulo N,
  • 2:38 - 2:41
    then in fact, that does imply factoring the modulus.
  • 2:41 - 2:45
    So, computing square roots is in fact as hard as factoring the modulus.
  • 2:45 - 2:48
    Unfortunately, if you think back to the definition of RSA,
  • 2:48 - 2:53
    that required that e times d be 1 modulo phi(N).
  • 2:53 - 2:59
    What that means is, that e necessarily needs to be relatively prime to phi(N).
  • 2:59 - 3:03
    Right, this, what the first equation says is that e is invertible modulo phi(N).
  • 3:03 - 3:06
    But, if e is invertible modulo phi(N), necessarily that means that
  • 3:06 - 3:09
    e must be relatively prime to phi(N).
  • 3:09 - 3:14
    But, phi(N), if you remember, that is equal to p minus 1 times q minus 1.
  • 3:14 - 3:19
    And, since p and q are both large primes, p - 1 times q - 1 is always even.
  • 3:19 - 3:26
    And, as a result, the GCD of 2 and phi(N) is equal to 2,
  • 3:26 - 3:28
    because phi(N) is even. And therefore, the public
  • 3:28 - 3:31
    exponent 2 is not relatively prime to phi(N).
  • 3:31 - 3:33
    Which means that, even though we have a reduction
  • 3:33 - 3:35
    from taking square roots to factoring,
  • 3:35 - 3:39
    e equals 2 cannot be used as an RSA exponent.
  • 3:39 - 3:44
    So, really the smallest RSA exponent that is legal is in fact e equals 3.
  • 3:44 - 3:47
    But, for e equal 3, the question of whether computing cube roots
  • 3:47 - 3:49
    is as hard as factoring, is an open problem.
  • 3:49 - 3:51
    It's actually a lot of fun to think about this question.
  • 3:51 - 3:53
    So, I would encourage you to think about it just a little bit.
  • 3:53 - 3:58
    That is, if I give you an efficient algorithm for computing cube roots modulo N,
  • 3:58 - 4:02
    can you use that algorithm to actually factor the modulus N?
  • 4:02 - 4:05
    I will tell you that there is a little bit of evidence to say
  • 4:05 - 4:09
    that a reduction like that, actually doesn't exist, but it is very, very weak evidence.
  • 4:09 - 4:11
    What this evidence says is basically, if you
  • 4:11 - 4:14
    give me a reduction of a very particular form.
  • 4:14 - 4:16
    In other words, if your reduction is what's called algebraic,
  • 4:16 - 4:19
    (I am not going to explain what that means here.)
  • 4:19 - 4:23
    That is, if given a cube root oracle, you could actually show me an algorithm
  • 4:23 - 4:26
    that would then factor. That reduction, by itself,
  • 4:26 - 4:29
    would actually imply a factoring algorithm.
  • 4:29 - 4:31
    Okay so, that would say that if factoring is hard,
  • 4:31 - 4:34
    a reduction actually doesn't exist.
  • 4:34 - 4:36
    But, as I say this is very weak evidence.
  • 4:36 - 4:38
    Because, who is to say that the reduction needs to be algebraic.
  • 4:38 - 4:40
    Maybe, there are some other types of reductions that
  • 4:40 - 4:43
    we haven't really considered. So, I would
  • 4:43 - 4:44
    encourage you to think a little bit about this
  • 4:44 - 4:46
    question. It's actually quite interesting.
  • 4:46 - 4:50
    How would you use a cube root algorithm to factor the modulus?
  • 4:51 - 4:54
    But as I said, as far as we know, RSA is a one way function.
  • 4:54 - 5:00
    In fact, breaking RSA, computing e'th roots that is, actually requires factoring the modulus.
  • 5:00 - 5:03
    We all believe that's true, and that's the state of the art.
  • 5:03 - 5:08
    But, now there has been a lot of work on trying to improve the performance of RSA.
  • 5:08 - 5:12
    Either, RSA encryption or improve the performance of RSA decryption.
  • 5:12 - 5:15
    And it turns out, there has been a number of false starts in this direction.
  • 5:15 - 5:19
    So I want to show you, this wonderful example as a warning.
  • 5:19 - 5:23
    So basically, this is an example of how not to improve the perfomance of RSA.
  • 5:23 - 5:27
    So, you might think that if I wanted to speed up RSA decryption,
  • 5:27 - 5:29
    remember decryption is done by raising the
  • 5:29 - 5:31
    ciphertext to the power of d. And, you remember
  • 5:31 - 5:34
    that the exponentiation algorithm ran in linear
  • 5:34 - 5:38
    time in the size of d. Linear time in log of d.
  • 5:38 - 5:40
    So, you might think to yourself, well if I wanted
  • 5:40 - 5:44
    to speed up RSA decryption, why don't I just use a small d.
  • 5:44 - 5:48
    I'll say, I'll say a decryption exponent that's on the order of 2 to the 128.
  • 5:48 - 5:52
    So it's clearly big enough so that exhaustive search against d is not possible.
  • 5:52 - 5:57
    But normally, the decryption exponent d would be as big as the modulus, say 2000 bits.
  • 5:57 - 6:05
    By using d that's only 128 bits, I basically speed up RSA decryption by a factor of 20.
  • 6:05 - 6:08
    Right, I went down from 2000 bits to 100 bits.
  • 6:08 - 6:11
    So, exponentiation would run 20 times as fast.
  • 6:11 - 6:15
    It turns out this is a terrible idea. Terrible, terrible idea, in the following sense.
  • 6:15 - 6:19
    There is an attack by Michael Wiener that shows that, in fact,
  • 6:19 - 6:23
    as soon as the private exponent d is less than the fourth root of the modulus.
  • 6:23 - 6:28
    Let's see, if the modulus is around 2048 bits
  • 6:28 - 6:35
    that means that if d is less that 2 to the 512, then RSA is completely, completely insecure.
  • 6:35 - 6:38
    And, this is, it's insecure in the worst possible way.
  • 6:38 - 6:43
    Namely, just given a public key and an e, you can very quickly recover the private key d.
  • 6:44 - 6:48
    Well, so some folks said: well this attack works up to 512 bits.
  • 6:48 - 6:52
    So, why don´t we make the modulus, say, you know 530 bits.
  • 6:52 - 6:54
    Then, this attack actually wouldn't apply.
  • 6:54 - 6:58
    But still, we get to speed up RSA decryption by a factor of 4,
  • 6:58 - 7:02
    because we shrunk the exponent from 2000 bits to, say, 530 bits.
  • 7:02 - 7:04
    Well it turns out, even that is not secure. In fact,
  • 7:04 - 7:06
    there is an extension to Wiener's attack, that's actually much
  • 7:06 - 7:08
    more complicated, that shows that if d
  • 7:08 - 7:13
    is less than N to the 0.292, then also RSA is insecure.
  • 7:13 - 7:17
    And in fact, the conjecture that this is true up to N to the 0.5.
  • 7:17 - 7:22
    So even if d is like N to the 0.4999, RSA should still be insecure,
  • 7:22 - 7:26
    although this is an open problem. It's again, a wonderful open problem,
  • 7:26 - 7:28
    It's been open for like, what is it, 14 years now.
  • 7:28 - 7:32
    And, nobody can progress beyond this 0.292.
  • 7:32 - 7:34
    Somehow, it seems kind of strange, why would 0.292
  • 7:34 - 7:38
    be the right answer and yet no one can go beyond 0.292.
  • 7:39 - 7:42
    So, just to be precise, when I say that RSA is insecure,
  • 7:42 - 7:45
    what I mean is just given the public key N and e,
  • 7:45 - 7:48
    your goal is to recover the secret key d.
  • 7:49 - 7:52
    If you are curious where 0.292 comes from,
  • 7:52 - 7:56
    I'll tell you that what it is, it's basically 1 minus 1 over square root of 2.
  • 7:56 - 7:59
    Now how could this possibly be the right answer to this problem?
  • 7:59 - 8:01
    It's much more natural that the answer is N to the 0.5.
  • 8:01 - 8:04
    But this is still an open problem. Again if you want to think about that,
  • 8:04 - 8:06
    it's kind of a fun problem to work on.
  • 8:06 - 8:10
    So the lesson in this is that one should not enforce any structure on d
  • 8:10 - 8:12
    for improving the performance of RSA, and in fact
  • 8:12 - 8:15
    now there's a slew of results like this that show
  • 8:15 - 8:20
    that basically, any kind of tricks like this to try and improve RSA's performance
  • 8:20 - 8:24
    is going to end up in disaster. So this is not the right way to improve RSA's performance.
  • 8:24 - 8:28
    Initially I wasn't going to cover the details of Wiener's attack.
  • 8:28 - 8:32
    But given the discussions in the class, I think some of you would enjoy seeing the details.
  • 8:32 - 8:35
    All it involves is just manipulating some inequalities.
  • 8:35 - 8:38
    If you're not comfortable with that, feel free to skip over this slide,
  • 8:38 - 8:41
    although I think many of you would actually enjoy seeing the details.
  • 8:41 - 8:43
    So let me remind you in Wiener's attack basically
  • 8:43 - 8:47
    we're given the modulus and the RSA exponent N and e,
  • 8:47 - 8:51
    and our goal is to recover d, the private exponent d,
  • 8:51 - 8:54
    and all we know is that d is basically less than the fourth root of N.
  • 8:54 - 8:58
    In fact, I'm going to assume that d is less than the fourth root of N divided by 3.
  • 8:58 - 9:02
    This 3 doesn't really matter, but the dominating term here is that d is less than the 4th root of N.
  • 9:02 - 9:06
    So let's see how to do it. So first of all, recall that
  • 9:06 - 9:09
    because e and d are RSA public and private exponents,
  • 9:09 - 9:14
    we know that e times d is 1 modulo phi(N). Well what does that mean?
  • 9:14 - 9:22
    That means that there exists some integer k such that e times d is equal to k times phi(N) plus 1.
  • 9:22 - 9:26
    Basically that's what it means for e times d to be 1 modulo phi(N).
  • 9:26 - 9:30
    Basically some integer multiple of phi(N) plus 1.
  • 9:30 - 9:33
    So now let's stare at this equation a little bit.
  • 9:33 - 9:36
    And in fact this equation is the key equation in the attack.
  • 9:36 - 9:40
    And what we're going to do is first of all divide both sides by d times phi(N).
  • 9:40 - 9:44
    And in fact I'm going to move this term here to the left.
  • 9:44 - 9:47
    So after I divide by d times phi(N), what I get is that
  • 9:47 - 9:58
    e divided by phi(N) minus k divided by d is equal to 1 over d times phi(N).
  • 9:59 - 10:03
    Okay, so all I did is I just divided by d times phi(N)
  • 10:03 - 10:06
    and I moved the k times phi(N) term to the left-hand side.
  • 10:06 - 10:09
    Now, just for the heck of it I'm going to add absolute values here.
  • 10:09 - 10:13
    These will become useful in just a minute, but of course they don't change this equality at all.
  • 10:13 - 10:20
    Now, phi(N) of course is almost N; phi(N) is very, very close to N, as we said earlier.
  • 10:20 - 10:23
    And all I'm going to need then for this fraction is just to say that
  • 10:23 - 10:27
    it's less than 1 over square root of N. It's actually much, much smaller
  • 10:27 - 10:31
    than 1 over square root of N, it's actually on the order of 1 over N or even more than that,
  • 10:31 - 10:36
    but for our purposes all we need is that this fraction is less than 1 over square root of N.
  • 10:36 - 10:38
    Now let's stare at this fraction for just a minute.
  • 10:38 - 10:45
    You realize that this fraction on the left here is a fraction that we don't actually know.
  • 10:45 - 10:49
    We know e, but we don't know phi(N), and as a result we don't know e over phi(N).
  • 10:49 - 10:54
    But we have a good approximation to e over phi(N). Namely we know that phi(N)
  • 10:54 - 10:59
    is very close to N. Therefore e over phi(N) is very close to e over N.
  • 10:59 - 11:03
    So we have a good approximation to this left-hand side fraction, namely e over N.
  • 11:03 - 11:06
    What we really want is the right-hand side fraction,
  • 11:06 - 11:08
    because once we get the right-hand side fraction,
  • 11:08 - 11:13
    basically that's going to involve d, and then we'll be able to recover d. Okay, so let's see
  • 11:13 - 11:19
    if we replace e over phi(N) by e over N, let's see what kind of error we're going to get.
  • 11:19 - 11:23
    So to analyze that, what we'll do is first of all remind ourselves
  • 11:23 - 11:26
    that phi(N) is basically N - p - q + 1,
  • 11:26 - 11:31
    which means that N minus phi(N) is going to be less than p + q.
  • 11:31 - 11:35
    Actually I should, to be precise I should really write p + q + 1, but you know,
  • 11:35 - 11:38
    who cares about this 1, it's not, it doesn't really affect anything.
  • 11:38 - 11:40
    So I'm just going to ignore it for simplicity.
  • 11:40 - 11:46
    Okay, so N - phi(N) is less than p + q. Both p and q are roughly half the length of N,
  • 11:46 - 11:49
    so you know, they're both kind of on the order of square root of N,
  • 11:49 - 11:54
    so basically p + q we'll say is less than 3 times square root of N.
  • 11:54 - 11:57
    Okay, so we're going to use this inequality in just a minute.
  • 11:57 - 12:00
    But now we're going to start using the fact that we know something about d,
  • 12:00 - 12:03
    namely that d is small. So if we look at this inequality here,
  • 12:03 - 12:06
    d is less than the fourth root of N divided by 3.
  • 12:06 - 12:09
    It's actually fairly easy to see that if I square both sides
  • 12:09 - 12:12
    and I just manipulate things a little bit, it's [not] difficult to see that
  • 12:12 - 12:16
    this directly implies the following relation,
  • 12:16 - 12:24
    basically 1 over 2 d squared minus 1 over square root of N is greater than 3 over square root of N.
  • 12:24 - 12:29
    As I said, this basically follows by squaring both sides, then taking the
  • 12:29 - 12:33
    inverse of both sides, and then I guess multiplying one side by a half.
  • 12:33 - 12:38
    Okay, so you can easily derive this relation, and we'll need this relation in just a minute.
  • 12:38 - 12:40
    So now let's see, what we'd like to do is bound
  • 12:40 - 12:45
    the difference of e over N and k over d. Well what do we know?
  • 12:45 - 12:48
    By the triangular inequality, we know that this is equal to
  • 12:48 - 12:52
    the distance between e over N and e over phi(N) plus
  • 12:52 - 12:57
    the distance from e over phi(N) to k over d.
  • 12:57 - 13:02
    This is just what's called a triangular inequality; this is just a property of absolute values.
  • 13:02 - 13:05
    Now this absolute value here, we already know how to bound.
  • 13:05 - 13:07
    If you think about it it's basically the bound that we've already derived.
  • 13:07 - 13:12
    So we know that this absolute value here is basically less than 1 over square root of N.
  • 13:12 - 13:18
    Now what do we know about this absolute value here? What is e over N minus e over phi(N)?
  • 13:18 - 13:20
    Well let's do common denominators and see what we get.
  • 13:20 - 13:25
    So the common denominator is going to be N times phi(N),
  • 13:25 - 13:31
    and the numerator in this case is going to be e times phi(N) minus N.
  • 13:31 - 13:36
    Which we know from this expression here is less than 3 times square root of N.
  • 13:36 - 13:41
    So really what this numerator is going to be is e times 3 square root of N.
  • 13:41 - 13:44
    The numerator is going to be less than e times 3 square root of N.
  • 13:44 - 13:51
    So now I know that e is less than phi(N), so I know that e over phi(N) is less than 1.
  • 13:51 - 13:57
    In other words, if I erase e and I erase phi(N) I've only made the fraction larger.
  • 13:57 - 14:00
    Okay, so this initial absolute value is now going to be
  • 14:00 - 14:04
    smaller than 3 square root of N over N, which is simply,
  • 14:04 - 14:09
    3 square root of N over N is simply 3 over square root of N.
  • 14:09 - 14:11
    Okay, but what do we know about 3 over square root of N?
  • 14:11 - 14:18
    We know that it's less than 1 over 2 d squared minus 1 over square root of N.
  • 14:18 - 14:20
    Okay, so that's the end of our derivation.
  • 14:20 - 14:26
    So now we know that the first absolute value is less than 1 over 2 d squared minus square root of N.
  • 14:26 - 14:30
    The second absolute value is less than 1 over square root of N.
  • 14:30 - 14:34
    And therefore their sum is less than 1 over 2 d squared.
  • 14:34 - 14:37
    And this is the expression that I want you to stare at.
  • 14:37 - 14:43
    So here, let me circle it a little bit. So let me circle this part and this part.
  • 14:44 - 14:46
    Now, so let's stare a little bit at this fraction here.
  • 14:46 - 14:51
    And what we see is first of all, as before, now we know the value of e over N,
  • 14:51 - 14:55
    and what we'd like to find out is the value k over d.
  • 14:55 - 14:57
    But what do we know about this fraction k over d?
  • 14:57 - 15:01
    We know somehow that the difference of these two fractions is really small;
  • 15:01 - 15:05
    it's less than 1 over 2 d squared. Now this turns out to happen very infrequently,
  • 15:05 - 15:11
    that k over d approximates e over N so well that
  • 15:11 - 15:15
    the difference between the two is less than the square of the denominator of k over d.
  • 15:15 - 15:17
    It turns out that that can't happen very often.
  • 15:17 - 15:22
    It turns out that there are very few fractions of the form k over d that approximate another fraction
  • 15:22 - 15:26
    so well that their difference is less than 1 over 2 d squared.
  • 15:26 - 15:30
    And in fact the number of such fractions is going to be at most logarithmic in N.
  • 15:30 - 15:34
    So now there's a continued fraction algorithm. It's a very famous fraction
  • 15:34 - 15:39
    that basically what it will do is, from the fraction e over N,
  • 15:39 - 15:43
    it will recover log(N) possible candidates for k over d.
  • 15:43 - 15:47
    So we just try them all one by one until we find the correct k over d.
  • 15:47 - 15:52
    And then we're done. We're done, because we know that,
  • 15:52 - 15:55
    well e times d is 1 mod k, therefore d is relatively prime to k,
  • 15:55 - 16:01
    so if we just represent k over d as a rational fraction, you know, numerator by denominator,
  • 16:01 - 16:05
    the denominator must be d. And so we've just recovered, you know,
  • 16:05 - 16:10
    we've tried all possible log(N) fractions that approximate e over N so well
  • 16:10 - 16:14
    that the difference is less than 1 over 2 d squared.
  • 16:14 - 16:19
    And then we just look at the denominator of all those fractions, and one of those denominators must be d.
  • 16:19 - 16:23
    And then we're done; we've just recovered the private key.
  • 16:23 - 16:26
    So this is a pretty cute attack. And it shows basically how,
  • 16:26 - 16:31
    if the private exponent is small, smaller than the fourth root of N,
  • 16:31 - 16:35
    then we can recover d completely, quite easily. Okay, so I'll stop here.
Title:
Is RSA a one-way function? (17 min)
Video Language:
English

English subtitles

Revisions