Re: DES implementation questions (FinalPermutation code)

From: Brian Ross (brian.ross.x_at_rogers.com)
Date: 06/15/05


Date: Wed, 15 Jun 2005 10:14:12 -0400


"tum_" <atoumantsev_spam@mail.ru> wrote in message
news:1118825427.292984.278010@o13g2000cwo.googlegroups.com...
> >ie.. if I do:
>> InitialPermutation(Left, Right)
>> FinalPermutation(Left, Right)
>
> Have you tried:
> InitialPermutation(Left, Right)
> FinalPermutation(Right, Left),
>

Thanks, this seems to be a large factor in what is causing me confusion.
When I swap the two sides as you suggest I am able to reproduce the original
values before the InitialPermutation.

Now I am a bit confused where the LR swaps are and why they are there.

Here are some followup questions:

Is there an extra LR swap at the end of the 16th round in the code
implementation (compared with the standard which mentions this LR swap is
skipped for symmetry between encryption and decryption).

Is this just due to how the inner loop is implemented with 2 rounds per loop
each with a swap?

If the answers to the above two questions yes - is this the reason why the
FP code has the swap built in? to undo this extra swap?

If I am wrong above, then why is this extra swap being done in the FP code?

Lastly, I don't really understand why the main DES encrypt/decrypt functions
swap the left and right sides again after the FinalPermutation is performed
while the users buffer is being repopulated (see code below). To me this
seems like an extra swap compared to the one that was performed in the FP
code?

Thanks
Brian

---
void CBlockCipherDES::EncryptBlock(const UnsignedInteger8* const 
pInputBlock, UnsignedInteger8* const pOutputBlock) const throw()
{
    UnsignedInteger32 Left = Encode8To32BE(pInputBlock);
    UnsignedInteger32 Right = Encode8To32BE( pInputBlock + 4 );
    DoInitialPermutation(Left, Right);
    DoRounds(Left, Right, m_EncryptKeySchedule);
    DoFinalPermutation(Left, Right);
    Encode32To8BE(Right, pOutputBlock);
    Encode32To8BE( Left, pOutputBlock + 4 );
}
---


Relevant Pages

  • Re: DES implementation questions (FinalPermutation code)
    ... this seems to be a large factor in what is causing me confusion. ... > When I swap the two sides as you suggest I am able to reproduce the original ... > seems like an extra swap compared to the one that was performed in the FP ...
    (sci.crypt)
  • Re: Hard disk running...and running...and running...and...
    ... The way the swap code is written, ... at least twice the size of RAM you will incur performance penalties if ... runaway process -- the extra swap may give you time to kill the ...
    (alt.os.linux.suse)
  • Re: Swap function driver
    ... swaps to unroll is a tunable compile-time constant in the form of the first ... Filling the swap buffer with random data. ... void operatorconst { ...
    (comp.programming)