applied cryptography - protocols, algorithms, and source code in c

395 415 425 445 463 477 499 31 31 31 31 31

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ster unsigned long *cook, *raw0; unsigned long dough[32]; register int i; cook = dough; for( i = 0; i < 16; i++, raw1++ ) { raw0 = raw1++; *cook = (*raw0 & 0×00fc0000L) << 6; *cook |= (*raw0 & 0×00000fc0L) << 10; *cook |= (*raw1 & 0×00fc0000L) >> 10; *cook++ |= (*raw1 & 0×00000fc0L) >> 6; *cook = (*raw0 & 0×0003f000L) << 12; *cook |= (*raw0 & 0×0000003fL) << 16; *cook |= (*raw1 & 0×0003f000L) >> 4; *cook++ |= (*raw1 & 0×0000003fL); } usekey(dough); return; } void cpkey(into) register unsigned long *into; { register unsigned long *from, *endp; from = KnL, endp = &ampKnL[32]; while( from < endp ) *into++ = *from++; return; } void usekey(from) register unsigned long *from; { register unsigned long *to, *endp; to = KnL, endp = &ampKnL[32]; while( to < endp ) *to++ = *from++; return; } void des(inblock, outblock) unsigned char *inblock, *outblock; { unsigned long work[2]; scrunch(inblock, work); desfunc(work, KnL); unscrun(work, outblock); return; } static void scrunch(outof, into) register unsigned char *outof; register unsigned long *into; { *into = (*outof++ & 0xffL) << *into |= (*outof++ & 0xffL) << *into |= (*outof++ & 0xffL) << *into++ |= (*outof++ & 0xffL); *into = (*outof++ & 0xffL) << *into |= (*outof++ & 0xffL) << *into |= (*outof++ & 0xffL) << *into |= (*outof & 0xffL); 24; 16; 8; 24; 16; 8; return; } static void unscrun(outof, into) register unsigned long *outof; register unsigned char *into; { *into++ = (*outof >> 24) & 0xffL; *into++ = (*outof >> 16) & 0xffL; *into++ = (*outof >> 8) & 0xffL; *into++ = *outof++ & 0xffL; *into++ = (*outof >> 24) & 0xffL; *into++ = (*outof >> 16) & 0xffL; *into++ = (*outof >> 8) & 0xffL; *into = *outof & 0xffL; return; } static unsigned long SP1[64] = { 0×01010400L, 0×00000000L, 0×00010000L, 0×01010004L, 0×00010404L, 0×00000004L, 0×00000400L, 0×01010400L, 0×01010404L, 0×01000404L, 0×01010004L, 0×01000000L, 0×00000404L, 0×01000400L, 0×01000400L, 0×00010400L, 0×01010000L, 0×01010000L, 0×00010004L, 0×01000004L, 0×01000004L, 0×00000000L, 0×00000404L, 0×00010404L, 0×00010000L, 0×01010404L, 0×00000004L, 0×01010400L, 0×01000000L, 0×01000000L, 0×01010004L, 0×00010000L, 0×00010400L, 0×00000400L, 0×00000004L, 0×01000404L, 0×01010404L, 0×00010004L, 0×0101000...
View Full Document

This note was uploaded on 10/18/2010 for the course MATH CS 301 taught by Professor Aliulger during the Fall '10 term at Koç University.

Ask a homework question - tutors are online