Skip to content

N-Bermparis/feistel-cipher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Feistel Cipher - Educational Reference Implementation

Language: C Cryptography Block Cipher License: MIT


1. Overview

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 C
  • index.html - A simple academic explanation of Feistel networks, including the mathematical formulation and diagram

2. The Feistel Structure (Mathematical Summary)

Feistel Cipher 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.


3. Round Function (F)

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;

About

Reference implementation of a Feistel cipher in C for educational and cryptographic study.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors