Lecture 10: Blowfish and Intro to Num Theory
Uses a key anywhere from 32 bits to 448 bits, in increments of 32 bits.
Let the key be n*32 bits, then the key can be split into n parts: K
1
, K
2
, .
.. K
n
, where n is an
int in between 1 and 14, inclusive.
Now, you'll have two main "arrays" to initialize, these are P and S. P has 18 32 bit
entries, and S has the dimensions 4x255. You first initialize all of these with the digits of
PI after the decimal in binary. The first few digits are 0010010000111111, in HEX this is
243F. To see that this works calculate 1/8+1/64+1/2048+.
..etc. and see how you
progressively approach PI from below.
The order you do this initialization is P
1
, P
2
, .
.., P
18
, S
1,0
, S
1,1
, .
.. S
1,255
, .
.. S
4,255
.
Next, change up the P array as follows: P
i
= P
i
⊕
K
(i -1)modn+1
Now, you will go ahead and make changes to both P and S as follows, changing two
entries at a time:
P
1
, P
2
= E
P,S
[0]
P
3
, P
4
= E
P,S
[P
1
, P
2
]
...
S
1,0
, S
1,1
= E
P,S
[P
17
, P
18
]
S
1,2
, S
1,3
= E
P,S
[S
1,0
, S
1,1
]
...
S
4,254
, S
4,255
= E
P,S
[S
4,252
, S
4,253
]
Now, at this point, you use these newly formed P and S arrays to encrypt as follows:
Y = E
P,S
[X], for a plaintext 64 bit block X.
Here are the details of the function E, and F: