< Return to Video

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

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

Spanish subtitles

Revisions