This repository provides a minimal, academic-oriented implementation of a Feistel block cipher in the C programming language.
Its purpose is strictly educational: to illustrate how Feistel networks operate mathematically and programmatically.
The repository contains:
feistel.c- A compact 4-round Feistel cipher implementation in Cindex.html- A simple academic explanation of Feistel networks, including the mathematical formulation and diagram
A Feistel cipher divides the input block into two halves:
M = (L0, R0)
For each round (i), with subkey (K_i), the transformation is:
L_{i+1} = R_i
R_{i+1} = L_i XOR F(R_i, K_i)
This process:
- Does not require the round function (F) to be invertible
- Ensures that encryption and decryption share the same structure
- Allows decryption simply by reversing key order
A full mathematical walkthrough and diagram are available in index.html.
The round function may be any transformation, such as:
- XOR operations
- Modular addition
- S-box substitutions
- Bit permutations
In this educational implementation, the round function is:
F(r, k) = r ^ k;