liveBook · Manning

Textbook rsa

As explained in Hacking Cryptography

The schoolbook RSA signature scheme is an unpadded textbook RSA signature method that applies direct modular exponentiation to a message representative.

Textbook RSA applies modular exponentiation directly to an unpadded message representative. For encryption, it computes c = m^e mod n; for decryption, m = c^d mod n. For signatures, the private exponent produces s = m^d mod n, and the public exponent verifies it by recovering m. section 8.4.2 section 9.4

Treat direct textbook RSA as an explanatory primitive, not a safe deployment format:

  • Deterministic encryption maps equal plaintexts to equal ciphertexts, revealing message equality; fixed points can also remain unchanged. section 8.4.2
  • Unpadded signatures permit existential forgery: choose a signature s first, then publish m = s^e mod n. section 9.4
  • Short private exponents enable Wiener’s attack when d < 1/3 n^(1/4); continued-fraction convergents of e/n can recover d. section 8.4.2
  • Use probabilistic padding and strict message formatting in real implementations; avoid weak private exponents during key generation. section 8.4.2 section 9.7

Recovering a weak private exponent

A vulnerable Go implementation deliberately generates d below n^(1/4)/3, computes e as the inverse of d modulo φ(n), and encrypts m = 1337 as c = 60818 modulo n = 111361. An attacker expands e/n into continued fractions, tests each convergent denominator as a candidate d, and confirms the correct one when decryption reproduces the plaintext. section 8.4.2

Equation 9.2
\[\begin{aligned} \begin{aligned} s &= \text{Sign}(m, \text{PrivKey}_{\text{Alice}}) \\ s &= m^d \bmod n \end{aligned} \label{equation:alice-rsa-sign} \end{aligned}\]

Follow the signing equation alongside verification to see how the private exponent creates a signature and the public exponent cancels it. section 9.4

How Hacking Cryptography covers it

How deep it goes
Descends from equations to Go implementations and attack tests, while deferring secure padding internals to later algorithms.
Examples
Uses equal plaintexts, fixed points, a forged signature, concrete modular values, and a Go test recovering a decrypted timestamp.
What it assumes
Assumes RSA keypairs, modular exponentiation, and private-public exponent relationships, while motivating padding through concrete failures.
What you can do after
Diagnose deterministic outputs, unpadded signature forgery, and short-exponent weaknesses, then select padding and safer key-generation practices.
How it connects
Connects RSA encryption, digital signatures, modular exponentiation, padding, existential forgery, Wiener attack, and continued fractions.

Also explained in

Compare how 2 books explain textbook rsa →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hacking Cryptography. The section links point to the parts of the book it draws on.