Skip to main content
Cipher Visualizers home

The Bellcore Attack: One Fault Breaks RSA-CRT

Most RSA implementations sign with the Chinese Remainder Theorem for a 4x speedup. A single bit-flip during that computation produces a faulty signature that is correct modulo one prime and wrong modulo the other, and one gcd then factors the key. This guide runs the Bellcore attack on a real 128-byte RSA key.

Pashalis Laoutaris 12 min read

Try it

Interactive Bellcore Fault Attack on RSA-CRT

🔐 Bellcore Fault Attack on RSA-CRT

Real 128-byte RSA, signed with the Chinese Remainder Theorem for speed. One glitched signature is enough to recover the whole private key.
Enter text and click a button to start!
1. Fast signing with the CRT (two half-exponentiations)
2. A single-bit glitch in the mod-q half
3. One gcd factors the modulus
4. The whole private key falls out
Click the button to recover an RSA private key from one faulty signature.

The Bellcore Attack: One Fault Breaks RSA-CRT

Introduction

RSA signing is slow, because it raises a large number to the private exponent modulo a large modulus. Almost every real implementation speeds it up with the Chinese Remainder Theorem. Instead of one exponentiation modulo n, it does two smaller ones, modulo the primes p and q, and glues the halves back together. This is about four times faster, and it is everywhere: OpenSSL, smartcards, hardware security modules.

In 1997 a team at Bellcore, Dan Boneh, Richard DeMillo, and Richard Lipton, showed that this optimization is fragile. If a single hardware fault corrupts just one of the two half-computations, the resulting signature is correct modulo one prime and wrong modulo the other. From that one faulty signature, a single greatest-common-divisor computes a prime factor of n, and the whole private key unravels. No search, no thousands of queries, just one glitch and one gcd. This guide runs it on a real 128-byte RSA key.

Table of Contents

Signing with the CRT

To sign a value m, plain RSA computes s = m^d mod n. The CRT version splits this into two halves using the private primes:

s_p = m^(d mod p-1) mod p
s_q = m^(d mod q-1) mod q
s   = s_q + q * ( (s_p - s_q) * (q^-1 mod p) mod p )

The last line is Garner’s recombination. The two exponentiations work with numbers half the size, and the exponents are half the size too, so the whole thing is roughly four times faster than the direct computation. The result is identical to m^d mod n, and it verifies normally: s^e ≡ m mod n.

What a Fault Does

Now suppose a glitch, from a voltage spike, a clock disturbance, a laser pulse on a chip, flips one bit of s_q while s_p is computed correctly. Trace the faulty signature s' through the recombination:

  • Modulo p: the q * (...) term vanishes in a way that leaves s' ≡ s_p mod p. The p-half was never touched, so s' is still correct modulo p, which means s'^e ≡ m mod p.
  • Modulo q: the recombination gives s' ≡ s_q' mod q, the corrupted value, so s'^e ≢ m mod q.

The faulty signature fails normal verification, because it is wrong modulo q. But it is still perfectly correct modulo p. That asymmetry is the whole attack.

One gcd Factors the Key

Look at the number s'^e - m. Modulo p it is zero, because s'^e ≡ m mod p. Modulo q it is nonzero. So s'^e - m is a multiple of p but not of q, which means:

gcd(s'^e - m mod n, n) = p

That gcd is one cheap computation, and it hands the attacker a 512-bit prime factor of the modulus. Then q = n / p, and the private exponent comes straight back from d = e^-1 mod (p-1)(q-1). The attacker has the full private key from a single faulty signature, the message, and the public key. There is also a two-signature variant, due to Arjen Lenstra: with a correct signature s and a faulty one s' for the same message, gcd(s - s', n) is a factor, because the two agree modulo p and differ modulo q.

Interactive Visualizer

The visualizer above runs the attack on a real 128-byte RSA key. Type a message, pick which bit of the mod-q half to glitch, and watch the four steps: the correct CRT signature, the single-bit fault, the gcd that factors n, and the recovered private exponent checked against the real one.

