Go Back

Source code

Details

Name: twofish_team
Created: Feb 21, 2002
Updated: Oct 17, 2002
SVN Updated: Mar 10, 2009

Other project properties

Category: Crypto core
Language:
Development status: Beta
Additional info:
WishBone Compliant: No
License:

Description

Twofish is a 128-bit block cipher that can accept variable key length 128,192 and 256 bit. In this project we just use key length
128 bit. Twofish is fundamental built by F-function, rotate-left one bit, rotate-right one bit, and XOR.The cipher has 16 round F-function . F-function is made up by four key-dependent 8-by-8-bit S-box, a fixed 4-by-4 maximum distance separable matrix over GF(2^8), a pseudo-Hadamard transform, bitwise rotation, and key scedule.
As can be seen from figure 1, input will be latched first into a register and then separated into four word. The four word then XOR with K0,K1,K2,K3. This step is called input-whitening. Data then goes through F-function. On F-function, there are various rotation, transformation and permutation are applied to it. F-function is made of two h-functions containing key-dependant S-boxes and Maximum Distance Separable Matrix (MDS) , Pseudo-Hadamard Transform (PHT). After going 16 time through this function, the four word of data are one again XOR-ed with four sub-key K4,K5,K6,K7. This step is called output whitening. Finally encrypted or decrypted data is latched into output register.

IMAGE: twofish.jpg

FILE: twofish.jpg
DESCRIPTION: Figure 1. Structure of Twofish block Cipher

IMAGE: qper.jpg

FILE: qper.jpg
DESCRIPTION: Q-permutation

IMAGE: s-boxes.jpg

FILE: s-boxes.jpg
DESCRIPTION: S-boxes

IMAGE: cleartext.jpg

FILE: cleartext.jpg
DESCRIPTION: Input register module

IMAGE: ciphertext.jpg

FILE: ciphertext.jpg
DESCRIPTION: Output register module

IMAGE: key-mod.jpg

FILE: key-mod.jpg
DESCRIPTION: Key-register module

IMAGE: modifiedF.jpg

FILE: modifiedF.jpg
DESCRIPTION: Modified-F module

Design specification

1. Twofish can accept key-length 128, 192, 256 bit. In this project we used 128 bit key-length
2. Use little-endian convention for input, output and key

Status

We have finished designing Twofish core using VHDL, and the test result is OK.