DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Securing Verifiable Credentials With DPoP: A Spring Boot Implementation
  • Python Async/Sync: Advanced Blocking Detection and Best Practices (Part 2)
  • Pydantic: Simplifying Data Validation in Python
  • Bridging Graphviz and Cytoscape.js for Interactive Graphs

Trending

  • AI Coding Agent Guardrails: Finding Gaps in Tool Permissions
  • Java 8 Optional - Avoid Null and NullPointerException Altogether - and Keep It Pretty
  • PWA on iOS, Part 1: PWAs on the iPhone Are Older Than They Look
  • Data Integration Landscape 2026: Event Streaming, API, and Batch in the Era of Agentic AI

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. Data
  4. An Attack on RSA With Exponent 3

An Attack on RSA With Exponent 3

Learn more about an attack possible on RSA encryption using a very specific exponent — click here for the details!

By 
John Cook
·
Mar. 08, 19 · Presentation
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
9.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

As I noted in this post, RSA encryption is often carried out reusing exponents. Sometimes, the exponent is exponent 3, which is subject to an attack we’ll describe below [1]. (The most common exponent is 65537.)

Suppose the same message m is sent to three recipients and all three use exponent e= 3. Each recipient has a different modulus Ni, and each will receive a different encrypted message

ci = m³ mod Ni.

Someone with access to c1, c2, and c3 can recover the message m as follows. We can assume each modulus Ni is relatively prime to the others; otherwise, we can recover the private keys using the method described here. Since the moduli are relatively prime, we can solve the three equations for m³ using the Chinese Remainder Theorem. There is a unique x < N1 N2 N3, such that:

x = c1 mod N1
x = c2 mod N2
x = c3 mod N3

And m is simply the cube root of x. What makes this possible is knowing m is a positive integer less than each of the Ns and that x < N1 N2 N3. It follows that we can simply take the cube root in the integers and not the cube root in modular arithmetic.

This is an attack on “textbook” RSA because the weakness in this post could be avoiding by real-world precautions such as adding random padding to each message so that no two recipients are sent the exact same message.

Python Example

Here, we’ll work out a specific example using realistic RSA moduli.

    from secrets import randbits, randbelow
    from sympy import nextprime
    from sympy.ntheory.modular import crt

    def modulus():
        p = nextprime(randbits(2048))
        q = nextprime(randbits(2048))
        return p*q

    N = [modulus() for _ in range(3)]
    m = randbelow(min(N))
    c = [pow(m, 3, N[i]) for i in range(3)]
    x = crt(N, c)[0]

    assert(cbrt(x) == m) # integer cube root


Note that crt is the Chinese Remainder Theorem. It returns a pair of numbers, the first being the solution we’re after, hence the [0] after the call.

The script takes a few seconds to run. Nearly all the time goes to finding the 2048-bit (617-digit) primes that go into the moduli. Encrypting and decrypting m takes less than a second.

Related Posts

  • Common RSA implementation flaws
  • Regression, modular arithmetic, and PQC

[1] I don’t know who first discovered this line of attack, but you can find it written up here. At least in the first edition, the link is to the 2nd edition, which I don’t have.

MOD (file format) PRIME (PLC) POST (HTTP) Theorem Modulus (algebraic number theory) Python (language) Implementation Data Types Links

Published at DZone with permission of John Cook. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Securing Verifiable Credentials With DPoP: A Spring Boot Implementation
  • Python Async/Sync: Advanced Blocking Detection and Best Practices (Part 2)
  • Pydantic: Simplifying Data Validation in Python
  • Bridging Graphviz and Cytoscape.js for Interactive Graphs

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook