Prerequisites:
- RSA Encryption/Decryption
- Chinese Remainder Theorem- Wikipedia
- Chinese Remainder Theorem- Crypto@Stanford
We will start by discussing the simplest form of Hastad's Broadcast Attack on unpadded messages and then generalise the attack on linearly padded messages using Coppersmith's Theorem.
Suppose Alice sends an unpadded message M to k
people P1, P2, ..., Pk each using a same small public key exponent e
and different moduli N
for ith individual, the public key for ith individual (Ni, e). The attack states that as soon as k >= e
, the message M is no longer secure and we can recover it easily using Chinese Remainder Theorem.
Let us understand this attack using an example: Alice sends a message M
to 3 three different people using the same public key exponent e = 3
. Let the ciphertext received by i
th receiver be Ci where Ci = M3 mod Ni. We have to assume that gcd(Ni, Nj) == 1 where i != j
Quick Question: What if GCD(Ni, Nj) != 1?
Then the moduli pair (Ni, Nj) is vulnerable to Common Prime Attack
We can now write:
Thus we can get the following by solving using Chinese Remainder Theorem:
where bi = N/Ni, bi' = bi-1 mod Ni and N = N1* N2* N3. Since we know that M < Ni (If our message M is larger than the modulus N, then we won't get the exact message when we decrypt the ciphertext, we will get an equivalent message instead, which is not favourable).
Therefore we can write M < N1N2N3. We can easily calculate M
now by directly taking the cube root
of M3 to get M
.
You can find an implementation of this attack here: hastad_unpadded.py
Hastad also showed that applying linear padding
to the message M prior to encryption does not protect from this attack.
Assuming Ci = fi(M)e for 1<=i<=k (k --> number of individuals the message is to be sent/has been sent). Here fi is a linear function to pad the message M, so that the recipients receive slightly different messages.
For ith individual, Message M = i*2m + M, where m is the number of bits in M. Hastad proved that a system of univariate equations modulo relatively prime composites, such as applying fixed polynomial could be solved if sufficient equations are provided.
This attack is an application of Chinese Remainder Theorem and Coppersmith's Theorem.
Exploit in a Nutshell:
- Calculate N = n1*n2*...
- Calculate each element T[j] as per the above conditions using CRT
- Assign P. = PolynomialRing(Zmod(N))
- g[j] = (i*(2^m) + x)^e - c, where the message is padded using the above conditions
- Assign g = Sum_of(T[j] * g[j])
- Check if g is a monic polynomial, if not transform it into a monic polynomial
- Find small roots of g and check if that is the flag