Skip to main content
6 of 15
Expand
fgrieu
  • 145.6k
  • 12
  • 319
  • 611

I'll leave alone the OpenPGP spec, and consider the problem of identifying among $k$ public keys $(n_i,e_i)$ the RSA public key $(n_j,e_j)$ used to encrypt $m$ messages per RSA with proper encryption padding. The only way is by examining the $m$ cryptograms $c_\ell$, which essentially are indistinguishable from uniformly random in $[0,n_j)$.

The analysis can use two facts:

  1. If $n_i\le\max c_\ell$ , that rules out $i=j$.
  2. $x=\frac1m\sum c_\ell$, which the attacker should compute, has Bates distribution close to normal for large $m$, with mean $(n_j-1)/2$, standard deviation $(n_j-1)/\sqrt{12m}$.

I think the optimum attacker's strategy in practice is to pick $j$ as $i$ with $n_i/2$ closest to $x$ among the $n_i$ surviving test 1. It should be computed $t_i=\lvert n_i/2-x\rvert\sqrt{12m}/n_i$ for the values of $i$ with $n_i/2$ the closest to $x$: the larger $t_i$, the least likely $i$ is, with $t_i<1$, $t_i<2$, $t_i<3$ per the 68-95-99.7% rule. That allows to evaluate how confident we are in the guess of $j$.

To go deeper in the analysis, we need an idea of the distribution of the $n_i$.

By making the say 256 high-order bits of the $n_i$ equal at generation time (fixed to some haphazard constant), which is easy and does not harm RSA security or interoperability, we could make identification hopeless.

For a common generation method with the prime factors $p_i$ and $q_i$ of $n_i$ independent and roughly uniform in $[2^{(b-1)/2},2^{b/2}]$ where $b$ is the bit size of $n_i$ (e.g. $b=3072$), I think an attacker would need $m$ in the order of a few times $k^2$ for a good success rate, and sizably more to conclude with good success rate and confidence. Keys with the highest $n_j$ tend to be easier to guess correctly, because rule 1 prunes best, and there tends to be less other keys with nearby $n_i$. The second effect also makes keys with the lowest $n_j$ easier to guess than those in the center of the pack: those with the high byte near 0xB9 (for $b$ multiple of 8) tend to be the most resistant to guessing. All this is amenable to simulation.

fgrieu
  • 145.6k
  • 12
  • 319
  • 611