The attacker code uses only the faulty signature, the message, and the public key. It never sees the private key, and it does no searching: the factorization is one gcd. The same arithmetic runs in the Python below, and the two agree exactly, including the hash that turns the message into the signed value.

A Worked Example

The key has a 128-byte modulus. The message is Transfer $1000 to account 12345, hashed with SHA-256 and reduced mod n to give the signed value m.

The signer computes the two halves and recombines them. The correct signature verifies. Then a glitch flips bit 37 of s_q. The faulty signature s' fails full verification, but checking one prime at a time shows the split: s'^e ≡ m mod p holds, while s'^e ≡ m mod q does not. The p-half survived; the q-half is corrupt.

The attacker computes gcd(s'^e - m mod n, n) and gets a 512-bit prime, which is exactly p. Dividing gives q, and d = e^-1 mod (p-1)(q-1) equals the real private exponent. The key is fully recovered from that one faulty signature. In testing, every faulty signature worked: 360 of 360 across many messages and fault positions.

Python Implementation

This is a real 128-byte RSA key, CRT signing, a single-bit fault injection, and the gcd attack.

# bellcore.py
#
# The Bellcore fault attack on RSA-CRT (Boneh, DeMillo, Lipton, 1997). Most RSA implementations sign
# with the Chinese Remainder Theorem for speed: they compute the signature modulo p and modulo q and
# glue the halves together. If a single fault corrupts one half, the faulty signature is correct modulo
# one prime and wrong modulo the other. Then gcd(s^e - m, n) is that prime, and the whole key falls out
# of ONE faulty signature. Teaching code, with a real 128-byte RSA key.

import hashlib
import math

# a fixed 1023-bit modulus from two 512-bit primes (generated once with a deterministic seed)
P = 0xef0610f23abfcd8a3effe777a4bc6d8b708dfabf54756769c467625a63fa7c5d38b2e08cab2d3223205ff2f9389c9f07110c8c003c4718aae1915f16c448e08f
Q = 0x83d525bab9e74667c2711f996f376dd2337fe751e052c39a328ef8bff3012e60ba87a5ab4eef18fed7a5d330d13c29e725e0358ab8108328d79332b4a1713f13
N = P * Q
E = 65537
PHI = (P - 1) * (Q - 1)
D = pow(E, -1, PHI)

# CRT private parameters, as a real implementation stores them
DP = D % (P - 1)
DQ = D % (Q - 1)
QINV = pow(Q, -1, P)


def message_to_int(message):
    """The value actually signed. Real RSA pads a hash; here we hash and reduce, which the attacker knows."""
    h = hashlib.sha256(message).digest()
    return int.from_bytes(h, "big") % N


def sign_crt(m):
    """A correct CRT signature: sign mod p and mod q, then recombine (Garner's formula)."""
    s_p = pow(m, DP, P)
    s_q = pow(m, DQ, Q)
    h = (QINV * (s_p - s_q)) % P
    return s_q + h * Q


def sign_crt_faulty(m, fault_bit=37):
    """The same, but a glitch flips one bit of the mod-q half before recombining."""
    s_p = pow(m, DP, P)
    s_q = pow(m, DQ, Q) ^ (1 << fault_bit)     # the injected fault
    h = (QINV * (s_p - s_q)) % P
    return s_q + h * Q


def verify(m, s):
    return pow(s, E, N) == m


def attack(m, s_faulty):
    """One faulty signature recovers a prime: gcd(s^e - m mod n, n). Returns (p, q, d) or None."""
    g = math.gcd((pow(s_faulty, E, N) - m) % N, N)
    if 1 < g < N:
        p = g
        q = N // p
        d = pow(E, -1, (p - 1) * (q - 1))
        return p, q, d
    return None


if __name__ == "__main__":
    print("RSA with a %d-bit modulus (%d bytes), e=%d, signed with CRT for speed." % (N.bit_length(), (N.bit_length() + 7) // 8, E))
    message = b"Transfer $1000 to account 12345"
    m = message_to_int(message)
    print("message:", message)

    good = sign_crt(m)
    print("\ncorrect signature verifies:", verify(m, good))

    faulty = sign_crt_faulty(m)
    print("faulty signature verifies: ", verify(m, faulty), "(one bit of the mod-q half was glitched)")
    print("  faulty mod p correct:", pow(faulty, E, P) == m % P)
    print("  faulty mod q correct:", pow(faulty, E, Q) == m % Q)

    print("\n-- the attack, from the single faulty signature, m, e, n --")
    result = attack(m, faulty)
    p, q, d = result
    recovered_prime = p if p in (P, Q) else None
    print("gcd(s^e - m, n) is a prime factor of n:", p in (P, Q) or q in (P, Q))
    print("recovered d == real d:", d == D)
    print("recovered key signs correctly:", pow(sign_crt(m), E, N) == m and pow(m, d, N) == pow(m, D, N))

    # the two-signature variant: gcd of a correct and faulty signature's difference
    alt = math.gcd((good - faulty) % N, N)
    print("\nalternative, gcd(correct - faulty, n) also gives a factor:", alt in (P, Q))

Running it prints this:

RSA with a 1023-bit modulus (128 bytes), e=65537, signed with CRT for speed.
message: b'Transfer $1000 to account 12345'

correct signature verifies: True
faulty signature verifies:  False (one bit of the mod-q half was glitched)
  faulty mod p correct: True
  faulty mod q correct: False

-- the attack, from the single faulty signature, m, e, n --
gcd(s^e - m, n) is a prime factor of n: True
recovered d == real d: True
recovered key signs correctly: True

alternative, gcd(correct - faulty, n) also gives a factor: True

I checked the code several ways. The modulus comes from two primes generated with a fixed seed, and e·d ≡ 1 modulo the Carmichael function, so the key is valid; correct signatures verify and round-trip. The faulty signature fails full verification but is correct modulo p and wrong modulo q, exactly as the attack requires. Across 200 random faulty signatures, every one recovered the real private exponent, and a fault placed in the p-half instead yields q from the gcd, as expected. The JavaScript in the visualizer agrees with the Python on all 360 message-and-fault cases, for the signed value, the correct and faulty signatures, the recovered factor, and the recovered exponent, and its from-scratch SHA-256 matches Python’s hashlib.

Limitations

The fault is simulated. The code flips a bit in software to stand in for a physical glitch. Real fault injection uses voltage or clock manipulation, a laser, or electromagnetic pulses against a chip, and getting a usable single-fault signature out is the hard, equipment-heavy part. The cryptanalysis afterward is the easy part, and that is what this guide shows.

Signatures, not arbitrary decryption. The attack needs the device to compute m^d with the CRT and then release a faulty result. That fits RSA signing and RSA decryption on a device the attacker can glitch, such as a smartcard. It does not apply to a correctly validated signature or to a server that checks its own output.

The attacker must know m. The gcd uses s'^e - m, so the attacker needs the exact value that was signed. For a deterministic padding scheme or a known message this is given; for randomized padding the attacker needs that value too.

Teaching code. The RSA key is 1023 bits, smaller than today’s 2048-bit minimum, and the arithmetic favors clarity. The attack is identical at any key size, since it is one gcd.

Security Status

The Bellcore attack is real and has driven defensive design for over two decades. It is the reason a careful RSA-CRT implementation verifies its own signature before releasing it: compute s, check that s^e ≡ m mod n, and refuse to output anything if the check fails. That one extra verification turns a faulty signature into no signature, and the attack gets nothing. Some implementations instead recompute or use redundant CRT formulas that detect the fault.

Fault attacks remain an active field. They extend to many other schemes, including elliptic-curve signatures and symmetric ciphers, and they drive hardware countermeasures like redundancy, sensors, and error-detecting computation in secure chips. The lesson from 1997 still holds: a cryptosystem can be mathematically sound and still fall to a single well-placed error, so correct hardware and output checking matter as much as the math.

FAQ

Does the attacker need the private key or many queries?

No, the attacker needs neither of those. The attack uses only one faulty signature, the message, and the public key. There is no search and no repeated querying; the factorization is a single gcd. That is what makes it so sharp compared with query-heavy attacks.

Why does a fault in one half leak a prime?

CRT recombination keeps the signature correct modulo the prime whose half was not corrupted. So s'^e - m is divisible by that prime but not the other. Its gcd with n is therefore exactly one prime factor.

Would a fault in the recombination step also work?

The clean result needs the fault in one of the two half-exponentiations, so that exactly one of the two congruences stays correct. A fault in the final recombination can corrupt the result in a way that breaks both congruences, which does not give the clean gcd. The classic attack targets a half.

How is this stopped in practice?

By verifying every signature before it leaves the device: recompute s^e mod n and compare it with m. A faulty signature fails that check and is never released, so the attacker never gets the one input the attack needs. Redundant or fault-detecting CRT variants do the same job.

They are related only in spirit. Both show that RSA is safe only when the surrounding implementation is careful. The Bleichenbacher attack exploits a server that leaks padding validity; this exploits a device that releases a faulty computation. Different mechanism, same theme.

References

  1. Boneh, Dan, Richard A. DeMillo, and Richard J. Lipton. “On the Importance of Checking Cryptographic Protocols for Faults.” Advances in Cryptology, EUROCRYPT ’97, Lecture Notes in Computer Science 1233, Springer, 1997, pp. 37-51.

  2. Boneh, Dan, Richard A. DeMillo, and Richard J. Lipton. “On the Importance of Eliminating Errors in Cryptographic Computations.” Journal of Cryptology 14(2), 2001, pp. 101-119 (the journal version).

  3. Lenstra, Arjen K. “Memo on RSA Signature Generation in the Presence of Faults,” 1996 (the two-signature gcd variant).

  4. Aumüller, C., P. Bier, W. Fischer, P. Hofreiter, and J.-P. Seifert. “Fault Attacks on RSA with CRT: Concrete Results and Practical Countermeasures.” CHES 2002.

  5. The RSA guide on this site, whose cryptosystem and CRT signing this attack targets: /blog/rsa_guide/

A visual representation of recovering an ECDH key from small-order points on invalid curves
Modern & Applied Cryptography Breakers Advanced

The Invalid-Curve Attack: Breaking ECDH by Sending Bad Points

ECDH point arithmetic never uses the curve's b parameter, so a server that skips the on-curve check will do math with points from other curves. This guide sends small-order points from invalid curves to a static-key ECDH server, leaks the key one small prime at a time, and reassembles it with the Chinese Remainder Theorem.

15 min read

A visual representation of an interval of possible RSA plaintexts narrowing to one under a padding oracle
Modern & Applied Cryptography Breakers Advanced

Bleichenbacher's Attack: Decrypting RSA with a Padding Oracle

A server that only reveals whether an RSA ciphertext has valid PKCS#1 v1.5 padding leaks enough to decrypt it completely. This guide runs Bleichenbacher's 1998 million-message attack on a toy RSA key, narrowing the plaintext to a single value from one-bit answers, with no access to the private key.

14 min read

A visual representation of a batch GCD finding a shared prime between two RSA moduli and factoring both
Modern & Applied Cryptography Breakers Advanced

Breaking RSA with Weak Keys: Shared Primes and Pollard's p-1

RSA is unbreakable only when its primes are chosen well. If two keys share a prime, one GCD factors both in microseconds, and if a prime p has a smooth p-1, Pollard's method factors it without any search. This guide runs both real attacks against real 1024-bit keys and recovers the private keys.

11 min read