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

for i0i64i p a 0x7fc b keytp4 a

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: ototypes and structures. */ /* ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– */ void mu(word32 *a) /* inverts the order of the bits of a */ { int i ; word32 b[3] ; b[0] = b[1] = b[2] = 0 ; for( i=0 ; i<32 ; i++ ) { b[0] <<= 1 ; b[1] <<= 1 ; b[2] <<= 1 ; if(a[0]&amp1) b[2] |= 1 ; if(a[1]&amp1) b[1] |= 1 ; if(a[2]&amp1) b[0] |= 1 ; a[0] >>= 1 ; a[1] >>= 1 ; a[2] >>= 1 ; } a[0] = b[0] ; a[1] = b[1] ; a[2] = b[2] ; } void gamma(word32 *a) { word32 b[3] ; /* the nonlinear step */ b[0] = a[0] ^ (a[1]|(~a[2])) ; b[1] = a[1] ^ (a[2]|(~a[0])) ; b[2] = a[2] ^ (a[0]|(~a[1])) ; a[0] = b[0] ; } a[1] = b[1] ; a[2] = b[2] ; void theta(word32 *a) { word32 b[3]; b[0] = a[0] ^ (a[0]>>16) (a[1]>>24) (a[2]>>16) (a[1]>>16) (a[2]>>24) (a[0]>>16) (a[2]>>16) (a[0]>>24) (a[1]>>16) a[1] = /* the linear step */ b[1] = a[1] ^ b[2] = a[2] ^ a[0] = b[0] ; } ^ (a[1]<<16) ^ ^ (a[2]<<8) ^ ^ (a[0]<<16) ^ ^ (a[2]<<16) ^ ^ (a[0]<<8) ^ ^ (a[1]<<16) ^ ^ (a[0]<<16) ^ ^ (a[1]<<8) ^ ^ (a[2]<<16) ^ b[1] ; a[2] = (a[1]>>16) (a[2]>>8) (a[2]>>24) (a[2]>>16) (a[0]>>8) (a[0]>>24) (a[0]>>16) (a[1]>>8) (a[1]>>24) b[2] ; ^ ^ ^ ^ ^ ^ ^ ^ ^ (a[2]<<16) (a[0]<<24) (a[0]<<8) (a[0]<<16) (a[1]<<24) (a[1]<<8) (a[1]<<16) (a[2]<<24) (a[2]<<8) ^ ^ ; ^ ^ ; ^ ^ ; void pi_1(word32 *a) { a[0] = (a[0]>>10) ^ (a[0]<<22); a[2] = (a[2]<<1) ^ (a[2]>>31); } void pi_2(word32 *a) { a[0] = (a[0]<<1) ^ (a[0]>>31); a[2] = (a[2]>>10) ^ (a[2]<<22); } void rho(word32 *a) { theta(a) ; pi_1(a) ; gamma(a) ; pi_2(a) ; } /* the round function */ void rndcon_gen(word32 strt,word32 *rtab) { /* genera...
View Full Document

Ask a homework question - tutors are online