Cryptography Reference
In-Depth Information
1. Split the eventual output of the round function into four separately addressable 8-bit parts: f ( α , ß ) =
f 0 ( α , ß ) || f 1 ( α , ß )|| f 2 ( α , ß )|| f 3 ( α , ß ). Callthe values it returns simply f 0 , f 1 , f 2 , and f 3 .
2. Split the 32-bit input, α, into four 8-bit parts: α = α 0 || α 1 || α 2 || α 3 .
3. Do the same for ß : ß = ß 0 || ß 1 || ß 2 || ß 3 .
4. Calculate f 1 = α 1 ß 0 a 0 .
5. Calculate f 2 = α 2 ß 1 a 3 .
6. Recalculate f 1 = S ( f 1 , f 2 , 1).
7. Recalculate f 2 = S ( f 2 , f 1 , 0).
8. Calculate f 0 = S 0 , f 1 , 0).
9. Calculate f 3 = S 3 , f 2 , 1).
To implement these nine steps, we first need to define a few helper functions, to split the 32-bit block into
four 8-bit parts (demux) and to recombine 8-bit parts into a single 32-bit block (mux). These are very similar to
those used in the SPN cipher above, EASY1. In Python, we can use the code in Listing 4-7 .
Listing 4-7 Multiplex and demultiplex routines for FEAL.
##########################################
# Splits a 32-bit block into four 8-bit values
# and vice-versa
##########################################
def demux(x):
# Create an array of size four to store
# the result
y = []
# Calculate each part in turn
for i in range(0,4):
# They are numbered left to right, 0 to 3
# But still in MSB order
y.append((x >> ((3 - i) * 8)) & 0xff)
return y
def mux(x):
# Initialize result to zero
y = 0
# The input, x, is an array of 8-bit values
for c in x:
# Combine each 8-bit value using OR
y = (y << 8) ^ c
return y
Now that we have all of the helper functions for FEAL, we can define the FEAL main round function, as
shown in Listing 4-8 .
 
 
 
Search WWH ::




Custom Search