← Back to section · Foundations of Cryptography

Why Textbook RSA Must Never Be Used As-Is

Raising a message directly to a power — 'textbook RSA' — is mathematically sound and a security sieve: determinism invites guessing, multiplicative homomorphism invites tampering, and small messages with small exponents never even meet the modulus. A defect-by-defect anatomy.

Published 22 November 2026 · 5 min read · PQ Frontier

Why Textbook RSA Must Never Be Used As-Is
AI-generated site artwork
Video explainer · The RSA system: signing and verification

Textbooks usually present RSA in three lines: encrypt as c=me mod nc = m^e \bmod n, decrypt as m=cd mod nm = c^d \bmod n, and sign and verify the same way. This scheme — encode the message as a number and exponentiate it directly — is called textbook RSA. It is mathematically impeccable: Euler’s theorem guarantees decryption works. As security engineering, it fails almost every modern definition. Understanding why it cannot be used is the prerequisite for understanding why every real RSA scheme looks the way it does.

Flaw one: determinism — the ciphertext gives you away

Textbook RSA contains no randomness at all: the same mm under the same public key always produces the same ciphertext. An attacker can therefore play “guess and check”: suspecting the ciphertext carries “yes” rather than “no”, they encrypt both candidates with the public key themselves and see which one matches the intercepted value. Whenever the message space is small — votes, yes/no answers, formatted protocol fields, amounts drawn from a few tiers — enumeration finishes the job.

Modern cryptography’s minimum bar for encryption is semantic security (formalised in the computational model as IND-CPA): even an attacker who can have chosen plaintexts encrypted should learn nothing from a ciphertext. Deterministic encryption fails this by definition, because the ciphertext is a fingerprint of the plaintext. A real scheme must roll dice on every encryption so the same plaintext opens into different ciphertexts.

Flaw two: multiplicative homomorphism — the ciphertext can be kneaded

RSA has an elegant algebraic property: E(m1)⋅E(m2)=(m1m2)e=E(m1m2)(modn)E(m_1) \cdot E(m_2) = (m_1 m_2)^e = E(m_1 m_2) \pmod n. Encryption commutes with multiplication; this is multiplicative homomorphism. In some advanced protocols it is a treasure, but for ordinary encryption it is a disaster: having intercepted cc, an attacker picks any ss, computes c′=c⋅se mod nc' = c \cdot s^e \bmod n, and c′c' decrypts to exactly m⋅sm \cdot s. Without knowing the plaintext at all, the attacker can scale it by a chosen factor — double a transfer amount, inflate a quantity, and so on.

Worse, it composes with any decryption service into a chosen-ciphertext attack: have the decryptor process a homomorphically reshaped ciphertext, divide the result by the known ss, and the original plaintext falls out. The modern notion of IND-CCA security (adaptive chosen-ciphertext security) exists precisely to close this route, and no malleable encryption can reach it.

On the signing side the same homomorphism is forgery: a signature is s=md mod ns = m^d \bmod n, so for any two signed messages m1,m2m_1, m_2, the product of their signatures s1s2s_1 s_2 is a valid signature on the never-signed message m1m2m_1 m_2. One can also run it backwards — pick an arbitrary number as a “signature” and derive which message it signs. That message is usually meaningless random bytes, but in protocols that sign arbitrary byte strings, it can already be enough.

Flaw three: small messages, small exponents, and the modulus never shows up

If the plaintext mm is small and the exponent ee is small too (say e=3e = 3), it can happen that me<nm^e < n: the reduction step then does nothing, the ciphertext is the ordinary integer mem^e, and an integer cube root recovers mm — no factoring required. A related family covers messages whose bits are mostly known: with only a small unknown segment, lattice techniques in the spirit of Coppersmith’s method can still recover the whole plaintext. The common thread: none of these attacks touches RSA’s hard problem; they exploit the absence of structural protection around a bare exponentiation.

Flaw four: no integrity — decryption “succeeding” proves nothing

Textbook RSA decryption produces an output for every input: feed it a random number and it will “decrypt” it into another random number. Nothing distinguishes “the peer really encrypted this” from “an attacker made it up”. Encryption alone provides neither integrity nor origin authentication — true for block ciphers used alone as well, but especially dangerous in the public-key setting, where the public key is available to everyone and anyone can manufacture a perfectly well-formed ciphertext. Combining encryption with authentication takes a dedicated construction; it is not a default.

A fair historical footnote: the definitions did not exist yet

In fairness, these four flaws are not mistakes the 1977 authors “made”. When RSA was born, cryptography had no formal security definitions: what it means for an encryption scheme to be secure existed as intuition, not as a provable standard. Semantic security took shape only in 1982, when Goldwasser and Micali proposed probabilistic encryption, and chosen-ciphertext security was refined through the 1990s. RSA, in other words, predates the yardsticks now used to judge it by several years. What its designers aimed for — a trapdoor function resting on a clear mathematical problem, one-way yet reversible — was achieved admirably by the standards of the time. The trouble came from later presentation: to teach the trapdoor idea, textbooks stripped the scheme down to bare exponentiation, leaving behind the padding layer that practice later added, and generations of students and engineers mistook the pedagogical simplification for a deployable scheme. A substantial share of real-world “RSA broken” incidents broke exactly this misused simplification. Keep the distinction: what has been retired is the bare exponentiation, not RSA’s mathematics.

The moral: the flaws are structural, not parametric

Notice that not one of these four flaws is fixed by moving from 2048-bit to 4096-bit keys. Determinism, malleability, integer-root recovery and missing integrity are properties of the scheme’s structure, unrelated to the difficulty of factoring. That is exactly why padding schemes exist: before the message reaches the exponentiation, it is encoded — together with randomness — into a full-size, tightly structured number, so determinism disappears, homomorphic reshaping loses its meaning, and malformed inputs are caught at decoding time. How OAEP and PSS plug these holes one by one is the next article’s subject. For now, keep the slogan: in the real world there is no such thing as “RSA encryption”, only “RSA with a named padding scheme”; a system that omits the second half is running textbook RSA, and textbook RSA is not cryptography — it is an arithmetic exercise.

Tags: RSAtextbook RSAsemantic security