Alloy Computer Products BWS-136 user manual Unsigned long

Page 18

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 -

Image 18
Contents Table of Contents Introduction OverviewProduct Specifications Switch SW1 Settings Connecting Ethernet PortConnecting Serial Port Getting StartedLED Status Serial Port Pin Assignments Digital I/OFactory Default Settings Configure BWS-136Java Configuration Install Java Configuration UtilityDevice Name Settings Serial and Data Packing SettingsTCP/IP Network Settings Access Control SettingsSave Configuration Save Configuration to FileWeb Configuration Customize Your Web Serial/Telnet Command Serial Console ModeTelnet Console Mode Forgot PasswordCommand Syntax XON/XOFF All command strings are in Upper Case Echo Syntax SliokcrlfUnsigned long