Documentation

CslibFrontier.Crypto.Computational.RSASignatureAttacks

Attacks on RSA signatures without a full-domain hash #

Without a full-domain hash, RSA signatures are forgeable ([BS23], Sections 13.3 and 13.6). Three forgers win Attack Game 13.1 (Signature.Scheme.eufCmaExperiment), each with an exact success law and a bound on its signing queries:

The forgers carry query bounds, and the blinding and unblinding maps are certified polynomial time (computableInPolyTime_rsaBlind, for a positive modulus, and computableInPolyTime_rsaUnblind). No forger is certified as a polynomial-time program: the game here is typed, the library has no polynomial-time predicate for typed oracle adversaries yet (#4894), and the word-coded form of the forgers is not in this module.

Where the book is silent:

The attack of p. 536 is stated there for any trapdoor permutation scheme; here it is stated for RSA, as p. 537 restates it.

Main definitions #

Main results #

References #

Blinding #

def Cslib.Crypto.rsaBlind (N e m r : ℕ) :

The blinded message m * r ^ e % N of the attack on unhashed RSA signatures.

Unblinding: σ * r⁻¹ % N, with the inverse of r modulo N computed by BinaryGcd.modInv.

theorem Cslib.Crypto.rsaEval_rsaUnblind {N e m r σ : ℕ} (hN : 0 < N) (hr : r.Coprime N) (hσ : rsaEval N e σ = rsaBlind N e m r) :
rsaEval N e (rsaUnblind N r σ) = m % N

Equation (13.4): if σ ^ e = m * r ^ e modulo N and r is a unit, then (σ / r) ^ e = m modulo N.

Existential forgery without a query (p. 536) #

The forger of [BS23], p. 536, against unhashed RSA signatures: pick σ and output the message σ ^ e % N with the signature σ. It makes no signing query.

The forger of p. 536 wins Attack Game 13.1 against unhashed RSA signatures with probability 1, for every key and every way of picking σ.

Universal forgery with one query (p. 537, equation (13.4)) #

def Cslib.Crypto.unhashedRSAUniversalForger (pk : RSAPublicKey) (m : Fin pk.N) (pick : ProbComp ℕ) :
ProbOracleComp (fun (x : Fin pk.N) => ℕ) (Fin pk.N × ℕ)

The forger of [BS23], p. 537, against unhashed RSA signatures. To sign a unit m, it picks r, asks for the signature σ' on the blinded message m * r ^ e % N and outputs σ' / r: one signing query. A message that is not a unit it signs itself, with rsaNonUnitRoot; this is the case the book leaves to the reader.

theorem Cslib.Crypto.eval_eufCmaExperiment_unhashedRSAUniversalForger (desc : RSADesc) {m : Fin desc.modulus} (hm : (↑m).Coprime desc.modulus) (pick : ProbComp ℕ) (hpick : ∀ r ∈ pick.eval.support, r.Coprime desc.modulus) :

Universal forgery of unhashed RSA signatures ([BS23], p. 537, equation (13.4)): on a unit m, when every r that pick returns is a unit modulo N, the forger's output always verifies, and the blinded message differs from m unless r = 1 modulo N: the forger wins Attack Game 13.1 exactly when pick returns some r ≠ 1 modulo N.

On a message that is not a unit modulo N, the forger of p. 537 makes no query and wins Attack Game 13.1 with probability 1.

Universal forgery with a uniform blinding factor ([BS23], p. 537): on a message that is a unit modulo N, the forger that draws r uniformly from the units loses Attack Game 13.1 exactly when r = 1, so with probability 1 / φ(N).

Unhashed RSA signatures are universally forgeable ([BS23], p. 537): with the blinding factor N - 1, the forger wins Attack Game 13.1 with probability 1, for every key and every message. It makes at most one signing query (isQueryBounded_unhashedRSAUniversalForger), and it is not certified as a polynomial-time program.

Multiplicative forgery with two queries (p. 547, equation (13.9)) #

def Cslib.Crypto.rsaMultiplicativeForger {M : Type} (pk : RSAPublicKey) (m₁ m₂ m₃ : M) :
ProbOracleComp (fun (x : M) => ℕ) (M × ℕ)

The forger of [BS23], p. 547: ask for the signatures on m₁ and m₂ and output their product modulo N as a signature on m₃. It makes two signing queries.

theorem Cslib.Crypto.eval_eufCmaExperiment_rsaMultiplicativeForger {M : Type} [DecidableEq M] (desc : RSADesc) (H : M → ℕ) {m₁ m₂ m₃ : M} (hH : H m₃ ≡ H m₁ * H m₂ [MOD desc.modulus]) (h₁ : m₃ ≠ m₁) (h₂ : m₃ ≠ m₂) :

Multiplicative forgery ([BS23], equation (13.9)): if the digest of m₃ is the product of the digests of m₁ and m₂ modulo N and m₃ is neither of them, the forger wins Attack Game 13.1 against rsaSignature desc H with probability 1.

Efficiency of the forgers' arithmetic #

Blinding is computable in polynomial time whenever N, e, m and r are, and 0 < N a. This certifies the map, not a forger.

Unblinding is computable in polynomial time whenever N, r and σ are. This certifies the map, not a forger.