Cryptography Reference
In-Depth Information
form) to the left by two places, with the most significant 2 bits (shifted out on the left) being rotated back in to
the least significant bits (on the right). For example:
ROT2
(00101011) = 10101100
A sample implementation of the
S
-function, including the rotation function, is shown in
Listing 4-6
.
Listing 4-6
Python code for the FEAL S-function.
##########################################
# The rot2 function - helper for the S-function
##########################################
def
rot2(x):
r = (x < 2) & 0xff # Calculate the left shift, removing extra bits
r = r ^ (x >> 6) # OR in the leftmost two bits onto the right
return
r
##########################################
# The FEAL S-function
##########################################
def
sbox(x, y, delta):
return
rot2((x + y + delta) & 0xff)
4.7.2 Key-Generating Function:
f
K
The
f
K
function is a helper function that churns the key to create various subkeys.
Here, the inputs to the key generating function, denoted
a
and
ß
, are 32-bit quantities, split into four 8-bit
quantities. Operations are then done with 8-bit arithmetic, probably since, when FEAL was designed, it was
much faster than 32-bit arithmetic, and the 8-bit results are recombined into the 32-bit result.
1. Let the 32-bit result of the key function be referenced by four 8-bit subparts, so that
2. Let the 32-bit input to
f
K
, α
, be referenced as four 8-bit quantities as well:
α
= α
0
|| α
1
|| α
2
|| α
3
.
3. Similarly for
ß
:
ß
=
ß
0
|| ß
1
||
ß
2
||
ß
3
.
4. Calculate
5. Calculate
6. Calculate
7. Calculate
8. Recombine the above three results to obtain
f
K
.
4.7.3 Round Function:
f
The
f
-function is the actual round function, acting as the heart of its Feistel structure. It takes as input two
32-bit values (
α
and
ß
), and produces a 32-bit result.
Search WWH ::
Custom Search