Skip to content

biham-lens

Differential Cryptanalysis · From toy SPN to FEAL-4

Trace XOR differences through a toy cipher, recover its last-round subkey, then carry the same idea to published FEAL-4 and test equivalent key material on unseen ciphertexts.

Teaching lab: the small SPN is deliberately weak. FEAL-4 and PRESENT panels have separate scopes; results here are not a security claim for modern ciphers.

Differential Trace

Start here. Two plaintexts P₁ and P₂ flow through every sub-stage of the cipher. The colored dots on each row are the XOR difference at that point. Watch the difference not change on XOR-K rows, get scrambled by S-box rows, and relocate on permute rows. Once you have seen a difference survive the key and mutate at the S-box, the Live Attack tab lets you exploit exactly that fact.

(shares with attack tab)

Stage 0 of 11.

active bit
inactive bit
XOR-K preserves Δ
S-box can change Δ
Permute relocates Δ

Live Differential Attack

New here? This tab is the payoff. The intuition it relies on — a difference survives the key XOR and only the S-box can change it — is built step by step in the tab. Watch a difference propagate there first, then come back and exploit that bias here.

A real chosen-plaintext differential attack on the 4-round toy SPN cipher: we exploit a high-probability differential to recover the last round subkey.

Cipher setup

Active S-box: Weak (toy) change →

Master key K: 0x5A69

Last round subkey K₄ (hidden from attacker): ••

Reproducibility

Same seed → identical pair stream → reproducible bias chart.

Step 1: Choose Plaintext Difference

Step 1½: Target Differential

Source: Eli Biham and Adi Shamir, Differential Cryptanalysis of the Data Encryption Standard (1993; authors’ 2009 rendering), §§3.3–3.4, printed pp. 22–30 (PDF pp. 28–36). This toy uses dependent round keys, so independent-key model estimates need not equal fixed-key observations.

We attack the last round by guessing K₄, partially decrypting, and counting how many pairs hit the difference we expect just before the last S-box. An endpoint differential sums all intermediate difference trails. A characteristic fixes a difference at every round.

The default uses the public differential model, without the victim key.

Step 2: Collect Ciphertext Pairs

0 pairs collected. Need ~500 for reliable recovery.

Step 3: Run Attack

Ready to analyze pairs.

Differential vs. Brute Force

The toy cipher is small enough that brute force is competitive. The win scales: on real ciphers a differential characteristic can save you tens of bits of search.

Cipher Brute force (key search) Differential cost Reference
Toy SPN (16-bit key, this demo) 2¹⁶ ≈ 65 536 — K₄ alone is 8 bits
DES (56-bit) 2⁵⁶ ≈ 7.2 × 10¹⁶ 2⁴⁷ ≈ 1.4 × 10¹⁴ Biham & Shamir 1991
AES-128 2¹²⁸ no usable characteristic Daemen & Rijmen 2002

Operations performed by the most recent attack: 0

FEAL-4 · A published cipher

The toy SPN introduced chosen plaintexts and the last-round peel. FEAL-4 applies the same idea to a published 1987 cipher: a 64-bit Feistel block cipher whose round function uses addition modulo 256 and a two-bit rotation. Here a probability-1 difference filters key guesses instead of ranking a statistical bias.

1 · Encrypt a block

2 · Follow the difference

Pair Δ = 8080000080800000. Each row shows the XOR difference of the two round states.

  1. Chosen pair—
  2. After input XOR—
  3. After round 1—
  4. Round 2 f output—
Round-by-round FEAL-4 difference trace
RoundΔ leftΔ rightΔ f output

3 · Peel four rounds

Collect two structured sets from an encryption oracle, then filter exact round-function differences in a Web Worker. Set A peels rounds 4 and 3; set B peels round 2; all observations constrain round 1.

Below 6 A + 4 B pairs, the search may take much longer or fail.

Collect chosen plaintexts to begin.

0 chosen plaintexts queried0 F evaluations

Each round starts with 2³² possible effective f-key values. The counts below are surviving partial key combinations; branching may increase a later count before the final consistency check.

Cipher specification and cross-check: CrypTool 2 FEAL implementation. This is a classroom round-peeling variant, not a reproduction of Murphy’s exact procedure.

S-box Analysis

The S-box is the only non-linear component of the cipher. Its differential properties determine whether the cipher falls to a differential attack — swap it below to feel the difference.

Swapping resets the cipher, clears collected pairs, and recomputes the DDT.

S-box Substitution

Input (outer number) → Output (colored square)

Difference Distribution Table (DDT)

Rows: Input Difference • Columns: Output Difference • Counts out of 16 input pairs

S-box Strength Assessment

Historical Impact: Differential Cryptanalysis

Differential cryptanalysis was the cryptanalytic breakthrough of the late 20th century.

Eli Biham

Affiliation: Technion — Israel Institute of Technology

Co-inventor of differential cryptanalysis. Later designed Serpent cipher to resist his own technique.

Adi Shamir

Affiliation: Weizmann Institute of Science, Israel

Co-inventor of differential cryptanalysis. Legendary cryptographer and co-founder of RSA cryptosystem.

Timeline of Discovery

Original Paper:

Eli Biham and Adi Shamir. "Differential Cryptanalysis of DES-like Cryptosystems." Journal of Cryptology, vol. 4, no. 1, pp. 3–72, 1991.

Why Serpent Survived: Defense Against Differential Cryptanalysis

Ross Anderson, Eli Biham and Lars Knudsen designed Serpent with a substantial margin against differential and linear cryptanalysis. Its 32 rounds are a design margin, not a proof of immunity.

Cipher Defense Comparison

Property DES (1977) AES (2001) Serpent (1998)
Max nonzero-input DDT entry / inputs 16 / 64 4 / 256 4 / 16
Rounds 16 10/12/14 32
What the comparison establishes Full-round differential attack needs about 2⁴⁷ chosen plaintexts S-box bounds alone do not prove whole-cipher security Additional rounds provide a design margin, not immunity
Design Philosophy Differential resistance designed in; criteria initially secret Resistant to known attacks Hardened by attack inventor

DDT entries are counts, so compare their input-space denominators. The zero input difference is excluded. Sources: DES S-boxes (FIPS 46-3), AES S-box (FIPS 197), and the Serpent proposal.

Portfolio Thread: A Cipher's Journey

This demo is part of a series exploring cipher design and cryptanalysis:

  • biham-lens (you are here) — Attack-side: differential cryptanalysis
  • iron-serpent — Defense-side: Serpent cipher designed to defeat differential attacks
  • dead-sea-cipher — Historical failures: why ciphers break
  • shamir-gate — The mind of Adi Shamir: RSA, differential cryptanalysis, secret sharing

Research context: reduced-round ChaCha

EUROCRYPT 2025: Improved Cryptanalysis of ChaCha — Beating PNBs with Bit Puncturing studies differential-linear attacks on 6, 7 and 7.5 rounds. Its reported costs are paper estimates, not browser measurements. This does not break the full 20-round ChaCha20 construction.

The ChaCha20 Stream encryption path remains 20 rounds (80 quarter-round operations per block), with RFC 8439 controls. Matsui Line and Biham Lens teach linear and differential attacks at their own toy/published-cipher scales; they do not execute this ChaCha attack. Reviewed 12 October 2026.