BlowFish (Cipher) 20161124

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 14

BlowFish (cipher)

Presented by: Eng. Rami K. Rouchdi


https://en.wikipedia.org/wiki/Blowfish_(cipher)#
cite_note-3
http://www.splashdata.com/splashid/blowfish.htm
http://
www.unige.ch/medecine/nouspikel/ti99/blowfish.htm

BlowFish (cipher) :
why???

BlowFish (cipher)

Alternative to the DESand free of the problems and constraints


associated with other algorithms.
Blowfish provides a good encryption rate in software and no effective
cryptanalysis of it has been found to date.

BlowFish (cipher)
Copyright:
Schneier has stated that, "Blowfish is
unpatented, and will remain so in all
countries. The algorithm is hereby
placed in thepublic domain, and can be
freely used by anyone.

BlowFish (cipher)
It is known for both its tremendous speed
and overall effectiveness.
It uses simple operations (XOR, Addition,
modulo & lookup tables), which are simply
implemented on microprocessors.

Applications:
One of the fastest block ciphers in public use, making it
ideal for a product like SplashID that functions on a wide
variety of processors found in:
Mobile phones, as well as in notebook and desktop computers

The algorithm
symmetric-key,block cipher
Block size: 64-bit
key length: variable(from 32 bits up to
448 bits).
16-roundFeistel cipher
uses large key-dependentS-boxes

s
wfi
Bl o

ip
hc

her

The algorithm

P (64 bits)
32 bits

32 bits

K [1] .. K [16]

Five precomputed subkeyarrays:


one 18-entry P-array (denoted
as K)
Four 256-entry S-boxes (S0, S1,
S2 and S3).
Every roundr:
1. XOR the left half (L) of the data
with therth P-array entry

15 rounds

2. Use the XORed data as input for


Blowfish's F-function
3. XOR the F-function's output with
the right half (R) of the data
4. Swap L and R.
. After the 16th round, undo the last
swap, and XOR L with K18 and R
with K17 (output whitening).

K [18]

K [17]
32 bits

32 bits

C (64 bits)
s
wfi
Bl o

ip
hc

her

F-function

32
bits

Notable features of the design include keydependent


S-boxes and a highly complex key schedule.
The 32-bit input to Blowfish function is split
into four eight-bit quarters.
The quarters are used as input to the S-boxes.
The S-boxes accept 8-bit input and produce
32-bit output.
The outputs are added modulo 2^32 and
XORed to produce the final 32-bit output.
N.B. Modulo addition means that there is a max. value that

32
bits

cannot be exceeded. This limits all results to 32 bits.

(A+B) mod 232

s
wfi
Bl o

ip
hc

her

Sub-keys generation
Algorithm
Given a key of 448 bits
Key schedule generates:
18x(32/8) + 256x4x(32/8) = 4,168
bytes of sub keys

1. The P-array consists of 18 32-bit sub-keys:


P1, P2,..., P18.

2. The four 32-bit S-boxes with 256 entries


each:
S1,0, S1,1,..., S1,255;
S2,0, S2,1,..,, S2,255;
S3,0, S3,1,..., S3,255;
S4,0, S4,1,..,, S4,255.

1. Repeat the Key K (key size = an integer multiple


of 32 bits) to generate the key K of length 18x32
bits

Key K =

K0 kn

Key K=

K0 k n

K0 k n

K0
ki

Sub-keys generation
Algorithm

2. Initialize P-array & then four S-boxes,


in order, with the hexadecimal digits of
the fraction part of Pi (i.e Pi-3)

1. The P-array consists of 18 32-bit subkeys:

P1, P2,..., P18.

2. There are four 32-bit S-boxes with 256 entries


each:

S1,0,
S2,0,
S3,0,
S4,0,

S1,1,...,
S2,1,..,,
S3,1,...,
S4,1,..,,

S1,255;
S2,255;
S3,255;
S4,255.

0x3.243F6 A8885 A308D 31319 8A2E0 37073 44A40 93822 299F3 1D008 2EFA9 8EC4E 6C894 52821 E638D 01377 BE546 6CF34 E90C6 CC0AC

=
=
=
=

0x243F6A88
0X85A308D3
0X13198A2E
0X03707344

=(0XD1310BA6, 0X98DFB5AC, 0X2FFD72DB, 0XD01ADFBF, 0XBBE1AFED, )

Sub-keys generation
Algorithm

3. XOR P(1) with 1st 32 bits of K

1. The P-array consists of 18 32-bit sub-keys:

XOR P(2) with 2nd 32 bits of K

2. There are four 32-bit S-boxes with 256 entries


each:
S1,0, S1,1,..., S1,255;
S2,0, S2,1,..,, S2,255;
S3,0, S3,1,..., S3,255;
S4,0, S4,1,..,, S4,255.

XOR P(3) with 3rd 32 bits of K

XOR P(18) with 18th 32 bits of K

P1, P2,..., P18.

Sub-keys generation
Algorithm

4. Consider a 64-bit all zero data.

1. The P-array consists of 18 32-bit subkeys:


P1, P2,..., P18.

Encrypt the all-zero string with Blowfish


algorithm, using the sub-keys obtained
earlier to obtain 64-bit string.

2. There are four 32-bit S-boxes with 256 entries


each:

i.e. P(i) = Pi(i) ^ K(i), S(i, n) = Pi(i+n)

S1,0,
S2,0,
S3,0,
S4,0,

S1,1,...,
S2,1,..,,
S3,1,...,
S4,1,..,,

S1,255;
S2,255;
S3,255;
S4,255.

5. Replace P(1) & P(2) with the output 64-bit string.


6. Encrypt the output of step (4) using the sub-keys, obtained in
step(5), and fill P(3) & P(4) with the output 64-bit string.
7. Continue the process, replacing all entries of P array, and then
four S-Boxes in order, with the output of Blowfish algorithm.

Sub-keys generation
Algorithm

521 iterations are needed to


generate all sub-keys.

1. The P-array consists of 18 32-bit subkeys:


P1, P2,..., P18.

2. There are four 32-bit S-boxes with 256 entries


each:

S1,0,
S2,0,
S3,0,
S4,0,

S1,1,...,
S2,1,..,,
S3,1,...,
S4,1,..,,

S1,255;
S2,255;
S3,255;
S4,255.

THANKS
https://en.wikipedia.org/wiki/Blowfish_(cipher)#
cite_note-3
http://www.splashdata.com/splashid/blowfish.htm
http://
www.unige.ch/medecine/nouspikel/ti99/blowfish.htm

You might also like