although impractical.

************************************************/

//#include "xtea.h"

void encipher(unsigned long *const v,unsigned long *const w, const unsigned long *const k)

{

register unsigned long y=v[0],z=v[1],sum=0,delta=0x9E3779B9,n=32; while(n-->0)

{y+= (z<<4 ^ z>>5) + z ^ sum + k[sum&3]; sum += delta;

z+= (y<<4 ^ y>>5) + y ^ sum + k[sum>>11 & 3];

}

w[0]=y; w[1]=z;

}

void decipher(unsigned long *const v,unsigned long *const w, const unsigned long *const k)

{

register

unsigned long

y=v[0],z=v[1],sum=0xC6EF3720,

 

 

delta=0x9E3779B9,n=32;

/* sum =

delta<<5, in general sum = delta * n */

while(n-->0)

 

{

 

 

z-= (y<<4 ^ y>>5) + y ^ sum + k[sum>>11 & 3]; sum -= delta;

y-= (z<<4 ^ z>>5) + z ^ sum + k[sum&3];

}

 

w[0]=y; w[1]=z;

 

BWS-136 User Manual_amend.doc

- 35 -

}

2.The TEA.H

#ifndef __XTEA_H__ #define __XTEA_H__

void encipher(unsigned long *const v,unsigned long *const w, const unsigned long *const k);

void decipher(unsigned long *const v,unsigned long *const w, const unsigned long *const k);

#endif

BWS-136 User Manual_amend.doc

- 36 -

Page 18
Image 18
Alloy Computer Products BWS-136 user manual Unsigned long