Skip to content

A simple self-made block cipher based on feistel cipher.

Notifications You must be signed in to change notification settings

Amirarsalan-sn/new-DES

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

New DES

This project demonstrates a python implementation of a simple block cipher algorithm. The algorithm is designed by me and it is based on Feistel cipher And It encrypts data longer than a single block size in CBC mode. For more information about the design, please read the document below.

Design

The algorithm uses 256 bit blocks and 128 bit key, the structure of the algorithm is as follows:

Encryption structure

As you can see the plain text is first encrypted using playfair cipher with the key showen below:

play fair 1

After that it is sliced into blocks and passed throught block ciphers (they are calculated in CBC mode). Then, the results of block encryptions are aggregated and again passed throught another playfair cipher with a different key:

play fair 2

This, was the encryption procedure, for decryption we pretty much do the same thing but, in the opposite direction, and instead of playfairs and block ciphers in encryption mode, we use decryption versions of them:

decryption structure

Each block cipher, contains 16 rounds of feistel network, just like the picture below:

block cipher encryption block cipher decryption

Again, for the block ciphers used in the decryption, every thing is the same except in the opposite direction.

In every feistel function (F in the pictures), first, the input data is passed throught an S_box, then, it is XORed with the round key in order to calculate the output of the function:

feistel structure

The S_box is a window of 6 bits long itterating throught the input bit by bit, it changes the value of the window according to the table below. Here is the substitution procedure:

  1. Pick the first 3 bits of the window, the value selects the row in the table below.
  2. Pick the second 3 bits of the window, the value selects the column of the table.
  3. Change the first 3 bits with the first value of the tuple selected by steps 1 & 2.
  4. Change the second 3 bits with the second value of the tuple.
  5. Move the window one bit to the right.

S box

The round key creation procedure is simple. The next round key is just the rotation of the current key by one byte to the left.

Result

A simple test of the algorithm is shown below, you can read the code for detailed structures and algorithms used for this self made block cipher.

S box