Cryptography Reference
In-Depth Information
{
if ( GET_BIT( src, ( permute_table[ i ] - 1 ) ) )
{
SET_BIT( target, i );
}
else
{
CLEAR_BIT( target, i );
}
}
}
Now, on to the steps involved in encrypting a block of data using DES.
DES Initial Permutation
DES specifi es that the input should undergo an initial permutation. The purpose
of this permutation is unclear, as it serves no cryptographic purpose (the output
would be just as secure without this). It may have been added for optimization
for certain hardware types. Nevertheless, if you don't include it, your output
will be wrong, and you won't be able to interoperate with other implementa-
tions. The specifi cation describes this permutation in terms of the input bits
and the output bits, but it works out to copying the second bit of the last byte
into the fi rst bit of the fi rst byte of the output, followed by the second bit of the
next-to-last byte into the second bit of the fi rst byte of the output, and so on, so
that the fi rst byte of output consists of the second bits of all of the input bytes,
“backward.” (Remember that the input is exactly eight-bytes long, so given an
8-bit byte, taking the second bit of each input byte yields one byte of output.)
The second byte of the output is the fourth bit of each of the input bytes, again
backward. The third is built from the sixth bits, the fourth from the eighth bits,
and the fi fth comes from the fi rst bits, and so on. So, given an 8-byte input as
shown in Figure 2-1:
Figure 2-1: Unpermuted 8-byte input
The fi rst byte of output comes from the second bits of each input byte, back-
ward as shown in Figure 2-2.
The second byte of output comes from the fourth bits of each input byte,
backward as shown in Figure 2-3.
Search WWH ::




Custom Search