CryptoBook
  • CryptoBook
  • Book Plan
  • Style Guide
    • Sample Page
  • Contributors
  • Fundamentals
    • Mathematical Notation
    • Division and Greatest common divisor
      • Euclidean Algorithm
    • Modular Arithmetic
      • Theorems of Wilson, Euler, and Fermat
        • Fermat's Little Theorem in Detail
        • Euler's Theorem in Detail
      • Quadratic Residues
    • Continued Fractions
  • Number Theory
  • Ideals
  • Polynomials With Shared Roots
  • Integer Factorization
    • Pollard rho
    • Sieves
  • Abstract algebra
    • Groups
      • Another take on groups
      • Discrete Log Problem
    • Rings
    • Fields
    • Polynomials
  • Elliptic Curves
    • Untitled
  • Lattices
    • Introduction
    • LLL reduction
      • Gram-Schmidt Orthogonalization
      • Lagrange's algorithm
      • LLL reduction
    • Lattice reduction
      • Minkowski reduced
      • HKZ reduced
      • LLL reduced
    • Applications
      • Coppersmith algorithm
      • Extensions of Coppersmith algorithm
    • Hard lattice problems
    • Lattices of interest
    • Cryptographic lattice problems
      • Short integer solutions (SIS)
      • Learning with errors (LWE)
      • Ring-LWE
      • NTRU
    • Interactive fun
    • Resources and notations
  • Asymmetric Cryptography
  • RSA
    • Proof of correctness
    • RSA application
    • Low Private Component Attacks
      • Wiener's Attack
      • Boneh-Durfee Attack
    • Common Modulus Attack
    • Recovering the Modulus
  • Diffie-Hellman
    • MITM
  • Elliptic Curve Cryptography
  • Symmetric Cryptography
    • Encryption
    • The One Time Pad
    • AES
      • Rijndael Finite Field
      • Round Transformations
  • Hashes
    • Introduction / overview
    • The Birthday paradox / attack
  • Isogeny Based Cryptography
    • Introduction to Isogeny Cryptography
    • Isogenies
    • Isogeny and Ramanujan Graphs
  • Appendices
    • Sets and Functions
    • Probability Theory
Powered by GitBook
On this page
  • What we know
  • Conditions of the attack
  • The math behind the attack

Was this helpful?

Export as PDF
  1. RSA

Common Modulus Attack

What to do when the same message is encrypted twice with the same modulus but a different public key?

PreviousBoneh-Durfee AttackNextRecovering the Modulus

Last updated 3 years ago

Was this helpful?

Imagine we have Alice and Bob. Alice sends the SAME message to Bob more than once using the same public key. The internet being the internet, a problem may happen; a bit is flipped, and the public key changed while the modulus stayed the same.

What we know

Let be the following:

  • m the message in plaintext

  • e1 the public key of the first ciphertext

  • c1 the first ciphertext

  • e2 the public key of the second ciphertext

  • c2 the second ciphertext

  • n the modulus that is common to both ciphertexts

All of these but m are essentially given to us.

Conditions of the attack

Because we are going to need to calculate inverses for this attack, we must first make sure that these inverses exist in the first place:

gcd(e1,e2)=1gcd(c2,n)=1gcd(e_1, e_2) = 1 \newline gcd(c_2, n) = 1 gcd(e1​,e2​)=1gcd(c2​,n)=1

The math behind the attack

We know that RSA goes as follows:

Now to truly recover the plaintext, we are actually doing:

c=me mod nc = m^e\ mod\ nc=me mod n

From the conditions above we also know that e1e1 e1 and e2e2e2 are co-prime. Thus using Bezout's Theorem we can get:

xe1+ye2=gcd(e1,e2)=1xe_1 +ye_2 = gcd(e_1, e_2) = 1xe1​+ye2​=gcd(e1​,e2​)=1

Using this, we can derive the original message mm m :

NB: all the calculations are done mod nn n

C1x∗C2y=(me1)x∗(me2)y=me1x+e2y=m1=mC_1^x * C_2^y = (m^{e_1})^x*(m^{e_2})^y \newline = m^{e_1x+e_2y} \newline = m^1 = m C1x​∗C2y​=(me1​)x∗(me2​)y=me1​x+e2​y=m1=m

In general, Bezout's Theorem gives a pair of positive and negative numbers. We just need to adapt this equation a little to make it work for us. In this case, let's assume yyy is the negative number:

Let y=−aC2y=C2−a=(C2−1)a=(C2−1)−yLet\ y = -a \newline C_2^y = C_2^{-a} \newline = (C_2^{-1})^a \newline = (C_2^{-1})^{-y}Let y=−aC2y​=C2−a​=(C2−1​)a=(C2−1​)−y
C1x×(C2−1)−y mod nC_1^x \times (C_2^{-1})^{-y}\ mod\ n C1x​×(C2−1​)−y mod n