You are on page 1of 12

TWO FISH ENCRYPTION

ALGORITHM
Jhansy Harshitha Vankayalapati
B190628EC
Introduction
Two Fish is a 128-bit symmetric-key block cipher and variable-length
key of size 128,192 or 256 bits.
• The cipher is a 16-round Feistel network.
Whitening
• Input and Output data are XOR-ed with eight subkeys K0…..K7.These
XOR operations are called input and output whitening.
• Input Whitening :
128-bit plain text (P0 P1 P2 P3)is given for the input whitening
which is XOR-ed with four keys(K0 K1 K2 K3). The resultant output is R0
R1 R2 R3.
Two Fish Round
• R0 AND R1 are passed through the function F. The results are F0 and
F1.
• R2 is XOR-ed with F0 and then rotated
right by one bit to get C2
• R3 is rotated left by one bit and
then XOR-ed with F1 to get C3

• Before sending the outputs to round 2 ,they are swapped.C2C3R0R1 is


sent to next round.
Function F

• F –function is made up of g function, a fixed 4-by-4 maximum distance separable(MDS),a pseudo-


Hadamard transform(PHT)
• It takes input R0 ,R1 and r.
• R0 passed through g function yields T0.R1 rotated left by 8 bits then passed to g function yields T1.
• The results T0 and T1 are combined in a PHT.
• Psedo-Hadamard Transform(PHT) is a simple mixing operation .
Given two inputs a and b
a’=a+b mod 2^32
• The results combined with two words of expanded key and gives F0 and F1.
K2r+8,K2r+9
Function g
• The input is split into four bytes
• Each byte is run through its own key-dependent S-box.
• Each S-box takes 8 bits of input
and produces 8-bits of output.
• The four outputs are interpreted as a vector
of length 4 over GF(2^8).
The resulting vector is interpreted as a
32bit word which is the result of g.
S-box
• Each S-box consists of three 8-by-8-bit fixed permutations chosen
from a set of two possible permutations q0 and q1.
• Between these permutations XOR operations are performed with
subkeys S0 and S1.
Maximum Distance Separble(MDS)
• It is a matrix of bytes that multiplies a vectrof 4 bytes.Multiplications
are carried out in the Galois Field GF(2^8) with the primitive
polynomial x^8+x^6+x^5+x^3+1
Key Schedule
• There are two different sets of subkeys: K and S
• In K set:
2 words of key in each round and 8 words for whitening ,each word
consists of 32 bit.
• In S set:
Two subkeys S0 an S1.They are fixed during the entire encryption
and decryption process.They are used in S-box inside the g function
Generation of subkeys S

You might also like