wiener.tex 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. \chapter{Wiener's Attack \label{chap:wiener}}
  2. Wiener's attack was first published in 1989 as a result of cryptanalysis on the
  3. use of short RSA secret keys ~\cite{wiener}. It exploited the fact that it is
  4. possible to find the private key in \emph{polynomial time} using continued fractions
  5. expansions whenever a good estimate of the fraction $\frac{e}{N}$ is known.
  6. More specifically, given $d < \frac{1}{3} ^{4}\sqrt{N}$ one can efficiently
  7. recover $d$ only knowing $\angular{N, e}$.
  8. The scandalous implication behind Wiener's attack is that, even if there are
  9. situations where having a small private exponent may be
  10. particularly tempting with respect to performance (for example, a smart card
  11. communication with a computer), they represent a threat to the security of the
  12. cipher.
  13. Fortunately, ~\cite{wiener} \S 6 presents a couple of precautions that make a
  14. RSA key-pair immune to this attack, namely
  15. (i) making $e > \sqrt{N}$ and
  16. (ii) $gcd(p-1, q-1)$ large.
  17. \section{Continued Fractions background \label{sec:wiener:cf}}
  18. Let us call ``continued fraction'' any expression of the form:
  19. %% why \cfrac sucks this much. |-------------------------|
  20. \begin{align*}
  21. a_0 + \frac{1}{a_1
  22. + \frac{1}{a_2
  23. + \frac{1}{a_3
  24. + \frac{1}{a_4 + \ldots}}}}
  25. \end{align*}
  26. hereby described as a series for convenience:
  27. $\angular{a_0, a_1, a_2, a_3, \ \ldots, a_n}$.
  28. Any floating point number $x$ can be represented as a continued fraction, and
  29. for each $i < n$ there exists fraction $\rfrac{h_i}{k_i}$ approximating $x$.
  30. By definition, each new approximation is recursively defined as:
  31. \begin{align}
  32. \label{eq:wiener:cf}
  33. \begin{cases}
  34. a_{-1} = 0 \\
  35. a_i = h_i // k_i \\
  36. \end{cases}
  37. \quad
  38. \begin{cases}
  39. h_{-2} = 0 \\
  40. h_{-1} = 1 \\
  41. h_i = a_i h_{i-1} + h_{i-2}
  42. \end{cases}
  43. \quad
  44. \begin{cases}
  45. k_{-2} = 1 \\
  46. k_{-1} = 0 \\
  47. k_i = a_i k_{i-1} + k_{i-2}
  48. \end{cases}
  49. \end{align}
  50. After a small digression into the properties of continued fractions, Wiener, in
  51. ~\cite{wiener}, shows that, if a continued fraction $f'$ is an underestimate of
  52. another one $f$:
  53. \begin{align}
  54. f' = f(1-\delta)
  55. \end{align}
  56. Then it is possible to recover $f$, having $f'$, if $\delta$ is small
  57. enough, where small enough means:
  58. \begin{align}
  59. \label{eq:wiener:cf_approx}
  60. \delta = 1 - \frac{f'}{f} < \frac{1}{\rfrac{3}{2}{h_1}{k_1}}
  61. \end{align}
  62. \\
  63. The ``continued fraction algorithm'' allowing us to recover $f$ is the
  64. following:
  65. \begin{enumerate}[(i)]
  66. \setlength{\itemsep}{1pt}
  67. \setlength{\parskip}{0pt}
  68. \setlength{\parsep}{0pt}
  69. \item generate the next $a_i$ of the continued fraction expansion of $f'$;
  70. \item use ~\ref{eq:wiener:cf} to generate the next fraction $\rfrac{h_i}{k_i}$
  71. equal to $\angular{a_0, a_1, \ldots, a_{i-1}, a_i}$ %% non e` proprio cosi`
  72. \item check whether $\rfrac{h_i}{k_i}$ is equal to $f$
  73. \end{enumerate}
  74. \section{The actual attack}
  75. As we saw in ~\ref{sec:preq:rsa}, by construction the two exponents are such that
  76. $ed \equiv 1 \pmod{\varphi(N)}$. This implies that there exists a
  77. $k \in \naturalN \mid ed = k\varphi(N) + 1$. This can be formalized to be
  78. the same problem we formalized in ~\ref{sec:wiener:cf}:
  79. \begin{align*}
  80. ed = k\varphi(N) + 1 \\
  81. \abs{\frac{ed - k\eulerphi{N}}{d\eulerphi{N}}} = \frac{1}{d\eulerphi{N}} \\
  82. \abs{\frac{e}{\eulerphi{N}} - \frac{k}{d}} = \frac{1}{d\eulerphi{N}} \\
  83. \end{align*}
  84. Now we proceed by substituting $\eulerphi{N}$ with $N$, since for large $N$, one
  85. approximates the other. We consider also the difference of the two, limited by
  86. $\abs{\cancel{N} + p + q - 1 - \cancel{N}} < 3\sqrt{N}$.
  87. For the last step, remember that $k < d < \rfrac{1}{3} {}^4\sqrt{N}$:
  88. \begin{align*}
  89. \abs{\frac{e}{N} - \frac{k}{d}} &= \abs{\frac{ed - kN}{Nd}} \\
  90. &= \abs{\frac{\cancel{ed} -kN - \cancel{k\eulerphi{N}} + k\eulerphi{N}}{Nd}} \\
  91. &= \abs{\frac{1-k(N-\eulerphi{N})}{Nd}} \\
  92. &\leq \abs{\frac{3k\sqrt{N}}{Nd}}
  93. = \frac{3k}{d\sqrt{N}}
  94. < \frac{3(\rfrac{1}{3} {}^4\sqrt{N})}{d\sqrt{N}}
  95. = \frac{1}{d{}^4\sqrt{N}}
  96. \end{align*}
  97. This demonstrates the conditions of ~\ref{eq:wiener:cf_approx} and allows us to
  98. proceed with the continued fraction algorithm to converge to a solution.
  99. \section{Again on the engine™}
  100. %%% Local Variables:
  101. %%% mode: latex
  102. %%% TeX-master: "question_authority"
  103. %%% End: