Skip to content
Crypto Write-up Advanced

Cryptanalysis Recovering An Affine Encryption Scheme Using Gf 2 Linear Algebra

The cipher's substitution box, bit permutation and key mixing are all affine over GF(2), so the 100-round construction collapses into a single affine transformation. An attacker can recover the matrix and constant by encrypting basis vectors, then invert the transformation to recover the plaintext from a digest without brute force.

Muhammad Ashraf Ali Follow

Published on infosecwriteups.com

Welcome to a cryptanalysis challenge. In this challenge, we will learn how a block cipher built entirely from linear components can be broken, and why secure block ciphers require nonlinear components.

Muhammad Ashraf Ali, on infosecwriteups.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The substitution box is affine over GF(2) and the permutation and key XOR are linear, so every round is affine and the whole cipher reduces to one affine map.

Impact

An attacker could recover the original plaintext from a digest without brute force or knowledge of any secret key.

What the attacker needed

The target digest; the cipher source code

The fix

The cipher should be fixed by using a genuinely nonlinear substitution box, as secure block ciphers such as AES do.

How it was found

  1. Test whether the SBOX satisfies the affine property for all 65,536 input pairs.
  2. Encrypt the all-zero vector to recover the constant vector c.
  3. Encrypt each of the 256 basis vectors and XOR with c to recover the columns of matrix M.
  4. Solve the linear system Mx = y XOR c over GF(2) using Gaussian elimination to recover the plaintext.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A cipher scrambles a message so it cannot be read. This one only used steps that can be undone with simple maths, so repeating them 100 times added no real protection. By feeding in special test inputs, the author worked out the whole scrambling rule and reversed it to get the original message back.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by Muhammad Ashraf Ali

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.